Skip to content

Commit 96d3f38

Browse files
committed
fix(linux:window-list): fix that only relevant windows (width && height > 1) are listed
1 parent 59d8139 commit 96d3f38

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/linux/x11_api.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ impl X11Api {
8787
let tree = conn.query_tree(root)?.reply()?;
8888
let mut result = vec![];
8989
for window in tree.children {
90-
let attr = conn.get_window_attributes(window)?.reply()?;
91-
if let MapState::Viewable = attr.map_state {
92-
result.push(window as WindowId);
90+
let window_id = window as WindowId;
91+
let (_, _, width, height) = self.get_window_geometry(&window_id)?;
92+
if width > 1 && height > 1 {
93+
let attr = conn.get_window_attributes(window)?.reply()?;
94+
if let MapState::Viewable = attr.map_state {
95+
result.push(window as WindowId);
96+
}
9397
}
94-
let mut sub_windows = self.get_all_sub_windows(&(window as WindowId))?;
98+
let mut sub_windows = self.get_all_sub_windows(&window_id)?;
9599
result.append(&mut sub_windows);
96100
}
97101

@@ -363,6 +367,11 @@ mod test {
363367
let api = X11Api::new()?;
364368
let windows = api.get_visible_windows()?;
365369
assert!(!windows.is_empty());
370+
for win in windows {
371+
let (_, _, width, height) = api.get_window_geometry(&win)?;
372+
assert!(width > 1);
373+
assert!(height > 1);
374+
}
366375

367376
Ok(())
368377
}

0 commit comments

Comments
 (0)