@@ -115,7 +115,7 @@ export interface IOpenConfiguration extends IBaseOpenConfiguration {
115
115
116
116
export interface IOpenEmptyConfiguration extends IBaseOpenConfiguration { }
117
117
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 } {
119
119
const themeMainService = accessor . get ( IThemeMainService ) ;
120
120
const productService = accessor . get ( IProductService ) ;
121
121
const configurationService = accessor . get ( IConfigurationService ) ;
@@ -129,10 +129,14 @@ export function defaultBrowserWindowOptions(accessor: ServicesAccessor, windowSt
129
129
minHeight : WindowMinimumSize . HEIGHT ,
130
130
title : productService . nameLong ,
131
131
...overrides ,
132
+ x : windowState . x ,
133
+ y : windowState . y ,
134
+ width : windowState . width ,
135
+ height : windowState . height ,
132
136
webPreferences : {
133
137
enableWebSQL : false ,
134
138
spellcheck : false ,
135
- zoomFactor : zoomLevelToZoomFactor ( windowState ? .zoomLevel ?? windowSettings ?. zoomLevel ) ,
139
+ zoomFactor : zoomLevelToZoomFactor ( windowState . zoomLevel ?? windowSettings ?. zoomLevel ) ,
136
140
autoplayPolicy : 'user-gesture-required' ,
137
141
// Enable experimental css highlight api https://chromestatus.com/feature/5436441440026624
138
142
// Refs https://github.com/microsoft/vscode/issues/140098
@@ -143,13 +147,6 @@ export function defaultBrowserWindowOptions(accessor: ServicesAccessor, windowSt
143
147
experimentalDarkMode : true
144
148
} ;
145
149
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
-
153
150
if ( isLinux ) {
154
151
options . icon = join ( environmentMainService . appRoot , 'resources/linux/code.png' ) ; // always on Linux
155
152
} else if ( isWindows && ! environmentMainService . isBuilt ) {
@@ -246,8 +243,9 @@ export namespace WindowStateValidator {
246
243
// some pixels (128) visible on the screen for the user to drag it back.
247
244
if ( displays . length === 1 ) {
248
245
const displayWorkingArea = getWorkingArea ( displays [ 0 ] ) ;
246
+ logService . trace ( 'window#validateWindowState: single monitor working area' , displayWorkingArea ) ;
247
+
249
248
if ( displayWorkingArea ) {
250
- logService . trace ( 'window#validateWindowState: 1 monitor working area' , displayWorkingArea ) ;
251
249
252
250
function ensureStateInDisplayWorkingArea ( ) : void {
253
251
if ( ! state || typeof state . x !== 'number' || typeof state . y !== 'number' || ! displayWorkingArea ) {
@@ -320,10 +318,13 @@ export namespace WindowStateValidator {
320
318
try {
321
319
display = screen . getDisplayMatching ( { x : state . x , y : state . y , width : state . width , height : state . height } ) ;
322
320
displayWorkingArea = getWorkingArea ( display ) ;
321
+
322
+ logService . trace ( 'window#validateWindowState: multi-monitor working area' , displayWorkingArea ) ;
323
323
} catch ( error ) {
324
324
// Electron has weird conditions under which it throws errors
325
325
// e.g. https://github.com/microsoft/vscode/issues/100334 when
326
326
// large numbers are passed in
327
+ logService . error ( 'window#validateWindowState: error finding display for window state' , error ) ;
327
328
}
328
329
329
330
if (
@@ -334,11 +335,11 @@ export namespace WindowStateValidator {
334
335
state . x < displayWorkingArea . x + displayWorkingArea . width && // prevent window from falling out of the screen to the right
335
336
state . y < displayWorkingArea . y + displayWorkingArea . height // prevent window from falling out of the screen to the bottom
336
337
) {
337
- logService . trace ( 'window#validateWindowState: multi-monitor working area' , displayWorkingArea ) ;
338
-
339
338
return state ;
340
339
}
341
340
341
+ logService . trace ( 'window#validateWindowState: state is outside of the multi-monitor working area' ) ;
342
+
342
343
return undefined ;
343
344
}
344
345
0 commit comments