From f644f62fbd9bd88a6d888ffd0b5d9a778eb01d11 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 21 Jun 2021 12:19:19 +0200 Subject: [PATCH] fix: child window alwaysOnTop level --- shell/browser/native_window_mac.mm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 58939680b6e31..36669ae07eb6d 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1795,8 +1795,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { NativeWindow::SetParentWindow(parent); // Do not remove/add if we are already properly attached. - if (attach && parent && - [window_ parentWindow] == parent->GetNativeWindow().GetNativeNSWindow()) + auto* native_window = parent->GetNativeWindow().GetNativeNSWindow(); + if (attach && parent && [window_ parentWindow] == native_window) return; // Remove current parent window. @@ -1805,10 +1805,13 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { // Set new parent window. // Note that this method will force the window to become visible. - if (parent && attach) - [parent->GetNativeWindow().GetNativeNSWindow() - addChildWindow:window_ - ordered:NSWindowAbove]; + if (parent && attach) { + // Attaching a window as a child window resets its window level, so + // save and restore it afterwards. + NSInteger level = window_.level; + [native_window addChildWindow:window_ ordered:NSWindowAbove]; + [window_ setLevel:level]; + } } void NativeWindowMac::SetForwardMouseMessages(bool forward) {