Fix linux double click (#18504)

Closes #17573

Release Notes:

- Check that double clicks on Linux are triggered by same button.
This commit is contained in:
Patrick MARIE 2024-10-01 01:51:05 +02:00 committed by GitHub
parent 938a0679c0
commit a752bbcee8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -236,6 +236,7 @@ pub struct DragState {
}
pub struct ClickState {
last_mouse_button: Option<MouseButton>,
last_click: Instant,
last_location: Point<Pixels>,
current_count: usize,
@ -535,6 +536,7 @@ impl WaylandClient {
},
click: ClickState {
last_click: Instant::now(),
last_mouse_button: None,
last_location: Point::default(),
current_count: 0,
},
@ -1524,6 +1526,10 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
let click_elapsed = state.click.last_click.elapsed();
if click_elapsed < DOUBLE_CLICK_INTERVAL
&& state
.click
.last_mouse_button
.is_some_and(|prev_button| prev_button == button)
&& is_within_click_distance(
state.click.last_location,
state.mouse_location.unwrap(),
@ -1535,6 +1541,7 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
}
state.click.last_click = Instant::now();
state.click.last_mouse_button = Some(button);
state.click.last_location = state.mouse_location.unwrap();
state.button_pressed = Some(button);