From 63b7de0e6fbd39cd752c7f7f4cbd4949cd2fab13 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Feb 2026 21:19:24 +0200 Subject: [PATCH] fix: window controls, dragging, and text selection - Add Tauri permissions for window minimize/maximize/close/drag - Rewrite WindowControls with plain buttons + stopPropagation to prevent drag region from capturing button clicks - Add data-tauri-drag-region to TopBar child containers - Make OpenPylon text pointer-events-none and select-none --- src-tauri/capabilities/default.json | 8 ++++ src/components/layout/TopBar.tsx | 6 +-- src/components/layout/WindowControls.tsx | 60 ++++++++++++++---------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 8af5128..343f402 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -5,6 +5,14 @@ "windows": ["main"], "permissions": [ "core:default", + "core:window:allow-close", + "core:window:allow-minimize", + "core:window:allow-maximize", + "core:window:allow-unmaximize", + "core:window:allow-toggle-maximize", + "core:window:allow-is-maximized", + "core:window:allow-start-dragging", + "core:window:allow-set-focus", "opener:default", "dialog:default", "shell:default", diff --git a/src/components/layout/TopBar.tsx b/src/components/layout/TopBar.tsx index 19582d4..df4348a 100644 --- a/src/components/layout/TopBar.tsx +++ b/src/components/layout/TopBar.tsx @@ -81,7 +81,7 @@ export function TopBar() { style={{ borderBottom: isBoardView && board ? `2px solid ${board.color}` : '1px solid var(--border)' }} > {/* Left section */} -
+
{isBoardView && ( @@ -104,7 +104,7 @@ export function TopBar() {
{/* Center section */} -
+
{isBoardView && board ? ( editing ? ( ) ) : ( - + OpenPylon )} diff --git a/src/components/layout/WindowControls.tsx b/src/components/layout/WindowControls.tsx index f1c46c3..59d40bf 100644 --- a/src/components/layout/WindowControls.tsx +++ b/src/components/layout/WindowControls.tsx @@ -1,8 +1,6 @@ -import { useState, useEffect } from "react"; +import { useState, useEffect, useCallback } from "react"; import { getCurrentWindow } from "@tauri-apps/api/window"; -import { motion } from "framer-motion"; import { Minus, Square, Copy, X } from "lucide-react"; -import { springs } from "@/lib/motion"; export function WindowControls() { const [isMaximized, setIsMaximized] = useState(false); @@ -22,32 +20,44 @@ export function WindowControls() { }; }, []); - const appWindow = getCurrentWindow(); + const handleMinimize = useCallback((e: React.MouseEvent) => { + e.stopPropagation(); + e.preventDefault(); + getCurrentWindow().minimize(); + }, []); + + const handleToggleMaximize = useCallback((e: React.MouseEvent) => { + e.stopPropagation(); + e.preventDefault(); + getCurrentWindow().toggleMaximize(); + }, []); + + const handleClose = useCallback((e: React.MouseEvent) => { + e.stopPropagation(); + e.preventDefault(); + getCurrentWindow().close(); + }, []); return ( -
+
e.stopPropagation()}> {/* Separator */}
{/* Minimize */} - appWindow.minimize()} - className="flex size-8 items-center justify-center rounded-md text-pylon-text-secondary transition-colors hover:bg-pylon-accent/10 hover:text-pylon-text" - whileHover={{ scale: 1.1 }} - whileTap={{ scale: 0.9 }} - transition={springs.snappy} + {/* Maximize / Restore */} - appWindow.toggleMaximize()} - className="flex size-8 items-center justify-center rounded-md text-pylon-text-secondary transition-colors hover:bg-pylon-accent/10 hover:text-pylon-text" - whileHover={{ scale: 1.1 }} - whileTap={{ scale: 0.9 }} - transition={springs.snappy} + {/* Close */} - appWindow.close()} - className="flex size-8 items-center justify-center rounded-md text-pylon-text-secondary transition-colors hover:bg-pylon-danger/15 hover:text-pylon-danger" - whileHover={{ scale: 1.1 }} - whileTap={{ scale: 0.9 }} - transition={springs.snappy} +
); }