From a67005d96bbea36a50532d76e78d3d843b89b16a Mon Sep 17 00:00:00 2001 From: Kasper Date: Mon, 25 Apr 2022 21:39:14 +0200 Subject: [PATCH 1/6] feat(macos): `transparent_titlebar` window option --- .changes/transparent-titlebar-macos.md | 6 ++++++ core/tauri-runtime-wry/src/lib.rs | 8 ++++++++ core/tauri-runtime/src/webview.rs | 5 +++++ core/tauri/src/test/mock_runtime.rs | 5 +++++ core/tauri/src/window.rs | 8 ++++++++ 5 files changed, 32 insertions(+) create mode 100644 .changes/transparent-titlebar-macos.md diff --git a/.changes/transparent-titlebar-macos.md b/.changes/transparent-titlebar-macos.md new file mode 100644 index 000000000000..f0ade5e3cce4 --- /dev/null +++ b/.changes/transparent-titlebar-macos.md @@ -0,0 +1,6 @@ +--- +'tauri': minor +"tauri-runtime-wry": minor +--- + +Add `transparent_titlebar` option for macOS windows. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 12a65d62f2af..d90e543ad912 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -878,6 +878,14 @@ impl WindowBuilder for WindowBuilderWrapper { self } + #[cfg(target_os = "macos")] + fn transparent_titlebar(mut self, transparent: bool) -> Self { + self.inner = self.inner.with_title_hidden(true); + self.inner = self.inner.with_fullsize_content_view(true); + self.inner = self.inner.with_titlebar_transparent(transparent); + self + } + fn icon(mut self, icon: WindowIcon) -> Result { self.inner = self .inner diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index 9071172c5d11..ecdcdf520074 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -189,6 +189,11 @@ pub trait WindowBuilder: WindowBuilderBase { #[must_use] fn owner_window(self, owner: HWND) -> Self; + /// Hides the titlebar. Titlebar buttons will still be visible. + #[cfg(target_os = "macos")] + #[must_use] + fn transparent_titlebar(self, transparent: 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/src/test/mock_runtime.rs b/core/tauri/src/test/mock_runtime.rs index 6088ae4b0466..28660746b852 100644 --- a/core/tauri/src/test/mock_runtime.rs +++ b/core/tauri/src/test/mock_runtime.rs @@ -252,6 +252,11 @@ impl WindowBuilder for MockWindowBuilder { self } + #[cfg(target_os = "macos")] + fn transparent_titlebar(self, transparent: 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 86f313f06cc6..23b518ba3144 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -421,6 +421,14 @@ impl WindowBuilder { self } + /// Hides the titlebar. Titlebar buttons will still be visible. + #[cfg(target_os = "macos")] + #[must_use] + pub fn transparent_titlebar(mut self, transparent: bool) -> Self { + self.window_builder = self.window_builder.transparent_titlebar(transparent); + self + } + // ------------------------------------------- Webview attributes ------------------------------------------- /// Sets the init script. From f0504c93d5587a6468d11e281120bd700b22ba78 Mon Sep 17 00:00:00 2001 From: Kasper Date: Mon, 16 May 2022 18:05:10 +0200 Subject: [PATCH 2/6] `hidden_title` and `fullscreen_content_view` --- core/tauri-runtime-wry/src/lib.rs | 14 ++++++++++++-- core/tauri-runtime/src/webview.rs | 12 +++++++++++- core/tauri/src/test/mock_runtime.rs | 10 ++++++++++ core/tauri/src/window.rs | 18 +++++++++++++++++- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index d90e543ad912..ad63fb8fb117 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -880,12 +880,22 @@ impl WindowBuilder for WindowBuilderWrapper { #[cfg(target_os = "macos")] fn transparent_titlebar(mut self, transparent: bool) -> Self { - self.inner = self.inner.with_title_hidden(true); - self.inner = self.inner.with_fullsize_content_view(true); self.inner = self.inner.with_titlebar_transparent(transparent); self } + #[cfg(target_os = "macos")] + fn hidden_title(mut self, hidden: bool) -> Self { + self.inner = self.inner.with_title_hidden(hidden); + self + } + + #[cfg(target_os = "macos")] + fn fullsize_content_view(mut self, fullsize: bool) -> Self { + self.inner = self.inner.with_fullsize_content_view(fullsize); + self + } + fn icon(mut self, icon: WindowIcon) -> Result { self.inner = self .inner diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index ecdcdf520074..c53b7cb5e176 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -189,11 +189,21 @@ pub trait WindowBuilder: WindowBuilderBase { #[must_use] fn owner_window(self, owner: HWND) -> Self; - /// Hides the titlebar. Titlebar buttons will still be visible. + /// Hide the titlebar. Titlebar buttons will still be visible. #[cfg(target_os = "macos")] #[must_use] fn transparent_titlebar(self, transparent: bool) -> Self; + /// Hide the window title. + #[cfg(target_os = "macos")] + #[must_use] + fn hidden_title(self, hidden: bool) -> Self; + + /// Make the content of the window take up the whole window. + #[cfg(target_os = "macos")] + #[must_use] + fn fullsize_content_view(self, fullsize: 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/src/test/mock_runtime.rs b/core/tauri/src/test/mock_runtime.rs index 28660746b852..16ab7056d62a 100644 --- a/core/tauri/src/test/mock_runtime.rs +++ b/core/tauri/src/test/mock_runtime.rs @@ -257,6 +257,16 @@ impl WindowBuilder for MockWindowBuilder { self } + #[cfg(target_os = "macos")] + fn hidden_title(self, transparent: bool) -> Self { + self + } + + #[cfg(target_os = "macos")] + fn fullsize_content_view(self, fullsize: 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 23b518ba3144..1a13193a3946 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -421,7 +421,7 @@ impl WindowBuilder { self } - /// Hides the titlebar. Titlebar buttons will still be visible. + /// Hide the titlebar. Titlebar buttons will still be visible. #[cfg(target_os = "macos")] #[must_use] pub fn transparent_titlebar(mut self, transparent: bool) -> Self { @@ -429,6 +429,22 @@ impl WindowBuilder { self } + /// Hide the window title. + #[cfg(target_os = "macos")] + #[must_use] + pub fn hidden_title(mut self, hidden: bool) -> Self { + self.window_builder = self.window_builder.hidden_title(hidden); + self + } + + /// Make the content of the window take up the whole window. + #[cfg(target_os = "macos")] + #[must_use] + pub fn fullsize_content_view(mut self, fullsize: bool) -> Self { + self.window_builder = self.window_builder.fullsize_content_view(fullsize); + self + } + // ------------------------------------------- Webview attributes ------------------------------------------- /// Sets the init script. From 9285e91836c4da49afc5bf8b31eb13216d4e27cd Mon Sep 17 00:00:00 2001 From: Kasper Date: Sat, 25 Jun 2022 09:30:39 +0200 Subject: [PATCH 3/6] Change to `title_bar_style` and `hidden_title` --- .changes/transparent-titlebar-macos.md | 2 +- core/tauri-runtime-wry/src/lib.rs | 32 +++++++++++++++----------- core/tauri-runtime/src/webview.rs | 9 +++----- core/tauri-utils/src/lib.rs | 19 +++++++++++++++ core/tauri/src/lib.rs | 2 ++ core/tauri/src/window.rs | 14 ++++------- 6 files changed, 48 insertions(+), 30 deletions(-) diff --git a/.changes/transparent-titlebar-macos.md b/.changes/transparent-titlebar-macos.md index f0ade5e3cce4..fba683818639 100644 --- a/.changes/transparent-titlebar-macos.md +++ b/.changes/transparent-titlebar-macos.md @@ -3,4 +3,4 @@ "tauri-runtime-wry": minor --- -Add `transparent_titlebar` option for macOS windows. +Add `title_bar_style` option for macOS windows. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 5030e4eec461..b14ddb291602 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -39,6 +39,8 @@ use wry::application::platform::windows::{WindowBuilderExtWindows, WindowExtWind #[cfg(feature = "system-tray")] use wry::application::system_tray::{SystemTray as WrySystemTray, SystemTrayBuilder}; +#[cfg(target_os = "macos")] +use tauri_utils::TitleBarStyle; use tauri_utils::{config::WindowConfig, debug_eprintln, Theme}; use uuid::Uuid; use wry::{ @@ -886,8 +888,23 @@ impl WindowBuilder for WindowBuilderWrapper { } #[cfg(target_os = "macos")] - fn transparent_titlebar(mut self, transparent: bool) -> Self { - self.inner = self.inner.with_titlebar_transparent(transparent); + fn title_bar_style(mut self, style: TitleBarStyle) -> Self { + println!("{:?}", style); + match style { + TitleBarStyle::Visible => { + self.inner = self.inner.with_titlebar_transparent(false); + // Fixes rendering issue when resizing window with devtools open (https://github.com/tauri-apps/tauri/issues/3914) + self.inner = self.inner.with_fullsize_content_view(true); + } + TitleBarStyle::Transparent => { + self.inner = self.inner.with_titlebar_transparent(true); + self.inner = self.inner.with_fullsize_content_view(false); + } + TitleBarStyle::Overlay => { + self.inner = self.inner.with_titlebar_transparent(true); + self.inner = self.inner.with_fullsize_content_view(true); + } + } self } @@ -897,12 +914,6 @@ impl WindowBuilder for WindowBuilderWrapper { self } - #[cfg(target_os = "macos")] - fn fullsize_content_view(mut self, fullsize: bool) -> Self { - self.inner = self.inner.with_fullsize_content_view(fullsize); - self - } - fn icon(mut self, icon: Icon) -> Result { self.inner = self .inner @@ -2948,11 +2959,6 @@ fn create_webview( #[cfg(windows)] let proxy = context.proxy.clone(); - #[cfg(target_os = "macos")] - { - window_builder.inner = window_builder.inner.with_fullsize_content_view(true); - } - let is_window_transparent = window_builder.inner.window.transparent; let menu_items = if let Some(menu) = window_builder.menu { let mut menu_items = HashMap::new(); diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index 7f887e5f4e56..4e906427cf61 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -6,6 +6,8 @@ use crate::{menu::Menu, window::DetachedWindow, Icon}; +#[cfg(target_os = "macos")] +use tauri_utils::TitleBarStyle; use tauri_utils::{ config::{WindowConfig, WindowUrl}, Theme, @@ -192,18 +194,13 @@ pub trait WindowBuilder: WindowBuilderBase { /// Hide the titlebar. Titlebar buttons will still be visible. #[cfg(target_os = "macos")] #[must_use] - fn transparent_titlebar(self, transparent: bool) -> Self; + fn title_bar_style(self, style: TitleBarStyle) -> Self; /// Hide the window title. #[cfg(target_os = "macos")] #[must_use] fn hidden_title(self, hidden: bool) -> Self; - /// Make the content of the window take up the whole window. - #[cfg(target_os = "macos")] - #[must_use] - fn fullsize_content_view(self, fullsize: 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/lib.rs b/core/tauri-utils/src/lib.rs index fe518187d24d..71f509e590bb 100644 --- a/core/tauri-utils/src/lib.rs +++ b/core/tauri-utils/src/lib.rs @@ -49,6 +49,25 @@ impl PackageInfo { } } +/// How the window title bar should be displayed. +#[cfg(target_os = "macos")] +#[derive(Debug, Clone)] +pub enum TitleBarStyle { + /// A normal title bar. + Visible, + /// Makes the title bar transparent, so the window background color is shown instead. + /// + /// Useful if you don't need to have actual HTML under the title bar. This lets you avoid the caveats of using `TitleBarStyle::Overlay`. Will be more useful when Tauri lets you set a custom window background color. + Transparent, + /// Shows the title bar as a transparent overlay over the window's content. + /// + /// Keep in mind: + /// - The height of the title bar is different on different OS versions, which can lead to window the controls and title not being where you don't expect. + /// - You need to define a custom drag region to make your window draggable, however due to a limitation you can't drag the window when it's not in focus (https://github.com/tauri-apps/tauri/issues/4316). + /// - The color of the window title depends on the system theme. + Overlay, +} + /// System theme. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index ee2319e0ce8c..fa5d496e3a51 100644 --- a/core/tauri/src/lib.rs +++ b/core/tauri/src/lib.rs @@ -200,6 +200,8 @@ pub use runtime::http; #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))] pub use runtime::{menu::NativeImage, ActivationPolicy}; +#[cfg(target_os = "macos")] +pub use self::utils::TitleBarStyle; #[cfg(feature = "system-tray")] #[cfg_attr(doc_cfg, doc(cfg(feature = "system-tray")))] pub use { diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index c76b951b8110..7c718df83ebb 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -8,6 +8,8 @@ pub(crate) mod menu; pub use menu::{MenuEvent, MenuHandle}; +#[cfg(target_os = "macos")] +use crate::TitleBarStyle; use crate::{ app::AppHandle, command::{CommandArg, CommandItem}, @@ -435,8 +437,8 @@ impl<'a, R: Runtime> WindowBuilder<'a, R> { /// Hide the titlebar. Titlebar buttons will still be visible. #[cfg(target_os = "macos")] #[must_use] - pub fn transparent_titlebar(mut self, transparent: bool) -> Self { - self.window_builder = self.window_builder.transparent_titlebar(transparent); + pub fn title_bar_style(mut self, style: TitleBarStyle) -> Self { + self.window_builder = self.window_builder.title_bar_style(style); self } @@ -448,14 +450,6 @@ impl<'a, R: Runtime> WindowBuilder<'a, R> { self } - /// Make the content of the window take up the whole window. - #[cfg(target_os = "macos")] - #[must_use] - pub fn fullsize_content_view(mut self, fullsize: bool) -> Self { - self.window_builder = self.window_builder.fullsize_content_view(fullsize); - self - } - // ------------------------------------------- Webview attributes ------------------------------------------- /// Sets the init script. From d30b9bc215ab5f9e5054e39da245d56d58ed0505 Mon Sep 17 00:00:00 2001 From: Kasper Date: Sat, 25 Jun 2022 09:33:10 +0200 Subject: [PATCH 4/6] Update mock runtime --- core/tauri/src/test/mock_runtime.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/tauri/src/test/mock_runtime.rs b/core/tauri/src/test/mock_runtime.rs index af629c7ad6f6..12f538e0b346 100644 --- a/core/tauri/src/test/mock_runtime.rs +++ b/core/tauri/src/test/mock_runtime.rs @@ -20,6 +20,8 @@ use tauri_runtime::{ menu::{SystemTrayMenu, TrayHandle}, SystemTray, SystemTrayEvent, }; +#[cfg(target_os = "macos")] +use tauri_utils::TitleBarStyle; use tauri_utils::{config::WindowConfig, Theme}; use uuid::Uuid; @@ -253,7 +255,7 @@ impl WindowBuilder for MockWindowBuilder { } #[cfg(target_os = "macos")] - fn transparent_titlebar(self, transparent: bool) -> Self { + fn title_bar_style(self, style: TitleBarStyle) -> Self { self } @@ -262,11 +264,6 @@ impl WindowBuilder for MockWindowBuilder { self } - #[cfg(target_os = "macos")] - fn fullsize_content_view(self, fullsize: bool) -> Self { - self - } - fn theme(self, theme: Option) -> Self { self } From 51eaacde0b137fb092517a9bcce714608ac11977 Mon Sep 17 00:00:00 2001 From: Kasper Date: Sat, 25 Jun 2022 09:34:37 +0200 Subject: [PATCH 5/6] Create hidden-title-macos.md --- .changes/hidden-title-macos.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/hidden-title-macos.md diff --git a/.changes/hidden-title-macos.md b/.changes/hidden-title-macos.md new file mode 100644 index 000000000000..2ff415c61946 --- /dev/null +++ b/.changes/hidden-title-macos.md @@ -0,0 +1,6 @@ +--- +'tauri': minor +"tauri-runtime-wry": minor +--- + +Add `hidden_title` option for macOS windows. From 47062128146ba7144a46806e646c1ab0fe29ffe0 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Fri, 30 Sep 2022 13:51:18 -0300 Subject: [PATCH 6/6] add to config & JS API --- core/tauri-runtime-wry/src/lib.rs | 11 +++++--- core/tauri-utils/src/config.rs | 28 +++++++++++++++++- core/tauri-utils/src/lib.rs | 47 +++++++++++++++++++++++++++++-- core/tauri/src/window.rs | 2 +- tooling/api/src/window.ts | 9 ++++++ tooling/cli/schema.json | 23 +++++++++++++++ 6 files changed, 112 insertions(+), 8 deletions(-) diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 4751fa83a5d6..8ec5ed8ad647 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -741,6 +741,13 @@ impl WindowBuilder for WindowBuilderWrapper { .skip_taskbar(config.skip_taskbar) .theme(config.theme); + #[cfg(target_os = "macos")] + { + window = window + .hidden_title(config.hidden_title) + .title_bar_style(config.title_bar_style); + } + #[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))] { window = window.transparent(config.transparent); @@ -2898,10 +2905,6 @@ fn create_webview( let window_event_listeners = WindowEventListeners::default(); - #[cfg(target_os = "macos")] - { - window_builder.inner = window_builder.inner.with_fullsize_content_view(true); - } #[cfg(windows)] { window_builder.inner = window_builder diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index 9fb28bd5d35c..fb8bf3d01161 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -34,6 +34,8 @@ use std::{ /// Items to help with parsing content into a [`Config`]. pub mod parse; +use crate::TitleBarStyle; + pub use self::parse::parse; /// An URL to open on a Tauri webview window. @@ -859,6 +861,12 @@ pub struct WindowConfig { pub skip_taskbar: bool, /// The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+. pub theme: Option, + /// The style of the macOS title bar. + #[serde(default, alias = "title-bar-style")] + pub title_bar_style: TitleBarStyle, + /// If `true`, sets the window title to be hidden on macOS. + #[serde(default, alias = "hidden-title")] + pub hidden_title: bool, } impl Default for WindowConfig { @@ -887,6 +895,8 @@ impl Default for WindowConfig { always_on_top: false, skip_taskbar: false, theme: None, + title_bar_style: Default::default(), + hidden_title: false, } } } @@ -2932,6 +2942,18 @@ mod build { } } + impl ToTokens for crate::TitleBarStyle { + fn to_tokens(&self, tokens: &mut TokenStream) { + let prefix = quote! { ::tauri::utils::TitleBarStyle }; + + tokens.append_all(match self { + Self::Visible => quote! { #prefix::Visible }, + Self::Transparent => quote! { #prefix::Transparent }, + Self::Overlay => quote! { #prefix::Overlay }, + }) + } + } + impl ToTokens for WindowConfig { fn to_tokens(&self, tokens: &mut TokenStream) { let label = str_lit(&self.label); @@ -2957,6 +2979,8 @@ mod build { let always_on_top = self.always_on_top; let skip_taskbar = self.skip_taskbar; let theme = opt_lit(self.theme.as_ref()); + let title_bar_style = &self.title_bar_style; + let hidden_title = self.hidden_title; literal_struct!( tokens, @@ -2983,7 +3007,9 @@ mod build { decorations, always_on_top, skip_taskbar, - theme + theme, + title_bar_style, + hidden_title ); } } diff --git a/core/tauri-utils/src/lib.rs b/core/tauri-utils/src/lib.rs index 005ccfbcaa89..b63e90ff38aa 100644 --- a/core/tauri-utils/src/lib.rs +++ b/core/tauri-utils/src/lib.rs @@ -51,8 +51,8 @@ impl PackageInfo { } /// How the window title bar should be displayed. -#[cfg(target_os = "macos")] -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub enum TitleBarStyle { /// A normal title bar. Visible, @@ -69,6 +69,49 @@ pub enum TitleBarStyle { Overlay, } +impl Default for TitleBarStyle { + fn default() -> Self { + Self::Visible + } +} + +impl Serialize for TitleBarStyle { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} + +impl<'de> Deserialize<'de> for TitleBarStyle { + fn deserialize(deserializer: D) -> std::result::Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + Ok(match s.to_lowercase().as_str() { + "transparent" => Self::Transparent, + "overlay" => Self::Overlay, + _ => Self::Visible, + }) + } +} + +impl Display for TitleBarStyle { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{}", + match self { + Self::Visible => "Visible", + Self::Transparent => "Transparent", + Self::Overlay => "Overlay", + } + ) + } +} + /// System theme. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index 17c38a5f3c54..e4b60f14d4f2 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -435,7 +435,7 @@ impl<'a, R: Runtime> WindowBuilder<'a, R> { self } - /// Hide the titlebar. Titlebar buttons will still be visible. + /// Sets the [`TitleBarStyle`]. #[cfg(target_os = "macos")] #[must_use] pub fn title_bar_style(mut self, style: TitleBarStyle) -> Self { diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index fa24cb9b3918..a372c9585330 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -67,6 +67,7 @@ import { emit, Event, listen, once } from './helpers/event' import { TauriEvent } from './event' type Theme = 'light' | 'dark' +type TitleBarStyle = 'visible' | 'transparent' | 'overlay' /** * Allows you to retrieve information about a given monitor. @@ -2033,6 +2034,14 @@ interface WindowOptions { * Only implemented on Windows and macOS 10.14+. */ theme?: Theme + /** + * The style of the macOS title bar. + */ + titleBarStyle?: TitleBarStyle + /** + * If `true`, sets the window title to be hidden on macOS. + */ + hiddenTitle?: boolean } /** diff --git a/tooling/cli/schema.json b/tooling/cli/schema.json index a00bf7a73a6d..bdd6aff6a6ad 100644 --- a/tooling/cli/schema.json +++ b/tooling/cli/schema.json @@ -639,6 +639,20 @@ "type": "null" } ] + }, + "titleBarStyle": { + "description": "The style of the macOS title bar.", + "default": "Visible", + "allOf": [ + { + "$ref": "#/definitions/TitleBarStyle" + } + ] + }, + "hiddenTitle": { + "description": "Sets the window title to be hidden on macOS.", + "default": false, + "type": "boolean" } }, "additionalProperties": false @@ -665,6 +679,15 @@ "Dark" ] }, + "TitleBarStyle": { + "description": "How the window title bar should be displayed.", + "type": "string", + "enum": [ + "Visible", + "Transparent", + "Overlay" + ] + }, "CliConfig": { "description": "describes a CLI configuration", "type": "object",