@@ -15,6 +15,7 @@ use crate::workspaces_dbus::CosmicWorkspaces;
1515use crate :: xdg_shell_wrapper:: client:: handlers:: cosmic_corner_radius:: CornerRadius ;
1616use crate :: xdg_shell_wrapper:: client:: handlers:: overlap:: OverlapNotifyV1 ;
1717use crate :: xdg_shell_wrapper:: client_state:: { ClientFocus , FocusStatus } ;
18+ use crate :: xdg_shell_wrapper:: server:: handlers:: cosmic_corner_radius:: { CacheableCorners , Corners } ;
1819use crate :: xdg_shell_wrapper:: server_state:: { ServerFocus , ServerPtrFocus } ;
1920use crate :: xdg_shell_wrapper:: shared_state:: GlobalState ;
2021use crate :: xdg_shell_wrapper:: space:: {
@@ -25,7 +26,6 @@ use crate::xdg_shell_wrapper::util::smootherstep;
2526use crate :: xdg_shell_wrapper:: wp_fractional_scaling:: FractionalScalingManager ;
2627use crate :: xdg_shell_wrapper:: wp_security_context:: SecurityContextManager ;
2728use crate :: xdg_shell_wrapper:: wp_viewporter:: ViewporterState ;
28- use cctk:: cosmic_protocols:: corner_radius;
2929use cctk:: cosmic_protocols:: corner_radius:: v1:: client:: cosmic_corner_radius_manager_v1:: CosmicCornerRadiusManagerV1 ;
3030use cctk:: cosmic_protocols:: overlap_notify:: v1:: client:: zcosmic_overlap_notification_v1:: ZcosmicOverlapNotificationV1 ;
3131use cctk:: sctk:: shell:: wlr_layer:: Layer ;
@@ -58,6 +58,7 @@ use smithay::desktop::{PopupManager, Space};
5858use smithay:: output:: Output ;
5959use smithay:: reexports:: wayland_protocols:: xdg:: shell:: client:: xdg_positioner:: { Anchor , Gravity } ;
6060use smithay:: reexports:: wayland_server:: backend:: ClientId ;
61+ use smithay:: reexports:: wayland_server:: protocol:: wl_surface:: WlSurface ;
6162use smithay:: reexports:: wayland_server:: { Client , DisplayHandle , Resource } ;
6263use smithay:: utils:: { Logical , Rectangle , Size } ;
6364use smithay:: wayland:: compositor:: with_states;
@@ -388,7 +389,7 @@ pub struct PanelSpace {
388389 pub ( crate ) hover_track : HoverTrack ,
389390 pub ( crate ) start_show_instant : Rc < RefCell < Option < Instant > > > ,
390391 pub shared : Rc < PanelSharedState > ,
391- qh : QueueHandle < GlobalState > ,
392+ pub ( crate ) qh : QueueHandle < GlobalState > ,
392393}
393394
394395impl PanelSpace {
@@ -2135,6 +2136,74 @@ impl PanelSpace {
21352136 }
21362137 self . is_dirty = true ;
21372138 }
2139+
2140+ pub ( crate ) fn update_popup_corners (
2141+ & mut self ,
2142+ corners : CacheableCorners ,
2143+ surface : & WlSurface ,
2144+ ) -> bool {
2145+ let Some ( popup) = self . popups . iter_mut ( ) . find ( |p| p. s_surface . wl_surface ( ) == surface)
2146+ else {
2147+ return false ;
2148+ } ;
2149+ let Some ( corner_manager) = self . corner_radius_manager . as_ref ( ) else {
2150+ return false ;
2151+ } ;
2152+
2153+ let corners_surface = popup. popup . corner_radius . take ( ) . unwrap_or_else ( || {
2154+ corner_manager. get_corner_radius_surface (
2155+ popup. popup . c_popup . xdg_surface ( ) ,
2156+ & self . qh ,
2157+ ( ) ,
2158+ )
2159+ } ) ;
2160+
2161+ if let Some ( Corners { top_left, top_right, bottom_right, bottom_left } ) = corners. 0 {
2162+ corners_surface. set_radius ( top_left, top_right, bottom_right, bottom_left) ;
2163+ } else {
2164+ corners_surface. unset_radius ( ) ;
2165+ }
2166+
2167+ popup. popup . corner_radius = Some ( corners_surface) ;
2168+
2169+ true
2170+ }
2171+
2172+ pub ( crate ) fn commit_popup_blur (
2173+ & mut self ,
2174+ region : Option < & Vec < Rectangle < i32 , Logical > > > ,
2175+ surface : & WlSurface ,
2176+ ) -> bool {
2177+ let Some ( popup) = self . popups . iter_mut ( ) . find ( |p| p. s_surface . wl_surface ( ) == surface)
2178+ else {
2179+ return false ;
2180+ } ;
2181+ let Some ( blur_manager) = self . blur_manager . as_ref ( ) else {
2182+ return false ;
2183+ } ;
2184+
2185+ let blur_surface = popup. popup . blur_surface . take ( ) . unwrap_or_else ( || {
2186+ blur_manager. get_background_effect ( popup. popup . c_popup . wl_surface ( ) , & self . qh , ( ) )
2187+ } ) ;
2188+
2189+ let Some ( compositor_state) = self . compositor_state . as_ref ( ) else {
2190+ tracing:: error!( "Missing compositor state" ) ;
2191+ return false ;
2192+ } ;
2193+
2194+ let region = region. map ( |r| {
2195+ let wl_region = Region :: new ( compositor_state) . unwrap ( ) ;
2196+ for Rectangle { loc, size } in r {
2197+ wl_region. add ( loc. x , loc. y , size. w , size. h ) ;
2198+ }
2199+ wl_region
2200+ } ) ;
2201+ blur_surface. set_blur_region ( region. as_ref ( ) . map ( |r| r. wl_region ( ) ) ) ;
2202+
2203+ popup. popup . blur_surface = Some ( blur_surface) ;
2204+
2205+ true
2206+ }
21382207}
21392208
21402209impl Drop for PanelSpace {
0 commit comments