From 3cf81f1930ae856d59f0e84a4fc213ee55143b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Oppeb=C3=B8en?= Date: Sun, 27 Nov 2022 02:50:47 +0100 Subject: [PATCH] MouseDemo: Restart timer when scrolling to avoid blinking indicator When scrolling, a timer is triggered to hide the indicator cross. When we continuously scroll, the indicator cross would then blink once the timer kicks in. Instead, let's cancel the current timer and schedule a new one, making the indicator visually smooth. --- Userland/Demos/Mouse/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Demos/Mouse/main.cpp b/Userland/Demos/Mouse/main.cpp index 2dc91268ee..56b29f684d 100644 --- a/Userland/Demos/Mouse/main.cpp +++ b/Userland/Demos/Mouse/main.cpp @@ -143,8 +143,9 @@ public: m_wheel_delta_acc = (m_wheel_delta_acc + event.wheel_delta_y() + 36) % 36; m_show_scroll_wheel = true; update(); - if (!has_timer()) - start_timer(500); + if (has_timer()) + stop_timer(); + start_timer(500); } private: