Center window based on primary display dimensions on linux only

This commit is contained in:
David Howell 2017-10-18 21:15:44 +10:30 committed by Ben Gotow
parent e22ad1621b
commit 96d0d9d071

View file

@ -2,6 +2,7 @@
/* eslint import/no-dynamic-require: 0 */
import _ from 'underscore';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { ipcRenderer, remote } from 'electron';
import { Emitter } from 'event-kit';
@ -585,7 +586,16 @@ export default class AppEnvConstructor {
// Extended: Move current window to the center of the screen.
center() {
return ipcRenderer.send('call-window-method', 'center');
if (os.platform() === 'linux') {
let dimensions = this.getWindowDimensions();
let bounds = remote.screen.getPrimaryDisplay().bounds;
let x = bounds.x + ((bounds.width - dimensions.width) / 2);
let y = bounds.y + ((bounds.height - dimensions.height) / 2);
return this.setPosition(x, y);
} else {
return ipcRenderer.send('call-window-method', 'center');
}
}
// Extended: Focus the current window. Note: this will not open the window