-
Notifications
You must be signed in to change notification settings - Fork 569
Support mouse scroll in X11. #961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
daddbea
5af8b67
5f5c013
a62c8ea
87331c4
add7f0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -602,6 +602,42 @@ impl Window { | |
| } | ||
| } | ||
|
|
||
| pub fn handle_wheel(&self, event: &xcb::ButtonPressEvent) -> Result<(), Error> { | ||
| let button = event.detail(); | ||
| // The scroll delta of 120.0 was stolen from the GTK code, which apparently came from the | ||
| // windows docs. | ||
| let delta = match button { | ||
xStrom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 4 => (0.0, -120.0), | ||
| 5 => (0.0, 120.0), | ||
| 6 => (-120.0, 0.0), | ||
| 7 => (120.0, 0.0), | ||
| _ => { | ||
| log::error!("unexpected mouse wheel button: {}", button); | ||
|
||
| (0.0, 0.0) | ||
| } | ||
| }; | ||
| let mouse_event = MouseEvent { | ||
| pos: Point::new(event.event_x() as f64, event.event_y() as f64), | ||
| buttons: mouse_buttons(event.state()), | ||
| mods: key_mods(event.state()), | ||
| count: 0, | ||
| focus: false, | ||
| button: MouseButton::None, | ||
| wheel_delta: delta.into(), | ||
| }; | ||
|
|
||
| match self.handler.try_borrow_mut() { | ||
| Ok(mut handler) => { | ||
| handler.wheel(&mouse_event); | ||
| Ok(()) | ||
| } | ||
| Err(err) => Err(Error::BorrowError(format!( | ||
| "Window::handle_wheel handle: {}", | ||
| err | ||
| ))), | ||
| } | ||
| } | ||
|
|
||
| pub fn handle_motion_notify( | ||
| &self, | ||
| motion_notify: &xcb::MotionNotifyEvent, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.