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(macos): add tabbing_identifier option, closes #2804, #3912 #5399

Merged
merged 7 commits into from Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/macos-automatic-tabbing.md
@@ -0,0 +1,6 @@
---
'tauri': minor
"tauri-runtime-wry": minor
---

Add `automatic_tabbing` option for macOS windows.
9 changes: 8 additions & 1 deletion core/tauri-runtime-wry/src/lib.rs
Expand Up @@ -710,7 +710,8 @@ impl WindowBuilder for WindowBuilderWrapper {
{
window = window
.hidden_title(config.hidden_title)
.title_bar_style(config.title_bar_style);
.title_bar_style(config.title_bar_style)
.automatic_tabbing(config.automatic_tabbing);
}

#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
Expand Down Expand Up @@ -878,6 +879,12 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}

#[cfg(target_os = "macos")]
fn automatic_tabbing(mut self, enabled: bool) -> Self {
self.inner = self.inner.with_automatic_window_tabbing(enabled);
self
}

fn icon(mut self, icon: Icon) -> Result<Self> {
self.inner = self
.inner
Expand Down
5 changes: 5 additions & 0 deletions core/tauri-runtime/src/webview.rs
Expand Up @@ -219,6 +219,11 @@ pub trait WindowBuilder: WindowBuilderBase {
#[must_use]
fn hidden_title(self, hidden: bool) -> Self;

/// Sets whether the system can automatically organize windows into tabs.
#[cfg(target_os = "macos")]
#[must_use]
fn automatic_tabbing(self, enabled: bool) -> Self;

/// Forces a theme or uses the system settings if None was provided.
fn theme(self, theme: Option<Theme>) -> Self;

Expand Down
8 changes: 7 additions & 1 deletion core/tauri-utils/src/config.rs
Expand Up @@ -873,6 +873,9 @@ pub struct WindowConfig {
/// Whether clicking an inactive window also clicks through to the webview.
#[serde(default, alias = "accept-first-mouse")]
pub accept_first_mouse: bool,
/// Sets whether macOS can automatically organize windows into tabs.
#[serde(default, alias = "automatic-tabbing")]
pub automatic_tabbing: bool,
}

impl Default for WindowConfig {
Expand Down Expand Up @@ -905,6 +908,7 @@ impl Default for WindowConfig {
title_bar_style: Default::default(),
hidden_title: false,
accept_first_mouse: false,
automatic_tabbing: true,
}
}
}
Expand Down Expand Up @@ -3037,6 +3041,7 @@ mod build {
let title_bar_style = &self.title_bar_style;
let hidden_title = self.hidden_title;
let accept_first_mouse = self.accept_first_mouse;
let automatic_tabbing = self.automatic_tabbing;

literal_struct!(
tokens,
Expand Down Expand Up @@ -3067,7 +3072,8 @@ mod build {
theme,
title_bar_style,
hidden_title,
accept_first_mouse
accept_first_mouse,
automatic_tabbing
);
}
}
Expand Down
5 changes: 5 additions & 0 deletions core/tauri/src/test/mock_runtime.rs
Expand Up @@ -283,6 +283,11 @@ impl WindowBuilder for MockWindowBuilder {
self
}

#[cfg(target_os = "macos")]
fn automatic_tabbing(self, enabled: bool) -> Self {
self
}

fn theme(self, theme: Option<Theme>) -> Self {
self
}
Expand Down
8 changes: 8 additions & 0 deletions core/tauri/src/window.rs
Expand Up @@ -462,6 +462,14 @@ impl<'a, R: Runtime> WindowBuilder<'a, R> {
self
}

/// Sets whether macOS can automatically organize windows into tabs.
#[cfg(target_os = "macos")]
#[must_use]
pub fn automatic_tabbing(mut self, enabled: bool) -> Self {
self.window_builder = self.window_builder.automatic_tabbing(enabled);
self
}

// ------------------------------------------- Webview attributes -------------------------------------------

/// Adds the provided JavaScript to a list of scripts that should be run after the global object has been created,
Expand Down
2 changes: 2 additions & 0 deletions examples/multiwindow/tauri.conf.json
Expand Up @@ -35,12 +35,14 @@
{
"label": "Main",
"title": "Tauri - Main",
"automaticTabbing": false,
"width": 800,
"height": 600
},
{
"label": "Secondary",
"title": "Tauri - Secondary",
"automaticTabbing": false,
"width": 600,
"height": 400
}
Expand Down
4 changes: 4 additions & 0 deletions tooling/api/src/window.ts
Expand Up @@ -2046,6 +2046,10 @@ interface WindowOptions {
* Whether clicking an inactive window also clicks through to the webview.
*/
acceptFirstMouse?: boolean
/**
* Sets whether macOS can automatically organize windows into tabs.
*/
automaticTabbing?: boolean
/**
* The user agent for the webview.
*/
Expand Down
7 changes: 6 additions & 1 deletion tooling/cli/schema.json
Expand Up @@ -675,6 +675,11 @@
"description": "Whether clicking an inactive window also clicks through to the webview.",
"default": false,
"type": "boolean"
},
"automaticTabbing": {
"description": "Sets whether macOS can automatically organize windows into tabs.",
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -2730,4 +2735,4 @@
"additionalProperties": true
}
}
}
}