@@ -1204,6 +1204,7 @@ pub enum WindowMessage {
1204
1204
SetIgnoreCursorEvents ( bool ) ,
1205
1205
SetProgressBar ( ProgressBarState ) ,
1206
1206
SetTitleBarStyle ( tauri_utils:: TitleBarStyle ) ,
1207
+ SetTheme ( Option < Theme > ) ,
1207
1208
DragWindow ,
1208
1209
ResizeDragWindow ( tauri_runtime:: ResizeDirection ) ,
1209
1210
RequestRedraw ,
@@ -2026,6 +2027,13 @@ impl<T: UserEvent> WindowDispatch<T> for WryWindowDispatcher<T> {
2026
2027
Message :: Window ( self . window_id , WindowMessage :: SetTitleBarStyle ( style) ) ,
2027
2028
)
2028
2029
}
2030
+
2031
+ fn set_theme ( & self , theme : Option < Theme > ) -> Result < ( ) > {
2032
+ send_user_message (
2033
+ & self . context ,
2034
+ Message :: Window ( self . window_id , WindowMessage :: SetTheme ( theme) ) ,
2035
+ )
2036
+ }
2029
2037
}
2030
2038
2031
2039
#[ derive( Clone ) ]
@@ -2286,6 +2294,18 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
2286
2294
. map_err ( |_| Error :: FailedToGetCursorPosition )
2287
2295
}
2288
2296
2297
+ fn set_theme ( & self , theme : Option < Theme > ) {
2298
+ self
2299
+ . context
2300
+ . main_thread
2301
+ . window_target
2302
+ . set_theme ( match theme {
2303
+ Some ( Theme :: Light ) => Some ( TaoTheme :: Light ) ,
2304
+ Some ( Theme :: Dark ) => Some ( TaoTheme :: Dark ) ,
2305
+ _ => None ,
2306
+ } ) ;
2307
+ }
2308
+
2289
2309
#[ cfg( target_os = "macos" ) ]
2290
2310
fn show ( & self ) -> tauri_runtime:: Result < ( ) > {
2291
2311
send_user_message (
@@ -2564,6 +2584,14 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
2564
2584
. map_err ( |_| Error :: FailedToGetCursorPosition )
2565
2585
}
2566
2586
2587
+ fn set_theme ( & self , theme : Option < Theme > ) {
2588
+ self . event_loop . set_theme ( match theme {
2589
+ Some ( Theme :: Light ) => Some ( TaoTheme :: Light ) ,
2590
+ Some ( Theme :: Dark ) => Some ( TaoTheme :: Dark ) ,
2591
+ _ => None ,
2592
+ } ) ;
2593
+ }
2594
+
2567
2595
#[ cfg( target_os = "macos" ) ]
2568
2596
fn set_activation_policy ( & mut self , activation_policy : ActivationPolicy ) {
2569
2597
self
@@ -2996,6 +3024,13 @@ fn handle_user_message<T: UserEvent>(
2996
3024
}
2997
3025
} ;
2998
3026
}
3027
+ WindowMessage :: SetTheme ( theme) => {
3028
+ window. set_theme ( match theme {
3029
+ Some ( Theme :: Light ) => Some ( TaoTheme :: Light ) ,
3030
+ Some ( Theme :: Dark ) => Some ( TaoTheme :: Dark ) ,
3031
+ _ => None ,
3032
+ } ) ;
3033
+ }
2999
3034
}
3000
3035
}
3001
3036
}
0 commit comments