|
@@ -460,6 +460,17 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static NSCursor *Cocoa_GetDesiredCursor(void)
|
|
|
+{
|
|
|
+ SDL_Mouse *mouse = SDL_GetMouse();
|
|
|
+
|
|
|
+ if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) {
|
|
|
+ return (__bridge NSCursor *)mouse->cur_cursor->driverdata;
|
|
|
+ }
|
|
|
+
|
|
|
+ return [NSCursor invisibleCursor];
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
@implementation Cocoa_WindowListener
|
|
|
|
|
@@ -1323,6 +1334,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
|
|
|
NSPoint point;
|
|
|
int x, y;
|
|
|
SDL_Window *window;
|
|
|
+ NSView *contentView;
|
|
|
|
|
|
if (!mouse) {
|
|
|
return;
|
|
@@ -1330,6 +1342,17 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
|
|
|
|
|
|
mouseID = mouse->mouseID;
|
|
|
window = _data.window;
|
|
|
+ contentView = _data.sdlContentView;
|
|
|
+ point = [theEvent locationInWindow];
|
|
|
+
|
|
|
+ if ([contentView mouse:[contentView convertPoint:point fromView:nil] inRect:[contentView bounds]] &&
|
|
|
+ [NSCursor currentCursor] != Cocoa_GetDesiredCursor()) {
|
|
|
+ // The wrong cursor is on screen, fix it. This fixes an macOS bug that is only known to
|
|
|
+ // occur in fullscreen windows on the built-in displays of newer MacBooks with camera
|
|
|
+ // notches. When the mouse is moved near the top of such a window (within about 44 units)
|
|
|
+ // and then moved back down, the cursor rects aren't respected.
|
|
|
+ [_data.nswindow invalidateCursorRectsForView:contentView];
|
|
|
+ }
|
|
|
|
|
|
if ([self processHitTest:theEvent]) {
|
|
|
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
|
|
@@ -1340,7 +1363,6 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- point = [theEvent locationInWindow];
|
|
|
x = (int)point.x;
|
|
|
y = (int)(window->h - point.y);
|
|
|
|
|
@@ -1590,17 +1612,9 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
|
|
|
|
|
|
- (void)resetCursorRects
|
|
|
{
|
|
|
- SDL_Mouse *mouse;
|
|
|
[super resetCursorRects];
|
|
|
- mouse = SDL_GetMouse();
|
|
|
-
|
|
|
- if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) {
|
|
|
- [self addCursorRect:[self bounds]
|
|
|
- cursor:(__bridge NSCursor *)mouse->cur_cursor->driverdata];
|
|
|
- } else {
|
|
|
- [self addCursorRect:[self bounds]
|
|
|
- cursor:[NSCursor invisibleCursor]];
|
|
|
- }
|
|
|
+ [self addCursorRect:[self bounds]
|
|
|
+ cursor:Cocoa_GetDesiredCursor()];
|
|
|
}
|
|
|
|
|
|
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|