@@ -115,7 +115,7 @@ export interface IOpenConfiguration extends IBaseOpenConfiguration {
115115
116116export interface IOpenEmptyConfiguration extends IBaseOpenConfiguration { }
117117
118- export function defaultBrowserWindowOptions ( accessor : ServicesAccessor , windowState ? : IWindowState , overrides ?: BrowserWindowConstructorOptions ) : BrowserWindowConstructorOptions & { experimentalDarkMode : boolean } {
118+ export function defaultBrowserWindowOptions ( accessor : ServicesAccessor , windowState : IWindowState , overrides ?: BrowserWindowConstructorOptions ) : BrowserWindowConstructorOptions & { experimentalDarkMode : boolean } {
119119 const themeMainService = accessor . get ( IThemeMainService ) ;
120120 const productService = accessor . get ( IProductService ) ;
121121 const configurationService = accessor . get ( IConfigurationService ) ;
@@ -129,10 +129,14 @@ export function defaultBrowserWindowOptions(accessor: ServicesAccessor, windowSt
129129 minHeight : WindowMinimumSize . HEIGHT ,
130130 title : productService . nameLong ,
131131 ...overrides ,
132+ x : windowState . x ,
133+ y : windowState . y ,
134+ width : windowState . width ,
135+ height : windowState . height ,
132136 webPreferences : {
133137 enableWebSQL : false ,
134138 spellcheck : false ,
135- zoomFactor : zoomLevelToZoomFactor ( windowState ? .zoomLevel ?? windowSettings ?. zoomLevel ) ,
139+ zoomFactor : zoomLevelToZoomFactor ( windowState . zoomLevel ?? windowSettings ?. zoomLevel ) ,
136140 autoplayPolicy : 'user-gesture-required' ,
137141 // Enable experimental css highlight api https://chromestatus.com/feature/5436441440026624
138142 // Refs https://github.com/microsoft/vscode/issues/140098
@@ -143,13 +147,6 @@ export function defaultBrowserWindowOptions(accessor: ServicesAccessor, windowSt
143147 experimentalDarkMode : true
144148 } ;
145149
146- if ( windowState ) {
147- options . x = windowState . x ;
148- options . y = windowState . y ;
149- options . width = windowState . width ;
150- options . height = windowState . height ;
151- }
152-
153150 if ( isLinux ) {
154151 options . icon = join ( environmentMainService . appRoot , 'resources/linux/code.png' ) ; // always on Linux
155152 } else if ( isWindows && ! environmentMainService . isBuilt ) {
@@ -246,8 +243,9 @@ export namespace WindowStateValidator {
246243 // some pixels (128) visible on the screen for the user to drag it back.
247244 if ( displays . length === 1 ) {
248245 const displayWorkingArea = getWorkingArea ( displays [ 0 ] ) ;
246+ logService . trace ( 'window#validateWindowState: single monitor working area' , displayWorkingArea ) ;
247+
249248 if ( displayWorkingArea ) {
250- logService . trace ( 'window#validateWindowState: 1 monitor working area' , displayWorkingArea ) ;
251249
252250 function ensureStateInDisplayWorkingArea ( ) : void {
253251 if ( ! state || typeof state . x !== 'number' || typeof state . y !== 'number' || ! displayWorkingArea ) {
@@ -320,10 +318,13 @@ export namespace WindowStateValidator {
320318 try {
321319 display = screen . getDisplayMatching ( { x : state . x , y : state . y , width : state . width , height : state . height } ) ;
322320 displayWorkingArea = getWorkingArea ( display ) ;
321+
322+ logService . trace ( 'window#validateWindowState: multi-monitor working area' , displayWorkingArea ) ;
323323 } catch ( error ) {
324324 // Electron has weird conditions under which it throws errors
325325 // e.g. https://github.com/microsoft/vscode/issues/100334 when
326326 // large numbers are passed in
327+ logService . error ( 'window#validateWindowState: error finding display for window state' , error ) ;
327328 }
328329
329330 if (
@@ -334,11 +335,11 @@ export namespace WindowStateValidator {
334335 state . x < displayWorkingArea . x + displayWorkingArea . width && // prevent window from falling out of the screen to the right
335336 state . y < displayWorkingArea . y + displayWorkingArea . height // prevent window from falling out of the screen to the bottom
336337 ) {
337- logService . trace ( 'window#validateWindowState: multi-monitor working area' , displayWorkingArea ) ;
338-
339338 return state ;
340339 }
341340
341+ logService . trace ( 'window#validateWindowState: state is outside of the multi-monitor working area' ) ;
342+
342343 return undefined ;
343344 }
344345
0 commit comments