diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-10-27 23:41:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-28 11:21:18 +0200 |
commit | 770c1935d40f6b5984602f4d61e894b3519798f1 (patch) | |
tree | aa912b74338d9ce4915db8a6a2d1d1dac79e578d /Userland/Applications/MouseSettings | |
parent | 7c939c58b8812057e1c11d5af53cc12d09a26c96 (diff) | |
download | serenity-770c1935d40f6b5984602f4d61e894b3519798f1.zip |
MouseSettings: Reset the double-click timer after every second click
The old behavior of restarting the timer after every second click could
result in double-click-chains (or triple+ clicks), which does not feel
like the right behavior.
By resetting the double-clicking timer, you need to perform a new full
double-click to make the arrows change color again.
Diffstat (limited to 'Userland/Applications/MouseSettings')
-rw-r--r-- | Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp index deccac60fd..8047bb19b3 100644 --- a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp +++ b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp @@ -55,20 +55,19 @@ void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event) void DoubleClickArrowWidget::mousedown_event(GUI::MouseEvent&) { - if (!m_double_click_timer.is_valid()) { + auto double_click_in_progress = m_double_click_timer.is_valid(); + auto elapsed_ms = double_click_in_progress ? m_double_click_timer.elapsed() : 0; + + if (!double_click_in_progress || elapsed_ms > m_double_click_speed) { m_double_click_timer.start(); return; } - auto elapsed_time = m_double_click_timer.elapsed(); - if (elapsed_time <= m_double_click_speed) { - dbgln("Double-click in {}ms", elapsed_time); - m_inverted = !m_inverted; - update(); - } + dbgln("Double-click in {}ms", elapsed_ms); + m_inverted = !m_inverted; + update(); - // Reset the timer after each click - m_double_click_timer.start(); + m_double_click_timer.reset(); } } |