refactor(corner-radius): corner_radius method for CosmicSurface

This commit is contained in:
Ashley Wulber 2025-09-25 11:00:57 -04:00 committed by Victoria Brekenfeld
parent 4e30513673
commit f01ebf2f6f
4 changed files with 33 additions and 113 deletions

View file

@ -1600,28 +1600,7 @@ impl FloatingLayout {
let active_window_hint = crate::theme::active_window_hint(theme);
let radius = elem
.active_window()
.wl_surface()
.and_then(|surface| {
with_states(&surface, |s| {
let d = s
.data_map
.get::<Mutex<Weak<CosmicCornerRadiusToplevelV1>>>()?;
let guard = d.lock().unwrap();
let weak_data = guard.upgrade().ok()?;
let corners = weak_data.data::<CornerRadiusData>()?;
let guard = corners.lock().unwrap();
Some([
guard.top_right,
guard.bottom_right,
guard.top_left,
guard.bottom_left,
])
})
})
.corner_radius()
.unwrap_or([indicator_thickness; 4]);
if indicator_thickness > 0 {
let element = IndicatorShader::focus_element(

View file

@ -5020,28 +5020,7 @@ where
}));
let radius = mapped
.active_window()
.wl_surface()
.and_then(|surface| {
with_states(&surface, |s| {
let d = s
.data_map
.get::<Mutex<WsWeak<CosmicCornerRadiusToplevelV1>>>()?;
let guard = d.lock().unwrap();
let weak_data = guard.upgrade().ok()?;
let corners = weak_data.data::<CornerRadiusData>()?;
let guard = corners.lock().unwrap();
Some([
guard.top_right,
guard.bottom_right,
guard.top_left,
guard.bottom_left,
])
})
})
.corner_radius()
.unwrap_or([indicator_thickness; 4]);
if is_minimizing && indicator_thickness > 0 {
elements.push(CosmicMappedRenderElement::FocusIndicator(
@ -5312,30 +5291,7 @@ where
)
.unwrap();
let radius = window
.wl_surface()
.and_then(|surface| {
with_states(&surface, |s| {
let d = s
.data_map
.get::<Mutex<WsWeak<CosmicCornerRadiusToplevelV1>>>()?;
let guard = d.lock().unwrap();
let weak_data = guard.upgrade().ok()?;
let corners = weak_data.data::<CornerRadiusData>()?;
let guard = corners.lock().unwrap();
Some([
guard.top_right,
guard.bottom_right,
guard.top_left,
guard.bottom_left,
])
})
})
.unwrap_or([indicator_thickness; 4]);
let radius = window.corner_radius().unwrap_or([indicator_thickness; 4]);
swap_elements.push(CosmicMappedRenderElement::FocusIndicator(
IndicatorShader::focus_element(
renderer,
@ -5416,28 +5372,7 @@ where
let radius = match data {
Data::Mapped { mapped, .. } => mapped
.active_window()
.wl_surface()
.and_then(|surface| {
with_states(&surface, |s| {
let d = s
.data_map
.get::<Mutex<WsWeak<CosmicCornerRadiusToplevelV1>>>()?;
let guard = d.lock().unwrap();
let weak_data = guard.upgrade().ok()?;
let corners = weak_data.data::<CornerRadiusData>()?;
let guard = corners.lock().unwrap();
Some([
guard.top_right,
guard.bottom_right,
guard.top_left,
guard.bottom_left,
])
})
})
.corner_radius()
.unwrap_or([indicator_thickness; 4]),
_ => [1; 4],
};