File tree 2 files changed +26
-2
lines changed
platform_impl/linux/wayland/window
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -77,9 +77,16 @@ impl EventLoopBuilderExtWayland for EventLoopBuilder {
77
77
/// Additional methods on [`Window`] that are specific to Wayland.
78
78
///
79
79
/// [`Window`]: crate::window::Window
80
- pub trait WindowExtWayland { }
80
+ pub trait WindowExtWayland {
81
+ fn set_region ( & self , region : Option < ( LogicalPosition < i32 > , LogicalSize < i32 > ) > ) ;
82
+ }
81
83
82
- impl WindowExtWayland for dyn CoreWindow + ' _ { }
84
+ impl WindowExtWayland for dyn CoreWindow + ' _ {
85
+ fn set_region ( & self , region : Option < ( LogicalPosition < i32 > , LogicalSize < i32 > ) > ) {
86
+ let window = self . as_any ( ) . downcast_ref :: < crate :: platform_impl:: wayland:: Window > ( ) . unwrap ( ) ;
87
+ window. set_region ( region) ;
88
+ }
89
+ }
83
90
84
91
/// Additional methods on [`WindowAttributes`] that are specific to Wayland.
85
92
pub trait WindowAttributesExtWayland {
Original file line number Diff line number Diff line change 3
3
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
4
4
use std:: sync:: { Arc , Mutex } ;
5
5
6
+ use dpi:: LogicalPosition ;
6
7
use sctk:: compositor:: { CompositorState , Region , SurfaceData } ;
7
8
use sctk:: reexports:: client:: protocol:: wl_display:: WlDisplay ;
8
9
use sctk:: reexports:: client:: protocol:: wl_surface:: WlSurface ;
@@ -332,6 +333,22 @@ impl Window {
332
333
pub fn set_layer ( & self , layer : Layer ) {
333
334
self . window . set_layer ( layer) ;
334
335
}
336
+
337
+ #[ inline]
338
+ pub fn set_region ( & self , region : Option < ( LogicalPosition < i32 > , LogicalSize < i32 > ) > ) {
339
+ match self . window {
340
+ WindowShell :: WlrLayer { surface } => {
341
+ if let Some ( ( pos, size) ) = region {
342
+ let region = Region :: new ( self . compositor . as_ref ( ) ) . unwrap ( ) ;
343
+ region. add ( pos. x , pos. y , size. width , size. height ) ;
344
+ surface. set_input_region ( Some ( region. wl_region ( ) ) ) ;
345
+ } else {
346
+ surface. set_input_region ( None ) ;
347
+ }
348
+ } ,
349
+ WindowShell :: Xdg { .. } => warn ! ( "Region is ignored for XDG windows" ) ,
350
+ }
351
+ }
335
352
}
336
353
337
354
impl Drop for Window {
You can’t perform that action at this time.
0 commit comments