From 785f64a72e1504b4d1e3253c1297e7050653ab2c Mon Sep 17 00:00:00 2001 From: 1xDed Date: Tue, 1 Dec 2026 16:23:52 +0300 Subject: [PATCH] fix(window): restore first-click titlebar dragging - update wry 0.57.0 -> 0.57.4, which drops the WM_ENTERSIZEMOVE focus call that swallowed the first drag on Windows - let the global drag handler take clicks on non-interactive children of data-tauri-drag-region elements (title text, logo), with double-click maximize --- src-tauri/Cargo.lock | 275 +++++++++++++++---- src/components/windowControls/windowDrag.tsx | 43 ++- 2 files changed, 257 insertions(+), 61 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index f0b3d99..9503418 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -91,7 +91,7 @@ dependencies = [ "objc2-foundation 0.3.2", "parking_lot", "percent-encoding", - "windows-sys 0.61.2", + "windows-sys 0.52.0", "wl-clipboard-rs", "x11rb", ] @@ -304,7 +304,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ - "bit-vec", + "bit-vec 0.8.0", +] + +[[package]] +name = "bit-set" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d87354e4229f54a44f7bf2435906a4656dba36026ab6eaca629a2c436a691c" +dependencies = [ + "bit-vec 0.10.2", ] [[package]] @@ -313,6 +322,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bit-vec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72503af1e72be411d74ca45cd6b309878fcb35354e252fc2a3a8bda3a97082a0" + [[package]] name = "bitflags" version = "1.3.2" @@ -860,7 +875,20 @@ dependencies = [ "cssparser-macros", "dtoa-short", "itoa", - "phf", + "phf 0.13.1", + "smallvec", +] + +[[package]] +name = "cssparser" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11119743ad110e8c1bdccd930d7f5c30c99e5fc76a7b63ec9807e84eef0c5f59" +dependencies = [ + "cssparser-macros", + "dtoa-short", + "itoa", + "phf 0.14.0", "smallvec", ] @@ -1040,7 +1068,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -1113,12 +1141,27 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fac5fca71e65e94cc718a6e2af65d6e0f9c6027751c2aa562fbb5087fda639bc" dependencies = [ - "bit-set", - "cssparser", + "bit-set 0.8.0", + "cssparser 0.37.0", "foldhash 0.2.0", - "html5ever", + "html5ever 0.39.0", "precomputed-hash", - "selectors", + "selectors 0.38.0", + "tendril", +] + +[[package]] +name = "dom_query" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35b4f772a1a8b88e5545a67c2d3a62a93d4edccc5a68f2145fe52e39c96d275" +dependencies = [ + "bit-set 0.11.1", + "cssparser 0.38.0", + "foldhash 0.2.0", + "html5ever 0.40.1", + "precomputed-hash", + "selectors 0.41.0", "tendril", ] @@ -1259,7 +1302,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -1928,7 +1971,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46a1761807faccc9a19e86944bbf40610014066306f96edcdedc2fb714bcb7b8" dependencies = [ "log", - "markup5ever", + "markup5ever 0.39.0", +] + +[[package]] +name = "html5ever" +version = "0.40.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456a1a377e608e555d22ddab27ac0114bc7a7b4199078108e34c2aeae6c9b130" +dependencies = [ + "log", + "markup5ever 0.40.0", + "memchr", ] [[package]] @@ -2616,7 +2670,18 @@ checksum = "7122d987ec5f704ee56f6e5b41a7d93722e9aae27ae07cafa4036c4d3f9757de" dependencies = [ "log", "tendril", - "web_atoms", + "web_atoms 0.2.6", +] + +[[package]] +name = "markup5ever" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab3dc68ac4a0f5719e560136778c1ee716e296030d75dbd4484e37e39e3a842" +dependencies = [ + "log", + "tendril", + "web_atoms 0.3.0", ] [[package]] @@ -2715,7 +2780,7 @@ dependencies = [ "png 0.18.1", "serde", "thiserror 2.0.21", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -3392,7 +3457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -3486,8 +3551,19 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" dependencies = [ - "phf_macros", - "phf_shared", + "phf_macros 0.13.1", + "phf_shared 0.13.1", + "serde", +] + +[[package]] +name = "phf" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010378780309880b08997fae13be7834dba947d36393bd372f2b1556deb2a2f6" +dependencies = [ + "phf_macros 0.14.0", + "phf_shared 0.14.0", "serde", ] @@ -3497,8 +3573,18 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.13.1", + "phf_shared 0.13.1", +] + +[[package]] +name = "phf_codegen" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b585a510fb76fdebead6897982ef2a03a21d8e6cbcca904999742a4afc6ffe" +dependencies = [ + "phf_generator 0.14.0", + "phf_shared 0.14.0", ] [[package]] @@ -3508,7 +3594,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" dependencies = [ "fastrand", - "phf_shared", + "phf_shared 0.13.1", +] + +[[package]] +name = "phf_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb62e0959d5a1bebc965f4d15d9e2b7cea002b6b0f5ba8cde6cc26738467100" +dependencies = [ + "fastrand", + "phf_shared 0.14.0", ] [[package]] @@ -3517,8 +3613,21 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.13.1", + "phf_shared 0.13.1", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "phf_macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fa8d0ca26d424d27630da600c6624696e7dec8bf7b3b492b383c5dc49e5e085" +dependencies = [ + "phf_generator 0.14.0", + "phf_shared 0.14.0", "proc-macro2", "quote", "syn 2.0.119", @@ -3533,6 +3642,15 @@ dependencies = [ "siphasher", ] +[[package]] +name = "phf_shared" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fd9027e2d9319be6349febd1db4e8d02aa544921200c9b777720ac34a3aa89" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project-lite" version = "0.2.17" @@ -3824,7 +3942,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4174,7 +4292,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4231,7 +4349,7 @@ dependencies = [ "security-framework 3.7.0", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4400,15 +4518,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8adfa1c298912827b8a28b223b3b874357397ae706e6190acd9bf28cee99114d" dependencies = [ "bitflags 2.13.2", - "cssparser", + "cssparser 0.37.0", "derive_more", "log", "new_debug_unreachable", - "phf", - "phf_codegen", + "phf 0.13.1", + "phf_codegen 0.13.1", "precomputed-hash", "rustc-hash", - "servo_arc", + "servo_arc 0.4.3", + "smallvec", +] + +[[package]] +name = "selectors" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8322aebea94a6cc288ff884e8a49bdbceef60206c400c6c46d22e62fc4fd91a6" +dependencies = [ + "bitflags 2.13.2", + "cssparser 0.38.0", + "derive_more", + "log", + "new_debug_unreachable", + "precomputed-hash", + "rustc-hash", + "servo_arc 0.5.0", "smallvec", ] @@ -4593,6 +4728,15 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "servo_arc" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eceb519ec34d8290aaf6e46f435102f2bfa63f22b05a144fb16ab266d3b198" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "sha1" version = "0.10.7" @@ -4688,7 +4832,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -4765,7 +4909,19 @@ checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" dependencies = [ "new_debug_unreachable", "parking_lot", - "phf_shared", + "phf_shared 0.13.1", + "precomputed-hash", +] + +[[package]] +name = "string_cache" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa8a5dbe8b3f0bbe29d4c3225daafaeead63afdc1b65fc4c01a1384166038e6" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared 0.14.0", "precomputed-hash", ] @@ -4775,8 +4931,20 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69" dependencies = [ - "phf_generator", - "phf_shared", + "phf_generator 0.13.1", + "phf_shared 0.13.1", + "proc-macro2", + "quote", +] + +[[package]] +name = "string_cache_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928dcdf75e47626b3617a976ec205d9f057584c371c1f23b782129268d0e6edc" +dependencies = [ + "phf_generator 0.14.0", + "phf_shared 0.14.0", "proc-macro2", "quote", ] @@ -5463,7 +5631,7 @@ dependencies = [ "brotli", "cargo_metadata", "ctor", - "dom_query", + "dom_query 0.28.0", "dunce", "glob", "http", @@ -5471,7 +5639,7 @@ dependencies = [ "json-patch", "log", "memchr", - "phf", + "phf 0.13.1", "plist", "proc-macro2", "quote", @@ -5523,7 +5691,7 @@ dependencies = [ "getrandom 0.4.3", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -5934,7 +6102,7 @@ dependencies = [ "png 0.18.1", "serde", "thiserror 2.0.21", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -6015,7 +6183,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -6335,10 +6503,22 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba8b815c1b593dc0baf78dd0f4fc8fdb2de53198fb1163738093e9a311c33fb3" dependencies = [ - "phf", - "phf_codegen", - "string_cache", - "string_cache_codegen", + "phf 0.13.1", + "phf_codegen 0.13.1", + "string_cache 0.9.0", + "string_cache_codegen 0.6.1", +] + +[[package]] +name = "web_atoms" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7572660c8890448ba236b7376f27e389c6a7e1c70195622faced601f855c0ada" +dependencies = [ + "phf 0.14.0", + "phf_codegen 0.14.0", + "string_cache 0.11.0", + "string_cache_codegen 0.11.2", ] [[package]] @@ -6474,7 +6654,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -6495,7 +6675,7 @@ dependencies = [ "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", "raw-window-handle", - "windows-sys 0.61.2", + "windows-sys 0.60.2", "windows-version", ] @@ -6885,7 +7065,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10" dependencies = [ "cfg-if", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -6920,16 +7100,16 @@ checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" [[package]] name = "wry" -version = "0.57.0" +version = "0.57.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a819957a01b3119af85e638a38d242af76dbc87d130dca67bfd0441072e21ff0" +checksum = "2c7bdc0b007462dd8a6cdb598e131e6899efa7eec16afdab4ee94b33f344c705" dependencies = [ - "base64 0.22.1", + "base64 0.23.1", "block2 0.6.2", "cookie", "crossbeam-channel", "dirs", - "dom_query", + "dom_query 0.30.0", "dpi", "dunce", "gdkx11", @@ -6945,7 +7125,6 @@ dependencies = [ "objc2-foundation 0.3.2", "objc2-ui-kit 0.3.2", "objc2-web-kit 0.3.2", - "once_cell", "percent-encoding", "raw-window-handle", "sha2", diff --git a/src/components/windowControls/windowDrag.tsx b/src/components/windowControls/windowDrag.tsx index f47ad3b..50c88b3 100644 --- a/src/components/windowControls/windowDrag.tsx +++ b/src/components/windowControls/windowDrag.tsx @@ -1,8 +1,11 @@ import { getCurrentWindow } from "@tauri-apps/api/window"; import { useEffect } from "react"; -/** Height of the draggable titlebar hit area. */ -const DRAG_ZONE = 36; +/** + * Height of the draggable titlebar hit area. Headers on every page fit inside + * it; interactive controls are filtered out below. + */ +const DRAG_ZONE = 64; /** * Interactive elements inside the titlebar must keep receiving clicks @@ -25,7 +28,6 @@ const INTERACTIVE_SELECTOR = [ "[role='checkbox']", "[role='slider']", "[role='combobox']", - "[data-tauri-drag-region]", ".MuiMenu-root", ".MuiPopover-root", ".MuiDialog-root", @@ -37,13 +39,16 @@ const INTERACTIVE_SELECTOR = [ /** * Lets the user drag the frameless window from the top area of any page. - * Existing headers still use their native Tauri drag regions; this covers - * pages without one (settings, login, empty states, etc.). + * + * Tauri's `data-tauri-drag-region` is not inherited by child elements, so a + * click on the text inside a header (the Blink wordmark, a title, an icon) + * would otherwise do nothing. Native regions are still left to Tauri; this + * handler only takes over clicks on their non-interactive children. */ const WindowDrag = () => { useEffect(() => { - const onPointerDown = (event: PointerEvent) => { - if (event.button !== 0 || event.pointerType !== "mouse") return; + const onMouseDown = (event: MouseEvent) => { + if (event.button !== 0 || event.buttons !== 1) return; if (event.clientY > DRAG_ZONE) return; if (document.fullscreenElement) return; if (window.location.pathname.startsWith("/player")) return; @@ -51,17 +56,29 @@ const WindowDrag = () => { const target = event.target as Element | null; if (!target || target.closest(INTERACTIVE_SELECTOR)) return; + // Let Tauri's native drag-region handler deal with the elements + // that explicitly carry the attribute. It does not bubble to + // children, and those are exactly the clicks handled below. + if (target.hasAttribute("data-tauri-drag-region")) return; + event.preventDefault(); - getCurrentWindow() - .startDragging() - .catch((error) => { - console.warn("Could not start dragging the window", error); + const appWindow = getCurrentWindow(); + + if (event.detail === 2) { + appWindow.toggleMaximize().catch((error) => { + console.warn("Could not toggle the window size", error); }); + return; + } + + appWindow.startDragging().catch((error) => { + console.warn("Could not start dragging the window", error); + }); }; - document.addEventListener("pointerdown", onPointerDown, true); + document.addEventListener("mousedown", onMouseDown, true); return () => { - document.removeEventListener("pointerdown", onPointerDown, true); + document.removeEventListener("mousedown", onMouseDown, true); }; }, []);