summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c3
-rw-r--r--src/ui/documentwidget.c5
-rw-r--r--src/ui/macos.m7
3 files changed, 14 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index f6ff045d..a8f97d52 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,7 +7,10 @@
7 7
8#include "app.h" 8#include "app.h"
9 9
10extern void enableWheel_MacOS(void);
11
10int main(int argc, char **argv) { 12int main(int argc, char **argv) {
13 enableWheel_MacOS();
11#if defined (iPlatformMsys) 14#if defined (iPlatformMsys)
12 /* MSYS runtime takes care of WinMain. */ 15 /* MSYS runtime takes care of WinMain. */
13 SDL_SetMainReady(); 16 SDL_SetMainReady();
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 48eb482f..6d3e7a9c 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -864,11 +864,16 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
864 } 864 }
865 } 865 }
866 else if (ev->type == SDL_MOUSEWHEEL) { 866 else if (ev->type == SDL_MOUSEWHEEL) {
867#if defined (iPlatformApple)
868 /* Momentum scrolling. */
869 scroll_DocumentWidget_(d, -ev->wheel.y * get_Window()->pixelRatio);
870#else
867 if (keyMods_Sym(SDL_GetModState()) == KMOD_PRIMARY) { 871 if (keyMods_Sym(SDL_GetModState()) == KMOD_PRIMARY) {
868 changeTextSize_DocumentWidget_(d, ev->wheel.y > 0 ? 10 : -10); 872 changeTextSize_DocumentWidget_(d, ev->wheel.y > 0 ? 10 : -10);
869 return iTrue; 873 return iTrue;
870 } 874 }
871 scroll_DocumentWidget_(d, -3 * ev->wheel.y * lineHeight_Text(default_FontId)); 875 scroll_DocumentWidget_(d, -3 * ev->wheel.y * lineHeight_Text(default_FontId));
876#endif
872 return iTrue; 877 return iTrue;
873 } 878 }
874 else if (ev->type == SDL_MOUSEMOTION) { 879 else if (ev->type == SDL_MOUSEMOTION) {
diff --git a/src/ui/macos.m b/src/ui/macos.m
index b50fbf38..46d2bfa1 100644
--- a/src/ui/macos.m
+++ b/src/ui/macos.m
@@ -98,7 +98,7 @@ enum iTouchBarVariant {
98//- (NSTouchBar *)makeTouchBar; 98//- (NSTouchBar *)makeTouchBar;
99/* SDL needs to do its own thing. */ 99/* SDL needs to do its own thing. */
100- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; 100- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
101- (void)applicationDidFinishLaunching:(NSNotification *)notificatiosn; 101- (void)applicationDidFinishLaunching:(NSNotification *)notifications;
102@end 102@end
103 103
104@implementation MyDelegate 104@implementation MyDelegate
@@ -333,6 +333,11 @@ enum iTouchBarVariant {
333 333
334@end 334@end
335 335
336void enableWheel_MacOS(void) {
337 [[NSUserDefaults standardUserDefaults] setBool: YES
338 forKey: @"AppleMomentumScrollSupported"];
339}
340
336void setupApplication_MacOS(void) { 341void setupApplication_MacOS(void) {
337 NSApplication *app = [NSApplication sharedApplication]; 342 NSApplication *app = [NSApplication sharedApplication];
338 /* Our delegate will override SDL's delegate. */ 343 /* Our delegate will override SDL's delegate. */