瀏覽代碼

feat(core): add `app-region: drag` to `data-tauri-drag-region` (#9789)

Tony 1 年之前
父節點
當前提交
ae6b13dfc0

+ 5 - 0
.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.

+ 2 - 2
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",

+ 1 - 1
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" }

+ 5 - 0
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]
+  }
 })()

+ 2 - 2
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",