Skip to content

Commit d899cc9

Browse files
authored
electron - always call window.show (microsoft#151404)
1 parent f3a57f6 commit d899cc9

File tree

1 file changed

+11
-13
lines changed
  • src/vs/platform/windows/electron-main

1 file changed

+11
-13
lines changed

src/vs/platform/windows/electron-main/window.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
174174
this.windowState = state;
175175
this.logService.trace('window#ctor: using window state', state);
176176

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

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

302303
if (isFullscreenOrMaximized) {
303304
mark('code/willMaximizeCodeWindow');
305+
306+
// this call may or may not show the window, depends
307+
// on the platform: currently on Windows and Linux will
308+
// show the window as active. To be on the safe side,
309+
// we show the window at the end of this block.
304310
this._win.maximize();
305311

306312
if (this.windowState.mode === WindowMode.Fullscreen) {
307313
this.setFullScreen(true);
308314
}
309315

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

0 commit comments

Comments
 (0)