From 81984bc72826cf203e1aec3c0ebaacec5755f552 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:33:51 +0100 Subject: [PATCH] fix: add missing `set_wants_to_be_visible(true)` to `NativeWindowMac::ShowInactive()` (#40658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: add missing set_wants_to_be_visible(true) to NativeWindowMac::ShowInactive() Co-authored-by: zaza * add test Co-authored-by: Tamás Zahola --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: zaza Co-authored-by: Tamás Zahola --- shell/browser/native_window_mac.mm | 2 ++ spec/api-browser-window-spec.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index ef91e443bcd1d..70cf93bcf28b4 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -510,6 +510,8 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) { } void NativeWindowMac::ShowInactive() { + set_wants_to_be_visible(true); + // Reattach the window to the parent to actually show it. if (parent()) InternalSetParentWindow(parent(), true); diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 95d532334f030..1adb84378a0f0 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1150,6 +1150,34 @@ describe('BrowserWindow module', () => { await shown; expect(w.isMaximized()).to.equal(true); }); + + ifit(process.platform === 'darwin')('should attach child window to parent', async () => { + const wShow = once(w, 'show'); + w.show(); + await wShow; + + const c = new BrowserWindow({ show: false, parent: w }); + const cShow = once(c, 'show'); + c.showInactive(); + await cShow; + + // verifying by checking that the child tracks the parent's visibility + const minimized = once(w, 'minimize'); + w.minimize(); + await minimized; + + expect(w.isVisible()).to.be.false('parent is visible'); + expect(c.isVisible()).to.be.false('child is visible'); + + const restored = once(w, 'restore'); + w.restore(); + await restored; + + expect(w.isVisible()).to.be.true('parent is visible'); + expect(c.isVisible()).to.be.true('child is visible'); + + closeWindow(c); + }); }); describe('BrowserWindow.focus()', () => {