From c34956839e4c0ce85893cc34856706684216a6b1 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 25 Aug 2020 08:16:51 -0400 Subject: [PATCH] LibGUI: Make ScrollBar shift-click use same code path as scrubber click It's slightly less code, and m_scrubber_in_use is now set correctly when shift-clicking, keeping the mouse button down, and then dragging the throbber. The shift-click brings the scrubber under the cursor, and then the scrubber_rect().contains() condition is true and both scrubber drags and shift-click-drags are handled the same naturally. --- Libraries/LibGUI/ScrollBar.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Libraries/LibGUI/ScrollBar.cpp b/Libraries/LibGUI/ScrollBar.cpp index 693263609ae..d9f526d653d 100644 --- a/Libraries/LibGUI/ScrollBar.cpp +++ b/Libraries/LibGUI/ScrollBar.cpp @@ -290,6 +290,9 @@ void ScrollBar::mousedown_event(MouseEvent& event) update(); return; } + + if (event.shift()) + scroll_to_position(event.position()); if (scrubber_rect().contains(event.position())) { m_scrubber_in_use = true; m_scrubbing = true; @@ -298,16 +301,10 @@ void ScrollBar::mousedown_event(MouseEvent& event) update(); return; } + ASSERT(!event.shift()); // FIXME: If scrolling by page, scroll every second or so while mouse is down. - if (event.shift()) - scroll_to_position(event.position()); - else - scroll_by_page(event.position()); - - m_scrubbing = true; - m_scrub_start_value = value(); - m_scrub_origin = event.position(); + scroll_by_page(event.position()); } void ScrollBar::mouseup_event(MouseEvent& event)