From 6f87b6d2846ed679a0537edcd4fff8e6b85d9f6a Mon Sep 17 00:00:00 2001 From: David Sanders Date: Tue, 29 Mar 2022 16:08:34 -0700 Subject: [PATCH] fix: on macOS show BrowserWindow on maximize if not currently shown --- shell/browser/native_window_mac.mm | 12 +++++++++++- spec-main/api-browser-window-spec.ts | 10 ++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 97dc4a7e3433e..b419730ec45df 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -602,13 +602,23 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { } void NativeWindowMac::Maximize() { - if (IsMaximized()) + const bool is_visible = [window_ isVisible]; + + if (IsMaximized()) { + if (!is_visible) + ShowInactive(); return; + } // Take note of the current window size if (IsNormal()) original_frame_ = [window_ frame]; [window_ zoom:nil]; + + if (!is_visible) { + ShowInactive(); + NotifyWindowMaximize(); + } } void NativeWindowMac::Unmaximize() { diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index b3e3ebfc906c2..4c88e1ebbd410 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -3553,22 +3553,24 @@ describe('BrowserWindow module', () => { // TODO(dsanders11): Enable once maximize event works on Linux again on CI ifdescribe(process.platform !== 'linux')('BrowserWindow.maximize()', () => { afterEach(closeAllWindows); - // TODO(dsanders11): Disabled on macOS, see https://github.com/electron/electron/issues/32947 - ifit(process.platform !== 'darwin')('should show the window if it is not currently shown', async () => { + it('should show the window if it is not currently shown', async () => { const w = new BrowserWindow({ show: false }); const hidden = emittedOnce(w, 'hide'); - const shown = emittedOnce(w, 'show'); + let shown = emittedOnce(w, 'show'); const maximize = emittedOnce(w, 'maximize'); expect(w.isVisible()).to.be.false('visible'); w.maximize(); await maximize; + await shown; + expect(w.isMaximized()).to.be.true('maximized'); expect(w.isVisible()).to.be.true('visible'); // Even if the window is already maximized w.hide(); await hidden; expect(w.isVisible()).to.be.false('visible'); + shown = emittedOnce(w, 'show'); w.maximize(); - await shown; // Ensure a 'show' event happens when it becomes visible + await shown; expect(w.isVisible()).to.be.true('visible'); }); }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy