@@ -207,18 +207,34 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
207
207
208
208
private async openWindow ( options ?: IAuxiliaryWindowOpenOptions ) : Promise < Window | undefined > {
209
209
const activeWindow = getActiveWindow ( ) ;
210
+ const activeWindowBounds = {
211
+ x : activeWindow . screenX ,
212
+ y : activeWindow . screenY ,
213
+ width : activeWindow . outerWidth ,
214
+ height : activeWindow . outerHeight
215
+ } ;
210
216
211
- const width = options ?. bounds ?. width ?? BrowserAuxiliaryWindowService . DEFAULT_SIZE . width ;
212
- const height = options ?. bounds ?. height ?? BrowserAuxiliaryWindowService . DEFAULT_SIZE . height ;
217
+ const width = Math . max ( options ?. bounds ?. width ?? BrowserAuxiliaryWindowService . DEFAULT_SIZE . width , WindowMinimumSize . WIDTH ) ;
218
+ const height = Math . max ( options ?. bounds ?. height ?? BrowserAuxiliaryWindowService . DEFAULT_SIZE . height , WindowMinimumSize . HEIGHT ) ;
213
219
214
- const bounds : IRectangle = {
215
- x : options ?. bounds ?. x ?? ( activeWindow . screen . availWidth / 2 - width / 2 ) ,
216
- y : options ?. bounds ?. y ?? ( activeWindow . screen . availHeight / 2 - height / 2 ) ,
217
- width : Math . max ( width , WindowMinimumSize . WIDTH ) ,
218
- height : Math . max ( height , WindowMinimumSize . HEIGHT )
220
+ let newWindowBounds : IRectangle = {
221
+ x : options ?. bounds ?. x ?? ( activeWindowBounds . x + activeWindowBounds . width / 2 - width / 2 ) ,
222
+ y : options ?. bounds ?. y ?? ( activeWindowBounds . y + activeWindowBounds . height / 2 - height / 2 ) ,
223
+ width,
224
+ height
219
225
} ;
220
226
221
- const auxiliaryWindow = mainWindow . open ( 'about:blank' , undefined , `popup=yes,left=${ bounds . x } ,top=${ bounds . y } ,width=${ bounds . width } ,height=${ bounds . height } ` ) ;
227
+ if ( newWindowBounds . x === activeWindowBounds . x && newWindowBounds . y === activeWindowBounds . y ) {
228
+ // Offset the new window a bit so that it does not overlap
229
+ // with the active window
230
+ newWindowBounds = {
231
+ ...newWindowBounds ,
232
+ x : newWindowBounds . x + 30 ,
233
+ y : newWindowBounds . y + 30
234
+ } ;
235
+ }
236
+
237
+ const auxiliaryWindow = mainWindow . open ( 'about:blank' , undefined , `popup=yes,left=${ newWindowBounds . x } ,top=${ newWindowBounds . y } ,width=${ newWindowBounds . width } ,height=${ newWindowBounds . height } ` ) ;
222
238
if ( ! auxiliaryWindow && isWeb ) {
223
239
return ( await this . dialogService . prompt ( {
224
240
type : Severity . Warning ,
@@ -227,7 +243,7 @@ export class BrowserAuxiliaryWindowService extends Disposable implements IAuxili
227
243
buttons : [
228
244
{
229
245
label : localize ( { key : 'retry' , comment : [ '&& denotes a mnemonic' ] } , "&&Retry" ) ,
230
- run : ( ) => this . openWindow ( { bounds } )
246
+ run : ( ) => this . openWindow ( options )
231
247
}
232
248
] ,
233
249
cancelButton : true
0 commit comments