From a553dafa7a9ce52cdb2a18e889fad8b3cafcdaf8 Mon Sep 17 00:00:00 2001 From: xRookieFight Date: Sat, 31 Oct 2026 07:43:01 +0300 Subject: [PATCH] feat(window): use the frameless title bar on Linux (#279) Linux windows used the GTK menu bar and the system title bar, unlike the frameless main toolbar on Windows. Linux project and Settings windows now turn off decorations, install no GTK menu bar and draw the main menu and caption buttons in the title bar. Co-authored-by: xRookieFight <50714128+xRookieFight@users.noreply.github.com> --- src-tauri/src/menu.rs | 6 +++--- src-tauri/src/windows.rs | 2 +- src-tauri/tauri.linux.conf.json | 18 ++++++++++++++++++ src/platform/platformInfo.ts | 6 +++--- src/workbench/MainMenu.tsx | 2 +- src/workbench/TitleBar.module.css | 2 +- src/workbench/TitleBar.tsx | 4 ++-- src/workbench/WindowControls.tsx | 2 +- 8 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 src-tauri/tauri.linux.conf.json diff --git a/src-tauri/src/menu.rs b/src-tauri/src/menu.rs index 0937bfce3..8ad7a7aee 100644 --- a/src-tauri/src/menu.rs +++ b/src-tauri/src/menu.rs @@ -1173,10 +1173,10 @@ pub fn model(spec: &[Entry], recent: &[RecentItem], config: &MenuConfig) -> Vec< out } -/// Whether the OS menu bar is used. Windows project windows draw IDEA's -/// hamburger menu in their own title bar instead. +/// Whether the OS menu bar is used. Windows and Linux project windows are +/// frameless and draw IDEA's hamburger menu in their own title bar instead. pub fn native_menu_bar() -> bool { - !cfg!(target_os = "windows") + cfg!(target_os = "macos") } /// Rebuilds and installs the app menu from the current config and recent list. diff --git a/src-tauri/src/windows.rs b/src-tauri/src/windows.rs index 78381f709..e7be69548 100644 --- a/src-tauri/src/windows.rs +++ b/src-tauri/src/windows.rs @@ -724,7 +724,7 @@ pub fn open_settings_window( let mut config = window_config(app)?; config.label = label.clone(); config.title = "Settings".into(); - // Frameless on Windows like project windows (tauri.windows.conf.json): the page draws + // Frameless on Windows and Linux like project windows (tauri..conf.json): the page draws // the title bar in the app theme instead of a system caption that follows the OS theme. (config.width, config.height) = SETTINGS_SIZE; (config.min_width, config.min_height) = (Some(SETTINGS_MIN_SIZE.0), Some(SETTINGS_MIN_SIZE.1)); diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json new file mode 100644 index 000000000..d3fb6d740 --- /dev/null +++ b/src-tauri/tauri.linux.conf.json @@ -0,0 +1,18 @@ +{ + "app": { + "windows": [ + { + "label": "main", + "create": false, + "title": "OpenIDEA", + "width": 1440, + "height": 900, + "minWidth": 800, + "minHeight": 500, + "decorations": false, + "backgroundColor": "#E9EAEE", + "dragDropEnabled": true + } + ] + } +} diff --git a/src/platform/platformInfo.ts b/src/platform/platformInfo.ts index 34e7938cf..230a34bdd 100644 --- a/src/platform/platformInfo.ts +++ b/src/platform/platformInfo.ts @@ -7,7 +7,7 @@ interface PlatformInfo { version: string | null; /** Native traffic lights overlay the title bar (Tauri, macOS, Overlay style). */ overlayTitleBar: boolean; - /** Frameless window: the title bar draws the main menu and caption buttons (Tauri, Windows). */ + /** Frameless window: the title bar draws the main menu and caption buttons (Tauri, Windows and Linux). */ framelessTitleBar: boolean; } @@ -27,7 +27,7 @@ export const usePlatform = create(() => { os, version: null, overlayTitleBar: isTauri() && os === "macos", - framelessTitleBar: isTauri() && os === "windows", + framelessTitleBar: isTauri() && (os === "windows" || os === "linux"), }; }); @@ -39,7 +39,7 @@ export async function loadPlatformInfo() { os: info.platform, version: info.version, overlayTitleBar: info.platform === "macos", - framelessTitleBar: info.platform === "windows", + framelessTitleBar: info.platform === "windows" || info.platform === "linux", }); } catch { /* keep the user-agent guess */ diff --git a/src/workbench/MainMenu.tsx b/src/workbench/MainMenu.tsx index 8dc9061fa..abac3a1bf 100644 --- a/src/workbench/MainMenu.tsx +++ b/src/workbench/MainMenu.tsx @@ -1,5 +1,5 @@ /** - * Windows title bar: IDEA's main menu button. Clicking ☰ expands the menu bar + * Frameless title bar (Windows, Linux): IDEA's main menu button. Clicking ☰ expands the menu bar * in place (File Edit View …) with File open; hovering another title switches * menus, ←/→ walk them, and closing the menu collapses the bar again. The * entries come from the same spec as the native menu (`menu_model`). As in diff --git a/src/workbench/TitleBar.module.css b/src/workbench/TitleBar.module.css index afed9c4b7..da2d54ded 100644 --- a/src/workbench/TitleBar.module.css +++ b/src/workbench/TitleBar.module.css @@ -99,7 +99,7 @@ color: var(--fg-secondary); } -/* Windows frameless window: caption buttons sit flush with the right and top edges. */ +/* Frameless window (Windows, Linux): caption buttons sit flush with the right and top edges. */ .frameless { padding-right: 0; } diff --git a/src/workbench/TitleBar.tsx b/src/workbench/TitleBar.tsx index 17306b2b7..e714e4f4f 100644 --- a/src/workbench/TitleBar.tsx +++ b/src/workbench/TitleBar.tsx @@ -256,7 +256,7 @@ function ToolbarEntry({ id, items }: { id: string; items: ReadonlyMap diff --git a/src/workbench/WindowControls.tsx b/src/workbench/WindowControls.tsx index 862b1b1f7..286fa71f5 100644 --- a/src/workbench/WindowControls.tsx +++ b/src/workbench/WindowControls.tsx @@ -1,5 +1,5 @@ /** - * Windows caption buttons (minimise, maximise / restore, close) for the frameless + * Caption buttons (minimise, maximise / restore, close) for the frameless * title bar. Dialog windows (Settings) only have close, as in IDEA. */ import { useEffect, useState } from "react";