@@ -44,15 +44,21 @@ fn main() {
4444 println ! ( "Error: {:?}" , res. err( ) ) ;
4545 }
4646 // Create window with transparency enabled
47- let window = WebviewWindowBuilder :: new ( app, "main" , WebviewUrl :: App ( "index.html" . into ( ) ) )
48- . title ( "" )
49- . inner_size ( 1100.0 , 800.0 )
50- . resizable ( true )
51- . min_inner_size ( 850.0 , 600.0 )
52- . fullscreen ( false )
53- . transparent ( true )
54- . title_bar_style ( tauri:: TitleBarStyle :: Overlay )
55- . build ( ) ?;
47+ let builder = {
48+ let b = WebviewWindowBuilder :: new ( app, "main" , WebviewUrl :: App ( "index.html" . into ( ) ) )
49+ . title ( "" )
50+ . inner_size ( 1100.0 , 800.0 )
51+ . resizable ( true )
52+ . min_inner_size ( 850.0 , 600.0 )
53+ . fullscreen ( false )
54+ . transparent ( true ) ;
55+ // Only set title_bar_style on platforms that support it (macOS, Windows).
56+ #[ cfg( any( target_os = "macos" , target_os = "windows" ) ) ]
57+ let b = b. title_bar_style ( tauri:: TitleBarStyle :: Overlay ) ;
58+ b
59+ } ;
60+
61+ let window = builder. build ( ) ?;
5662
5763 // Apply macOS translucent vibrancy effect immediately
5864 #[ cfg( target_os = "macos" ) ]
@@ -61,12 +67,14 @@ fn main() {
6167 . expect ( "Unsupported platform! 'apply_vibrancy' is only supported on macOS" ) ;
6268 }
6369
64- // Handle window close events for macOS
65- #[ cfg( target_os = "macos" ) ]
70+ // Handle window close events on desktop (macOS, Windows, Linux)
71+ // On close, hide the window instead of exiting the app.
72+ #[ cfg( any( target_os = "macos" , target_os = "windows" , target_os = "linux" ) ) ]
6673 {
6774 let window_clone = window. clone ( ) ;
6875 window. on_window_event ( move |event| {
6976 if let WindowEvent :: CloseRequested { api, .. } = event {
77+ // hide() and prevent_close() are cross-platform; keep vibrancy mac-only.
7078 window_clone. hide ( ) . unwrap ( ) ;
7179 api. prevent_close ( ) ;
7280 }
0 commit comments