Skip to content
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

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

kchibisov
Copy link
Member

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.

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'.
@@ -33,7 +33,7 @@ raw-window-handle = "0.3"
bitflags = "1"

[dev-dependencies]
image = "0.23"
image = "0.23.12"
Copy link
Member Author

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.

Copy link
Contributor

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),
Copy link
Member Author

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),
Copy link
Member Author

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.

Copy link
Contributor

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?

@kchibisov
Copy link
Member Author

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 0x100 for them if it matters, but we can keep u16 for now, since it's more clear.

@kchibisov kchibisov merged commit c5620ef into rust-windowing:master Dec 9, 2020
@kchibisov kchibisov deleted the wayland-mouse-extra branch December 9, 2020 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants