From 151feb0b568fd645a9a0a04822d411de5ead233e Mon Sep 17 00:00:00 2001 From: Sam Wray Date: Sun, 11 Jun 2023 11:09:11 +0100 Subject: [PATCH] fix(output-window): removes immediate setSize call (#849) * fix(output-window): removes immediate setSize call window timings are tricky, occasionally the setSize call sets width and height to 0 * feat(window): prevent accidental close or reload of output window * fix: undo in-dev changes --- src/application/window-handler.js | 14 ++++++++++---- src/background/window-prefs.js | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/application/window-handler.js b/src/application/window-handler.js index ffea8834e..39dfd17b6 100644 --- a/src/application/window-handler.js +++ b/src/application/window-handler.js @@ -1,5 +1,6 @@ export default function windowHandler() { const windows = {}; + const that = this; function createHideMouseTimerhandler(canvas) { let mouseTimer; @@ -18,10 +19,16 @@ export default function windowHandler() { }; } - function configureWindow({ win, canvas, title, backgroundColor }) { + function configureWindow({ win, canvas, backgroundColor }) { win.document.body.appendChild(canvas); - win.document.title = title; win.document.body.style.backgroundColor = backgroundColor; + win.addEventListener("beforeunload", ev => { + // Setting any value other than undefined here will prevent the window + // from closing or reloading + ev.returnValue = true; + }); + + setSize.call(that, win); } function pollToConfigureWindow(args) { @@ -62,6 +69,7 @@ export default function windowHandler() { "modal", `width=${width}, height=${height}, location=no, menubar=no, left=0` ); + win.document.title = title; if (win === null || typeof win === "undefined") { console.log( @@ -120,8 +128,6 @@ export default function windowHandler() { setSize.call(this, win); }); }); - - setSize.call(this, win); } }); diff --git a/src/background/window-prefs.js b/src/background/window-prefs.js index 1471df3f1..abed2ec64 100644 --- a/src/background/window-prefs.js +++ b/src/background/window-prefs.js @@ -90,7 +90,10 @@ const windowPrefs = { event.preventDefault(); event.newGuest = new BrowserWindow({ ...options, - autoHideMenuBar: true + autoHideMenuBar: true, + closable: false, + enableLargerThanScreen: true, + title: "" }); event.newGuest.removeMenu();