Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): make setting of gtk app id optional #10397

Merged
merged 7 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/linux-option-gtk-app-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-utils": "patch:enhance"
"tauri": "patch:enhance"
---

Make the set of gtk application id optional, to allow more then one instance of the app running at the same time.
6 changes: 6 additions & 0 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"app": {
"description": "The App configuration.",
"default": {
"enableGTKAppId": false,
"macOSPrivateApi": false,
"security": {
"assetProtocol": {
Expand Down Expand Up @@ -195,6 +196,11 @@
"description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
"default": false,
"type": "boolean"
},
"enableGTKAppId": {
"description": "If set to true \"identifier\" will be set as GTK app ID (on systems that use GTK).",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
8 changes: 7 additions & 1 deletion core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,9 @@ pub struct AppConfig {
/// Whether we should inject the Tauri API on `window.__TAURI__` or not.
#[serde(default, alias = "with-global-tauri")]
pub with_global_tauri: bool,
/// If set to true "identifier" will be set as GTK app ID (on systems that use GTK).
#[serde(rename = "enableGTKAppId", alias = "enable-gtk-app-id", default)]
pub enable_gtk_app_id: bool,
}

impl AppConfig {
Expand Down Expand Up @@ -2732,6 +2735,7 @@ mod build {
let tray_icon = opt_lit(self.tray_icon.as_ref());
let macos_private_api = self.macos_private_api;
let with_global_tauri = self.with_global_tauri;
let enable_gtk_app_id = self.enable_gtk_app_id;

literal_struct!(
tokens,
Expand All @@ -2740,7 +2744,8 @@ mod build {
security,
tray_icon,
macos_private_api,
with_global_tauri
with_global_tauri,
enable_gtk_app_id
);
}
}
Expand Down Expand Up @@ -2817,6 +2822,7 @@ mod test {
tray_icon: None,
macos_private_api: false,
with_global_tauri: false,
enable_gtk_app_id: false,
};

// create a build config
Expand Down
8 changes: 7 additions & 1 deletion core/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,12 @@ tauri::Builder::default()
self.invoke_key,
));

let app_id = if manager.config.app.enable_gtk_app_id {
Some(manager.config.identifier.clone())
} else {
None
};

let runtime_args = RuntimeInitArgs {
#[cfg(any(
target_os = "linux",
Expand All @@ -1714,7 +1720,7 @@ tauri::Builder::default()
target_os = "netbsd",
target_os = "openbsd"
))]
app_id: Some(manager.config.identifier.clone()),
app_id,

#[cfg(windows)]
msg_hook: {
Expand Down
1 change: 1 addition & 0 deletions core/tauri/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub fn mock_context<R: Runtime, A: Assets<R>>(assets: A) -> crate::Context<R> {
security: Default::default(),
tray_icon: None,
macos_private_api: false,
enable_gtk_app_id: false,
},
bundle: Default::default(),
build: Default::default(),
Expand Down
6 changes: 6 additions & 0 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"app": {
"description": "The App configuration.",
"default": {
"enableGTKAppId": false,
"macOSPrivateApi": false,
"security": {
"assetProtocol": {
Expand Down Expand Up @@ -195,6 +196,11 @@
"description": "Whether we should inject the Tauri API on `window.__TAURI__` or not.",
"default": false,
"type": "boolean"
},
"enableGTKAppId": {
"description": "If set to true \"identifier\" will be set as GTK app ID (on systems that use GTK).",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
Loading