From a3fb411d8aa3f60beba508ab76a841d9b5bdf584 Mon Sep 17 00:00:00 2001 From: theolivenbaum Date: Mon, 6 Sep 2021 12:39:32 +0200 Subject: [PATCH] always keep default values when creating window --- ElectronNET.API/WindowManager.cs | 4 ++-- ElectronNET.Host/api/browserWindows.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ElectronNET.API/WindowManager.cs b/ElectronNET.API/WindowManager.cs index 60f4a1c..6be6071 100644 --- a/ElectronNET.API/WindowManager.cs +++ b/ElectronNET.API/WindowManager.cs @@ -126,10 +126,10 @@ namespace ElectronNET.API if (options.X == -1 && options.Y == -1) { - options.X = 0; + options.X = 0; //This is manually removed by the browserWindows.js code before creating the window options.Y = 0; - BridgeConnector.Emit("createBrowserWindow", guid, JObject.FromObject(options, _jsonSerializer), loadUrl); + BridgeConnector.Emit("createBrowserWindow", guid, JObject.FromObject(options, _keepDefaultValuesSerializer), loadUrl); } else { diff --git a/ElectronNET.Host/api/browserWindows.js b/ElectronNET.Host/api/browserWindows.js index 458c4d9..ecf3209 100644 --- a/ElectronNET.Host/api/browserWindows.js +++ b/ElectronNET.Host/api/browserWindows.js @@ -182,6 +182,12 @@ module.exports = (socket, app) => { else if (!options.webPreferences) { options = { ...options, webPreferences: { nodeIntegration: true, contextIsolation: false } }; } + + if (options.x && options.y && options.x == 0 && options.y == 0) { + delete options.x; + delete options.y; + } + // we dont want to recreate the window when watch is ready. if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) { window = app['mainWindow'];