feat: theme integration

refactor: only apply updates if there is a change in the theme

refactor: include theme in state

cleanup: theme integration
This commit is contained in:
Ashley Wulber 2023-10-10 13:55:34 -04:00 committed by Victoria Brekenfeld
parent c16b86d1bf
commit abbe94e6e1
24 changed files with 409 additions and 139 deletions

View file

@ -501,6 +501,7 @@ impl CosmicMapped {
pub fn convert_to_stack<'a>(
&mut self,
(output, overlap): (&'a Output, Rectangle<i32, Logical>),
theme: cosmic::Theme,
) {
match &self.element {
CosmicMappedInternal::Window(window) => {
@ -508,7 +509,7 @@ impl CosmicMapped {
let activated = surface.is_activated(true);
let handle = window.loop_handle();
let stack = CosmicStack::new(std::iter::once(surface), handle);
let stack = CosmicStack::new(std::iter::once(surface), handle, theme);
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
stack.set_geometry(geo.to_global(&output));
}
@ -527,11 +528,12 @@ impl CosmicMapped {
&mut self,
surface: CosmicSurface,
(output, overlap): (&'a Output, Rectangle<i32, Logical>),
theme: cosmic::Theme,
) {
let handle = self.loop_handle();
surface.try_force_undecorated(false);
surface.set_tiled(false);
let window = CosmicWindow::new(surface, handle);
let window = CosmicWindow::new(surface, handle, theme);
if let Some(geo) = self.last_geometry.lock().unwrap().clone() {
window.set_geometry(geo.to_global(&output));
@ -764,6 +766,22 @@ impl CosmicMapped {
popup_elements.into_iter().map(C::from).collect(),
)
}
pub(crate) fn update_theme(&self, theme: cosmic::Theme) {
match &self.element {
CosmicMappedInternal::Window(w) => w.set_theme(theme),
CosmicMappedInternal::Stack(s) => s.set_theme(theme),
CosmicMappedInternal::_GenericCatcher(_) => {}
}
}
pub(crate) fn force_redraw(&self) {
match &self.element {
CosmicMappedInternal::Window(w) => w.force_redraw(),
CosmicMappedInternal::Stack(s) => s.force_redraw(),
CosmicMappedInternal::_GenericCatcher(_) => {}
}
}
}
impl IsAlive for CosmicMapped {