-
Notifications
You must be signed in to change notification settings - Fork 919
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
On Wayland, don't drop extra mouse buttons #1787
Conversation
This commit forwards "unknown" Wayland mouse buttons downstream via 'MouseButton::Other'. Possible values for those could be found in <linux/input-event-codes.h>. Also, since Wayland just forwards buttons from the kernel, which are 'u16', we must adjust 'MouseButton::Other' to take 'u16' instead of 'u8'.
026071f
to
d22e6b9
Compare
@@ -33,7 +33,7 @@ raw-window-handle = "0.3" | |||
bitflags = "1" | |||
|
|||
[dev-dependencies] | |||
image = "0.23" | |||
image = "0.23.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't build with earlier version of image afaics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the reasons why I would always encourage specifying the full versions. Only because it builds with 0.23.X, doesn't mean it builds with 0.23.0. So I'd rather have it a bit higher than necessary than too low.
@@ -1307,7 +1307,7 @@ unsafe extern "system" fn public_window_callback<T: 'static>( | |||
event: MouseInput { | |||
device_id: DEVICE_ID, | |||
state: Pressed, | |||
button: Other(xbutton as u8), | |||
button: Other(xbutton), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it was also incorrectly converted here.
@@ -709,7 +709,7 @@ impl<T: 'static> EventProcessor<T> { | |||
event: MouseInput { | |||
device_id, | |||
state, | |||
button: Other(x as u8), | |||
button: Other(x as u16), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how sane X11 is, but I think it's fine to use u16, given that kernel uses u16 as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the type natively? usize?
I've looked into kernel docs and it seems like the the only mouse buttons starting from BTN_MISC up to BTN_TASK, so we can subtract |
Since Wayland mouse buttons are generally u16, we can only somehow
translate them into u8 used by winit. Also, they're coming from
linux/input-event-codes.h directly, thus translating them into
something cross-platform is cumbersome, thus just passing them
downstream as 'button - BTN_LEFT' for now.