Reputation: 897
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 as well.
I've used:
self.window.add_events( gdk.FOCUS_CHANGE_MASK )
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.
Upvotes: 1
Views: 2051
Reputation: 4228
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)
Upvotes: 2