8000 fix: show maximized frameless window by trop[bot] · Pull Request #30863 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: show maximized frameless window #30863

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion shell/browser/native_window_views.cc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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