cocoa: Don't report trackpad mouse events as synthesized touches.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 02 Jul 2019 12:29:36 -0400
changeset 1292373091a9e72f7
parent 12922 db02dca46a9e
child 12924 9cbdc68e4a5e
cocoa: Don't report trackpad mouse events as synthesized touches.

Fixes Bugzilla #4690, sort of. I guess.
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Tue Jul 02 10:26:54 2019 -0400
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Tue Jul 02 12:29:36 2019 -0400
     1.3 @@ -38,6 +38,8 @@
     1.4  #define DLog(...) do { } while (0)
     1.5  #endif
     1.6  
     1.7 +#define TRACKPAD_REPORTS_TOUCH_MOUSEID 0
     1.8 +
     1.9  @implementation NSCursor (InvisibleCursor)
    1.10  + (NSCursor *)invisibleCursor
    1.11  {
    1.12 @@ -379,6 +381,7 @@
    1.13      }
    1.14  
    1.15      SDL_MouseID mouseID = mouse ? mouse->mouseID : 0;
    1.16 +    #if TRACKPAD_REPORTS_TOUCH_MOUSEID
    1.17      if ([event subtype] == NSEventSubtypeTouch) {  /* this is a synthetic from the OS */
    1.18          if (mouse->touch_mouse_events) {
    1.19              mouseID = SDL_TOUCH_MOUSEID;   /* Hint is set */
    1.20 @@ -386,6 +389,7 @@
    1.21              return;  /* no hint set, drop this one. */
    1.22          }
    1.23      }
    1.24 +    #endif
    1.25  
    1.26      const SDL_bool seenWarp = driverdata->seenWarp;
    1.27      driverdata->seenWarp = NO;
    1.28 @@ -432,6 +436,7 @@
    1.29      }
    1.30  
    1.31      SDL_MouseID mouseID = mouse->mouseID;
    1.32 +    #if TRACKPAD_REPORTS_TOUCH_MOUSEID
    1.33      if ([event subtype] == NSEventSubtypeTouch) {  /* this is a synthetic from the OS */
    1.34          if (mouse->touch_mouse_events) {
    1.35              mouseID = SDL_TOUCH_MOUSEID;   /* Hint is set */
    1.36 @@ -439,6 +444,7 @@
    1.37              return;  /* no hint set, drop this one. */
    1.38          }
    1.39      }
    1.40 +    #endif
    1.41  
    1.42      CGFloat x = -[event deltaX];
    1.43      CGFloat y = [event deltaY];
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue Jul 02 10:26:54 2019 -0400
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Jul 02 12:29:36 2019 -0400
     2.3 @@ -922,6 +922,7 @@
     2.4      int button;
     2.5      int clicks;
     2.6  
     2.7 +    #if TRACKPAD_REPORTS_TOUCH_MOUSEID
     2.8      if ([theEvent subtype] == NSEventSubtypeTouch) {  /* this is a synthetic from the OS */
     2.9          if (mouse->touch_mouse_events) {
    2.10              mouseID = SDL_TOUCH_MOUSEID;   /* Hint is set */
    2.11 @@ -929,6 +930,7 @@
    2.12              return;  /* no hint set, drop this one. */
    2.13          }
    2.14      }
    2.15 +    #endif
    2.16  
    2.17      /* Ignore events that aren't inside the client area (i.e. title bar.) */
    2.18      if ([theEvent window]) {
    2.19 @@ -991,6 +993,7 @@
    2.20      int button;
    2.21      int clicks;
    2.22  
    2.23 +    #if TRACKPAD_REPORTS_TOUCH_MOUSEID
    2.24      if ([theEvent subtype] == NSEventSubtypeTouch) {  /* this is a synthetic from the OS */
    2.25          if (mouse->touch_mouse_events) {
    2.26              mouseID = SDL_TOUCH_MOUSEID;   /* Hint is set */
    2.27 @@ -998,6 +1001,7 @@
    2.28              return;  /* no hint set, drop this one. */
    2.29          }
    2.30      }
    2.31 +    #endif
    2.32  
    2.33      if ([self processHitTest:theEvent]) {
    2.34          SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
    2.35 @@ -1051,6 +1055,7 @@
    2.36      NSPoint point;
    2.37      int x, y;
    2.38  
    2.39 +    #if TRACKPAD_REPORTS_TOUCH_MOUSEID
    2.40      if ([theEvent subtype] == NSEventSubtypeTouch) {  /* this is a synthetic from the OS */
    2.41          if (mouse->touch_mouse_events) {
    2.42              mouseID = SDL_TOUCH_MOUSEID;   /* Hint is set */
    2.43 @@ -1058,6 +1063,7 @@
    2.44              return;  /* no hint set, drop this one. */
    2.45          }
    2.46      }
    2.47 +    #endif
    2.48  
    2.49      if ([self processHitTest:theEvent]) {
    2.50          SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);