How do I check that a pygtk Window is on the current desktop?
A program I'm fixing has:
if self.pymp.window.get_property('visible'):
self.pymp.window.hide()
else:
self.pymp.window.move(self.pymp.position[0], self.pymp.position[1])
self.pymp.window.show()
self.pymp.window.present()
I want to replace:
if self.pymp.window.get_property('visible'):
With:
if self.pymp.window.get_property('visible') and window_is_on_current_workspace(self.pymp.window):
I can implement window_is_on_current_workspace(window)
with wnck
as:
def window_is_on_current_workspace(window):
import wnck
v = wnck.screen_get_default() # needed due to known bug
xid = window.window.xid
win = None
while win is None:
win = wnck.window_get(xid)
if gtk.events_pending():
gtk.main_iteration()
wor = win.get_screen().get_active_workspace()
return win.is_on_workspace(wor)
And it works but it's icky. Is there a better way to do this?