Skip to content

Commit 28f2fbd

Browse files
author
Benjamin Pasero
committed
Window opens in fullscreen when window.newWindowDimensions set to inherit or fullscreen (fixes microsoft#19628)
1 parent c2dfb60 commit 28f2fbd

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/vs/code/electron-main/window.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface IWindowCreationOptions {
3333
state: IWindowState;
3434
extensionDevelopmentPath?: string;
3535
isExtensionTestHost?: boolean;
36-
allowFullscreen?: boolean;
3736
titleBarStyle?: 'native' | 'custom';
3837
}
3938

@@ -592,14 +591,6 @@ export class VSCodeWindow implements IVSCodeWindow {
592591
return null;
593592
}
594593

595-
if (state.mode === WindowMode.Fullscreen) {
596-
if (this.options.allowFullscreen) {
597-
return state;
598-
}
599-
600-
state.mode = WindowMode.Normal; // if we do not allow fullscreen, treat this state as normal window state
601-
}
602-
603594
if ([state.x, state.y, state.width, state.height].some(n => typeof n !== 'number')) {
604595
return null;
605596
}

src/vs/code/electron-main/windows.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export interface IOpenConfiguration {
6666
initialStartup?: boolean;
6767
}
6868

69+
interface INewWindowState extends ISingleWindowState {
70+
hasDefaultState?: boolean;
71+
}
72+
6973
interface IWindowState {
7074
workspacePath?: string;
7175
uiState: ISingleWindowState;
@@ -762,12 +766,27 @@ export class WindowsManager implements IWindowsMainService {
762766
// New window
763767
if (!vscodeWindow) {
764768
const windowConfig = this.configurationService.getConfiguration<IWindowSettings>('window');
769+
const state = this.getNewWindowState(configuration);
770+
771+
// Window state is not from a previous session: only allow fullscreen if we inherit it or user wants fullscreen
772+
let allowFullscreen: boolean;
773+
if (state.hasDefaultState) {
774+
allowFullscreen = (windowConfig && windowConfig.newWindowDimensions && ['fullscreen', 'inherit'].indexOf(windowConfig.newWindowDimensions) >= 0);
775+
}
776+
777+
// Window state is from a previous session: only allow fullscreen when we got updated or user wants to restore
778+
else {
779+
allowFullscreen = this.lifecycleService.wasUpdated || (windowConfig && windowConfig.restoreFullscreen);
780+
}
781+
782+
if (state.mode === WindowMode.Fullscreen && !allowFullscreen) {
783+
state.mode = WindowMode.Normal;
784+
}
765785

766786
vscodeWindow = new VSCodeWindow({
767-
state: this.getNewWindowState(configuration),
787+
state,
768788
extensionDevelopmentPath: configuration.extensionDevelopmentPath,
769789
isExtensionTestHost: !!configuration.extensionTestsPath,
770-
allowFullscreen: this.lifecycleService.wasUpdated || (windowConfig && windowConfig.restoreFullscreen) || (windowConfig && windowConfig.newWindowDimensions && ['fullscreen', 'inherit'].indexOf(windowConfig.newWindowDimensions) >= 0),
771790
titleBarStyle: windowConfig ? windowConfig.titleBarStyle : void 0
772791
},
773792
this.logService,
@@ -822,7 +841,7 @@ export class WindowsManager implements IWindowsMainService {
822841
return vscodeWindow;
823842
}
824843

825-
private getNewWindowState(configuration: IWindowConfiguration): ISingleWindowState {
844+
private getNewWindowState(configuration: IWindowConfiguration): INewWindowState {
826845

827846
// extension development host Window - load from stored settings if any
828847
if (!!configuration.extensionDevelopmentPath && this.windowsState.lastPluginDevelopmentHostWindow) {
@@ -876,7 +895,7 @@ export class WindowsManager implements IWindowsMainService {
876895
}
877896
}
878897

879-
let state = defaultWindowState();
898+
let state = defaultWindowState() as INewWindowState;
880899
state.x = displayToUse.bounds.x + (displayToUse.bounds.width / 2) - (state.width / 2);
881900
state.y = displayToUse.bounds.y + (displayToUse.bounds.height / 2) - (state.height / 2);
882901

@@ -906,6 +925,8 @@ export class WindowsManager implements IWindowsMainService {
906925
state = this.ensureNoOverlap(state);
907926
}
908927

928+
state.hasDefaultState = true; // flag as default state
929+
909930
return state;
910931
}
911932

0 commit comments

Comments
 (0)