From 9546548ec0c83ba620b1bc9d1d424a7009d0b423 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Wed, 17 Jul 2024 11:40:38 +0800 Subject: [PATCH] fix(macos): set default title-bar style to `Visible`, close #10225 (#10297) * fix(macos): set default title-bar style to `Visible` * chore: add TODO --- .../runtime-macos-default-visible-titlebat.md | 6 ++++++ core/tauri-runtime-wry/src/lib.rs | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changes/runtime-macos-default-visible-titlebat.md diff --git a/.changes/runtime-macos-default-visible-titlebat.md b/.changes/runtime-macos-default-visible-titlebat.md new file mode 100644 index 000000000000..d998fce28688 --- /dev/null +++ b/.changes/runtime-macos-default-visible-titlebat.md @@ -0,0 +1,6 @@ +--- +"tauri": "patch:bug" +"tauri-runtime-wry": "patch" +--- + +On macOS, set default titlebar style to `Visible` to prevent webview move out of the view. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index a7a552d88bc9..baad3ea36263 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -715,7 +715,20 @@ unsafe impl Send for WindowBuilderWrapper {} impl WindowBuilderBase for WindowBuilderWrapper {} impl WindowBuilder for WindowBuilderWrapper { fn new() -> Self { - Self::default().focused(true) + #[allow(unused_mut)] + let mut builder = Self::default().focused(true); + + #[cfg(target_os = "macos")] + { + // TODO: find a proper way to prevent webview being pushed out of the window. + // Workround for issue: https://github.com/tauri-apps/tauri/issues/10225 + // The window requies `NSFullSizeContentViewWindowMask` flag to prevent devtools + // pushing the content view out of the window. + // By setting the default style to `TitleBarStyle::Visible` should fix the issue for most of the users. + builder = builder.title_bar_style(TitleBarStyle::Visible); + } + + builder } fn with_config(config: &WindowConfig) -> Self {