Преглед на файлове

feat(core): set gtk app id (#9621)

* feat(core): set gtk app id

ref: https://github.com/tauri-apps/tao/issues/910

* Update core/tauri-runtime-wry/Cargo.toml

* Discard changes to Cargo.lock
Amr Bashir преди 1 година
родител
ревизия
669b9c6b5a
променени са 4 файла, в които са добавени 36 реда и са изтрити 0 реда
  1. 7 0
      .changes/linux-gtk-app-id.md
  2. 12 0
      core/tauri-runtime-wry/src/lib.rs
  3. 8 0
      core/tauri-runtime/src/lib.rs
  4. 9 0
      core/tauri/src/app.rs

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

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

@@ -2245,6 +2245,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

@@ -339,6 +339,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

@@ -1633,6 +1633,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();