Browse Source

macOS: Don't raise the parent top-level window when raising a child window, only raise the child window to the top of the parent

Sam Lantinga 1 year ago
parent
commit
a7eea9997d
1 changed files with 14 additions and 13 deletions
  1. 14 13
      src/video/cocoa/SDL_cocoawindow.m

+ 14 - 13
src/video/cocoa/SDL_cocoawindow.m

@@ -2170,16 +2170,17 @@ void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
             if (SDL_WINDOW_IS_POPUP(window)) {
                 NSWindow *nsparent = ((__bridge SDL_CocoaWindowData *)window->parent->driverdata).nswindow;
                 [nsparent addChildWindow:nswindow ordered:NSWindowAbove];
-            }
-            if (bActivate) {
-                [nswindow makeKeyAndOrderFront:nil];
             } else {
-                /* Order this window below the key window if we're not activating it */
-                if ([NSApp keyWindow]) {
-                    [nswindow orderWindow:NSWindowBelow relativeTo:[[NSApp keyWindow] windowNumber]];
+                if (bActivate) {
+                    [nswindow makeKeyAndOrderFront:nil];
+                } else {
+                    /* Order this window below the key window if we're not activating it */
+                    if ([NSApp keyWindow]) {
+                        [nswindow orderWindow:NSWindowBelow relativeTo:[[NSApp keyWindow] windowNumber]];
+                    }
                 }
-                [nswindow setIsVisible:YES];
             }
+            [nswindow setIsVisible:YES];
             [windowData.listener resumeVisibleObservation];
         }
     }
@@ -2234,13 +2235,13 @@ void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window)
             if (SDL_WINDOW_IS_POPUP(window)) {
                 NSWindow *nsparent = ((__bridge SDL_CocoaWindowData *)window->parent->driverdata).nswindow;
                 [nsparent addChildWindow:nswindow ordered:NSWindowAbove];
-            }
-
-            if (bActivate) {
-                [NSApp activateIgnoringOtherApps:YES];
-                [nswindow makeKeyAndOrderFront:nil];
             } else {
-                [nswindow orderFront:nil];
+                if (bActivate) {
+                    [NSApp activateIgnoringOtherApps:YES];
+                    [nswindow makeKeyAndOrderFront:nil];
+                } else {
+                    [nswindow orderFront:nil];
+                }
             }
         }
         [windowData.listener resumeVisibleObservation];