Skip to content

ui.gestures: increase mouse wheel scroll amount - #2739

Open
defaultxr wants to merge 1 commit into
factor:masterfrom
defaultxr:increase-scroll-speed
Open

defaultxr wants to merge 1 commit into
factor:masterfrom
defaultxr:increase-scroll-speed

Conversation

@defaultxr

Copy link
Copy Markdown

Scrolling with the mouse wheel seems to scroll a lot less in Factor than it does in most other GUI programs. This change multiplies the scroll by 3 which makes it feel a lot closer to how scrolling works in other programs, requiring less mouse scrolling to move down a page.

@mrjbq7

mrjbq7 commented Oct 13, 2023

Copy link
Copy Markdown
Member

I wonder if an acceleration amount is more natural, so slow scrolling is a bit more like what we have and fast scrolling is a bit more like this PR

@inivekin

Copy link
Copy Markdown
Contributor

I took a smooth-brained approach and added a timer to allow a linear build-up of mouse-scroll gestures within an interval.
At first I thought it would need to be more complicated than this but I was surprised how ok it felt, personally. Maybe with some behavioural tweaks and a cleaner implementation this method could be acceptable?

diff --git a/basis/ui/gestures/gestures.factor b/basis/ui/gestures/gestures.factor
index 269033e020..c974c8c2e5 100644
--- a/basis/ui/gestures/gestures.factor
+++ b/basis/ui/gestures/gestures.factor
@@ -201,6 +201,42 @@ SYMBOL: drag-timer
         [ stop-timer ] [ drop ] if
     ] when ;
 
+SYMBOL: scroll-timer
+<box> scroll-timer set-global
+INITIALIZED-SYMBOL: scroll-acceleration [ 1 ]
+INITIALIZED-SYMBOL: scroll-accelerating-direction [ { 0 0 } ]
+DEFER: stop-scroll-timer
+: scroll-gesture ( -- )
+    scroll-acceleration get-global 0 = not [ scroll-acceleration get-global scroll-acceleration [ 1 - ] change-global [ mouse-scroll hand-gadget get-global propagate-gesture ] times ] [ stop-scroll-timer ] if ;
+
+: start-scroll-timer ( -- )
+        scroll-timer get-global occupied>> not
+        [
+            1 scroll-acceleration set-global
+            [ scroll-gesture ]
+            30 milliseconds
+            30 milliseconds
+            <timer>
+            [ scroll-timer get-global >box ]
+            [ start-timer ] bi
+        ]
+        [
+            ! scroll-direction change? set acceleration to 0
+            scroll-direction get-global scroll-accelerating-direction get-global = 
+            [
+                scroll-acceleration [ 2 + ] change-global
+            ]
+            [
+                0 scroll-acceleration set-global
+                scroll-direction get-global scroll-accelerating-direction set-global
+            ] if
+        ] if
+    ;
+: stop-scroll-timer ( -- )
+        scroll-timer get-global ?box
+        [ stop-timer ] [ drop ] if
+    ;
+
 : fire-motion ( -- )
     hand-buttons get-global empty? [
         motion hand-gadget get-global propagate-gesture
@@ -311,7 +347,8 @@ SYMBOL: drag-timer
 : send-scroll ( direction loc world -- )
     move-hand
     scroll-direction set-global
-    mouse-scroll hand-gadget get-global propagate-gesture ;
+    start-scroll-timer ;
+    ! mouse-scroll hand-gadget get-global propagate-gesture ;
 
 : send-action ( world gesture -- )
     swap world-focus propagate-gesture ;

This could maybe worsen things like #2912 , though maybe we could introduce some sort of capacity to the gesture-queue to start dropping actions when filled up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants