feat(electron): enable native window buttons on frameless

This commit is contained in:
Elian Doran 2024-12-01 02:02:33 +02:00
parent 3a0a6bc388
commit 0089346d04
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View File

@ -103,7 +103,6 @@ export default class DesktopLayout {
.class("tab-row-container")
.child(new LeftPaneToggleWidget(true))
.child(new TabRowWidget().class("full-width"))
.child(new TitleBarButtonsWidget())
.css('height', '40px')
.css('background-color', 'var(--launcher-pane-background-color)')
.setParent(appContext)
@ -122,7 +121,6 @@ export default class DesktopLayout {
.css("flex-grow", "1")
.optChild(!launcherPaneIsHorizontal, new FlexContainer('row')
.child(new TabRowWidget())
.child(new TitleBarButtonsWidget())
.css('height', '40px')
)
.child(new FlexContainer('row')

View File

@ -8,7 +8,7 @@ import sqlInit from "./sql_init.js";
import cls from "./cls.js";
import keyboardActionsService from "./keyboard_actions.js";
import remoteMain from "@electron/remote/main/index.js";
import { App, BrowserWindow, WebContents, ipcMain } from 'electron';
import { App, BrowserWindow, BrowserWindowConstructorOptions, WebContents, ipcMain } from 'electron';
import { fileURLToPath } from "url";
import { dirname } from "path";
@ -71,6 +71,12 @@ async function createMainWindow(app: App) {
const { BrowserWindow } = (await import('electron')); // should not be statically imported
const extraOpts: Partial<BrowserWindowConstructorOptions> = {};
if (!optionService.getOptionBool('nativeTitleBarVisible')) {
extraOpts.titleBarStyle = "hidden";
extraOpts.titleBarOverlay = (process.platform !== "darwin");
}
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
@ -82,9 +88,9 @@ async function createMainWindow(app: App) {
contextIsolation: false,
spellcheck: spellcheckEnabled,
webviewTag: true
},
frame: optionService.getOptionBool('nativeTitleBarVisible'),
icon: getIcon()
},
icon: getIcon(),
...extraOpts
});
mainWindowState.manage(mainWindow);