Skip to content

Commit 3f5e040

Browse files
authored
fix: on macOS show BrowserWindow on maximize if not currently shown (#33535)
1 parent 43d242f commit 3f5e040

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

shell/browser/native_window_mac.mm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,13 +602,23 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
602602
}
603603

604604
void NativeWindowMac::Maximize() {
605-
if (IsMaximized())
605+
const bool is_visible = [window_ isVisible];
606+
607+
if (IsMaximized()) {
608+
if (!is_visible)
609+
ShowInactive();
606610
return;
611+
}
607612

608613
// Take note of the current window size
609614
if (IsNormal())
610615
original_frame_ = [window_ frame];
611616
[window_ zoom:nil];
617+
618+
if (!is_visible) {
619+
ShowInactive();
620+
NotifyWindowMaximize();
621+
}
612622
}
613623

614624
void NativeWindowMac::Unmaximize() {

spec-main/api-browser-window-spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,22 +3553,24 @@ describe('BrowserWindow module', () => {
35533553
// TODO(dsanders11): Enable once maximize event works on Linux again on CI
35543554
ifdescribe(process.platform !== 'linux')('BrowserWindow.maximize()', () => {
35553555
afterEach(closeAllWindows);
3556-
// TODO(dsanders11): Disabled on macOS, see https://github.com/electron/electron/issues/32947
3557-
ifit(process.platform !== 'darwin')('should show the window if it is not currently shown', async () => {
3556+
it('should show the window if it is not currently shown', async () => {
35583557
const w = new BrowserWindow({ show: false });
35593558
const hidden = emittedOnce(w, 'hide');
3560-
const shown = emittedOnce(w, 'show');
3559+
let shown = emittedOnce(w, 'show');
35613560
const maximize = emittedOnce(w, 'maximize');
35623561
expect(w.isVisible()).to.be.false('visible');
35633562
w.maximize();
35643563
await maximize;
3564+
await shown;
3565+
expect(w.isMaximized()).to.be.true('maximized');
35653566
expect(w.isVisible()).to.be.true('visible');
35663567
// Even if the window is already maximized
35673568
w.hide();
35683569
await hidden;
35693570
expect(w.isVisible()).to.be.false('visible');
3571+
shown = emittedOnce(w, 'show');
35703572
w.maximize();
3571-
await shown; // Ensure a 'show' event happens when it becomes visible
3573+
await shown;
35723574
expect(w.isVisible()).to.be.true('visible');
35733575
});
35743576
});

0 commit comments

Comments
 (0)
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