Skip to content

Commit

Permalink
fix: show maximized frameless window (#30863)
Browse files Browse the repository at this point in the history
* fix: show maximized frameless window

* test: show maximized transparent window

* fix: test using wrong bounds

BrowserWindow will be sized to the workArea when the Windows taskbar is
visible.

Co-authored-by: samuelmaddock <samuel.maddock@gmail.com>
  • Loading branch information
trop[bot] and samuelmaddock committed Sep 7, 2021
1 parent 5ff2f65 commit b4d322a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
11 changes: 10 additions & 1 deletion shell/browser/native_window_views.cc
Expand Up @@ -1582,8 +1582,17 @@ void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) {
}

ui::WindowShowState NativeWindowViews::GetRestoredState() {
if (IsMaximized())
if (IsMaximized()) {
#if defined(OS_WIN)
// Only restore Maximized state when window is NOT transparent style
if (!transparent()) {
return ui::SHOW_STATE_MAXIMIZED;
}
#else
return ui::SHOW_STATE_MAXIMIZED;
#endif
}

if (IsFullscreen())
return ui::SHOW_STATE_FULLSCREEN;

Expand Down
28 changes: 28 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -4676,4 +4676,32 @@ describe('BrowserWindow module', () => {
});
});
});

describe('"transparent" option', () => {
afterEach(closeAllWindows);

// Only applicable on Windows where transparent windows can't be maximized.
ifit(process.platform === 'win32')('can show maximized frameless window', async () => {
const display = screen.getPrimaryDisplay();

const w = new BrowserWindow({
...display.bounds,
frame: false,
transparent: true,
show: true
});

w.loadURL('about:blank');
await emittedOnce(w, 'ready-to-show');

expect(w.isMaximized()).to.be.true();

// Fails when the transparent HWND is in an invalid maximized state.
expect(w.getBounds()).to.deep.equal(display.workArea);

const newBounds = { width: 256, height: 256, x: 0, y: 0 };
w.setBounds(newBounds);
expect(w.getBounds()).to.deep.equal(newBounds);
});
});
});

0 comments on commit b4d322a

Please sign in to comment.