diff --git a/.changes/macos-automatic-tabbing.md b/.changes/macos-automatic-tabbing.md new file mode 100644 index 00000000000..4d8b11355b3 --- /dev/null +++ b/.changes/macos-automatic-tabbing.md @@ -0,0 +1,6 @@ +--- +'tauri': minor +"tauri-runtime-wry": minor +--- + +Add `automatic_tabbing` option for macOS windows. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 0eb4076e55c..8bd73be907a 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -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"))] @@ -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.inner = self .inner diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index 8bdd9af339f..320f1d8552e 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -210,6 +210,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) -> Self; diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index 6ec40950315..f816dee0cf6 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -870,6 +870,9 @@ pub struct WindowConfig { /// If `true`, sets the window title to be hidden on macOS. #[serde(default, alias = "hidden-title")] pub hidden_title: bool, + /// Sets whether macOS can automatically organize windows into tabs. + #[serde(default, alias = "automatic-tabbing")] + pub automatic_tabbing: bool, } impl Default for WindowConfig { @@ -901,6 +904,7 @@ impl Default for WindowConfig { theme: None, title_bar_style: Default::default(), hidden_title: false, + automatic_tabbing: true, } } } @@ -3032,6 +3036,7 @@ mod build { let theme = opt_lit(self.theme.as_ref()); let title_bar_style = &self.title_bar_style; let hidden_title = self.hidden_title; + let automatic_tabbing = self.automatic_tabbing; literal_struct!( tokens, @@ -3061,7 +3066,8 @@ mod build { skip_taskbar, theme, title_bar_style, - hidden_title + hidden_title, + automatic_tabbing ); } } diff --git a/core/tauri/src/test/mock_runtime.rs b/core/tauri/src/test/mock_runtime.rs index 8a19ffdc9ce..88675bb0240 100644 --- a/core/tauri/src/test/mock_runtime.rs +++ b/core/tauri/src/test/mock_runtime.rs @@ -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) -> Self { self } diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index d5196ea46e1..667fc026d53 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -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, diff --git a/examples/multiwindow/main.rs b/examples/multiwindow/main.rs index b9251e50468..7b03edf83a7 100644 --- a/examples/multiwindow/main.rs +++ b/examples/multiwindow/main.rs @@ -24,6 +24,7 @@ fn main() { tauri::WindowUrl::App("index.html".into()), ) .title("Tauri - Rust") + .automatic_tabbing(false) .build()?; Ok(()) }) diff --git a/examples/multiwindow/tauri.conf.json b/examples/multiwindow/tauri.conf.json index 1c50fec1e85..21a3dae8b32 100644 --- a/examples/multiwindow/tauri.conf.json +++ b/examples/multiwindow/tauri.conf.json @@ -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 } diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index 0a4e831a28b..c6368387b72 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -2042,6 +2042,10 @@ interface WindowOptions { * If `true`, sets the window title to be hidden on macOS. */ hiddenTitle?: boolean + /** + * Sets whether macOS can automatically organize windows into tabs. + */ + automaticTabbing?: boolean /** * The user agent for the webview. */ diff --git a/tooling/cli/schema.json b/tooling/cli/schema.json index 7357c7409f6..9729a13d8ee 100644 --- a/tooling/cli/schema.json +++ b/tooling/cli/schema.json @@ -670,6 +670,11 @@ "description": "If `true`, sets the window title to be hidden on macOS.", "default": false, "type": "boolean" + }, + "automaticTabbing": { + "description": "Sets whether macOS can automatically organize windows into tabs.", + "default": true, + "type": "boolean" } }, "additionalProperties": false @@ -2725,4 +2730,4 @@ "additionalProperties": true } } -} \ No newline at end of file +}