Skip to content

Commit

Permalink
fix: check for maximized window before unmaximizings (#32493)
Browse files Browse the repository at this point in the history
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
  • Loading branch information
trop[bot] and dsanders11 committed Jan 18, 2022
1 parent 2d0d51e commit 34d77ca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
12 changes: 7 additions & 5 deletions shell/browser/native_window_views.cc
Expand Up @@ -589,14 +589,16 @@ void NativeWindowViews::Maximize() {
#endif

void NativeWindowViews::Unmaximize() {
if (IsMaximized()) {
#if defined(OS_WIN)
if (transparent()) {
SetBounds(restore_bounds_, false);
return;
}
if (transparent()) {
SetBounds(restore_bounds_, false);
return;
}
#endif

widget()->Restore();
widget()->Restore();
}
}

bool NativeWindowViews::IsMaximized() {
Expand Down
23 changes: 23 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -3417,6 +3417,29 @@ describe('BrowserWindow module', () => {
w.unmaximize();
expectBoundsEqual(w.getPosition(), initialPosition);
});

// TODO(dsanders11): Enable once minimize event works on Linux again.
// See https://github.com/electron/electron/issues/28699
ifit(process.platform !== 'linux')('should not restore a minimized window', async () => {
const w = new BrowserWindow();
const minimize = emittedOnce(w, 'minimize');
w.minimize();
await minimize;
w.unmaximize();
await delay(1000);
expect(w.isMinimized()).to.be.true();
});

it('should not change the size or position of a normal window', async () => {
const w = new BrowserWindow();

const initialSize = w.getSize();
const initialPosition = w.getPosition();
w.unmaximize();
await delay(1000);
expectBoundsEqual(w.getSize(), initialSize);
expectBoundsEqual(w.getPosition(), initialPosition);
});
});

describe('setFullScreen(false)', () => {
Expand Down

0 comments on commit 34d77ca

Please sign in to comment.