views:

87

answers:

1

I would like to find out if a window has focus. I am using pyGTK and would be helpful to us that but have got some Xlib in my script aswell.

I've used:

self.window.add_events( gdk.FOCUS_CHANGE_MASK ) # It took me ages to research this self.window.connect("focus-in-event", self.helloworld)

but this gives me the event every time the window is being focused in, even if it is already focused. I want it to tell me just if it isn't focused before

A: 

You can check whether a window is active using the is-active property. Connect to notify::is-active to get a notification when the property value changes.

Example:

def is_active_changed(window, param):
    print window.props.is_active
window.connect('notify::is-active', is_active_changed)
Johannes Sasongko
Thanks so much!
drnessie