8000 fix: check for maximized window before unmaximizing by trop[bot] · Pull Request #32495 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: check for maximized window before unmaximizing #32495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions shell/browser/native_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,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
Original file line number Diff line number Diff line change
Expand Up @@ -3404,6 +3404,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