mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-20 23:36:21 +08:00
Center window based on primary display dimensions on linux only
This commit is contained in:
parent
e22ad1621b
commit
96d0d9d071
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue