Skip to content

Commit 3a861aa

Browse files
authored
fix: remove menubar on output windows (#915)
updates electron and replaces deprecated new-window event handler with setWindowOpenHandler
1 parent 4e12899 commit 3a861aa

3 files changed

Lines changed: 37 additions & 21 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"babel-eslint": "^10.0.3",
8181
"babel-loader": "^9.1.2",
8282
"core-js": "^3.19.1",
83-
"electron": "29.1.5",
83+
"electron": "31.3.1",
8484
"electron-builder": "^22.9.1",
8585
"electron-notarize": "^1.2.2",
8686
"electron-playwright-helpers": "^1.5.3",

src/background/window-prefs.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ const windowPrefs = {
7777
};
7878
},
7979

80+
/**
81+
*
82+
* @param {BrowserWindow} window
83+
*/
8084
async create(window) {
8185
require("@electron/remote/main").enable(window.webContents);
8286

@@ -87,23 +91,35 @@ const windowPrefs = {
8791
window.setTitle("Untitled");
8892

8993
// Configure child windows to open without a menubar (windows/linux)
90-
window.webContents.on(
91-
"new-window",
92-
(event, url, frameName, disposition, options) => {
93-
if (frameName === "modal") {
94-
event.preventDefault();
95-
event.newGuest = new BrowserWindow({
96-
...options,
97-
autoHideMenuBar: true,
98-
closable: false,
99-
enableLargerThanScreen: true,
100-
title: ""
101-
});
102-
103-
event.newGuest.removeMenu();
104-
}
94+
window.webContents.setWindowOpenHandler(({ frameName }) => {
95+
if (frameName === "modal") {
96+
return {
97+
action: "allow",
98+
createWindow: options => {
99+
const window = new BrowserWindow({
100+
...options,
101+
autoHideMenuBar: true,
102+
closable: false,
103+
enableLargerThanScreen: true,
104+
title: ""
105+
});
106+
107+
window.webContents.on("dom-ready", () => {
108+
// Ugly hack
109+
setTimeout(() => {
110+
window.removeMenu();
111+
}, 1000);
112+
});
113+
114+
return window.webContents;
115+
}
116+
};
105117
}
106-
);
118+
119+
return {
120+
action: "deny"
121+
};
122+
});
107123

108124
const mm = getMediaManager();
109125

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5143,10 +5143,10 @@ electron-updater@^4.3.1:
51435143
lodash.isequal "^4.5.0"
51445144
semver "^7.3.5"
51455145

5146-
electron@29.1.5:
5147-
version "29.1.5"
5148-
resolved "https://registry.yarnpkg.com/electron/-/electron-29.1.5.tgz#b745b4d201c1ac9f84d6aa034126288dde34d5a1"
5149-
integrity sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg==
5146+
electron@31.3.1:
5147+
version "31.3.1"
5148+
resolved "https://registry.yarnpkg.com/electron/-/electron-31.3.1.tgz#de5f21f10db1ba0568e0cdd7ae76ec40a4b800c3"
5149+
integrity sha512-9fiuWlRhBfygtcT+auRd/WdBK/f8LZZcrpx0RjpXhH2DPTP/PfnkC4JB1PW55qCbGbh4wAgkYbf4ExIag8oGCA==
51505150
dependencies:
51515151
"@electron/get" "^2.0.0"
51525152
"@types/node" "^20.9.0"

0 commit comments

Comments
 (0)