mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-12-23 10:25:54 +00:00
fix: mouse button detection
This commit is contained in:
parent
7ace00da50
commit
d42df2153e
2 changed files with 15 additions and 4 deletions
|
|
@ -238,11 +238,12 @@ impl Dispatch<WlPointer, ()> 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 } => {
|
||||
|
|
|
|||
|
|
@ -125,19 +125,29 @@ impl SurfaceState {
|
|||
pub(crate) fn handle_pointer_button(
|
||||
&mut self,
|
||||
serial: u32,
|
||||
button: u32,
|
||||
button_state: WEnum<wl_pointer::ButtonState>,
|
||||
) {
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue