fix: transparent window max/unmax event firing (#32688)

* fix: transparent window max/unmax event firing

* chore: fixup tests

* Update spec-main/api-browser-window-spec.ts

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
trop[bot]
2022-02-01 20:21:42 +09:00
committed by GitHub
parent 98603c645e
commit 42c2eecdef
3 changed files with 34 additions and 3 deletions

View File

@@ -593,6 +593,7 @@ void NativeWindowViews::Unmaximize() {
#if defined(OS_WIN)
if (transparent()) {
SetBounds(restore_bounds_, false);
NotifyWindowUnmaximize();
return;
}
#endif

View File

@@ -187,6 +187,7 @@ void NativeWindowViews::Maximize() {
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetNativeWindow());
SetBounds(display.work_area(), false);
NotifyWindowMaximize();
}
}

View File

@@ -1118,7 +1118,7 @@ describe('BrowserWindow module', () => {
await unmaximize;
expectBoundsEqual(w.getNormalBounds(), bounds);
});
it('can check transparent window maximization', async () => {
it('correctly checks transparent window maximization state', async () => {
w.destroy();
w = new BrowserWindow({
show: false,
@@ -1127,12 +1127,12 @@ describe('BrowserWindow module', () => {
transparent: true
});
const maximize = emittedOnce(w, 'resize');
const maximize = emittedOnce(w, 'maximize');
w.show();
w.maximize();
await maximize;
expect(w.isMaximized()).to.equal(true);
const unmaximize = emittedOnce(w, 'resize');
const unmaximize = emittedOnce(w, 'unmaximize');
w.unmaximize();
await unmaximize;
expect(w.isMaximized()).to.equal(false);
@@ -3224,6 +3224,19 @@ describe('BrowserWindow module', () => {
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', () => {
const w = new BrowserWindow({ show: false, frame: false });
let emitted = 0;
@@ -3242,6 +3255,22 @@ describe('BrowserWindow module', () => {
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 () => {
const w = new BrowserWindow({ show: false });
const minimize = emittedOnce(w, 'minimize');