From ae6b13dfc0590dcaedbdb619c148072f072df050 Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Thu, 23 May 2024 00:45:39 +0800 Subject: [PATCH] feat(core): add `app-region: drag` to `data-tauri-drag-region` (#9789) --- .changes/app-region-drag.md | 5 +++++ Cargo.lock | 4 ++-- core/tauri-runtime-wry/Cargo.toml | 2 +- core/tauri/src/window/scripts/drag.js | 5 +++++ examples/api/src-tauri/Cargo.lock | 4 ++-- 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .changes/app-region-drag.md diff --git a/.changes/app-region-drag.md b/.changes/app-region-drag.md new file mode 100644 index 000000000..0cbb45e47 --- /dev/null +++ b/.changes/app-region-drag.md @@ -0,0 +1,5 @@ +--- +"tauri": patch:feat +--- + +Add `app-region: drag` to HTML elements with `data-tauri-drag-region` on Windows, only WebView2 123+, which should fix dragging using touch. diff --git a/Cargo.lock b/Cargo.lock index 11a6d1f8a..e8828d363 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4885,9 +4885,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.39.3" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e180ac2740d6cb4d5cec0abf63eacbea90f1b7e5e3803043b13c1c84c4b7884" +checksum = "7cd42682bad8d1efd0e0d0593770c602c13b8922bb1ca705cb845967de81bbc4" dependencies = [ "base64 0.22.0", "block", diff --git a/core/tauri-runtime-wry/Cargo.toml b/core/tauri-runtime-wry/Cargo.toml index 18a45ada1..9778020e8 100644 --- a/core/tauri-runtime-wry/Cargo.toml +++ b/core/tauri-runtime-wry/Cargo.toml @@ -13,7 +13,7 @@ edition = { workspace = true } rust-version = { workspace = true } [dependencies] -wry = { version = "0.39.3", default-features = false, features = [ "drag-drop", "protocol", "os-webview" ] } +wry = { version = "0.40", default-features = false, features = [ "drag-drop", "protocol", "os-webview" ] } tao = { version = "0.28", default-features = false, features = [ "rwh_06" ] } tauri-runtime = { version = "2.0.0-beta.16", path = "../tauri-runtime" } tauri-utils = { version = "2.0.0-beta.15", path = "../tauri-utils" } diff --git a/core/tauri/src/window/scripts/drag.js b/core/tauri/src/window/scripts/drag.js index a247a41bb..6c2fef222 100644 --- a/core/tauri/src/window/scripts/drag.js +++ b/core/tauri/src/window/scripts/drag.js @@ -63,4 +63,9 @@ } }) } + if (osName === 'windows' && 'adoptedStyleSheets' in document) { + const sheet = new CSSStyleSheet() + sheet.replaceSync('*[data-tauri-drag-region] { app-region: drag; }') + document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet] + } })() diff --git a/examples/api/src-tauri/Cargo.lock b/examples/api/src-tauri/Cargo.lock index 1de0a9af7..5ec6656a1 100644 --- a/examples/api/src-tauri/Cargo.lock +++ b/examples/api/src-tauri/Cargo.lock @@ -4257,9 +4257,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.39.5" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7172fc76376d55d089c627a31a5b604b4ac372793fb5378d1c7ddf008703008" +checksum = "7cd42682bad8d1efd0e0d0593770c602c13b8922bb1ca705cb845967de81bbc4" dependencies = [ "base64 0.22.1", "block",