fix: transparent window max/unmax event firing (#32643)
This commit is contained in:
parent
365933f1f3
commit
f5dc2a6535
3 changed files with 34 additions and 3 deletions
|
@ -594,6 +594,7 @@ void NativeWindowViews::Unmaximize() {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (transparent()) {
|
if (transparent()) {
|
||||||
SetBounds(restore_bounds_, false);
|
SetBounds(restore_bounds_, false);
|
||||||
|
NotifyWindowUnmaximize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -187,6 +187,7 @@ void NativeWindowViews::Maximize() {
|
||||||
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
|
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
|
||||||
GetNativeWindow());
|
GetNativeWindow());
|
||||||
SetBounds(display.work_area(), false);
|
SetBounds(display.work_area(), false);
|
||||||
|
NotifyWindowMaximize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ describe('BrowserWindow module', () => {
|
||||||
await unmaximize;
|
await unmaximize;
|
||||||
expectBoundsEqual(w.getNormalBounds(), bounds);
|
expectBoundsEqual(w.getNormalBounds(), bounds);
|
||||||
});
|
});
|
||||||
it('can check transparent window maximization', async () => {
|
it('correctly checks transparent window maximization state', async () => {
|
||||||
w.destroy();
|
w.destroy();
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
show: false,
|
show: false,
|
||||||
|
@ -1128,12 +1128,12 @@ describe('BrowserWindow module', () => {
|
||||||
transparent: true
|
transparent: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const maximize = emittedOnce(w, 'resize');
|
const maximize = emittedOnce(w, 'maximize');
|
||||||
w.show();
|
w.show();
|
||||||
w.maximize();
|
w.maximize();
|
||||||
await maximize;
|
await maximize;
|
||||||
expect(w.isMaximized()).to.equal(true);
|
expect(w.isMaximized()).to.equal(true);
|
||||||
const unmaximize = emittedOnce(w, 'resize');
|
const unmaximize = emittedOnce(w, 'unmaximize');
|
||||||
w.unmaximize();
|
w.unmaximize();
|
||||||
await unmaximize;
|
await unmaximize;
|
||||||
expect(w.isMaximized()).to.equal(false);
|
expect(w.isMaximized()).to.equal(false);
|
||||||
|
@ -3266,6 +3266,19 @@ describe('BrowserWindow module', () => {
|
||||||
await maximize;
|
await maximize;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('emits an event when a transparent window is maximized', async () => {
|
||||||
|
const w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
frame: false,
|
||||||
|
transparent: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const maximize = emittedOnce(w, 'maximize');
|
||||||
|
w.show();
|
||||||
|
w.maximize();
|
||||||
|
await maximize;
|
||||||
|
});
|
||||||
|
|
||||||
it('emits only one event when frameless window is maximized', () => {
|
it('emits only one event when frameless window is maximized', () => {
|
||||||
const w = new BrowserWindow({ show: false, frame: false });
|
const w = new BrowserWindow({ show: false, frame: false });
|
||||||
let emitted = 0;
|
let emitted = 0;
|
||||||
|
@ -3284,6 +3297,22 @@ describe('BrowserWindow module', () => {
|
||||||
await unmaximize;
|
await unmaximize;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('emits an event when a transparent window is unmaximized', async () => {
|
||||||
|
const w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
frame: false,
|
||||||
|
transparent: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const maximize = emittedOnce(w, 'maximize');
|
||||||
|
const unmaximize = emittedOnce(w, 'unmaximize');
|
||||||
|
w.show();
|
||||||
|
w.maximize();
|
||||||
|
await maximize;
|
||||||
|
w.unmaximize();
|
||||||
|
await unmaximize;
|
||||||
|
});
|
||||||
|
|
||||||
it('emits an event when window is minimized', async () => {
|
it('emits an event when window is minimized', async () => {
|
||||||
const w = new BrowserWindow({ show: false });
|
const w = new BrowserWindow({ show: false });
|
||||||
const minimize = emittedOnce(w, 'minimize');
|
const minimize = emittedOnce(w, 'minimize');
|
||||||
|
|
Loading…
Reference in a new issue