feat: corner radius for CosmicMapped
This commit is contained in:
parent
228af1037a
commit
3465ce7602
7 changed files with 49 additions and 23 deletions
|
|
@ -848,6 +848,16 @@ impl CosmicMapped {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn corner_radius(&self, geometry_size: Size<i32, Logical>, default_radius: u8) -> [u8; 4] {
|
||||
match &self.element {
|
||||
CosmicMappedInternal::Window(w) => w
|
||||
.corner_radius(geometry_size)
|
||||
.unwrap_or([default_radius; 4]),
|
||||
CosmicMappedInternal::Stack(s) => s.corner_radius(geometry_size, default_radius),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IsAlive for CosmicMapped {
|
||||
|
|
|
|||
|
|
@ -785,6 +785,20 @@ impl CosmicStack {
|
|||
(Some(max), Some(min)) => Some((max.w.max(min.w), max.h.max(min.h)).into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn corner_radius(&self, geometry_size: Size<i32, Logical>, default_radius: u8) -> [u8; 4] {
|
||||
self.0.with_program(|p| {
|
||||
let active_window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)];
|
||||
let mut corners = active_window
|
||||
.corner_radius(geometry_size)
|
||||
.unwrap_or([default_radius; 4]);
|
||||
|
||||
corners[1] = 8;
|
||||
corners[3] = 8;
|
||||
|
||||
corners
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -421,6 +421,11 @@ impl CosmicWindow {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn corner_radius(&self, geometry_size: Size<i32, Logical>) -> Option<[u8; 4]> {
|
||||
self.0
|
||||
.with_program(|p| p.window.corner_radius(geometry_size))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -110,9 +110,8 @@ impl MoveGrabState {
|
|||
|
||||
let active_window_hint = crate::theme::active_window_hint(theme);
|
||||
let radius = self
|
||||
.window()
|
||||
.corner_radius(window_geo.size)
|
||||
.unwrap_or([self.indicator_thickness; 4]);
|
||||
.element()
|
||||
.corner_radius(window_geo.size, self.indicator_thickness);
|
||||
|
||||
let focus_element = if self.indicator_thickness > 0 {
|
||||
Some(
|
||||
|
|
|
|||
|
|
@ -1589,10 +1589,7 @@ impl FloatingLayout {
|
|||
}
|
||||
|
||||
let active_window_hint = crate::theme::active_window_hint(theme);
|
||||
let radius = elem
|
||||
.active_window()
|
||||
.corner_radius(geometry.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]);
|
||||
let radius = elem.corner_radius(geometry.size.as_logical(), indicator_thickness);
|
||||
if indicator_thickness > 0 {
|
||||
let element = IndicatorShader::focus_element(
|
||||
renderer,
|
||||
|
|
|
|||
|
|
@ -5015,10 +5015,7 @@ where
|
|||
x => Some(x),
|
||||
}
|
||||
}));
|
||||
let radius = mapped
|
||||
.active_window()
|
||||
.corner_radius(geo.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]);
|
||||
let radius = mapped.corner_radius(geo.size.as_logical(), indicator_thickness);
|
||||
if is_minimizing && indicator_thickness > 0 {
|
||||
elements.push(CosmicMappedRenderElement::FocusIndicator(
|
||||
IndicatorShader::focus_element(
|
||||
|
|
@ -5369,10 +5366,9 @@ where
|
|||
));
|
||||
}
|
||||
let radius = match data {
|
||||
Data::Mapped { mapped, .. } => mapped
|
||||
.active_window()
|
||||
.corner_radius(geo.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]),
|
||||
Data::Mapped { mapped, .. } => {
|
||||
mapped.corner_radius(geo.size.as_logical(), indicator_thickness)
|
||||
}
|
||||
_ => [1; 4],
|
||||
};
|
||||
if !swap_desc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue