Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit c445ee1

Browse files
dsanders11khalwa
authored andcommitted
fix: on macOS show BrowserWindow on maximize if not currently shown (electron#32949)
1 parent 886401e commit c445ee1

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
@@ -3579,22 +3579,24 @@ describe('BrowserWindow module', () => {
35793579
// TODO(dsanders11): Enable once maximize event works on Linux again on CI
35803580
ifdescribe(process.platform !== 'linux')('BrowserWindow.maximize()', () => {
35813581
afterEach(closeAllWindows);
3582-
// TODO(dsanders11): Disabled on macOS, see https://github.com/electron/electron/issues/32947
3583-
ifit(process.platform !== 'darwin')('should show the window if it is not currently shown', async () => {
3582+
it('should show the window if it is not currently shown', async () => {
35843583
const w = new BrowserWindow({ show: false });
35853584
const hidden = emittedOnce(w, 'hide');
3586-
const shown = emittedOnce(w, 'show');
3585+
let shown = emittedOnce(w, 'show');
35873586
const maximize = emittedOnce(w, 'maximize');
35883587
expect(w.isVisible()).to.be.false('visible');
35893588
w.maximize();
35903589
await maximize;
3590+
await shown;
3591+
expect(w.isMaximized()).to.be.true('maximized');
35913592
expect(w.isVisible()).to.be.true('visible');
35923593
// Even if the window is already maximized
35933594
w.hide();
35943595
await hidden;
35953596
expect(w.isVisible()).to.be.false('visible');
3597+
shown = emittedOnce(w, 'show');
35963598
w.maximize();
3597-
await shown; // Ensure a 'show' event happens when it becomes visible
3599+
await shown;
35983600
expect(w.isVisible()).to.be.true('visible');
35993601
});
36003602
});

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