Skip to content

Commit

Permalink
cocoa: Don't report trackpad mouse events as synthesized touches.
Browse files Browse the repository at this point in the history
Fixes Bugzilla #4690, sort of. I guess.
  • Loading branch information
icculus committed Jul 2, 2019
1 parent d2058b4 commit d2d06f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/video/cocoa/SDL_cocoamouse.m
Expand Up @@ -38,6 +38,8 @@
#define DLog(...) do { } while (0)
#endif

#define TRACKPAD_REPORTS_TOUCH_MOUSEID 0

@implementation NSCursor (InvisibleCursor)
+ (NSCursor *)invisibleCursor
{
Expand Down Expand Up @@ -379,13 +381,15 @@ + (NSCursor *)invisibleCursor
}

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 */
} else {
return; /* no hint set, drop this one. */
}
}
#endif

const SDL_bool seenWarp = driverdata->seenWarp;
driverdata->seenWarp = NO;
Expand Down Expand Up @@ -432,13 +436,15 @@ + (NSCursor *)invisibleCursor
}

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 */
} else {
return; /* no hint set, drop this one. */
}
}
#endif

CGFloat x = -[event deltaX];
CGFloat y = [event deltaY];
Expand Down
6 changes: 6 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -922,13 +922,15 @@ - (void)mouseDown:(NSEvent *)theEvent
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 */
} else {
return; /* no hint set, drop this one. */
}
}
#endif

/* Ignore events that aren't inside the client area (i.e. title bar.) */
if ([theEvent window]) {
Expand Down Expand Up @@ -991,13 +993,15 @@ - (void)mouseUp:(NSEvent *)theEvent
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 */
} else {
return; /* no hint set, drop this one. */
}
}
#endif

if ([self processHitTest:theEvent]) {
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
Expand Down Expand Up @@ -1051,13 +1055,15 @@ - (void)mouseMoved:(NSEvent *)theEvent
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 */
} else {
return; /* no hint set, drop this one. */
}
}
#endif

if ([self processHitTest:theEvent]) {
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
Expand Down

0 comments on commit d2d06f4

Please sign in to comment.