diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index d90e543ad91..a61c5226e2e 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -880,12 +880,20 @@ 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_title_hidden(transparent); + // self.inner = self.inner.with_fullsize_content_view(transparent); self.inner = self.inner.with_titlebar_transparent(transparent); self } + #[cfg(target_os = "macos")] + fn transparent_title(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 ecdcdf52007..0a02be3fadf 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -194,6 +194,8 @@ pub trait WindowBuilder: WindowBuilderBase { #[must_use] fn transparent_titlebar(self, transparent: bool) -> Self; + fn transparent_title(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/window.rs b/core/tauri/src/window.rs index 23b518ba314..5bfe67537c8 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -429,6 +429,14 @@ impl WindowBuilder { self } + /// Hides the title. + #[cfg(target_os = "macos")] + #[must_use] + pub fn transparent_title(mut self, transparent: bool) -> Self { + self.window_builder = self.window_builder.transparent_title(transparent); + self + } + // ------------------------------------------- Webview attributes ------------------------------------------- /// Sets the init script. diff --git a/examples/helloworld/main.rs b/examples/helloworld/main.rs index d538ecda745..3fd1955a356 100644 --- a/examples/helloworld/main.rs +++ b/examples/helloworld/main.rs @@ -7,10 +7,26 @@ windows_subsystem = "windows" )] +use tauri::{window, Manager, WindowUrl}; + fn main() { - tauri::Builder::default() - .run(tauri::generate_context!( + let tauri_app = tauri::Builder::default() + .build(tauri::generate_context!( "../../examples/helloworld/tauri.conf.json" )) .expect("error while running tauri application"); + + window::WindowBuilder::new(&tauri_app.app_handle(), "main", WindowUrl::default()) + .title("Kryp") + .resizable(true) + .decorations(true) + .always_on_top(false) + .transparent_titlebar(true) + // .transparent_title(false) + .inner_size(1050.0, 800.0) + .min_inner_size(300.0, 200.0) + .fullscreen(false) + .build(); + + tauri_app.run(|_, _| {}); } diff --git a/examples/helloworld/tauri.conf.json b/examples/helloworld/tauri.conf.json index 09bc55c9624..7d3f125b2a0 100644 --- a/examples/helloworld/tauri.conf.json +++ b/examples/helloworld/tauri.conf.json @@ -1,7 +1,11 @@ { "build": { - "distDir": ["index.html"], - "devPath": ["index.html"], + "distDir": [ + "index.html" + ], + "devPath": [ + "index.html" + ], "beforeDevCommand": "", "beforeBuildCommand": "" }, @@ -34,15 +38,6 @@ "allowlist": { "all": false }, - "windows": [ - { - "title": "Welcome to Tauri!", - "width": 800, - "height": 600, - "resizable": true, - "fullscreen": false - } - ], "security": { "csp": "default-src 'self'" }