mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
WSWindowManager: Fix a small whoopsie with double click delivery
We must reset the click clock to invalid after delivering the double click event. Otherwise, a subsequent click will make us (incorrectly) deliver another double click.
This commit is contained in:
parent
966c5d10b1
commit
c4610b825d
Notes:
sideshowbarker
2024-07-19 14:07:33 +09:00
Author: https://github.com/rburchell Commit: https://github.com/SerenityOS/serenity/commit/c4610b825d6 Pull-request: https://github.com/SerenityOS/serenity/pull/40 Reviewed-by: https://github.com/awesomekling
@ -688,7 +688,9 @@ void WSWindowManager::deliver_mouse_event(WSWindow& window, WSMouseEvent& event)
|
||||
|
||||
// if the clock is invalid, we haven't clicked with this button on this
|
||||
// window yet, so there's nothing to do.
|
||||
if (clock.is_valid()) {
|
||||
if (!clock.is_valid()) {
|
||||
clock.start();
|
||||
} else {
|
||||
int elapsed_since_last_click = clock.elapsed();
|
||||
clock.start();
|
||||
|
||||
@ -699,11 +701,14 @@ void WSWindowManager::deliver_mouse_event(WSWindow& window, WSMouseEvent& event)
|
||||
dbgprintf("Transforming MouseUp to MouseDoubleClick!\n");
|
||||
#endif
|
||||
event = WSMouseEvent(WSEvent::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta());
|
||||
// invalidate this now we've delivered a doubleclick, otherwise
|
||||
// tripleclick will deliver two doubleclick events (incorrectly).
|
||||
clock = CElapsedTimer();
|
||||
} else {
|
||||
// too slow; try again
|
||||
clock.start();
|
||||
}
|
||||
}
|
||||
|
||||
// start (or re-start, if it was invalid) the double click timer again.
|
||||
clock.start();
|
||||
}
|
||||
|
||||
window.event(event);
|
||||
|
Loading…
Reference in New Issue
Block a user