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

@ -212,6 +212,7 @@ pub fn draw_surface_cursor<R>(
1.0,
false,
[0; 4],
None,
blur_strength,
Kind::Cursor,
&mut |elem| push(elem.into(), h),
@ -247,6 +248,7 @@ pub fn draw_dnd_icon<R>(
1.0,
false,
[0; 4],
None,
blur_strength,
FRAME_TIME_FILTER,
push,

View file

@ -39,6 +39,7 @@ use crate::{
wayland::{
handlers::{
compositor::FRAME_TIME_FILTER,
corner_radius::{pad_rect, surface_corners, surface_padding},
data_device::get_dnd_icon,
image_copy_capture::{FrameHolder, SessionData, render_session},
},
@ -78,7 +79,7 @@ use smithay::{
utils::{
IsAlive, Logical, Monotonic, Physical, Point, Rectangle, Scale, Size, Time, Transform,
},
wayland::{dmabuf::get_dmabuf, session_lock::LockSurface},
wayland::{compositor::with_states, dmabuf::get_dmabuf, session_lock::LockSurface},
};
#[cfg(feature = "debug")]
@ -838,6 +839,11 @@ where
let mut geometry = popup.geometry().as_global();
geometry.loc += location;
let radii = with_states(popup.wl_surface(), |states| {
surface_corners(states, geometry.size.as_logical())
})
.unwrap_or([0; 4]);
push_render_elements_from_surface_tree(
renderer,
popup.wl_surface(),
@ -849,7 +855,8 @@ where
Scale::from(scale),
1.0,
false,
[0; 4],
radii,
None,
blur_strength,
FRAME_TIME_FILTER,
&mut |elem| {
@ -868,6 +875,17 @@ where
} => {
let mut geometry = layer.geometry().as_global();
geometry.loc += location;
let geometry = geometry.to_local(output).as_logical();
let padded = with_states(layer.wl_surface(), |states| {
surface_padding(states, geometry.size)
.and_then(|padding| pad_rect(geometry, &padding))
})
.unwrap_or(geometry);
let radii = with_states(layer.wl_surface(), |states| {
surface_corners(states, padded.size)
})
.unwrap_or([0; 4]);
push_render_elements_from_surface_tree(
renderer,
@ -876,11 +894,12 @@ where
.to_local(output)
.as_logical()
.to_physical_precise_round(scale),
geometry.to_local(output).as_logical().to_f64(),
geometry.to_f64(),
Scale::from(scale),
1.0,
false,
[0; 4],
radii,
padded.to_f64(),
blur_strength,
FRAME_TIME_FILTER,
&mut |elem| {
@ -909,6 +928,7 @@ where
1.0,
false,
[0; 4],
None,
blur_strength,
FRAME_TIME_FILTER,
&mut |elem| elements.extend(crop_to_output(elem.into()).map(Into::into)),
@ -1056,6 +1076,7 @@ fn session_lock_elements<R>(
1.0,
false,
[0; 4],
None,
0,
FRAME_TIME_FILTER,
push,

View file

@ -35,6 +35,7 @@ pub fn push_render_elements_from_surface_tree<R>(
alpha: f32,
should_clip: bool,
radii: [u8; 4],
blur_geometry: impl Into<Option<Rectangle<f64, Logical>>>,
blur_strength: usize,
kind: impl Into<KindEvaluation>,
push_above: &mut dyn FnMut(SurfaceRenderElement<R>),
@ -44,7 +45,8 @@ pub fn push_render_elements_from_surface_tree<R>(
R::TextureId: Clone + 'static,
{
let location = location.into().to_f64();
let geometry = geometry.into().to_f64();
let geometry = geometry.into();
let blur_geometry = blur_geometry.into();
let scale = scale.into();
let kind = kind.into();
let mut passed_main = false;
@ -87,10 +89,11 @@ pub fn push_render_elements_from_surface_tree<R>(
renderer, surface, states, location, alpha, kind,
) {
Ok(Some(surface)) => {
let blur_geo = blur_geometry.unwrap_or(geometry);
blur = BlurElement::from_surface(
renderer,
states,
geometry,
blur_geo,
scale.x,
radii,
blur_strength,