wayland: Support cosmic-corner-radius v2

This commit is contained in:
Victoria Brekenfeld 2026-04-17 17:57:48 +02:00 committed by Victoria Brekenfeld
parent 55d57ddba2
commit 5ee2fa911a
7 changed files with 679 additions and 147 deletions

View file

@ -4,9 +4,7 @@ use crate::{
wayland::{SurfaceRenderElement, push_render_elements_from_surface_tree},
},
shell::focus::target::PointerFocusTarget,
wayland::{
handlers::compositor::frame_time_filter_fn, protocols::corner_radius::CacheableCorners,
},
wayland::handlers::{compositor::frame_time_filter_fn, corner_radius::surface_corners},
};
use std::{
borrow::Cow,
@ -193,22 +191,7 @@ impl CosmicSurface {
pub fn corner_radius(&self, geometry_size: Size<i32, Logical>) -> Option<[u8; 4]> {
self.wl_surface().and_then(|surface| {
with_states(&surface, |states| {
let mut guard = states.cached_state.get::<CacheableCorners>();
// guard against corner radius being too large, potentially disconnecting the outline
let half_min_dim =
u8::try_from(geometry_size.w.min(geometry_size.h) / 2).unwrap_or(u8::MAX);
let corners = guard.current().0?;
Some([
corners.top_left.min(half_min_dim),
corners.top_right.min(half_min_dim),
corners.bottom_right.min(half_min_dim),
corners.bottom_left.min(half_min_dim),
])
})
with_states(&surface, |states| surface_corners(states, geometry_size))
})
}
@ -880,6 +863,10 @@ impl CosmicSurface {
.to_physical_precise_round(scale);
let mut geometry = popup.geometry().to_f64();
geometry.loc += location.to_f64().to_logical(scale) + popup_offset.to_f64();
let radii = with_states(popup.wl_surface(), |states| {
surface_corners(states, geometry.size.to_i32_round())
})
.unwrap_or([0; 4]);
push_render_elements_from_surface_tree(
renderer,
@ -889,7 +876,8 @@ impl CosmicSurface {
scale,
alpha,
false,
[0; 4],
radii,
None,
blur_strength,
scanout_kind_eval(None, scanout_node),
push,
@ -934,6 +922,7 @@ impl CosmicSurface {
alpha,
should_clip,
radii,
None,
blur_strength,
scanout_kind_eval(scanout_override, scanout_node),
push_above,
@ -954,6 +943,7 @@ impl CosmicSurface {
alpha,
should_clip,
radii,
None,
blur_strength,
scanout_kind_eval(scanout_override, scanout_node),
push_above,