Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: transparent window max/unmax event firing #32643

Merged
merged 3 commits into from Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions shell/browser/native_window_views.cc
Expand Up @@ -594,6 +594,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 @@ -1119,7 +1119,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 @@ -1128,12 +1128,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 @@ -3249,6 +3249,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 @@ -3267,6 +3280,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