Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(titlebar): seamless window titlebar on Windows, macOS and Linux

Etienne Lescotd57e6e552885
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index 2c14fd619..24b9a5bbb 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -316,6 +316,7 @@ interface Window {
onMenuSaveProject: (callback: () => void) => () => void;
onMenuSaveProjectAs: (callback: () => void) => () => void;
quitApp: () => void;
+ setTitleBarOverlay: (color: string, symbolColor: string) => void;
getPlatform: () => Promise<string>;
revealInFolder: (
filePath: string,
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index d2facad8f..bbdda1cfb 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -3287,6 +3287,18 @@ export function registerIpcHandlers(
return process.platform;
});
+ // Keep the native Windows/Linux window-control overlay in the app's theme
+ // colours. The renderer sends the resolved CSS values so the palette stays in
+ // one place. No-op on macOS (traffic lights aren't tintable) and on any window
+ // that wasn't created with an overlay, which is what setTitleBarOverlay throws on.
+ ipcMain.on("set-titlebar-overlay", (event, color: string, symbolColor: string) => {
+ try {
+ BrowserWindow.fromWebContents(event.sender)?.setTitleBarOverlay({ color, symbolColor });
+ } catch {
+ // Best-effort cosmetic.
+ }
+ });
+
ipcMain.handle("get-shortcuts", async () => {
try {
const data = await fs.readFile(SHORTCUTS_FILE, "utf-8");
diff --git a/electron/preload.ts b/electron/preload.ts
index 47acee6f2..381723d60 100644
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@ -311,6 +311,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
quitApp: () => {
ipcRenderer.send("app-quit");
},
+ setTitleBarOverlay: (color: string, symbolColor: string) => {
+ ipcRenderer.send("set-titlebar-overlay", color, symbolColor);
+ },
getPlatform: () => {
return ipcRenderer.invoke("get-platform");
},
diff --git a/electron/windows.ts b/electron/windows.ts
index ca6713627..129eb8757 100644
--- a/electron/windows.ts
+++ b/electron/windows.ts
@@ -259,10 +259,16 @@ export function createEditorWindow(query: Record<string, string> = {}): BrowserW
height: 800,
minWidth: 800,
minHeight: 600,
- ...(isMac && {
- titleBarStyle: "hiddenInset",
- trafficLightPosition: { x: 12, y: 12 },
- }),
+ // Seamless titlebar on every platform: the app's own topbar IS the titlebar
+ // (it already carries the logo, the title and a drag region). macOS keeps its
+ // traffic lights, Windows/Linux get the native Window Controls Overlay — which
+ // preserves Snap Layouts and the system close/maximise semantics instead of
+ // re-implementing them as HTML buttons. Its colours follow the app theme via
+ // the "set-titlebar-overlay" IPC (see handlers.ts).
+ titleBarStyle: "hidden",
+ ...(isMac
+ ? { trafficLightPosition: { x: 18, y: 21 } }
+ : { titleBarOverlay: { color: "#09090b", symbolColor: "#a1a1aa", height: 58 } }),
transparent: false,
resizable: true,
alwaysOnTop: false,
@@ -297,9 +303,16 @@ export function createEditorWindow(query: Record<string, string> = {}): BrowserW
// Inject dark background before any React paint so the sub-titlebar area never
// flashes white on a cold Vite load.
win.webContents.on("dom-ready", () => {
- win.webContents.insertCSS("html, body, #root { background: #09090b !important; }").catch(() => {
- // Best-effort cosmetic; ignore if the page is mid-teardown.
- });
+ // `--titlebar-inset-left` reserves room for the macOS traffic lights; on
+ // Windows/Linux the topbar uses the `titlebar-area-*` env vars instead.
+ win.webContents
+ .insertCSS(
+ `html, body, #root { background: #09090b !important; }
+ :root { --titlebar-inset-left: ${isMac ? "68px" : "0px"}; }`,
+ )
+ .catch(() => {
+ // Best-effort cosmetic; ignore if the page is mid-teardown.
+ });
});
win.webContents.on("did-finish-load", () => {
diff --git a/src/components/ai-edition/v4/EditorShellV4.module.css b/src/components/ai-edition/v4/EditorShellV4.module.css
index 6ebe3c021..62be5ecd5 100644
--- a/src/components/ai-edition/v4/EditorShellV4.module.css
+++ b/src/components/ai-edition/v4/EditorShellV4.module.css
@@ -29,7 +29,15 @@
display: flex;
align-items: center;
gap: 14px;
- padding: 0 18px;
+ /* The topbar doubles as the window titlebar, so it keeps clear of the native
+ window controls: the macOS traffic lights (--titlebar-inset-left, injected
+ per-platform by the main process) on the left, and the Windows/Linux Window
+ Controls Overlay on the right. `titlebar-area-width` is 100vw minus the
+ overlay; without an overlay both terms fall back to a plain 18px gutter. */
+ padding-left: calc(18px + var(--titlebar-inset-left, 0px));
+ padding-right: calc(
+ 18px + 100vw - env(titlebar-area-width, 100vw) - env(titlebar-area-x, 0px)
+ );
background: transparent;
border-bottom: 1px solid var(--border-soft);
min-width: 0;
diff --git a/src/hooks/useTheme.ts b/src/hooks/useTheme.ts
index 8cbb5464e..f99994082 100644
--- a/src/hooks/useTheme.ts
+++ b/src/hooks/useTheme.ts
@@ -25,6 +25,15 @@ function applyTheme(theme: Theme) {
// happen to share property names, so leaving `.dark` stuck on regardless
// of the real theme silently overrides design-tokens.css's light values.
document.documentElement.classList.toggle("dark", theme === "dark");
+
+ // Repaint the native Windows/Linux window controls in the new theme, so the
+ // titlebar reads as one continuous surface with the app. Reading the tokens
+ // back keeps the palette in design-tokens.css only. No-op elsewhere.
+ const css = getComputedStyle(document.documentElement);
+ window.electronAPI?.setTitleBarOverlay?.(
+ css.getPropertyValue("--bg").trim(),
+ css.getPropertyValue("--muted").trim(),
+ );
}
export function useTheme(): { theme: Theme; toggle: () => void; setTheme: (t: Theme) => void } {