Skip to content

Commit dcf83f1

Browse files
bqueninclaude
andauthored
Fix empty window list on KDE Plasma (reparenting window managers) (#207)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 73fceb7 commit dcf83f1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/interpreter/capture/linux_x11.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,29 @@ def _is_normal_window(disp: display.Display, window) -> bool:
114114
def _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:

0 commit comments

Comments
 (0)