Skip to content

Commit

Permalink
fix: transparent window max/unmax event firing (#32690)
Browse files Browse the repository at this point in the history
* 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>

* chore: update patches

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Jan 31, 2022
1 parent 2abe74e commit a9b71c1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions shell/browser/native_window_views.cc
Expand Up @@ -595,6 +595,7 @@ void NativeWindowViews::Unmaximize() {
#if defined(OS_WIN)
if (transparent()) {
SetBounds(restore_bounds_, false);
NotifyWindowUnmaximize();
return;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions shell/browser/native_window_views_win.cc
Expand Up @@ -187,6 +187,7 @@ void NativeWindowViews::Maximize() {
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetNativeWindow());
SetBounds(display.work_area(), false);
NotifyWindowMaximize();
}
}

Expand Down
35 changes: 32 additions & 3 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -3241,6 +3241,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;
Expand All @@ -3259,6 +3272,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');
Expand Down

0 comments on commit a9b71c1

Please sign in to comment.