Browse Source

enumerate engine windows based on horizontal position

Fabian Peter Hammerle 4 years ago
parent
commit
22eb1cbc76
1 changed files with 8 additions and 2 deletions
  1. 8 2
      rescriptoon/__init__.py

+ 8 - 2
rescriptoon/__init__.py

@@ -237,11 +237,17 @@ class Overlay:
             window.ungrab_key(keycode, X.AnyModifier)
 
     def _find_engine_windows(self) -> typing.List["Xlib.display.Window"]:
-        return list(
+        return sorted(
             filter(
                 lambda w: w.get_wm_name() == _TOONTOWN_ENGINE_WINDOW_NAME,
                 _x_walk_children_windows(self.xdisplay.screen().root),
-            )
+            ),
+            # relative x
+            # won't work when using a reparenting window manager
+            # https://stackoverflow.com/a/12854004/5894777
+            # possible workaround:
+            # http://science.su/stuff/so/print_frame_geometry_of_all_windows.py
+            key=lambda w: w.get_geometry().x,
         )
 
     def _update_active_key_registry(self, xkeyevent):