diff --git a/src/x11/event_loop.rs b/src/x11/event_loop.rs index 194d1a1..3a3f0bb 100644 --- a/src/x11/event_loop.rs +++ b/src/x11/event_loop.rs @@ -240,30 +240,22 @@ impl EventLoop { let mut physical_pos = PhyPoint::new(x as i32, y as i32); // The coordinates are relative to the root window, not our window >:( - if let Ok(r) = self - .window - .xcb_connection - .conn - .get_geometry(self.window.window_id) - .unwrap() - .reply() - { - if r.root != self.window.window_id { - if let Ok(r) = self - .window - .xcb_connection - .conn - .translate_coordinates( - r.root, - self.window.window_id, - physical_pos.x as i16, - physical_pos.y as i16, - ) - .unwrap() - .reply() - { - physical_pos = PhyPoint::new(r.dst_x as i32, r.dst_y as i32); - } + let root_id = self.window.xcb_connection.screen().root; + if root_id != self.window.window_id { + if let Ok(r) = self + .window + .xcb_connection + .conn + .translate_coordinates( + root_id, + self.window.window_id, + physical_pos.x as i16, + physical_pos.y as i16, + ) + .unwrap() + .reply() + { + physical_pos = PhyPoint::new(r.dst_x as i32, r.dst_y as i32); } } diff --git a/src/x11/window.rs b/src/x11/window.rs index dfd890d..56eb4a5 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -99,7 +99,6 @@ pub(crate) struct WindowInner { pub(crate) window_info: WindowInfo, visual_id: Visualid, mouse_cursor: Cell, - root_window_id: Option, pub(crate) close_requested: Cell, @@ -281,24 +280,12 @@ impl<'a> Window<'a> { GlContext::new(context) }); - let root_window_id = - if let Ok(r) = xcb_connection.conn.get_geometry(window_id).unwrap().reply() { - if r.root != window_id { - Some(r.root) - } else { - None - } - } else { - None - }; - let mut inner = WindowInner { xcb_connection, window_id, window_info, visual_id: visual_info.visual_id, mouse_cursor: Cell::new(MouseCursor::default()), - root_window_id, close_requested: Cell::new(false),