Windows: window on secondary monitor does not restore at exact position (fixes #36122)

This commit is contained in:
Benjamin Pasero
2017-11-01 11:46:54 +01:00
parent fce8c3913e
commit 3589bcd250
+17
View File
@@ -189,6 +189,23 @@ export class CodeWindow implements ICodeWindow {
this._win = new BrowserWindow(options);
this._id = this._win.id;
// TODO@Ben Bug in Electron (https://github.com/electron/electron/issues/10862). On multi-monitor setups,
// it can happen that the position we set to the window is not the correct one on the display.
// To workaround, we ask the window for its position and set it again if not matching.
// This only applies if the window is not fullscreen or maximized and multiple monitors are used.
if (isWindows && !isFullscreenOrMaximized) {
try {
if (screen.getAllDisplays().length > 1) {
const [x, y] = this._win.getPosition();
if (x !== this.windowState.x || y !== this.windowState.y) {
this._win.setPosition(x, y, false);
}
}
} catch (err) {
this.logService.log(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`);
}
}
if (useCustomTitleStyle) {
this._win.setSheetOffset(22); // offset dialogs by the height of the custom title bar if we have any
}