Add native frame to pop-out windows

Signed-off-by: Luka Leer <luka.leer@gmail.com>
This commit is contained in:
Luka Leer 2024-02-29 01:09:00 +01:00
parent d736b6860a
commit c50895837e
No known key found for this signature in database
GPG Key ID: AA82C4EBCB1682E0
1 changed files with 21 additions and 0 deletions

View File

@ -23,6 +23,27 @@ class BrowserWindow extends electron.BrowserWindow {
super(options);
this.__originalPreload = originalPreload;
BetterDiscord.setup(this);
if (typeof(shouldHaveFrame) === "boolean" && shouldHaveFrame) {
// Override the window open handler to force new windows (such as pop-outs) to have frames
this.webContents.on("did-finish-load", () => {
const originalWindowOpenHandler = this.webContents._windowOpenHandler;
this.webContents.setWindowOpenHandler((details) => {
const originalResponse = originalWindowOpenHandler(details);
originalResponse.overrideBrowserWindowOptions.frame = true;
return originalResponse;
});
});
// Remove the title bar and menu from new windows
this.webContents.on("did-create-window", (window) => {
window.removeMenu();
window.webContents.insertCSS(`div[class^="titleBar_"], div[class*=" titleBar_"] {
display: none !important;
}`);
});
}
}
}