I've got a gtk application which features a tray icon, if the user clicks on the icon the visibility of the window is toggled when he's on the same workspace as the window is. When he's on another workspace the window moves to that one.
Now, if the application and user are on the same screen and the app is completely overlayed by another one, I want to raise the window so it's on the top, instead of first hiding it and the on the next tray icon click showing it again.
My code so far:
def inOverlayed(self):
windows = self.window.get_screen().get_toplevel_windows()
win = self.window.get_window()
x, y, w, h, b = win.get_geometry()
for i in windows:
if win != i:
x2, y2, w2, h2, b2 = i.get_geometry()
if x >= x2 and x + w <= x2 + w2:
if y >= y2 and y + h <= y2 + h2:
return True
return False
The biggest problem is seems that there is no way to determine a windows z-level, but without one can't distinguish if the window is just inside another one or if it's acutally overlayed by one.
So my question is, how do I find out a windows z-level(the docs don't say anything about this) or is there a simpler solution for this problem