mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: check for maximized window before unmaximizings (#32495)
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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)', () => {
|
||||
|
||||
Reference in New Issue
Block a user