mirror of https://github.com/laurent22/joplin.git
* ElectronClient window minimum size set Hardcoded minimum width and height of 100 px. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com> * Set Electron window position if outside displays Set Electron window at the center of primaryDisplay if BrowserWindow is not on any displays. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com> * Set Electron window default size dependent on screen Set Electron window defaultWidth, defaultHeight to 80% of primary display workArea width, height, respectively. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com> * Hotfixing Electron defaultHeight depending on width, not height Hotfix of a typo that calculates Electron app's default height at first run using primary screen's width, not height. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com> * Refactoring Electron app defaultWidth/defaultHeight setup Setting defaultWidth/defaultHeight directly without extra variables. Rounding defaultWidth/defaultHeight. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com>pull/2648/head
parent
54dc2219fe
commit
ec64bf2f0f
|
@ -1,4 +1,4 @@
|
|||
const { BrowserWindow, Tray } = require('electron');
|
||||
const { BrowserWindow, Tray, screen } = require('electron');
|
||||
const { shim } = require('lib/shim');
|
||||
const url = require('url');
|
||||
const path = require('path');
|
||||
|
@ -43,9 +43,10 @@ class ElectronAppWrapper {
|
|||
|
||||
const windowStateKeeper = require('electron-window-state');
|
||||
|
||||
|
||||
const stateOptions = {
|
||||
defaultWidth: 800,
|
||||
defaultHeight: 600,
|
||||
defaultWidth: Math.round(0.8*screen.getPrimaryDisplay().workArea.width),
|
||||
defaultHeight: Math.round(0.8*screen.getPrimaryDisplay().workArea.height),
|
||||
file: `window-state-${this.env_}.json`,
|
||||
};
|
||||
|
||||
|
@ -59,6 +60,8 @@ class ElectronAppWrapper {
|
|||
y: windowState.y,
|
||||
width: windowState.width,
|
||||
height: windowState.height,
|
||||
minWidth: 100,
|
||||
minHeight: 100,
|
||||
backgroundColor: '#fff', // required to enable sub pixel rendering, can't be in css
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
|
@ -83,6 +86,12 @@ class ElectronAppWrapper {
|
|||
|
||||
this.win_ = new BrowserWindow(windowOptions);
|
||||
|
||||
if (!screen.getDisplayMatching(this.win_.getBounds())) {
|
||||
const { width: windowWidth, height: windowHeight } = this.win_.getBounds();
|
||||
const { width: primaryDisplayWidth, height: primaryDisplayHeight } = screen.getPrimaryDisplay().workArea;
|
||||
this.win_.setPosition(primaryDisplayWidth/2 - windowWidth, primaryDisplayHeight/2 - windowHeight);
|
||||
}
|
||||
|
||||
this.win_.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
|
|
Loading…
Reference in New Issue