config: Add and propagate appearance_config

This commit is contained in:
Victoria Brekenfeld 2025-12-08 18:21:58 +01:00 committed by Victoria Brekenfeld
parent 94d49210e6
commit 2adebb5fe1
10 changed files with 213 additions and 40 deletions

View file

@ -6,6 +6,7 @@ use std::{
time::{Duration, Instant},
};
use cosmic_comp_config::AppearanceConfig;
use cosmic_settings_config::shortcuts::action::ResizeDirection;
use keyframe::{ease, functions::EaseInOutCubic};
use smithay::{
@ -59,6 +60,7 @@ pub struct FloatingLayout {
hovered_stack: Option<(CosmicMapped, Rectangle<i32, Local>)>,
dirty: AtomicBool,
pub theme: cosmic::Theme,
pub appearance: AppearanceConfig,
}
#[derive(Debug)]
@ -263,10 +265,15 @@ impl TiledCorners {
}
impl FloatingLayout {
pub fn new(theme: cosmic::Theme, output: &Output) -> FloatingLayout {
pub fn new(
theme: cosmic::Theme,
appearance: AppearanceConfig,
output: &Output,
) -> FloatingLayout {
let mut layout = Self {
theme,
last_output_size: output.geometry().size.as_local(),
appearance,
..Default::default()
};
layout.space.map_output(output, (0, 0));
@ -1014,7 +1021,11 @@ impl FloatingLayout {
if mapped.is_window() {
// if it is just a window
self.space.unmap_elem(&mapped);
mapped.convert_to_stack((&output, mapped.bbox()), self.theme.clone());
mapped.convert_to_stack(
(&output, mapped.bbox()),
self.theme.clone(),
self.appearance,
);
self.map_internal(
mapped.clone(),
Some(location.as_local()),
@ -1031,7 +1042,12 @@ impl FloatingLayout {
self.space.unmap_elem(&mapped);
let handle = mapped.loop_handle();
mapped.convert_to_surface(first, (&output, mapped.bbox()), self.theme.clone());
mapped.convert_to_surface(
first,
(&output, mapped.bbox()),
self.theme.clone(),
self.appearance,
);
let mut new_elements = vec![mapped.clone()];
// map the rest
@ -1043,6 +1059,7 @@ impl FloatingLayout {
other,
handle.clone(),
self.theme.clone(),
self.appearance,
));
window.output_enter(&output, window.bbox());
@ -1094,7 +1111,7 @@ impl FloatingLayout {
StackMoveResult::Handled => MoveResult::Done,
StackMoveResult::MoveOut(surface, loop_handle) => {
let mapped: CosmicMapped =
CosmicWindow::new(surface, loop_handle, theme.clone()).into();
CosmicWindow::new(surface, loop_handle, theme.clone(), self.appearance).into();
let output = seat.active_output();
let pos = self.space.element_geometry(element).unwrap().loc
+ match direction {

View file

@ -38,6 +38,7 @@ use crate::{
},
};
use cosmic_comp_config::AppearanceConfig;
use cosmic_settings_config::shortcuts::action::{FocusDirection, ResizeDirection};
use id_tree::{InsertBehavior, MoveBehavior, Node, NodeId, NodeIdError, RemoveBehavior, Tree};
use keyframe::{
@ -134,6 +135,7 @@ pub struct TilingLayout {
swapping_stack_surface_id: Id,
last_overview_hover: Option<(Option<Instant>, TargetZone)>,
pub theme: cosmic::Theme,
pub appearance: AppearanceConfig,
}
#[derive(Debug, Clone, PartialEq)]
@ -345,7 +347,11 @@ pub struct RestoreTilingState {
}
impl TilingLayout {
pub fn new(theme: cosmic::Theme, output: &Output) -> TilingLayout {
pub fn new(
theme: cosmic::Theme,
appearance: AppearanceConfig,
output: &Output,
) -> TilingLayout {
TilingLayout {
queue: TreeQueue {
trees: {
@ -360,6 +366,7 @@ impl TilingLayout {
swapping_stack_surface_id: Id::new(),
last_overview_hover: None,
theme,
appearance,
}
}
@ -664,9 +671,13 @@ impl TilingLayout {
let _ = this.unmap(this_mapped, None);
}
let mapped: CosmicMapped =
CosmicWindow::new(stack_surface, this_stack.loop_handle(), this.theme.clone())
.into();
let mapped: CosmicMapped = CosmicWindow::new(
stack_surface,
this_stack.loop_handle(),
this.theme.clone(),
this.appearance,
)
.into();
if this.output != other.output {
mapped.output_leave(&this.output);
mapped.output_enter(&other.output, mapped.bbox());
@ -1071,6 +1082,7 @@ impl TilingLayout {
this_surface.clone(),
this_stack.loop_handle(),
this.theme.clone(),
this.appearance,
)
.into();
mapped.set_tiled(true);
@ -1156,6 +1168,7 @@ impl TilingLayout {
other_surface.clone(),
other_stack.loop_handle(),
this.theme.clone(),
this.appearance,
)
.into();
mapped.set_tiled(true);
@ -1504,8 +1517,13 @@ impl TilingLayout {
match window.handle_move(direction) {
StackMoveResult::Handled => return MoveResult::Done,
StackMoveResult::MoveOut(surface, loop_handle) => {
let mapped: CosmicMapped =
CosmicWindow::new(surface, loop_handle, self.theme.clone()).into();
let mapped: CosmicMapped = CosmicWindow::new(
surface,
loop_handle,
self.theme.clone(),
self.appearance,
)
.into();
mapped.output_enter(&self.output, mapped.bbox());
let orientation = match direction {
Direction::Left | Direction::Right => Orientation::Vertical,
@ -2126,7 +2144,11 @@ impl TilingLayout {
// if it is just a window
match tree.get_mut(&node_id).unwrap().data_mut() {
Data::Mapped { mapped, .. } => {
mapped.convert_to_stack((&self.output, mapped.bbox()), self.theme.clone());
mapped.convert_to_stack(
(&self.output, mapped.bbox()),
self.theme.clone(),
self.appearance,
);
focus_stack.append(mapped.clone());
KeyboardFocusTarget::Element(mapped.clone())
}
@ -2147,6 +2169,7 @@ impl TilingLayout {
first,
(&self.output, mapped.bbox()),
self.theme.clone(),
self.appearance,
);
new_elements.push(mapped.clone());
handle
@ -2164,6 +2187,7 @@ impl TilingLayout {
other,
handle.clone(),
self.theme.clone(),
self.appearance,
));
window.output_enter(&self.output, window.bbox());
@ -2261,7 +2285,12 @@ impl TilingLayout {
return None;
}
let handle = handle.unwrap();
let stack = CosmicStack::new(surfaces.into_iter(), handle, self.theme.clone());
let stack = CosmicStack::new(
surfaces.into_iter(),
handle,
self.theme.clone(),
self.appearance,
);
for child in tree
.children_ids(&last_active)
@ -2732,7 +2761,11 @@ impl TilingLayout {
Some(TargetZone::WindowStack(window_id, _)) if tree.get(window_id).is_ok() => {
match tree.get_mut(window_id).unwrap().data_mut() {
Data::Mapped { mapped, .. } => {
mapped.convert_to_stack((&self.output, mapped.bbox()), self.theme.clone());
mapped.convert_to_stack(
(&self.output, mapped.bbox()),
self.theme.clone(),
self.appearance,
);
let Some(stack) = mapped.stack_ref() else {
unreachable!()
};