25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(linux): draw rounded corners, shadow and resize handles
Cristian786ccad3c461
diff --git a/Cargo.lock b/Cargo.lockindex e3289f682c..ca1b5a9524 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2153,6 +2153,7 @@ dependencies = ["font-kit","futures","grep",+ "gtk","ignore","libloading 0.8.9","log",diff --git a/apps/desktop/index.html b/apps/desktop/index.htmlindex da70d59a60..d86279e230 100644--- a/apps/desktop/index.html+++ b/apps/desktop/index.html@@ -23,6 +23,39 @@background-color: rgb(19 20 22);}+ /* Linux floating frame (see create_linux_main_window). Lives here, not in the app+ * bundle, so the margin, rounded corners and shadow exist from the very first paint.+ * #root is the frame: `contain: layout` makes it the containing block of the+ * position:fixed startup/app layers. Keep the 20px in sync with LinuxResizeHandles. */+ html.dbx-linux-floating,+ html.dbx-linux-floating body {+ background: transparent !important;+ }++ html.dbx-linux-floating #root {+ position: fixed;+ inset: 20px;+ /* globals.css sets html, body, #root to 100%, which would override inset */+ width: auto;+ height: auto;+ contain: layout;+ overflow: hidden;+ border-radius: 12px;+ box-shadow:+ 0 0 0 1px rgb(0 0 0 / 0.14),+ 0 3px 12px rgb(0 0 0 / 0.16);+ }++ html.dark.dbx-linux-floating #root {+ box-shadow:+ 0 0 0 1px rgb(255 255 255 / 0.1),+ 0 3px 12px rgb(0 0 0 / 0.45);+ }++ html.dbx-linux-floating #startup-loading {+ min-height: 100%;+ }+#startup-loading {display: flex;flex-direction: column;@@ -69,6 +102,10 @@}}</style>+ <script>+ // Injected by the Rust side only for the main window when a compositor is running.+ if (window.__DBX_LINUX_FLOATING__) document.documentElement.classList.add("dbx-linux-floating");+ </script><script data-dbx-startup-theme>(() => {const root = document.documentElement;diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex 9a8cd199cd..ad695fc31e 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -10,6 +10,7 @@ import { useI18n } from "vue-i18n";import { FileText, FolderPlus } from "@lucide/vue";import { TooltipProvider } from "@/components/ui/tooltip";import AppToolbar from "@/components/layout/AppToolbar.vue";+import LinuxResizeHandles from "@/components/layout/LinuxResizeHandles.vue";import AppTabBar from "@/components/layout/AppTabBar.vue";import { createGroupTabBarPortal, GROUP_TAB_BAR_PORTAL } from "@/components/layout/groupTabBarPortal";import PluginShortcutBar from "@/components/plugins/PluginShortcutBar.vue";@@ -74,7 +75,7 @@ import { useExternalSqlFileChanges } from "@/composables/useExternalSqlFileChangimport { useWebDavAutoUpload } from "@/composables/useWebDavAutoUpload";import { readSyncMethod, readWebDavAutoUploadConfig, readWebDavBackupSelection } from "@/lib/webdav/webdavAutoUploadConfig";import { useScheduledDatabaseBackups } from "@/composables/useScheduledDatabaseBackups";-import { shouldDrawDesktopWindowFrame } from "@/composables/useWindowControls";+import { shouldDrawDesktopWindowFrame, shouldDrawLinuxFloatingFrame, useWindowControls } from "@/composables/useWindowControls";import { createOpenTabsRestorationBarrier, initializeDesktopOpenTabs, initializeOpenTabs, type OpenTabsRestorationBarrier } from "@/lib/app/openTabsStartup";import { finishAppCloseWithRequiredPersist } from "@/lib/app/appClosePersistence";import { useSaveSqlFolderSelection } from "@/composables/useSaveSqlFolderSelection";@@ -95,7 +96,7 @@ import { schemaAfterConnectionSwitch } from "@/lib/schema/connectionSchemaInitiaimport { resolveHistorySqlRestoreTarget } from "@/lib/history/historyRestoreTarget";import { resolveExecutableSql, resolveExecutableSqlWithBackend, type SqlExecutionOverride, type SqlExecutionSnapshot } from "@/lib/sql/sqlExecutionTarget";import { uuid } from "@/lib/common/utils";-import { isMacOS, isWindows } from "@/lib/backend/platform";+import { getPlatform, isMacOS, isWindows } from "@/lib/backend/platform";import { isTauriRuntime } from "@/lib/backend/tauriRuntime";import { openQueryResultArchiveFile } from "@/lib/query/queryResultArchiveFile";import { activeTabExternalSqlFileTarget, rememberExternalSqlFileTarget, resolveExternalSqlFileTarget, resolveExternalSqlFileTargetForActiveTab, unassociatedExternalSqlFileTarget, type ExternalSqlFileTarget } from "@/lib/sql/externalSqlFileTarget";@@ -387,6 +388,22 @@ let updateCheckTimer: ReturnType<typeof setInterval> | undefined;const needsAuth = ref(!isDesktop && (startupProps.startupAuthentication?.required ?? true));const authenticated = ref(isDesktop || (startupProps.startupAuthentication?.authenticated ?? false));const setupRequired = ref(!isDesktop && (startupProps.startupAuthentication?.setup_required ?? false));+const { isMaximized: windowMaximized, isFullscreen: windowFullscreen } = useWindowControls();+// The Rust side injects this flag into the main window only when a compositing manager is+// running (see create_linux_main_window); detached-tab and plugin windows never get it.+const linuxCompositing = (window as unknown as { __DBX_LINUX_FLOATING__?: boolean }).__DBX_LINUX_FLOATING__ === true;+const drawLinuxFloatingFrame = computed(() =>+ shouldDrawLinuxFloatingFrame({+ isLinux: getPlatform() === "linux",+ isDesktop,+ isMainWindow: windowContext.kind === "main",+ compositing: linuxCompositing,+ showingAuthPage: setupRequired.value || (needsAuth.value && !authenticated.value),+ isMaximized: windowMaximized.value,+ isFullscreen: windowFullscreen.value,+ }),+);+watch(drawLinuxFloatingFrame, (enabled) => document.documentElement.classList.toggle("dbx-linux-floating", enabled), { immediate: true });// Mirrors the template gate above the app shell. The backend liveness stream is registered// against it so the web runtime only opens an authenticated subscription.const appReady = computed(() => !setupRequired.value && (!needsAuth.value || authenticated.value));@@ -4737,12 +4754,13 @@ onUnmounted(() => {<template><LoginPage v-if="setupRequired || (needsAuth && !authenticated)" :setup-mode="setupRequired" @authenticated="onLoginSuccess" />- <div v-show="!setupRequired && (!needsAuth || authenticated)" class="fixed inset-0 h-screen w-screen overflow-hidden">+ <div v-show="!setupRequired && (!needsAuth || authenticated)" class="dbx-app-root fixed inset-0 h-screen w-screen overflow-hidden"><div v-if="appBackgroundActive && appBackgroundObjectUrl" data-app-background class="pointer-events-none fixed inset-0 -z-10 overflow-hidden"><div class="h-full w-full" :style="appBackgroundImageStyle"></div></div><TooltipProvider :delay-duration="300"><SidebarDangerDialogHost />+ <LinuxResizeHandles v-if="drawLinuxFloatingFrame" /><div data-app-shell class="h-screen w-screen max-w-full min-w-[760px] min-h-[600px] flex flex-col bg-background text-foreground overflow-hidden" :class="{ 'dbx-desktop-window-frame': drawDesktopWindowFrame }" :style="appUiFontFamilyStyle"><AppToolbarv-if="!isDetachedWindowContext"diff --git a/apps/desktop/src/components/layout/LinuxResizeHandles.vue b/apps/desktop/src/components/layout/LinuxResizeHandles.vuenew file mode 100644index 0000000000..e6056a6ac8--- /dev/null+++ b/apps/desktop/src/components/layout/LinuxResizeHandles.vue@@ -0,0 +1,40 @@+<script setup lang="ts">+// The transparent margin around the Linux floating frame (see .dbx-linux-floating)+// is covered by the webview, which owns the cursor there, so tao's own edge+// hit-testing never shows a resize cursor. These handles live in that margin.+import type { Window } from "@tauri-apps/api/window";++type ResizeDirection = Parameters<Window["startResizeDragging"]>[0];++// Geometry matches `.dbx-app-root` padding (MARGIN). Only the GRAB px just outside the+// visible edge are grabbable, so the rest of the transparent margin (the shadow) is inert.+const MARGIN = 20;+const GRAB = 6;+const CORNER = 14;+const OUTER = MARGIN - GRAB;+const EDGE_INSET = OUTER + CORNER;++const handles: { direction: ResizeDirection; cursor: string; style: Record<string, string> }[] = [+ { direction: "North", cursor: "n-resize", style: { top: `${OUTER}px`, left: `${EDGE_INSET}px`, right: `${EDGE_INSET}px`, height: `${GRAB}px` } },+ { direction: "South", cursor: "s-resize", style: { bottom: `${OUTER}px`, left: `${EDGE_INSET}px`, right: `${EDGE_INSET}px`, height: `${GRAB}px` } },+ { direction: "West", cursor: "w-resize", style: { left: `${OUTER}px`, top: `${EDGE_INSET}px`, bottom: `${EDGE_INSET}px`, width: `${GRAB}px` } },+ { direction: "East", cursor: "e-resize", style: { right: `${OUTER}px`, top: `${EDGE_INSET}px`, bottom: `${EDGE_INSET}px`, width: `${GRAB}px` } },+ { direction: "NorthWest", cursor: "nw-resize", style: { top: `${OUTER}px`, left: `${OUTER}px`, width: `${CORNER}px`, height: `${CORNER}px` } },+ { direction: "NorthEast", cursor: "ne-resize", style: { top: `${OUTER}px`, right: `${OUTER}px`, width: `${CORNER}px`, height: `${CORNER}px` } },+ { direction: "SouthWest", cursor: "sw-resize", style: { bottom: `${OUTER}px`, left: `${OUTER}px`, width: `${CORNER}px`, height: `${CORNER}px` } },+ { direction: "SouthEast", cursor: "se-resize", style: { bottom: `${OUTER}px`, right: `${OUTER}px`, width: `${CORNER}px`, height: `${CORNER}px` } },+];++async function startResize(direction: ResizeDirection, event: MouseEvent) {+ if (event.button !== 0) return;+ event.preventDefault();+ const { getCurrentWindow } = await import("@tauri-apps/api/window");+ await getCurrentWindow().startResizeDragging(direction);+}+</script>++<template>+ <Teleport to="body">+ <div v-for="handle in handles" :key="handle.direction" class="fixed z-[100000]" :style="{ ...handle.style, cursor: handle.cursor }" @mousedown="startResize(handle.direction, $event)" />+ </Teleport>+</template>diff --git a/apps/desktop/src/components/layout/WindowControls.vue b/apps/desktop/src/components/layout/WindowControls.vueindex 3205ea366f..9bf8e30af7 100644--- a/apps/desktop/src/components/layout/WindowControls.vue+++ b/apps/desktop/src/components/layout/WindowControls.vue@@ -1,7 +1,17 @@<script setup lang="ts">+import { computed, onMounted, ref } from "vue";import { Minus, Square, Copy, X } from "@lucide/vue";+import { getPlatform } from "@/lib/backend/platform";+import { isTauriRuntime } from "@/lib/backend/tauriRuntime";-defineProps<{+interface LinuxWindowControlIcons {+ minimize: string;+ maximize: string;+ restore: string;+ close: string;+}++const props = defineProps<{isMaximized: boolean;}>();@@ -10,10 +20,55 @@ const emit = defineEmits<{"toggle-maximize": [];close: [];}>();++// GNOME headerbars use round, symbolic Adwaita-style buttons rather than the+// full-height rectangular Windows buttons.+const isLinux = getPlatform() === "linux";++// Glyphs from the active GTK icon theme, used as CSS masks so they take the text+// colour and cannot run script. Null until loaded or when the theme lacks them,+// in which case the bundled inline icons below are used.+const themeIcons = ref<Record<keyof LinuxWindowControlIcons, string> | null>(null);+const maximizeMask = computed(() => (props.isMaximized ? themeIcons.value?.restore : themeIcons.value?.maximize));++function svgMask(svg: string): string {+ return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;+}++onMounted(async () => {+ if (!isLinux || !isTauriRuntime()) return;+ try {+ const { invoke } = await import("@tauri-apps/api/core");+ const icons = await invoke<LinuxWindowControlIcons | null>("get_linux_window_control_icons");+ if (icons) {+ themeIcons.value = { minimize: svgMask(icons.minimize), maximize: svgMask(icons.maximize), restore: svgMask(icons.restore), close: svgMask(icons.close) };+ }+ } catch {+ // keep the bundled icons+ }+});</script><template>- <div class="flex items-stretch -mr-2 ml-1">+ <div v-if="isLinux" class="flex items-center gap-[13px] ml-1 mr-1">+ <button type="button" class="dbx-gnome-window-button" @click="emit('minimize')">+ <span v-if="themeIcons" class="dbx-gnome-window-glyph" :style="{ maskImage: themeIcons.minimize, WebkitMaskImage: themeIcons.minimize }" />+ <svg v-else viewBox="0 0 16 16" class="size-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M4 11.5h8" /></svg>+ </button>+ <button type="button" class="dbx-gnome-window-button" @click="emit('toggle-maximize')">+ <span v-if="themeIcons" class="dbx-gnome-window-glyph" :style="{ maskImage: maximizeMask, WebkitMaskImage: maximizeMask }" />+ <svg v-else-if="isMaximized" viewBox="0 0 16 16" class="size-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round">+ <path d="M5.5 5.5V4.25a.75.75 0 0 1 .75-.75h5.5a.75.75 0 0 1 .75.75v5.5a.75.75 0 0 1-.75.75H10.5" />+ <rect x="3.5" y="5.5" width="7" height="7" rx=".75" />+ </svg>+ <svg v-else viewBox="0 0 16 16" class="size-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><rect x="3.5" y="3.5" width="9" height="9" rx="1" /></svg>+ </button>+ <button type="button" class="dbx-gnome-window-button" @click="emit('close')">+ <span v-if="themeIcons" class="dbx-gnome-window-glyph" :style="{ maskImage: themeIcons.close, WebkitMaskImage: themeIcons.close }" />+ <svg v-else viewBox="0 0 16 16" class="size-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="m4.5 4.5 7 7m0-7-7 7" /></svg>+ </button>+ </div>+ <div v-else class="flex items-stretch -mr-2 ml-1"><button class="inline-flex items-center justify-center w-11.5 h-10 hover:bg-foreground/10 transition-colors" @click="emit('minimize')"><Minus class="h-4 w-4" /></button>@@ -26,3 +81,38 @@ const emit = defineEmits<{</button></div></template>++<style scoped>+.dbx-gnome-window-button {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 24px;+ height: 24px;+ border-radius: 9999px;+ color: var(--foreground);+ background: color-mix(in srgb, var(--foreground) 8%, transparent);+ transition: background-color 0.12s;+}++.dbx-gnome-window-glyph {+ display: block;+ width: 16px;+ height: 16px;+ background-color: currentColor;+ mask-repeat: no-repeat;+ mask-position: center;+ mask-size: contain;+ -webkit-mask-repeat: no-repeat;+ -webkit-mask-position: center;+ -webkit-mask-size: contain;+}++.dbx-gnome-window-button:hover {+ background: color-mix(in srgb, var(--foreground) 16%, transparent);+}++.dbx-gnome-window-button:active {+ background: color-mix(in srgb, var(--foreground) 24%, transparent);+}+</style>diff --git a/apps/desktop/src/components/tabs/TabSwitcherDialog.vue b/apps/desktop/src/components/tabs/TabSwitcherDialog.vueindex 64ccf797e8..2cb55004da 100644--- a/apps/desktop/src/components/tabs/TabSwitcherDialog.vue+++ b/apps/desktop/src/components/tabs/TabSwitcherDialog.vue@@ -52,7 +52,7 @@ watch(<template><Teleport to="body">- <div v-if="open" class="fixed inset-0 z-[100] flex items-start justify-center pt-[18vh]" @mousedown.self="emit('update:open', false)">+ <div v-if="open" data-slot="dialog-overlay" class="fixed inset-0 z-[100] flex items-start justify-center pt-[18vh]" @mousedown.self="emit('update:open', false)"><div class="w-[420px] max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border bg-popover shadow-2xl" role="listbox" :aria-label="t('tabs.switcherTitle')"><div class="border-b px-3 py-2 text-xs font-medium text-muted-foreground">{{ t("tabs.switcherTitle") }}</div><div ref="listRef" class="max-h-[60vh] overflow-y-auto p-1">diff --git a/apps/desktop/src/composables/__tests__/useWindowControls.spec.ts b/apps/desktop/src/composables/__tests__/useWindowControls.spec.tsindex b0bc7c4119..09e843701e 100644--- a/apps/desktop/src/composables/__tests__/useWindowControls.spec.ts+++ b/apps/desktop/src/composables/__tests__/useWindowControls.spec.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { macTrafficLightInsetPaddingForScale, macTrafficLightPositionForScale, shouldDrawDesktopWindowFrame, shouldReserveMacTrafficLightInset, shouldShowWindowControls } from "@/composables/useWindowControls";+import { macTrafficLightInsetPaddingForScale, macTrafficLightPositionForScale, shouldDrawDesktopWindowFrame, shouldDrawLinuxFloatingFrame, shouldReserveMacTrafficLightInset, shouldShowWindowControls } from "@/composables/useWindowControls";describe("window controls", () => {it("shows custom controls for non-macOS desktop windows", () => {@@ -21,6 +21,20 @@ describe("window controls", () => {expect(shouldDrawDesktopWindowFrame(false, false, false)).toBe(false);});+ it.each([+ ["restored Linux main window with a compositor", {}, true],+ ["maximized window", { isMaximized: true }, false],+ ["fullscreen window", { isFullscreen: true }, false],+ ["non-Linux platform", { isLinux: false }, false],+ ["web runtime", { isDesktop: false }, false],+ ["detached or plugin window (not created transparent)", { isMainWindow: false }, false],+ ["no compositing manager", { compositing: false }, false],+ ["login or setup page", { showingAuthPage: true }, false],+ ])("floating Linux frame: %s", (_name, override, expected) => {+ const base = { isLinux: true, isDesktop: true, isMainWindow: true, compositing: true, showingAuthPage: false, isMaximized: false, isFullscreen: false };+ expect(shouldDrawLinuxFloatingFrame({ ...base, ...override })).toBe(expected);+ });+it("reserves traffic light inset only for non-fullscreen macOS desktop windows", () => {expect(shouldReserveMacTrafficLightInset(true, false, true)).toBe(true);expect(shouldReserveMacTrafficLightInset(true, true, true)).toBe(false);diff --git a/apps/desktop/src/composables/useWindowControls.ts b/apps/desktop/src/composables/useWindowControls.tsindex ab722e027d..5e05c085e0 100644--- a/apps/desktop/src/composables/useWindowControls.ts+++ b/apps/desktop/src/composables/useWindowControls.ts@@ -42,6 +42,27 @@ export function shouldDrawDesktopWindowFrame(isMac: boolean, isDesktop = true, ireturn isDesktop && !isMac && !isWindows;}+export interface LinuxFloatingFrameState {+ isLinux: boolean;+ isDesktop: boolean;+ /** Only the main window is created transparent; detached-tab and plugin windows are opaque. */+ isMainWindow: boolean;+ /** The main window is only transparent when a compositing manager is running. */+ compositing: boolean;+ /** Login/setup pages paint the whole window themselves. */+ showingAuthPage: boolean;+ isMaximized: boolean;+ isFullscreen: boolean;+}++// Compositors draw neither shadow nor rounded corners for undecorated windows, so on Linux+// the transparent main window (see create_linux_main_window) paints its own: a transparent+// margin that carries the shadow, and a rounded shell. Maximized/fullscreen windows must fill+// the screen, so the floating frame is dropped there.+export function shouldDrawLinuxFloatingFrame(state: LinuxFloatingFrameState): boolean {+ return state.isDesktop && state.isLinux && state.isMainWindow && state.compositing && !state.showingAuthPage && !state.isMaximized && !state.isFullscreen;+}+export function useWindowControls() {const isMaximized = ref(false);const isFullscreen = ref(false);diff --git a/apps/desktop/src/styles/globals.css b/apps/desktop/src/styles/globals.cssindex b91c8a70a9..6df4c2047e 100644--- a/apps/desktop/src/styles/globals.css+++ b/apps/desktop/src/styles/globals.css@@ -1619,6 +1619,31 @@ html.dbx-data-grid-native-selection-blocked [role="textbox"] * {background: var(--dbx-window-top-border);}+/* Linux floating frame: the transparent margin, rounded corners and shadow are drawn on+ * #root from index.html so they exist before the bundle loads. Here: the app root fills+ * that frame instead of the viewport. */+html.dbx-linux-floating .dbx-app-root {+ width: 100%;+ height: 100%;+}++html.dbx-linux-floating [data-app-shell] {+ width: 100%;+ height: 100%;+}++/* Full-viewport dialog layers are portaled to <body>; keep them inside the shell so they+ * do not paint over the transparent margin and square off the rounded corners. */+html.dbx-linux-floating [data-slot="dialog-overlay"],+html.dbx-linux-floating [data-slot="dialog-positioner"] {+ inset: 20px;+ border-radius: 12px;+}++html.dbx-linux-floating .dbx-desktop-window-frame::before {+ display: none;+}+.dbx-editor-font-family {font-family: var(--dbx-editor-font-family, var(--font-mono, monospace));}diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex e0081a0fc7..7694fd33f9 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -94,6 +94,7 @@ objc2-foundation = { version = "0.3.2", default-features = false, features = ["N[target.'cfg(target_os = "linux")'.dependencies]libloading = "0.8"+gtk = "0.18"[target.'cfg(target_os = "windows")'.dependencies]windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Threading", "Win32_UI_WindowsAndMessaging"] }diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex dbb3fa9994..46cc3f6ce5 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -19,6 +19,7 @@"core:window:allow-close","core:window:allow-destroy","core:window:allow-start-dragging",+ "core:window:allow-start-resize-dragging","core:window:allow-set-focus","core:window:allow-set-always-on-top","core:window:allow-is-always-on-top",diff --git a/src-tauri/src/commands/window_controls.rs b/src-tauri/src/commands/window_controls.rsindex 2f136ff884..68e785d6cf 100644--- a/src-tauri/src/commands/window_controls.rs+++ b/src-tauri/src/commands/window_controls.rs@@ -156,6 +156,7 @@ pub async fn set_macos_traffic_light_position(#[cfg(test)]mod tests {use super::validate_macos_traffic_light_position;+ use serde_json::Value;#[test]fn validates_macos_traffic_light_position_inputs() {@@ -164,4 +165,63 @@ mod tests {assert!(validate_macos_traffic_light_position(16.0, f64::INFINITY, 1.0).is_err());assert!(validate_macos_traffic_light_position(16.0, 18.0, 0.0).is_err());}++ // platform config arrays replace the base array wholesale, so the Linux window object+ // is a copy of the base one; keep them from drifting apart.+ #[test]+ fn linux_main_window_config_mirrors_the_base_window() {+ let base: Value = serde_json::from_str(include_str!("../../tauri.conf.json")).unwrap();+ let linux: Value = serde_json::from_str(include_str!("../../tauri.linux.conf.json")).unwrap();+ let mut base_window = base["app"]["windows"][0].clone();+ let mut linux_window = linux["app"]["windows"][0].clone();++ // macOS-only keys in the base, and the Linux-only overrides.+ for key in ["titleBarStyle", "trafficLightPosition"] {+ base_window.as_object_mut().unwrap().remove(key);+ }+ assert_eq!(linux_window["create"], Value::Bool(false));+ assert_eq!(linux_window["transparent"], Value::Bool(true));+ for key in ["create", "transparent"] {+ linux_window.as_object_mut().unwrap().remove(key);+ }+ assert_eq!(linux_window, base_window);+ }+}++#[derive(serde::Serialize)]+pub struct LinuxWindowControlIcons {+ minimize: String,+ maximize: String,+ restore: String,+ close: String,+}++/// Reads the window-control glyphs from the active GTK icon theme (Adwaita, Yaru, ...)+/// so the custom Linux controls look like the system's. Returns `None` when any glyph+/// is missing, in which case the frontend falls back to its bundled icons.+/// Sync command: GTK must be used from the main thread.+#[tauri::command]+pub fn get_linux_window_control_icons() -> Option<LinuxWindowControlIcons> {+ #[cfg(target_os = "linux")]+ {+ use gtk::prelude::*;++ let theme = gtk::IconTheme::default()?;+ let load = |name: &str| -> Option<String> {+ let info = theme.lookup_icon(name, 16, gtk::IconLookupFlags::FORCE_SVG)?;+ let svg = std::fs::read_to_string(info.filename()?).ok()?;+ // Anything beyond a small glyph is not a window-control icon.+ (svg.len() < 16 * 1024 && svg.contains("<svg")).then_some(svg)+ };+ Some(LinuxWindowControlIcons {+ minimize: load("window-minimize-symbolic")?,+ maximize: load("window-maximize-symbolic")?,+ restore: load("window-restore-symbolic")?,+ close: load("window-close-symbolic")?,+ })+ }+ #[cfg(not(target_os = "linux"))]+ {+ None+ }}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 96c8b1d070..a4f51e8ecc 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -168,6 +168,30 @@ fn linux_appindicator_available() -> bool {})}+/// Without a compositing manager (XFCE with compositing off, i3, openbox, ...) a transparent+/// window renders black where it should be see-through.+#[cfg(target_os = "linux")]+pub(crate) fn linux_compositing_available() -> bool {+ gtk::gdk::Screen::default().is_some_and(|screen| screen.is_composited())+}++/// The Linux config declares the main window with `create: false` so its transparency can+/// depend on the compositor, which is only known at runtime.+#[cfg(target_os = "linux")]+fn create_linux_main_window(app: &tauri::App) -> tauri::Result<()> {+ let Some(config) = app.config().app.windows.iter().find(|window| window.label == "main").cloned() else {+ return Ok(());+ };+ let compositing = linux_compositing_available();+ let mut builder = tauri::WebviewWindowBuilder::from_config(app.handle(), &config)?.transparent(compositing);+ if compositing {+ // Read by index.html before first paint to draw the rounded, shadowed frame.+ builder = builder.initialization_script("window.__DBX_LINUX_FLOATING__ = true;");+ }+ builder.build()?;+ Ok(())+}+#[cfg(not(target_os = "linux"))]fn linux_appindicator_available() -> bool {false@@ -1579,6 +1603,8 @@ pub fn run() {}).setup(move |app| {let setup_start = Instant::now();+ #[cfg(target_os = "linux")]+ create_linux_main_window(app)?;eprintln!("[STARTUP] plugins registered in {:?}", startup_begin.elapsed());append_startup_probe(format!("setup entered after {:?}", startup_begin.elapsed()));@@ -1906,6 +1932,7 @@ pub fn run() {commands::app_settings::mark_frontend_ready,commands::app_settings::request_app_close_from_window_controls,commands::window_controls::set_macos_traffic_light_position,+ commands::window_controls::get_linux_window_control_icons,commands::app_settings::set_driver_store_dir,commands::app_settings::set_plugin_store_dir,commands::app_settings::set_agent_store_dir,diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.jsonnew file mode 100644index 0000000000..b03ce03b15--- /dev/null+++ b/src-tauri/tauri.linux.conf.json@@ -0,0 +1,20 @@+{+ "app": {+ "windows": [+ {+ "title": "DBX",+ "width": 1280,+ "height": 800,+ "minWidth": 900,+ "minHeight": 600,+ "resizable": true,+ "fullscreen": false,+ "visible": false,+ "transparent": true,+ "hiddenTitle": true,+ "acceptFirstMouse": true,+ "create": false+ }+ ]+ }+}