cocoa: Don't report trackpad mouse events as synthesized touches. Fixes Bugzilla #4690, sort of. I guess.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
index 937057d..f5c06be 100644
--- a/src/video/cocoa/SDL_cocoamouse.m
+++ b/src/video/cocoa/SDL_cocoamouse.m
@@ -38,6 +38,8 @@
#define DLog(...) do { } while (0)
#endif
+#define TRACKPAD_REPORTS_TOUCH_MOUSEID 0
+
@implementation NSCursor (InvisibleCursor)
+ (NSCursor *)invisibleCursor
{
@@ -379,6 +381,7 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
}
SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
+ #if TRACKPAD_REPORTS_TOUCH_MOUSEID
if ([event subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
@@ -386,6 +389,7 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
return; /* no hint set, drop this one. */
}
}
+ #endif
const SDL_bool seenWarp = driverdata->seenWarp;
driverdata->seenWarp = NO;
@@ -432,6 +436,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
}
SDL_MouseID mouseID = mouse->mouseID;
+ #if TRACKPAD_REPORTS_TOUCH_MOUSEID
if ([event subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
@@ -439,6 +444,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
return; /* no hint set, drop this one. */
}
}
+ #endif
CGFloat x = -[event deltaX];
CGFloat y = [event deltaY];
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index e030d9e..fd56f5c 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -922,6 +922,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
int button;
int clicks;
+ #if TRACKPAD_REPORTS_TOUCH_MOUSEID
if ([theEvent subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
@@ -929,6 +930,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
return; /* no hint set, drop this one. */
}
}
+ #endif
/* Ignore events that aren't inside the client area (i.e. title bar.) */
if ([theEvent window]) {
@@ -991,6 +993,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
int button;
int clicks;
+ #if TRACKPAD_REPORTS_TOUCH_MOUSEID
if ([theEvent subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
@@ -998,6 +1001,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
return; /* no hint set, drop this one. */
}
}
+ #endif
if ([self processHitTest:theEvent]) {
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
@@ -1051,6 +1055,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
NSPoint point;
int x, y;
+ #if TRACKPAD_REPORTS_TOUCH_MOUSEID
if ([theEvent subtype] == NSEventSubtypeTouch) { /* this is a synthetic from the OS */
if (mouse->touch_mouse_events) {
mouseID = SDL_TOUCH_MOUSEID; /* Hint is set */
@@ -1058,6 +1063,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
return; /* no hint set, drop this one. */
}
}
+ #endif
if ([self processHitTest:theEvent]) {
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);