mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 12:06:07 +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:
parent
7c939c58b8
commit
770c1935d4
Notes:
sideshowbarker
2024-07-18 01:50:20 +09:00
Author: https://github.com/gmta
Commit: 770c1935d4
Pull-request: https://github.com/SerenityOS/serenity/pull/10662
Reviewed-by: https://github.com/awesomekling
1 changed files with 8 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue