From 311b6402cf84a6e927aca23b179bd5f2a5114b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=99=A8=E6=98=B1?= Date: Sat, 18 Jul 2026 17:24:44 +0800 Subject: [PATCH] fix(desktop): use custom titlebar on linux --- packages/app/src/components/titlebar.tsx | 2 +- packages/desktop/src/main/windows.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/app/src/components/titlebar.tsx b/packages/app/src/components/titlebar.tsx index 45786561077a..a2ed4380598d 100644 --- a/packages/app/src/components/titlebar.tsx +++ b/packages/app/src/components/titlebar.tsx @@ -84,8 +84,8 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl const mac = createMemo(() => platform.platform === "desktop" && platform.os === "macos") const windows = createMemo(() => platform.platform === "desktop" && platform.os === "windows") - const electronWindows = createMemo(() => windows() && !tauriApi()) const linux = createMemo(() => platform.platform === "desktop" && platform.os === "linux") + const electronWindows = createMemo(() => (windows() || linux()) && !tauriApi()) const web = createMemo(() => platform.platform === "web") const zoom = () => platform.webviewZoom?.() ?? 1 const titlebarZoom = () => (windows() ? Math.max(zoom(), minTitlebarZoom) : zoom()) diff --git a/packages/desktop/src/main/windows.ts b/packages/desktop/src/main/windows.ts index 7a594b5302e9..d80d1bc0ea7c 100644 --- a/packages/desktop/src/main/windows.ts +++ b/packages/desktop/src/main/windows.ts @@ -76,6 +76,7 @@ export function setBackgroundColor(color: string) { BrowserWindow.getAllWindows().forEach((win) => { win.setBackgroundColor(color) if (process.platform === "darwin") win.invalidateShadow() + if (process.platform === "linux") updateTitlebar(win) }) } @@ -103,7 +104,7 @@ function defaultBackgroundColor() { function overlay(theme: Partial = {}, zoom = 1) { const mode = theme.mode ?? tone() return { - color: "#00000000", + color: process.platform === "linux" ? (backgroundColor ?? defaultBackgroundColor()) : "#00000000", symbolColor: mode === "dark" ? "white" : "black", height: Math.max(titlebarHeight, Math.round(titlebarHeight * zoom)), } @@ -122,7 +123,7 @@ export function setTitlebar(win: BrowserWindow, theme: Partial = } export function updateTitlebar(win: BrowserWindow) { - if (process.platform !== "win32") return + if (process.platform !== "win32" && process.platform !== "linux") return win.setTitleBarOverlay(overlay(titlebarThemes.get(win), win.webContents.getZoomFactor())) } @@ -187,7 +188,7 @@ export function createMainWindow(id: string = randomUUID()) { trafficLightPosition: { x: 14, y: 14 }, } : {}), - ...(process.platform === "win32" + ...(process.platform === "win32" || process.platform === "linux" ? { frame: false, titleBarStyle: "hidden" as const,