fix: win.isMaximized() for transparent windows on Windows (#38345)

fix: win.isMaximized() for transparent windows

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2023-05-17 13:14:42 +02:00
committed by GitHub
parent 37caca046f
commit ad6155f08e
2 changed files with 19 additions and 1 deletions

View File

@@ -640,7 +640,7 @@ bool NativeWindowViews::IsMaximized() {
return true;
} else {
#if BUILDFLAG(IS_WIN)
if (transparent()) {
if (transparent() && !IsMinimized()) {
// Compare the size of the window with the size of the display
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetNativeWindow());

View File

@@ -6047,6 +6047,24 @@ describe('BrowserWindow module', () => {
describe('"transparent" option', () => {
afterEach(closeAllWindows);
ifit(process.platform !== 'linux')('correctly returns isMaximized() when the window is maximized then minimized', async () => {
const w = new BrowserWindow({
frame: false,
transparent: true
});
const maximize = once(w, 'maximize');
w.maximize();
await maximize;
const minimize = once(w, 'minimize');
w.minimize();
await minimize;
expect(w.isMaximized()).to.be.false();
expect(w.isMinimized()).to.be.true();
});
// 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();