diff --git a/index.js b/index.js index 97491eb..58e1243 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,8 @@ module.exports = function (options) { file: 'window-state.json', path: app.getPath('userData'), maximize: true, - fullScreen: true + fullScreen: true, + resetToCenter: false }, options); const fullStoreFileName = path.join(config.path, config.file); @@ -33,14 +34,22 @@ module.exports = function (options) { } function resetStateToDefault() { + let x = 0; + let y = 0; + const width = config.defaultWidth || 800; + const height = config.defaultHeight || 600; const displayBounds = screen.getPrimaryDisplay().bounds; // Reset state to default values on the primary display + if (config.resetToCenter) { + x = (displayBounds.width - width) / 2; + y = (displayBounds.height - height) / 2; + } state = { - width: config.defaultWidth || 800, - height: config.defaultHeight || 600, - x: 0, - y: 0, + width, + height, + x, + y, displayBounds }; } diff --git a/package-lock.json b/package-lock.json index 86886cc..b993f6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2842,7 +2842,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2863,12 +2864,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2883,17 +2886,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3010,7 +3016,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3022,6 +3029,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3036,6 +3044,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3043,12 +3052,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -3067,6 +3078,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3147,7 +3159,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3159,6 +3172,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3244,7 +3258,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3280,6 +3295,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3299,6 +3315,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3342,12 +3359,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } },