From d42df2153e8bc585f74d05598fed77b628e5df79 Mon Sep 17 00:00:00 2001 From: drendog Date: Mon, 22 Dec 2025 10:32:21 +0100 Subject: [PATCH] fix: mouse button detection --- .../src/wayland/event_handling/app_dispatcher.rs | 3 ++- .../wayland/event_handling/event_dispatcher.rs | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/adapters/src/wayland/event_handling/app_dispatcher.rs b/crates/adapters/src/wayland/event_handling/app_dispatcher.rs index 89bf92a..d86d1d1 100644 --- a/crates/adapters/src/wayland/event_handling/app_dispatcher.rs +++ b/crates/adapters/src/wayland/event_handling/app_dispatcher.rs @@ -238,11 +238,12 @@ impl Dispatch for AppState { wl_pointer::Event::Button { serial, + button, state: button_state, .. } => { if let Some(surface) = state.active_surface_mut() { - surface.handle_pointer_button(serial, button_state); + surface.handle_pointer_button(serial, button, button_state); } } wl_pointer::Event::AxisSource { axis_source } => { diff --git a/crates/adapters/src/wayland/event_handling/event_dispatcher.rs b/crates/adapters/src/wayland/event_handling/event_dispatcher.rs index 1a4c903..60817e7 100644 --- a/crates/adapters/src/wayland/event_handling/event_dispatcher.rs +++ b/crates/adapters/src/wayland/event_handling/event_dispatcher.rs @@ -125,19 +125,29 @@ impl SurfaceState { pub(crate) fn handle_pointer_button( &mut self, serial: u32, + button: u32, button_state: WEnum, ) { self.set_last_pointer_serial(serial); let position = self.current_pointer_position(); + let slint_button = match button { + 0x110 => PointerEventButton::Left, + 0x111 => PointerEventButton::Right, + 0x112 => PointerEventButton::Middle, + 0x115 => PointerEventButton::Forward, + 0x116 => PointerEventButton::Back, + _ => PointerEventButton::Other, + }; let event = match button_state { WEnum::Value(wl_pointer::ButtonState::Pressed) => WindowEvent::PointerPressed { - button: PointerEventButton::Left, + button: slint_button, position, }, - _ => WindowEvent::PointerReleased { - button: PointerEventButton::Left, + WEnum::Value(wl_pointer::ButtonState::Released) => WindowEvent::PointerReleased { + button: slint_button, position, }, + _ => return, }; self.dispatch_to_active_window(event);