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:
parent
c16b86d1bf
commit
abbe94e6e1
24 changed files with 409 additions and 139 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ pub fn resize_indicator(
|
|||
direction: ResizeDirection,
|
||||
config: &Config,
|
||||
evlh: LoopHandle<'static, crate::state::State>,
|
||||
theme: cosmic::Theme,
|
||||
) -> ResizeIndicator {
|
||||
ResizeIndicator::new(
|
||||
ResizeIndicatorInternal {
|
||||
|
|
@ -49,6 +50,7 @@ pub fn resize_indicator(
|
|||
},
|
||||
Size::from((1, 1)),
|
||||
evlh,
|
||||
theme,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ impl CosmicStack {
|
|||
pub fn new<I: Into<CosmicSurface>>(
|
||||
windows: impl Iterator<Item = I>,
|
||||
handle: LoopHandle<'static, crate::state::State>,
|
||||
theme: cosmic::Theme,
|
||||
) -> CosmicStack {
|
||||
let windows = windows.map(Into::into).collect::<Vec<_>>();
|
||||
assert!(!windows.is_empty());
|
||||
|
|
@ -160,6 +161,7 @@ impl CosmicStack {
|
|||
},
|
||||
(width, TAB_HEIGHT),
|
||||
handle,
|
||||
theme,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
@ -544,6 +546,14 @@ impl CosmicStack {
|
|||
popup_elements.into_iter().map(C::from).collect(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn set_theme(&self, theme: cosmic::Theme) {
|
||||
self.0.set_theme(theme);
|
||||
}
|
||||
|
||||
pub(crate) fn force_redraw(&self) {
|
||||
self.0.force_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -1056,11 +1066,12 @@ impl PointerTarget<State> for CosmicStack {
|
|||
let mapped = CosmicMapped::from(CosmicWindow::new(
|
||||
surface,
|
||||
self.0.loop_handle(),
|
||||
data.common.theme.clone(),
|
||||
));
|
||||
let elem_geo =
|
||||
workspace.element_geometry(stack_mapped).unwrap();
|
||||
let indicator_thickness =
|
||||
data.common.config.static_conf.active_hint;
|
||||
data.common.theme.cosmic().active_hint as u8;
|
||||
let was_tiled = workspace.is_tiled(stack_mapped);
|
||||
|
||||
self.remove_idx(dragged_out);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ pub type StackHover = IcedElement<StackHoverInternal>;
|
|||
pub fn stack_hover(
|
||||
evlh: LoopHandle<'static, crate::state::State>,
|
||||
size: Size<i32, Logical>,
|
||||
theme: cosmic::Theme,
|
||||
) -> StackHover {
|
||||
StackHover::new(StackHoverInternal, size, evlh)
|
||||
StackHover::new(StackHoverInternal, size, evlh, theme)
|
||||
}
|
||||
|
||||
pub struct StackHoverInternal;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ use smithay::utils::Size;
|
|||
|
||||
pub type SwapIndicator = IcedElement<SwapIndicatorInternal>;
|
||||
|
||||
pub fn swap_indicator(evlh: LoopHandle<'static, crate::state::State>) -> SwapIndicator {
|
||||
SwapIndicator::new(SwapIndicatorInternal, Size::from((1, 1)), evlh)
|
||||
pub fn swap_indicator(
|
||||
evlh: LoopHandle<'static, crate::state::State>,
|
||||
theme: cosmic::Theme,
|
||||
) -> SwapIndicator {
|
||||
SwapIndicator::new(SwapIndicatorInternal, Size::from((1, 1)), evlh, theme)
|
||||
}
|
||||
|
||||
pub struct SwapIndicatorInternal;
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ impl CosmicWindow {
|
|||
pub fn new(
|
||||
window: impl Into<CosmicSurface>,
|
||||
handle: LoopHandle<'static, crate::state::State>,
|
||||
theme: cosmic::Theme,
|
||||
) -> CosmicWindow {
|
||||
let window = window.into();
|
||||
let width = window.geometry().size.w;
|
||||
|
|
@ -129,6 +130,7 @@ impl CosmicWindow {
|
|||
},
|
||||
(width, SSD_HEIGHT),
|
||||
handle,
|
||||
theme,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
@ -213,6 +215,14 @@ impl CosmicWindow {
|
|||
popup_elements.into_iter().map(C::from).collect(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn set_theme(&self, theme: cosmic::Theme) {
|
||||
self.0.set_theme(theme);
|
||||
}
|
||||
|
||||
pub(crate) fn force_redraw(&self) {
|
||||
self.0.force_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue