Skip to content

Commit a286059

Browse files
committed
macOS - workaround fullscreen window regression (microsoft#125122)
1 parent e57462f commit a286059

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ export class WindowsStateHandler extends Disposable {
232232
const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
233233

234234
// Window state is not from a previous session: only allow fullscreen if we inherit it or user wants fullscreen
235+
// or to address a Electron issue on macOS (https://github.com/microsoft/vscode/issues/125122)
235236
let allowFullscreen: boolean;
236237
if (state.hasDefaultState) {
237-
allowFullscreen = !!(windowConfig?.newWindowDimensions && ['fullscreen', 'inherit', 'offset'].indexOf(windowConfig.newWindowDimensions) >= 0);
238+
const configAllowsFullScreen = !!(windowConfig?.newWindowDimensions && ['fullscreen', 'inherit', 'offset'].indexOf(windowConfig.newWindowDimensions) >= 0);
239+
allowFullscreen = configAllowsFullScreen || (isMacintosh && windowConfig?.nativeFullScreen !== false);
238240
}
239241

240242
// Window state is from a previous session: only allow fullscreen when we got updated or user wants to restore
@@ -337,14 +339,22 @@ export class WindowsStateHandler extends Disposable {
337339
// Compute x/y based on display bounds
338340
// Note: important to use Math.round() because Electron does not seem to be too happy about
339341
// display coordinates that are not absolute numbers.
340-
let state = defaultWindowState();
342+
let state: INewWindowState = defaultWindowState();
341343
state.x = Math.round(displayToUse.bounds.x + (displayToUse.bounds.width / 2) - (state.width! / 2));
342344
state.y = Math.round(displayToUse.bounds.y + (displayToUse.bounds.height / 2) - (state.height! / 2));
343345

344-
// Check for newWindowDimensions setting and adjust accordingly
345346
const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
346347
let ensureNoOverlap = true;
347-
if (windowConfig?.newWindowDimensions) {
348+
349+
// TODO@electron macOS: if the current window is fullscreen and native fullscreen
350+
// is not disabled, always open a new window in fullscreen. This is a workaround
351+
// for regression https://github.com/microsoft/vscode/issues/125122
352+
if (isMacintosh && windowConfig?.nativeFullScreen !== false && lastActive?.isFullScreen) {
353+
state.mode = WindowMode.Fullscreen;
354+
}
355+
356+
// Adjust according to `newWindowDimensions` user setting
357+
else if (windowConfig?.newWindowDimensions) {
348358
if (windowConfig.newWindowDimensions === 'maximized') {
349359
state.mode = WindowMode.Maximized;
350360
ensureNoOverlap = false;
@@ -367,7 +377,7 @@ export class WindowsStateHandler extends Disposable {
367377
state = this.ensureNoOverlap(state);
368378
}
369379

370-
(state as INewWindowState).hasDefaultState = true; // flag as default state
380+
state.hasDefaultState = true; // flag as default state
371381

372382
return state;
373383
}

0 commit comments

Comments
 (0)