Skip to content

Commit

Permalink
fix: remove menubar on output windows (#915)
Browse files Browse the repository at this point in the history
updates electron and replaces deprecated new-window event handler with setWindowOpenHandler
  • Loading branch information
2xAA committed Aug 2, 2024
1 parent 6333add commit c4d9ed9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"babel-eslint": "^10.0.3",
"babel-loader": "^9.1.2",
"core-js": "^3.19.1",
"electron": "29.1.5",
"electron": "31.3.1",
"electron-builder": "^22.9.1",
"electron-notarize": "^1.2.2",
"electron-playwright-helpers": "^1.5.3",
Expand Down
48 changes: 32 additions & 16 deletions src/background/window-prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const windowPrefs = {
};
},

/**
*
* @param {BrowserWindow} window
*/
async create(window) {
require("@electron/remote/main").enable(window.webContents);

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

// Configure child windows to open without a menubar (windows/linux)
window.webContents.on(
"new-window",
(event, url, frameName, disposition, options) => {
if (frameName === "modal") {
event.preventDefault();
event.newGuest = new BrowserWindow({
...options,
autoHideMenuBar: true,
closable: false,
enableLargerThanScreen: true,
title: ""
});

event.newGuest.removeMenu();
}
window.webContents.setWindowOpenHandler(({ frameName }) => {
if (frameName === "modal") {
return {
action: "allow",
createWindow: options => {
const window = new BrowserWindow({
...options,
autoHideMenuBar: true,
closable: false,
enableLargerThanScreen: true,
title: ""
});

window.webContents.on("dom-ready", () => {
// Ugly hack
setTimeout(() => {
window.removeMenu();
}, 1000);
});

return window.webContents;
}
};
}
);

return {
action: "deny"
};
});

const mm = getMediaManager();

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5143,10 +5143,10 @@ electron-updater@^4.3.1:
lodash.isequal "^4.5.0"
semver "^7.3.5"

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

0 comments on commit c4d9ed9

Please sign in to comment.