fix: check for maximized window before unmaximizings (#32438)
This commit is contained in:
parent
2a8d49a059
commit
0c75b3b2ea
2 changed files with 30 additions and 5 deletions
|
@ -581,14 +581,16 @@ void NativeWindowViews::Maximize() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void NativeWindowViews::Unmaximize() {
|
void NativeWindowViews::Unmaximize() {
|
||||||
|
if (IsMaximized()) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (transparent()) {
|
if (transparent()) {
|
||||||
SetBounds(restore_bounds_, false);
|
SetBounds(restore_bounds_, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
widget()->Restore();
|
widget()->Restore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowViews::IsMaximized() {
|
bool NativeWindowViews::IsMaximized() {
|
||||||
|
|
|
@ -3379,6 +3379,29 @@ describe('BrowserWindow module', () => {
|
||||||
w.unmaximize();
|
w.unmaximize();
|
||||||
expectBoundsEqual(w.getPosition(), initialPosition);
|
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)', () => {
|
describe('setFullScreen(false)', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue