From 71b478ebc490222fd6e10624566dd33f5a7574ed Mon Sep 17 00:00:00 2001 From: Amirhossein Akhlaghpour Date: Wed, 27 May 2026 21:42:54 +0330 Subject: [PATCH] feat(macos): expose compact control size metrics option Signed-off-by: Amirhossein Akhlaghpour --- crates/tauri-cli/config.schema.json | 5 +++++ crates/tauri-runtime-wry/src/lib.rs | 12 +++++++++++- crates/tauri-runtime/src/window.rs | 5 +++++ .../schemas/config.schema.json | 5 +++++ crates/tauri-utils/src/config.rs | 9 +++++++++ crates/tauri/src/webview/webview_window.rs | 10 ++++++++++ crates/tauri/src/window/mod.rs | 10 ++++++++++ 7 files changed, 55 insertions(+), 1 deletion(-) diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index 898317a465a0..bc08f4a6d409 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -456,6 +456,11 @@ } ] }, + "prefersCompactControlSizeMetrics": { + "description": "Whether the window prefers compact control size metrics on macOS.\n\n On macOS 26 with SDK 26 or newer this can restore the older compact\n traffic light metrics for windows using overlay title bars.", + "default": false, + "type": "boolean" + }, "hiddenTitle": { "description": "If `true`, sets the window title to be hidden on macOS.", "default": false, diff --git a/crates/tauri-runtime-wry/src/lib.rs b/crates/tauri-runtime-wry/src/lib.rs index 7cfbe1855033..b2895c6b7e47 100644 --- a/crates/tauri-runtime-wry/src/lib.rs +++ b/crates/tauri-runtime-wry/src/lib.rs @@ -861,7 +861,9 @@ 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) + .prefers_compact_control_size_metrics(config.prefers_compact_control_size_metrics); + if let Some(identifier) = &config.tabbing_identifier { window = window.tabbing_identifier(identifier); } @@ -1224,6 +1226,14 @@ impl WindowBuilder for WindowBuilderWrapper { self } + #[cfg(target_os = "macos")] + fn prefers_compact_control_size_metrics(mut self, enabled: bool) -> Self { + self.inner = self + .inner + .with_prefers_compact_control_size_metrics(enabled); + self + } + #[cfg(target_os = "macos")] fn hidden_title(mut self, hidden: bool) -> Self { self.inner = self.inner.with_title_hidden(hidden); diff --git a/crates/tauri-runtime/src/window.rs b/crates/tauri-runtime/src/window.rs index e20613ea260d..1deab027bdab 100644 --- a/crates/tauri-runtime/src/window.rs +++ b/crates/tauri-runtime/src/window.rs @@ -471,6 +471,11 @@ pub trait WindowBuilder: WindowBuilderBase { #[must_use] fn traffic_light_position>(self, position: P) -> Self; + /// Whether the window prefers compact control size metrics on macOS. + #[cfg(target_os = "macos")] + #[must_use] + fn prefers_compact_control_size_metrics(self, enabled: bool) -> Self; + /// Hide the window title. #[cfg(target_os = "macos")] #[must_use] diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index 898317a465a0..bc08f4a6d409 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -456,6 +456,11 @@ } ] }, + "prefersCompactControlSizeMetrics": { + "description": "Whether the window prefers compact control size metrics on macOS.\n\n On macOS 26 with SDK 26 or newer this can restore the older compact\n traffic light metrics for windows using overlay title bars.", + "default": false, + "type": "boolean" + }, "hiddenTitle": { "description": "If `true`, sets the window title to be hidden on macOS.", "default": false, diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index a54c619e3f6f..8b55b8330c92 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -2063,6 +2063,12 @@ pub struct WindowConfig { /// Requires titleBarStyle: Overlay and decorations: true. #[serde(default, alias = "traffic-light-position")] pub traffic_light_position: Option, + /// Whether the window prefers compact control size metrics on macOS. + /// + /// On macOS 26 with SDK 26 or newer this can restore the older compact + /// traffic light metrics for windows using overlay title bars. + #[serde(default, alias = "prefers-compact-control-size-metrics")] + pub prefers_compact_control_size_metrics: bool, /// If `true`, sets the window title to be hidden on macOS. #[serde(default, alias = "hidden-title")] pub hidden_title: bool, @@ -2330,6 +2336,7 @@ impl Default for WindowConfig { theme: None, title_bar_style: Default::default(), traffic_light_position: None, + prefers_compact_control_size_metrics: false, hidden_title: false, accept_first_mouse: false, tabbing_identifier: None, @@ -3876,6 +3883,7 @@ mod build { let theme = opt_lit(self.theme.as_ref()); let title_bar_style = &self.title_bar_style; let traffic_light_position = opt_lit(self.traffic_light_position.as_ref()); + let prefers_compact_control_size_metrics = self.prefers_compact_control_size_metrics; let hidden_title = self.hidden_title; let accept_first_mouse = self.accept_first_mouse; let tabbing_identifier = opt_str_lit(self.tabbing_identifier.as_ref()); @@ -3941,6 +3949,7 @@ mod build { theme, title_bar_style, traffic_light_position, + prefers_compact_control_size_metrics, hidden_title, accept_first_mouse, tabbing_identifier, diff --git a/crates/tauri/src/webview/webview_window.rs b/crates/tauri/src/webview/webview_window.rs index 8db5db27dbd3..e14bb31b3ca5 100644 --- a/crates/tauri/src/webview/webview_window.rs +++ b/crates/tauri/src/webview/webview_window.rs @@ -741,6 +741,16 @@ impl<'a, R: Runtime, M: Manager> WebviewWindowBuilder<'a, R, M> { self } + /// Whether the window prefers compact control size metrics on macOS. + #[cfg(target_os = "macos")] + #[must_use] + pub fn prefers_compact_control_size_metrics(mut self, enabled: bool) -> Self { + self.window_builder = self + .window_builder + .prefers_compact_control_size_metrics(enabled); + self + } + /// Whether to show a link preview when long pressing on links. Available on macOS and iOS only. /// /// Default is true. diff --git a/crates/tauri/src/window/mod.rs b/crates/tauri/src/window/mod.rs index 6be20288bd0c..a7ee519501f5 100644 --- a/crates/tauri/src/window/mod.rs +++ b/crates/tauri/src/window/mod.rs @@ -770,6 +770,16 @@ impl<'a, R: Runtime, M: Manager> WindowBuilder<'a, R, M> { self } + /// Whether the window prefers compact control size metrics on macOS. + #[cfg(target_os = "macos")] + #[must_use] + pub fn prefers_compact_control_size_metrics(mut self, enabled: bool) -> Self { + self.window_builder = self + .window_builder + .prefers_compact_control_size_metrics(enabled); + self + } + /// Hide the window title. #[cfg(target_os = "macos")] #[must_use]