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:
Robin Burchell 2019-05-16 00:40:11 +02:00 committed by Andreas Kling
parent 966c5d10b1
commit c4610b825d
Notes: sideshowbarker 2024-07-19 14:07:33 +09:00

View File

@ -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);