Skip to content

Commit

Permalink
Remove unneeded root window ID fetching, use the id provided by the c…
Browse files Browse the repository at this point in the history
…onnection instead.
  • Loading branch information
prokopyl committed Apr 19, 2024
1 parent 0065a4d commit 5757c06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
40 changes: 16 additions & 24 deletions src/x11/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
13 changes: 0 additions & 13 deletions src/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ pub(crate) struct WindowInner {
pub(crate) window_info: WindowInfo,
visual_id: Visualid,
mouse_cursor: Cell<MouseCursor>,
root_window_id: Option<XWindow>,

pub(crate) close_requested: Cell<bool>,

Expand Down Expand Up @@ -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),

Expand Down

0 comments on commit 5757c06

Please sign in to comment.