Skip to content

Commit 0a267e6

Browse files
2 parents aba3b32 + 85e3432 commit 0a267e6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

recorder-bin/src/linux_x11.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn get_top_window_id(display_ptr: *mut x11::xlib::Display, start_window_id: c_ul
7070
)
7171
};
7272

73-
if status == (x11::xlib::Success as i32) {
73+
if status != 0 {
7474
unsafe {
7575
x11::xlib::XFree(child_window_ids as *mut c_void);
7676
};
@@ -171,6 +171,11 @@ fn get_process_id_from_window_tree(
171171
unsafe {
172172
x11::xlib::XSetErrorHandler(Some(handle_error_callback));
173173
}
174+
// https://tronche.com/gui/x/xlib/window-information/XQueryTree.html
175+
// XQueryTree() returns zero if it fails and nonzero if it succeeds
176+
// Comparing with xlib::Success is incorrect as that assumes zero is success
177+
// https://docs.rs/x11-dl/2.21.0/x11_dl/xlib/constant.Success.html
178+
// pub const Success: c_uchar = 0;
174179
let status = unsafe {
175180
x11::xlib::XQueryTree(
176181
display_ptr,
@@ -195,7 +200,7 @@ fn get_process_id_from_window_tree(
195200
}
196201
}
197202

198-
if status == (x11::xlib::Success as i32) {
203+
if status != 0 {
199204
unsafe {
200205
x11::xlib::XFree(child_window_ids as *mut c_void);
201206
};

0 commit comments

Comments
 (0)