diff --git a/resources/docs/docs/getting-started/server-configuration.md b/resources/docs/docs/getting-started/server-configuration.md index 2a2807cc..cc94f48d 100644 --- a/resources/docs/docs/getting-started/server-configuration.md +++ b/resources/docs/docs/getting-started/server-configuration.md @@ -170,6 +170,20 @@ The following options can only be set from a terminal. Override default config file location (contains session history and launcher config). Defaults to `cache-dir/config.json`. + +!!! quote "" + #### `client-position` + + Define the built-in client window position, must be a pair of integers separated by a comma (`x,y`). + + + +!!! quote "" + #### `client-size` + + Define the built-in client window size, must be a pair of integers separated by a comma (`width,height`). + + !!! quote "" #### `help` diff --git a/src/server/electron-window.js b/src/server/electron-window.js index 46bfef27..c58017ec 100644 --- a/src/server/electron-window.js +++ b/src/server/electron-window.js @@ -33,20 +33,33 @@ module.exports = function(options={}) { height = options.height || screenSize.height, bounds = currentScreen.bounds, x = Math.ceil(bounds.x + ((bounds.width - width) / 2)), - y = Math.ceil(bounds.y + ((bounds.height - height) / 2)) - - window.setBounds({x, y, width, height}) + y = Math.ceil(bounds.y + ((bounds.height - height) / 2)), + geometry = {x, y, width, height} // retrieve last geometry if (settings.read('geometry') && settings.read('geometry')[options.id]) { - var geometry = settings.read('geometry')[options.id], + var last_geometry = settings.read('geometry')[options.id], mScreen = screen.getDisplayMatching(geometry) if (intersectionArea(geometry, mScreen.bounds) > 20000) { // don't load geometry if the window is not visible enough - window.setBounds(geometry) + Object.assign(geometry, last_geometry) } } + if (options.id === 'client') { + if (settings.read('client-position')) { + [x, y] = settings.read('client-position').split(',').map(x=>parseInt(x)) + Object.assign(geometry, {x, y}) + } + + if (settings.read('client-size')) { + [width, height] = settings.read('client-size').split(',').map(x=>parseInt(x)) + Object.assign(geometry, {width, height}) + } + } + + window.setBounds(geometry) + window.once('ready-to-show', ()=>{ window.show() }) diff --git a/src/server/options.js b/src/server/options.js index ad4f9ca7..c350539a 100644 --- a/src/server/options.js +++ b/src/server/options.js @@ -93,5 +93,17 @@ module.exports = { 'inspect': {type: 'boolean', describe: 'enable node/electron inspector', launcher: false}, 'cache-dir': {type: 'string', describe: 'override default cache directory', launcher: false}, 'config-file': {type: 'string', describe: 'override default config file (defaults to cache-dir/config.json)', launcher: false}, - 'docs': {type: 'boolean', describe: 'serve documentation website locally and open it with the system\'s default browser', launcher: false} + 'docs': {type: 'boolean', describe: 'serve documentation website locally and open it with the system\'s default browser', launcher: false}, + 'client-position': {type: 'string', describe: 'position of the client window ("x,y" pair of integers)', launcher: false, + check: (s)=>{ + return s.match(/^[0-9]+,[0-9]+$/) ? + 'Position must a x,y pair of integers' : true + } + }, + 'client-size': {type: 'string', describe: 'size of the client window ("width,height" pair of integers)', launcher: false, + check: (s)=>{ + return s.match(/^[0-9]+,[0-9]+$/) ? + 'Size must a x,y pair of integers' : true + } + }, }