File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -114,19 +114,29 @@ def _is_normal_window(disp: display.Display, window) -> bool:
114114def _enumerate_windows (disp : display .Display ) -> list [dict ]:
115115 """Enumerate top-level application windows.
116116
117- Only returns direct children of the root window that are normal
118- application windows (not dialogs, tooltips, etc.).
117+ Uses _NET_CLIENT_LIST (EWMH standard) to get managed windows,
118+ which works correctly with reparenting window managers like KDE/KWin.
119+ Falls back to root.query_tree() for minimal window managers.
119120 """
120121 root = disp .screen ().root
121122 windows = []
122123
124+ # Try _NET_CLIENT_LIST first (works with reparenting WMs like KDE)
123125 try :
124- children = root .query_tree ().children
126+ net_client_list = disp .intern_atom ("_NET_CLIENT_LIST" )
127+ prop = root .get_full_property (net_client_list , Xatom .WINDOW )
128+ if prop is not None and prop .value is not None :
129+ window_ids = prop .value
130+ else :
131+ # Fallback: direct children of root (for minimal WMs without EWMH)
132+ window_ids = [child .id for child in root .query_tree ().children ]
125133 except BadWindow :
126134 return windows
127135
128- for child in children :
136+ for wid in window_ids :
129137 try :
138+ child = disp .create_resource_object ("window" , wid )
139+
130140 # Get window attributes
131141 attrs = child .get_attributes ()
132142 if attrs .map_state != X .IsViewable :
You can’t perform that action at this time.
0 commit comments