@@ -28,14 +28,13 @@ use sctk::shell::WaylandSurface;
2828use sctk:: shm:: slot:: SlotPool ;
2929use sctk:: shm:: Shm ;
3030use sctk:: subcompositor:: SubcompositorState ;
31- use wayland_protocols_plasma:: blur:: client:: org_kde_kwin_blur:: OrgKdeKwinBlur ;
3231
3332use crate :: cursor:: CustomCursor as RootCustomCursor ;
3433use crate :: dpi:: { LogicalPosition , LogicalSize , PhysicalPosition , PhysicalSize , Size } ;
3534use crate :: error:: { ExternalError , NotSupportedError } ;
3635use crate :: platform_impl:: wayland:: logical_to_physical_rounded;
3736use crate :: platform_impl:: wayland:: types:: cursor:: { CustomCursor , SelectedCursor } ;
38- use crate :: platform_impl:: wayland:: types:: kwin_blur :: KWinBlurManager ;
37+ use crate :: platform_impl:: wayland:: types:: bgr_effects :: { BgrEffectManager , SurfaceBlurEffect } ;
3938use crate :: platform_impl:: { PlatformCustomCursor , WindowId } ;
4039use crate :: window:: { CursorGrabMode , CursorIcon , ImePurpose , ResizeDirection , Theme } ;
4140
@@ -143,8 +142,8 @@ pub struct WindowState {
143142
144143 viewport : Option < WpViewport > ,
145144 fractional_scale : Option < WpFractionalScaleV1 > ,
146- blur : Option < OrgKdeKwinBlur > ,
147- blur_manager : Option < KWinBlurManager > ,
145+ blur : Option < SurfaceBlurEffect > ,
146+ blur_manager : Option < BgrEffectManager > ,
148147
149148 /// Whether the client side decorations have pending move operations.
150149 ///
@@ -185,7 +184,7 @@ impl WindowState {
185184
186185 Self {
187186 blur : None ,
188- blur_manager : winit_state. kwin_blur_manager . clone ( ) ,
187+ blur_manager : winit_state. blur_manager . clone ( ) ,
189188 compositor,
190189 connection,
191190 csd_fails : false ,
@@ -717,6 +716,13 @@ impl WindowState {
717716 // Set inner size without the borders.
718717 viewport. set_destination ( self . size . width as _ , self . size . height as _ ) ;
719718 }
719+
720+ // Update blur region with new size.
721+ if self . blur . is_some ( ) {
722+ // NOTE: either user resized or configure, in both cases
723+ // the redraw scheduling is done on the caller side.
724+ let _ = self . set_blur ( true ) ;
725+ }
720726 }
721727
722728 /// Get the scale factor of the window.
@@ -1077,20 +1083,37 @@ impl WindowState {
10771083 }
10781084 }
10791085
1080- /// Make window background blurred
1081- #[ inline]
1082- pub fn set_blur ( & mut self , blurred : bool ) {
1083- if blurred && self . blur . is_none ( ) {
1084- if let Some ( blur_manager) = self . blur_manager . as_ref ( ) {
1085- let blur = blur_manager. blur ( self . window . wl_surface ( ) , & self . queue_handle ) ;
1086- blur. commit ( ) ;
1087- self . blur = Some ( blur) ;
1088- } else {
1089- info ! ( "Blur manager unavailable, unable to change blur" )
1090- }
1091- } else if !blurred && self . blur . is_some ( ) {
1092- self . blur_manager . as_ref ( ) . unwrap ( ) . unset ( self . window . wl_surface ( ) ) ;
1093- self . blur . take ( ) . unwrap ( ) . release ( ) ;
1086+ /// Make window background blurred.
1087+ ///
1088+ /// Returns `true` if redraw is required.
1089+ #[ must_use]
1090+ pub fn set_blur ( & mut self , blurred : bool ) -> bool {
1091+ if !blurred {
1092+ self . blur = None ;
1093+ return true ;
1094+ }
1095+
1096+ let mgr = match self . blur_manager . as_mut ( ) {
1097+ Some ( mgr) => mgr,
1098+ None => {
1099+ info ! ( "Blur manager unavailable, unable to change blur" ) ;
1100+ return false ;
1101+ } ,
1102+ } ;
1103+
1104+ let blur = match self . blur . as_ref ( ) {
1105+ Some ( blur) => blur,
1106+ None => {
1107+ self . blur = Some ( mgr. new_blur_effect ( self . window . wl_surface ( ) , & self . queue_handle ) ) ;
1108+ self . blur . as_ref ( ) . unwrap ( )
1109+ } ,
1110+ } ;
1111+
1112+ if let Ok ( region) = Region :: new ( & * self . compositor ) {
1113+ region. add ( 0 , 0 , i32:: MAX , i32:: MAX ) ;
1114+ blur. set_blur ( Some ( & region) )
1115+ } else {
1116+ false
10941117 }
10951118 }
10961119
@@ -1149,10 +1172,6 @@ impl WindowState {
11491172
11501173impl Drop for WindowState {
11511174 fn drop ( & mut self ) {
1152- if let Some ( blur) = self . blur . take ( ) {
1153- blur. release ( ) ;
1154- }
1155-
11561175 if let Some ( fs) = self . fractional_scale . take ( ) {
11571176 fs. destroy ( ) ;
11581177 }
0 commit comments