gdk: fix reversed and sluggish scrolling on MacOS
authorAndy Russell <arussell123@gmail.com>
Mon, 14 Feb 2022 17:43:07 +0000 (12:43 -0500)
committerAndy Russell <arussell123@gmail.com>
Mon, 14 Feb 2022 19:05:39 +0000 (14:05 -0500)
When using an external mouse on MacOS, the scrolling behavior is
reversed from the user's scrolling preference. Additionally, it is
noticeably sluggish.

This commit fixes both issues by negating the deltas and multiplying
them by 32 before constructing a new scroll event. 32 seems to be the
"traditional" scaling factor according to [Druid], but I'm not sure
where that value actually comes from. Regardless, scaling the deltas by
this amount makes scrolling feel a lot more responsive in the GTK demos.

Scrolling with a trackpad is not affected by either issue because it
triggers a different code path that uses more precise deltas, and
already negates them.

[Druid]: https://linebender.gitbook.io/linebender-graphics-wiki/mouse-wheel#external-mouse-wheel-vs-trackpad

gdk/macos/gdkmacosdisplay-translate.c

index ef73d7c86637b034a9c2d82bf68501e313ef5a51..4eac28a8af701577b755d3203cf5202e7d22e2b8 100644 (file)
@@ -688,8 +688,8 @@ fill_scroll_event (GdkMacosDisplay *self,
                                       NULL,
                                       get_time_from_ns_event (nsevent),
                                       state,
-                                      dx,
-                                      dy,
+                                      -dx * 32,
+                                      -dy * 32,
                                       FALSE);
         }
     }