1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:27:35 +00:00

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.
This commit is contained in:
Jelle Raaijmakers 2021-10-27 23:41:38 +02:00 committed by Andreas Kling
parent 7c939c58b8
commit 770c1935d4

View file

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