瀏覽代碼

feat(core): set gtk app id

ref: https://github.com/tauri-apps/tao/issues/910
amrbashir 1 年之前
父節點
當前提交
8b0a4f06da

+ 7 - 0
.changes/linux-gtk-app-id.md

@@ -0,0 +1,7 @@
+---
+"tauri": "patch:enhance"
+"tauri-runtime-wry": "patch"
+---
+
+Set the gtk application to the identifier defined in `tauri.conf.json` to ensure the app uniqueness.
+

+ 13 - 4
Cargo.lock

@@ -3472,8 +3472,7 @@ dependencies = [
 [[package]]
 name = "tao"
 version = "0.27.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "92bcf8885e147b56d6e26751263b45876284f32ca404703f6d3b8f80d16ff4dd"
+source = "git+https://github.com/tauri-apps/tao#cd38f237481b58585cc2da98c3bb9a0ce8e64b9f"
 dependencies = [
  "bitflags 2.5.0",
  "cocoa",
@@ -3499,7 +3498,7 @@ dependencies = [
  "parking_lot",
  "raw-window-handle 0.6.0",
  "scopeguard",
- "tao-macros",
+ "tao-macros 0.1.2 (git+https://github.com/tauri-apps/tao)",
  "unicode-segmentation",
  "url",
  "windows 0.56.0",
@@ -3519,6 +3518,16 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "tao-macros"
+version = "0.1.2"
+source = "git+https://github.com/tauri-apps/tao#cd38f237481b58585cc2da98c3bb9a0ce8e64b9f"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.57",
+]
+
 [[package]]
 name = "target-lexicon"
 version = "0.12.14"
@@ -4914,7 +4923,7 @@ dependencies = [
  "raw-window-handle 0.6.0",
  "sha2",
  "soup3",
- "tao-macros",
+ "tao-macros 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "thiserror",
  "tracing",
  "webkit2gtk",

+ 1 - 1
core/tauri-runtime-wry/Cargo.toml

@@ -14,7 +14,7 @@ rust-version = { workspace = true }
 
 [dependencies]
 wry = { version = "0.39.3", default-features = false, features = [ "drag-drop", "protocol", "os-webview" ] }
-tao = { version = "0.27", default-features = false, features = [ "rwh_06" ] }
+tao = { git = "https://github.com/tauri-apps/tao", default-features = false, features = [ "rwh_06" ] }
 tauri-runtime = { version = "2.0.0-beta.13", path = "../tauri-runtime" }
 tauri-utils = { version = "2.0.0-beta.13", path = "../tauri-utils" }
 raw-window-handle = "0.6"

+ 12 - 0
core/tauri-runtime-wry/src/lib.rs

@@ -2218,6 +2218,18 @@ impl<T: UserEvent> Wry<T> {
       use tao::platform::windows::EventLoopBuilderExtWindows;
       event_loop_builder.with_msg_hook(hook);
     }
+
+    #[cfg(any(
+      target_os = "linux",
+      target_os = "dragonfly",
+      target_os = "freebsd",
+      target_os = "netbsd",
+      target_os = "openbsd"
+    ))]
+    if let Some(app_id) = args.app_id {
+      use tao::platform::unix::EventLoopBuilderExtUnix;
+      event_loop_builder.with_app_id(app_id);
+    }
     Self::init(event_loop_builder.build())
   }
 

+ 8 - 0
core/tauri-runtime/src/lib.rs

@@ -332,6 +332,14 @@ pub trait EventLoopProxy<T: UserEvent>: Debug + Clone + Send + Sync {
 
 #[derive(Default)]
 pub struct RuntimeInitArgs {
+  #[cfg(any(
+    target_os = "linux",
+    target_os = "dragonfly",
+    target_os = "freebsd",
+    target_os = "netbsd",
+    target_os = "openbsd"
+  ))]
+  pub app_id: Option<String>,
   #[cfg(windows)]
   pub msg_hook: Option<Box<dyn FnMut(*const std::ffi::c_void) -> bool + 'static>>,
 }

+ 9 - 0
core/tauri/src/app.rs

@@ -1592,6 +1592,15 @@ tauri::Builder::default()
     ));
 
     let runtime_args = RuntimeInitArgs {
+      #[cfg(any(
+        target_os = "linux",
+        target_os = "dragonfly",
+        target_os = "freebsd",
+        target_os = "netbsd",
+        target_os = "openbsd"
+      ))]
+      app_id: Some(manager.config.identifier.clone()),
+
       #[cfg(windows)]
       msg_hook: {
         let menus = manager.menu.menus.clone();