@@ -66,6 +66,10 @@ export interface IOpenConfiguration {
6666 initialStartup ?: boolean ;
6767}
6868
69+ interface INewWindowState extends ISingleWindowState {
70+ hasDefaultState ?: boolean ;
71+ }
72+
6973interface 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