@@ -200,6 +200,7 @@ pub struct SlideApp {
200200 pending_shots : Vec < ( u64 , Option < String > , Sender < ControlResponse > , f64 ) > ,
201201 styled : bool ,
202202 restyle : bool ,
203+ last_system_theme : Option < egui:: Theme > ,
203204 fonts_ready : bool ,
204205 last_time : f64 ,
205206 /// When AutoRecover data was last written (seconds, egui time).
@@ -238,6 +239,7 @@ impl SlideApp {
238239 pending_shots : vec ! [ ] ,
239240 styled : false ,
240241 restyle : true ,
242+ last_system_theme : None ,
241243 fonts_ready : false ,
242244 last_time : 0.0 ,
243245 last_recovery : 0.0 ,
@@ -325,7 +327,7 @@ impl SlideApp {
325327 }
326328 "view.collapseRibbon" => self . ui . ribbon_collapsed = !self . ui . ribbon_collapsed ,
327329 "view.dark" => {
328- let on = self . flag ( p, self . ui . brightness = = theme:: Brightness :: Dark ) ;
330+ let on = self . flag ( p, self . ui . brightness ! = theme:: Brightness :: Dark ) ;
329331 self . ui . brightness = if on { theme:: Brightness :: Dark } else { theme:: Brightness :: Light } ;
330332 self . restyle = true ;
331333 }
@@ -530,6 +532,11 @@ impl SlideApp {
530532
531533 /// Per-frame logic before layout: styles, control requests, screenshots, shortcuts.
532534 pub fn logic ( & mut self , ctx : & egui:: Context ) {
535+ let system_theme = ctx. system_theme ( ) ;
536+ if self . ui . brightness == theme:: Brightness :: System && system_theme != self . last_system_theme {
537+ self . restyle = true ;
538+ }
539+ self . last_system_theme = system_theme;
533540 let scale = self . ui . ui_scale . clamp ( 0.5 , 3.0 ) ;
534541 if ( ctx. zoom_factor ( ) - scale) . abs ( ) > 1e-3 {
535542 ctx. set_zoom_factor ( scale) ;
@@ -542,7 +549,14 @@ impl SlideApp {
542549 self . fonts_ready = true ;
543550 }
544551 if self . restyle {
545- theme:: apply ( ctx, & theme:: Tokens :: for_brightness ( self . ui . brightness ) ) ;
552+ let brightness = match self . ui . brightness {
553+ theme:: Brightness :: System => match system_theme {
554+ Some ( egui:: Theme :: Dark ) => theme:: Brightness :: Dark ,
555+ Some ( egui:: Theme :: Light ) | None => theme:: Brightness :: Light ,
556+ } ,
557+ brightness => brightness,
558+ } ;
559+ theme:: apply ( ctx, & theme:: Tokens :: for_brightness ( brightness) ) ;
546560 self . restyle = false ;
547561 }
548562 let now = ctx. input ( |i| i. time ) ;
0 commit comments