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

electron - always call window.show #151404

Merged
merged 1 commit into from Jun 7, 2022
Merged
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
24 changes: 11 additions & 13 deletions src/vs/platform/windows/electron-main/window.ts
Expand Up @@ -174,7 +174,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this.windowState = state;
this.logService.trace('window#ctor: using window state', state);

// in case we are maximized or fullscreen, only show later after the call to maximize/fullscreen (see below)
// In case we are maximized or fullscreen, only show later
// after the call to maximize/fullscreen (see below)
const isFullscreenOrMaximized = (this.windowState.mode === WindowMode.Maximized || this.windowState.mode === WindowMode.Fullscreen);

const windowSettings = this.configurationService.getValue<IWindowSettings | undefined>('window');
Expand All @@ -187,7 +188,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
backgroundColor: this.themeMainService.getBackgroundColor(),
minWidth: WindowMinimumSize.WIDTH,
minHeight: WindowMinimumSize.HEIGHT,
show: !isFullscreenOrMaximized,
show: !isFullscreenOrMaximized, // reduce flicker by showing later
title: this.productService.nameLong,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
Expand Down Expand Up @@ -301,23 +302,20 @@ export class CodeWindow extends Disposable implements ICodeWindow {

if (isFullscreenOrMaximized) {
mark('code/willMaximizeCodeWindow');

// this call may or may not show the window, depends
// on the platform: currently on Windows and Linux will
// show the window as active. To be on the safe side,
// we show the window at the end of this block.
this._win.maximize();

if (this.windowState.mode === WindowMode.Fullscreen) {
this.setFullScreen(true);
}

if (
!this._win.isVisible() ||
// TODO@electron: Required condition ever since https://github.com/electron/electron/pull/33536
// landed in Electron 17.4.2: calling `window.maximize()` on macOS will wrongly result in
// `window.isVisible()` to return `true` even though a different window might still be on top.
// As such, we also need to ask for `window.isFocused()` which on macOS will ask whether the
// window is a "key" window.
(isMacintosh && !this._win.isFocused())
) {
this._win.show(); // to reduce flicker from the default window size to maximize, we only show after maximize
}
// to reduce flicker from the default window size
// to maximize or fullscreen, we only show after
this._win.show();
mark('code/didMaximizeCodeWindow');
}

Expand Down