Skip to content

Commit

Permalink
x11: mouse motion tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Feb 15, 2024
1 parent 3f70aa6 commit 3cc76f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
3 changes: 0 additions & 3 deletions crates/gpui/src/platform/linux.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//todo!(linux): remove this
#![allow(unused_variables)]

mod blade_atlas;
mod blade_belt;
mod blade_renderer;
Expand Down
24 changes: 24 additions & 0 deletions crates/gpui/src/platform/linux/x11/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ impl Client for X11Client {
}));
}
}
xcb::Event::X(x::Event::MotionNotify(ev)) => {
let window = self.get_window(ev.event());
let pressed_button = super::button_from_state(ev.state());
let position =
Point::new((ev.event_x() as f32).into(), (ev.event_y() as f32).into());
let modifiers = super::modifiers_from_state(ev.state());
window.handle_input(PlatformInput::MouseMove(crate::MouseMoveEvent {
pressed_button,
position,
modifiers,
}));
}
xcb::Event::X(x::Event::LeaveNotify(ev)) => {
let window = self.get_window(ev.event());
let pressed_button = super::button_from_state(ev.state());
let position =
Point::new((ev.event_x() as f32).into(), (ev.event_y() as f32).into());
let modifiers = super::modifiers_from_state(ev.state());
window.handle_input(PlatformInput::MouseExited(crate::MouseExitEvent {
pressed_button,
position,
modifiers,
}));
}
_ => {}
}

Expand Down

0 comments on commit 3cc76f5

Please sign in to comment.