config: Load toolkit config on start

This commit is contained in:
Victoria Brekenfeld 2024-08-02 20:40:44 +02:00
parent 24462f728b
commit c299748997
2 changed files with 52 additions and 8 deletions

View file

@ -1028,9 +1028,7 @@ impl Workspaces {
s.sticky_layer.theme = theme.clone();
s.sticky_layer.mapped().for_each(|m| {
m.update_theme(theme.clone());
m.force_redraw();
});
s.sticky_layer.refresh();
for w in &mut s.workspaces {
w.tiling_layer.theme = theme.clone();
@ -1038,6 +1036,22 @@ impl Workspaces {
w.mapped().for_each(|m| {
m.update_theme(theme.clone());
});
}
}
self.force_redraw(xdg_activation_state);
}
pub fn force_redraw(&mut self, xdg_activation_state: &XdgActivationState) {
for (_, s) in &mut self.sets {
s.sticky_layer.mapped().for_each(|m| {
m.force_redraw();
});
s.sticky_layer.refresh();
for w in &mut s.workspaces {
w.mapped().for_each(|m| {
m.force_redraw();
});
@ -3313,6 +3327,25 @@ impl Shell {
}
}
pub fn update_toolkit(
&mut self,
toolkit: cosmic::config::CosmicTk,
xdg_activation_state: &XdgActivationState,
workspace_state: &mut WorkspaceUpdateGuard<'_, State>,
) {
if cosmic::icon_theme::default() != toolkit.icon_theme {
cosmic::icon_theme::set_default(toolkit.icon_theme.clone());
}
let mut container = cosmic::config::COSMIC_TK.lock().unwrap();
if &*container != &toolkit {
*container = toolkit;
drop(container);
self.refresh(xdg_activation_state, workspace_state);
self.workspaces.force_redraw(xdg_activation_state);
}
}
pub fn set_theme(
&mut self,
theme: cosmic::Theme,