summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Weiss <ik@alexanderweiss.nl>2019-01-26 16:22:18 +0100
committerMichael Lutz <michi@icosahedron.de>2019-02-24 17:54:59 +0100
commit0bb395b21db53d65e195c59d9995a0fb4fa74463 (patch)
tree6c94fd147d6b845fe153876f4451b47665f240af
parent195fd0dc60cc895539ac6c04ff83b6f99f739830 (diff)
downloadopenttd-0bb395b21db53d65e195c59d9995a0fb4fa74463.tar.xz
Change #6800: [OSX] Use high-precision scrolling deltas for 2D scrolling
-rw-r--r--src/video/cocoa/event.mm22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm
index 30b6563b6..77f683af8 100644
--- a/src/video/cocoa/event.mm
+++ b/src/video/cocoa/event.mm
@@ -575,9 +575,25 @@ static bool QZ_PollEvent()
_cursor.wheel++;
} /* else: deltaY was 0.0 and we don't want to do anything */
- /* Set the scroll count for scrollwheel scrolling */
- _cursor.h_wheel -= (int)([ event deltaX ] * 5 * _settings_client.gui.scrollwheel_multiplier);
- _cursor.v_wheel -= (int)([ event deltaY ] * 5 * _settings_client.gui.scrollwheel_multiplier);
+ /* Update the scroll count for 2D scrolling */
+ CGFloat deltaX;
+ CGFloat deltaY;
+
+ /* Use precise scrolling-specific deltas if they're supported. */
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
+ if ([event respondsToSelector:@selector(scrollingDeltaX)]) {
+ deltaX = [ event scrollingDeltaX ] * 0.5f;
+ deltaY = [ event scrollingDeltaY ] * 0.5f;
+ } else
+#endif
+ {
+ deltaX = [ event deltaX ] * 5;
+ deltaY = [ event deltaY ] * 5;
+ }
+
+ _cursor.h_wheel -= (int)(deltaX * _settings_client.gui.scrollwheel_multiplier);
+ _cursor.v_wheel -= (int)(deltaY * _settings_client.gui.scrollwheel_multiplier);
+
break;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)