On Wayland, don't drop extra mouse buttons

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'.
This commit is contained in:
Kirill Chibisov 2020-12-09 23:11:25 +03:00 committed by GitHub
parent 8fb7aa5cef
commit c5620efc9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 10 deletions

View file

@ -21,6 +21,8 @@
- On Wayland, default font size in CSD increased from 11 to 17. - On Wayland, default font size in CSD increased from 11 to 17.
- On Windows, fix bug causing message boxes to appear delayed. - On Windows, fix bug causing message boxes to appear delayed.
- On Android, support multi-touch. - On Android, support multi-touch.
- On Wayland, extra mouse buttons are not dropped anymore.
- **Breaking**: `MouseButton::Other` now uses `u16`.
# 0.23.0 (2020-10-02) # 0.23.0 (2020-10-02)

View file

@ -33,7 +33,7 @@ raw-window-handle = "0.3"
bitflags = "1" bitflags = "1"
[dev-dependencies] [dev-dependencies]
image = "0.23" image = "0.23.12"
simple_logger = "1.9" simple_logger = "1.9"
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]

View file

@ -745,7 +745,7 @@ pub enum MouseButton {
Left, Left,
Right, Right,
Middle, Middle,
Other(u8), Other(u16),
} }
/// Describes a difference in the mouse scroll wheel state. /// Describes a difference in the mouse scroll wheel state.

View file

@ -17,6 +17,11 @@ use crate::platform_impl::wayland::{self, DeviceId};
use super::{PointerData, WinitPointer}; use super::{PointerData, WinitPointer};
// These values are comming from <linux/input-event-codes.h>.
const BTN_LEFT: u32 = 0x110;
const BTN_RIGHT: u32 = 0x111;
const BTN_MIDDLE: u32 = 0x112;
#[inline] #[inline]
pub(super) fn handle_pointer( pub(super) fn handle_pointer(
pointer: ThemedPointer, pointer: ThemedPointer,
@ -153,11 +158,10 @@ pub(super) fn handle_pointer(
}; };
let button = match button { let button = match button {
0x110 => MouseButton::Left, BTN_LEFT => MouseButton::Left,
0x111 => MouseButton::Right, BTN_RIGHT => MouseButton::Right,
0x112 => MouseButton::Middle, BTN_MIDDLE => MouseButton::Middle,
// TODO - figure out the translation. button => MouseButton::Other(button as u16),
_ => return,
}; };
event_sink.push_window_event( event_sink.push_window_event(

View file

@ -709,7 +709,7 @@ impl<T: 'static> EventProcessor<T> {
event: MouseInput { event: MouseInput {
device_id, device_id,
state, state,
button: Other(x as u8), button: Other(x as u16),
modifiers, modifiers,
}, },
}), }),

View file

@ -1307,7 +1307,7 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
event: MouseInput { event: MouseInput {
device_id: DEVICE_ID, device_id: DEVICE_ID,
state: Pressed, state: Pressed,
button: Other(xbutton as u8), button: Other(xbutton),
modifiers: event::get_key_mods(), modifiers: event::get_key_mods(),
}, },
}); });
@ -1329,7 +1329,7 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
event: MouseInput { event: MouseInput {
device_id: DEVICE_ID, device_id: DEVICE_ID,
state: Released, state: Released,
button: Other(xbutton as u8), button: Other(xbutton),
modifiers: event::get_key_mods(), modifiers: event::get_key_mods(),
}, },
}); });