diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index 0d13e3fd..edda1a6e 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -213,6 +213,7 @@ impl Cosmic { iced::Command::single(Action::Window(WindowAction::Close)) } + #[allow(clippy::too_many_lines)] fn cosmic_update(&mut self, message: Message) -> iced::Command> { match message { Message::WindowResize(id, width, height) => { @@ -330,7 +331,18 @@ impl Cosmic { } Message::SystemThemeModeChange(mode) => { let core = self.app.core_mut(); + let changed = core.system_theme_mode.is_dark != mode.is_dark; core.system_theme_mode = mode; + if changed { + THEME.with(move |t| { + let mut cosmic_theme = t.borrow_mut(); + + // Only apply update if the theme is set to load a system theme + if let ThemeType::System(_) = cosmic_theme.theme_type { + cosmic_theme.set_theme(crate::theme::system_preference().theme_type); + } + }); + } } }