From 28dca8c6477c848b9a6fac9b219fb8e49f3aebab Mon Sep 17 00:00:00 2001 From: Matt Harris Date: Tue, 26 Dec 2017 18:00:39 +0000 Subject: [PATCH] Fix #325 - Add --x and --y window position flags (PR #515) --- app/src/components/mainWindow/mainWindow.js | 4 ++-- docs/api.md | 18 ++++++++++++++++++ src/build/buildApp.js | 2 ++ src/cli.js | 2 ++ src/options/optionsMain.js | 8 ++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/src/components/mainWindow/mainWindow.js b/app/src/components/mainWindow/mainWindow.js index ab344ea..5d8ae55 100644 --- a/app/src/components/mainWindow/mainWindow.js +++ b/app/src/components/mainWindow/mainWindow.js @@ -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, diff --git a/docs/api.md b/docs/api.md index f45b85b..a73e9a6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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 +``` + +X location of the packaged application window. + +#### [y] + +``` +--y +``` + +Y location of the packaged application window. + #### [show-menu-bar] ``` diff --git a/src/build/buildApp.js b/src/build/buildApp.js index 1d9c5b6..436bb1b 100644 --- a/src/build/buildApp.js +++ b/src/build/buildApp.js @@ -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, diff --git a/src/cli.js b/src/cli.js index 44097e4..e219490 100755 --- a/src/cli.js +++ b/src/cli.js @@ -60,6 +60,8 @@ if (require.main === module) { .option('--min-height ', 'set window minimum height, defaults to 0px', parseInt) .option('--max-width ', 'set window maximum width, default is no limit', parseInt) .option('--max-height ', 'set window maximum height, default is no limit', parseInt) + .option('--x ', 'set window x location', parseInt) + .option('--y ', '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 ', 'set the user agent string for the app') diff --git a/src/options/optionsMain.js b/src/options/optionsMain.js index e6207a7..9d25f0e 100644 --- a/src/options/optionsMain.js +++ b/src/options/optionsMain.js @@ -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); }