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 {
|
wl_pointer::Event::Button {
|
||||||
serial,
|
serial,
|
||||||
|
button,
|
||||||
state: button_state,
|
state: button_state,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if let Some(surface) = state.active_surface_mut() {
|
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 } => {
|
wl_pointer::Event::AxisSource { axis_source } => {
|
||||||
|
|
|
||||||
|
|
@ -125,19 +125,29 @@ impl SurfaceState {
|
||||||
pub(crate) fn handle_pointer_button(
|
pub(crate) fn handle_pointer_button(
|
||||||
&mut self,
|
&mut self,
|
||||||
serial: u32,
|
serial: u32,
|
||||||
|
button: u32,
|
||||||
button_state: WEnum<wl_pointer::ButtonState>,
|
button_state: WEnum<wl_pointer::ButtonState>,
|
||||||
) {
|
) {
|
||||||
self.set_last_pointer_serial(serial);
|
self.set_last_pointer_serial(serial);
|
||||||
let position = self.current_pointer_position();
|
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 {
|
let event = match button_state {
|
||||||
WEnum::Value(wl_pointer::ButtonState::Pressed) => WindowEvent::PointerPressed {
|
WEnum::Value(wl_pointer::ButtonState::Pressed) => WindowEvent::PointerPressed {
|
||||||
button: PointerEventButton::Left,
|
button: slint_button,
|
||||||
position,
|
position,
|
||||||
},
|
},
|
||||||
_ => WindowEvent::PointerReleased {
|
WEnum::Value(wl_pointer::ButtonState::Released) => WindowEvent::PointerReleased {
|
||||||
button: PointerEventButton::Left,
|
button: slint_button,
|
||||||
position,
|
position,
|
||||||
},
|
},
|
||||||
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.dispatch_to_active_window(event);
|
self.dispatch_to_active_window(event);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue