File tree 2 files changed +25
-2
lines changed
platform_impl/linux/wayland/window
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 13
13
//! * `wayland-csd-adwaita` (default).
14
14
//! * `wayland-csd-adwaita-crossfont`.
15
15
//! * `wayland-csd-adwaita-notitle`.
16
+
17
+ use std:: ffi:: c_void;
18
+ use std:: ptr:: null_mut;
19
+
20
+ use sctk:: reexports:: client:: Proxy ;
21
+
16
22
use crate :: event_loop:: { ActiveEventLoop , EventLoop , EventLoopBuilder } ;
17
23
use crate :: monitor:: MonitorHandle ;
18
24
pub use crate :: window:: Theme ;
@@ -73,9 +79,20 @@ impl EventLoopBuilderExtWayland for EventLoopBuilder {
73
79
/// Additional methods on [`Window`] that are specific to Wayland.
74
80
///
75
81
/// [`Window`]: crate::window::Window
76
- pub trait WindowExtWayland { }
82
+ pub trait WindowExtWayland {
83
+ /// Returns `xdg_toplevel` of the window or null if the window is X11 window.
84
+ fn xdg_toplevel ( & self ) -> * mut c_void ;
85
+ }
77
86
78
- impl WindowExtWayland for dyn CoreWindow + ' _ { }
87
+ impl WindowExtWayland for dyn CoreWindow + ' _ {
88
+ #[ inline]
89
+ fn xdg_toplevel ( & self ) -> * mut c_void {
90
+ self . as_any ( )
91
+ . downcast_ref :: < crate :: platform_impl:: wayland:: Window > ( )
92
+ . map ( |w| w. xdg_toplevel ( ) . id ( ) . as_ptr ( ) . cast ( ) )
93
+ . unwrap_or ( null_mut ( ) )
94
+ }
95
+ }
79
96
80
97
/// Additional methods on [`WindowAttributes`] that are specific to Wayland.
81
98
pub trait WindowAttributesExtWayland {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use sctk::reexports::client::protocol::wl_display::WlDisplay;
8
8
use sctk:: reexports:: client:: protocol:: wl_surface:: WlSurface ;
9
9
use sctk:: reexports:: client:: { Proxy , QueueHandle } ;
10
10
use sctk:: reexports:: protocols:: xdg:: activation:: v1:: client:: xdg_activation_v1:: XdgActivationV1 ;
11
+ use sctk:: reexports:: protocols:: xdg:: shell:: client:: xdg_toplevel:: XdgToplevel ;
11
12
use sctk:: shell:: xdg:: window:: { Window as SctkWindow , WindowDecorations } ;
12
13
use sctk:: shell:: WaylandSurface ;
13
14
use tracing:: warn;
@@ -239,6 +240,11 @@ impl Window {
239
240
pub fn surface ( & self ) -> & WlSurface {
240
241
self . window . wl_surface ( )
241
242
}
243
+
244
+ #[ inline]
245
+ pub fn xdg_toplevel ( & self ) -> & XdgToplevel {
246
+ self . window . xdg_toplevel ( )
247
+ }
242
248
}
243
249
244
250
impl Drop for Window {
You can’t perform that action at this time.
0 commit comments