From 0c0d8e1caac36cbd3507555fed30f5331e07dae1 Mon Sep 17 00:00:00 2001 From: thibaud-leclere Date: Tue, 14 Apr 2026 11:00:37 +0200 Subject: [PATCH] fix: enable window controls permissions and reliable drag behavior --- src-tauri/capabilities/default.json | 4 ++++ src/components/layout/AppLayout.tsx | 14 ++++++++++++++ src/components/layout/WindowControls.tsx | 12 ++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index b75b73f..e6f4c90 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -5,6 +5,10 @@ "windows": ["main"], "permissions": [ "core:default", + "core:window:allow-minimize", + "core:window:allow-toggle-maximize", + "core:window:allow-close", + "core:window:allow-start-dragging", "dialog:default", "notification:default" ] diff --git a/src/components/layout/AppLayout.tsx b/src/components/layout/AppLayout.tsx index 89d460f..289afc6 100644 --- a/src/components/layout/AppLayout.tsx +++ b/src/components/layout/AppLayout.tsx @@ -1,9 +1,18 @@ +import { getCurrentWindow } from "@tauri-apps/api/window"; import { Outlet } from "react-router-dom"; import NotificationCenter from "./NotificationCenter"; import Sidebar from "./Sidebar"; import WindowControls from "./WindowControls"; export default function AppLayout() { + async function startDragging() { + try { + await getCurrentWindow().startDragging(); + } catch (error) { + console.error("Unable to drag window:", error); + } + } + return (
@@ -12,6 +21,11 @@ export default function AppLayout() {
{ + if (event.button === 0) { + void startDragging(); + } + }} className="min-w-0 flex-1 select-none text-sm font-semibold text-gray-700" > Orchai diff --git a/src/components/layout/WindowControls.tsx b/src/components/layout/WindowControls.tsx index 43abc97..09b3404 100644 --- a/src/components/layout/WindowControls.tsx +++ b/src/components/layout/WindowControls.tsx @@ -3,24 +3,24 @@ import { getCurrentWindow } from "@tauri-apps/api/window"; async function minimizeWindow() { try { await getCurrentWindow().minimize(); - } catch { - // No-op outside Tauri runtime + } catch (error) { + console.error("Unable to minimize window:", error); } } async function toggleMaximizeWindow() { try { await getCurrentWindow().toggleMaximize(); - } catch { - // No-op outside Tauri runtime + } catch (error) { + console.error("Unable to toggle maximize:", error); } } async function closeWindow() { try { await getCurrentWindow().close(); - } catch { - // No-op outside Tauri runtime + } catch (error) { + console.error("Unable to close window:", error); } }