Fix #325 - Add --x and --y window position flags (PR #515)

This commit is contained in:
Matt Harris 2017-12-26 18:00:39 +00:00 committed by Ronan Jouchet
parent eb08d85830
commit 28dca8c647
5 changed files with 32 additions and 2 deletions

View File

@ -71,8 +71,8 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
minHeight: options.minHeight,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
x: mainWindowState.x,
y: mainWindowState.y,
x: options.x,
y: options.y,
autoHideMenuBar: !options.showMenuBar,
// Convert dashes to spaces because on linux the app name is joined with dashes
title: options.name,

View File

@ -21,6 +21,8 @@
- [[min-height]](#min-height)
- [[max-width]](#max-width)
- [[max-height]](#max-height)
- [[x]](#x)
- [[y]](#y)
- [[show-menu-bar]](#show-menu-bar)
- [[fast-quit]](#fast-quit)
- [[user-agent]](#user-agent)
@ -229,6 +231,22 @@ Maximum width of the packaged application, default is no limit.
Maximum height of the packaged application, default is no limit.
#### [x]
```
--x <value>
```
X location of the packaged application window.
#### [y]
```
--y <value>
```
Y location of the packaged application window.
#### [show-menu-bar]
```

View File

@ -21,6 +21,8 @@ function selectAppArgs(options) {
minHeight: options.minHeight,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
x: options.x,
y: options.y,
showMenuBar: options.showMenuBar,
fastQuit: options.fastQuit,
userAgent: options.userAgent,

View File

@ -60,6 +60,8 @@ if (require.main === module) {
.option('--min-height <value>', 'set window minimum height, defaults to 0px', parseInt)
.option('--max-width <value>', 'set window maximum width, default is no limit', parseInt)
.option('--max-height <value>', 'set window maximum height, default is no limit', parseInt)
.option('--x <value>', 'set window x location', parseInt)
.option('--y <value>', 'set window y location', parseInt)
.option('-m, --show-menu-bar', 'set menu bar visible, defaults to false')
.option('-f, --fast-quit', 'quit app after window close (OSX only), defaults to false')
.option('-u, --user-agent <value>', 'set the user agent string for the app')

View File

@ -101,5 +101,13 @@ export default function (inpOptions) {
options.height = options.maxHeight;
}
if (typeof inpOptions.x !== 'undefined') {
options.x = inpOptions.x;
}
if (typeof inpOptions.y !== 'undefined') {
options.y = inpOptions.y;
}
return asyncConfig(options);
}