Browse Source

Fixes #8190.
From #7249, reverted the hunks other than #7239.

kanjitalk755 1 year ago
parent
commit
e152129787
2 changed files with 20 additions and 9 deletions
  1. 5 9
      src/video/cocoa/SDL_cocoamouse.m
  2. 15 0
      src/video/cocoa/SDL_cocoawindow.m

+ 5 - 9
src/video/cocoa/SDL_cocoamouse.m

@@ -219,15 +219,11 @@ static int Cocoa_ShowCursor(SDL_Cursor *cursor)
         SDL_VideoDevice *device = SDL_GetVideoDevice();
         SDL_Window *window = (device ? device->windows : NULL);
         for (; window != NULL; window = window->next) {
-            SDL_Mouse *mouse = SDL_GetMouse();
-            if(mouse->focus) {
-                if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) {
-                    [(__bridge NSCursor*)mouse->cur_cursor->driverdata set];
-                } else {
-                    [[NSCursor invisibleCursor] set];
-                }
-            } else {
-                [[NSCursor arrowCursor] set];
+            SDL_CocoaWindowData *driverdata = (__bridge SDL_CocoaWindowData *)window->driverdata;
+            if (driverdata) {
+                [driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
+                                                      withObject:[driverdata.nswindow contentView]
+                                                   waitUntilDone:NO];
             }
         }
         return 0;

+ 15 - 0
src/video/cocoa/SDL_cocoawindow.m

@@ -1727,6 +1727,21 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
     return YES;
 }
 
+- (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]];
+    }
+}
+
 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
 {
     if (SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH)) {