Skip to content

Commit c4610b8

Browse files
rburchellawesomekling
authored andcommitted
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.
1 parent 966c5d1 commit c4610b8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Servers/WindowServer/WSWindowManager.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,9 @@ void WSWindowManager::deliver_mouse_event(WSWindow& window, WSMouseEvent& event)
688688

689689
// if the clock is invalid, we haven't clicked with this button on this
690690
// window yet, so there's nothing to do.
691-
if (clock.is_valid()) {
691+
if (!clock.is_valid()) {
692+
clock.start();
693+
} else {
692694
int elapsed_since_last_click = clock.elapsed();
693695
clock.start();
694696

@@ -699,11 +701,14 @@ void WSWindowManager::deliver_mouse_event(WSWindow& window, WSMouseEvent& event)
699701
dbgprintf("Transforming MouseUp to MouseDoubleClick!\n");
700702
#endif
701703
event = WSMouseEvent(WSEvent::MouseDoubleClick, event.position(), event.buttons(), event.button(), event.modifiers(), event.wheel_delta());
704+
// invalidate this now we've delivered a doubleclick, otherwise
705+
// tripleclick will deliver two doubleclick events (incorrectly).
706+
clock = CElapsedTimer();
707+
} else {
708+
// too slow; try again
709+
clock.start();
702710
}
703711
}
704-
705-
// start (or re-start, if it was invalid) the double click timer again.
706-
clock.start();
707712
}
708713

709714
window.event(event);

0 commit comments

Comments
 (0)