fix(corner-radius): properly handle no value, and use geometry
This commit is contained in:
parent
6f93b8774d
commit
2873d6b27e
5 changed files with 52 additions and 42 deletions
|
|
@ -127,10 +127,10 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn corner_radius(&self) -> Option<[u8; 4]> {
|
||||
pub fn corner_radius(&self, geometry_size: Size<i32, Logical>) -> Option<[u8; 4]> {
|
||||
self.wl_surface().and_then(|surface| {
|
||||
with_states(&surface, |s| {
|
||||
let d = s
|
||||
with_states(&surface, |states| {
|
||||
let d = states
|
||||
.data_map
|
||||
.get::<Mutex<Weak<CosmicCornerRadiusToplevelV1>>>()?;
|
||||
let guard = d.lock().unwrap();
|
||||
|
|
@ -141,16 +141,18 @@ impl CosmicSurface {
|
|||
|
||||
let guard = corners.lock().unwrap();
|
||||
|
||||
let size = <CosmicSurface as SpaceElement>::geometry(self).size;
|
||||
// guard against corner radius being too large, potentially disconnecting the outline
|
||||
let half_min_dim = u8::try_from(size.w.min(size.h) / 2).unwrap_or(u8::MAX);
|
||||
let half_min_dim =
|
||||
u8::try_from(geometry_size.w.min(geometry_size.h) / 2).unwrap_or(u8::MAX);
|
||||
|
||||
Some([
|
||||
guard.top_right.min(half_min_dim),
|
||||
guard.bottom_right.min(half_min_dim),
|
||||
guard.top_left.min(half_min_dim),
|
||||
guard.bottom_left.min(half_min_dim),
|
||||
])
|
||||
guard.corners.map(|corners| {
|
||||
[
|
||||
corners.top_right.min(half_min_dim),
|
||||
corners.bottom_right.min(half_min_dim),
|
||||
corners.top_left.min(half_min_dim),
|
||||
corners.bottom_left.min(half_min_dim),
|
||||
]
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ impl MoveGrabState {
|
|||
let active_window_hint = crate::theme::active_window_hint(theme);
|
||||
let radius = self
|
||||
.window()
|
||||
.corner_radius()
|
||||
.corner_radius(window_geo.size)
|
||||
.unwrap_or([self.indicator_thickness; 4]);
|
||||
|
||||
let focus_element = if self.indicator_thickness > 0 {
|
||||
|
|
|
|||
|
|
@ -1591,7 +1591,7 @@ impl FloatingLayout {
|
|||
let active_window_hint = crate::theme::active_window_hint(theme);
|
||||
let radius = elem
|
||||
.active_window()
|
||||
.corner_radius()
|
||||
.corner_radius(geometry.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]);
|
||||
if indicator_thickness > 0 {
|
||||
let element = IndicatorShader::focus_element(
|
||||
|
|
|
|||
|
|
@ -5017,7 +5017,7 @@ where
|
|||
}));
|
||||
let radius = mapped
|
||||
.active_window()
|
||||
.corner_radius()
|
||||
.corner_radius(geo.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]);
|
||||
if is_minimizing && indicator_thickness > 0 {
|
||||
elements.push(CosmicMappedRenderElement::FocusIndicator(
|
||||
|
|
@ -5288,7 +5288,9 @@ where
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let radius = window.corner_radius().unwrap_or([indicator_thickness; 4]);
|
||||
let radius = window
|
||||
.corner_radius(swap_geo.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]);
|
||||
swap_elements.push(CosmicMappedRenderElement::FocusIndicator(
|
||||
IndicatorShader::focus_element(
|
||||
renderer,
|
||||
|
|
@ -5369,7 +5371,7 @@ where
|
|||
let radius = match data {
|
||||
Data::Mapped { mapped, .. } => mapped
|
||||
.active_window()
|
||||
.corner_radius()
|
||||
.corner_radius(geo.size.as_logical())
|
||||
.unwrap_or([indicator_thickness; 4]),
|
||||
_ => [1; 4],
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue