Skip to main content

get_registry/common/protocols_data/wayland/
wl_shell_surface.rs

1//! desktop-style metadata interface
2//!
3//! An interface that may be implemented by a wl_surface, for
4//! implementations that provide a desktop-style user interface.
5//!
6//! It provides requests to treat surfaces like toplevel, fullscreen
7//! or popup windows, move, resize or maximize them, associate
8//! metadata like title and class, etc.
9//!
10//! On the server side the object is automatically destroyed when
11//! the related wl_surface is destroyed. On the client side,
12//! wl_shell_surface_destroy() must be called before destroying
13//! the wl_surface object.
14
15use super::super::all_types::*;
16use ::wl_client::builder::prelude::*;
17
18static INTERFACE: wl_interface = wl_interface {
19    name: c"wl_shell_surface".as_ptr(),
20    version: 1,
21    method_count: 10,
22    methods: {
23        static MESSAGES: [wl_message; 10] = [
24            wl_message {
25                name: c"pong".as_ptr(),
26                signature: c"u".as_ptr(),
27                types: {
28                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
29                    TYPES.as_ptr().cast()
30                },
31            },
32            wl_message {
33                name: c"move".as_ptr(),
34                signature: c"ou".as_ptr(),
35                types: {
36                    static TYPES: [Option<&'static wl_interface>; 2] =
37                        [Some(WlSeat::WL_INTERFACE), None];
38                    TYPES.as_ptr().cast()
39                },
40            },
41            wl_message {
42                name: c"resize".as_ptr(),
43                signature: c"ouu".as_ptr(),
44                types: {
45                    static TYPES: [Option<&'static wl_interface>; 3] =
46                        [Some(WlSeat::WL_INTERFACE), None, None];
47                    TYPES.as_ptr().cast()
48                },
49            },
50            wl_message {
51                name: c"set_toplevel".as_ptr(),
52                signature: c"".as_ptr(),
53                types: {
54                    static TYPES: [Option<&'static wl_interface>; 0] = [];
55                    TYPES.as_ptr().cast()
56                },
57            },
58            wl_message {
59                name: c"set_transient".as_ptr(),
60                signature: c"oiiu".as_ptr(),
61                types: {
62                    static TYPES: [Option<&'static wl_interface>; 4] =
63                        [Some(WlSurface::WL_INTERFACE), None, None, None];
64                    TYPES.as_ptr().cast()
65                },
66            },
67            wl_message {
68                name: c"set_fullscreen".as_ptr(),
69                signature: c"uu?o".as_ptr(),
70                types: {
71                    static TYPES: [Option<&'static wl_interface>; 3] =
72                        [None, None, Some(WlOutput::WL_INTERFACE)];
73                    TYPES.as_ptr().cast()
74                },
75            },
76            wl_message {
77                name: c"set_popup".as_ptr(),
78                signature: c"ouoiiu".as_ptr(),
79                types: {
80                    static TYPES: [Option<&'static wl_interface>; 6] = [
81                        Some(WlSeat::WL_INTERFACE),
82                        None,
83                        Some(WlSurface::WL_INTERFACE),
84                        None,
85                        None,
86                        None,
87                    ];
88                    TYPES.as_ptr().cast()
89                },
90            },
91            wl_message {
92                name: c"set_maximized".as_ptr(),
93                signature: c"?o".as_ptr(),
94                types: {
95                    static TYPES: [Option<&'static wl_interface>; 1] =
96                        [Some(WlOutput::WL_INTERFACE)];
97                    TYPES.as_ptr().cast()
98                },
99            },
100            wl_message {
101                name: c"set_title".as_ptr(),
102                signature: c"s".as_ptr(),
103                types: {
104                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
105                    TYPES.as_ptr().cast()
106                },
107            },
108            wl_message {
109                name: c"set_class".as_ptr(),
110                signature: c"s".as_ptr(),
111                types: {
112                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
113                    TYPES.as_ptr().cast()
114                },
115            },
116        ];
117        MESSAGES.as_ptr()
118    },
119    event_count: 3,
120    events: {
121        static MESSAGES: [wl_message; 3] = [
122            wl_message {
123                name: c"ping".as_ptr(),
124                signature: c"u".as_ptr(),
125                types: {
126                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
127                    TYPES.as_ptr().cast()
128                },
129            },
130            wl_message {
131                name: c"configure".as_ptr(),
132                signature: c"uii".as_ptr(),
133                types: {
134                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
135                    TYPES.as_ptr().cast()
136                },
137            },
138            wl_message {
139                name: c"popup_done".as_ptr(),
140                signature: c"".as_ptr(),
141                types: {
142                    static TYPES: [Option<&'static wl_interface>; 0] = [];
143                    TYPES.as_ptr().cast()
144                },
145            },
146        ];
147        MESSAGES.as_ptr()
148    },
149};
150
151/// An owned wl_shell_surface proxy.
152///
153/// See the documentation of [the module][self] for the interface description.
154#[derive(Clone, Eq, PartialEq)]
155#[repr(transparent)]
156pub struct WlShellSurface {
157    /// This proxy has the interface INTERFACE.
158    proxy: UntypedOwnedProxy,
159}
160
161/// A borrowed wl_shell_surface proxy.
162///
163/// See the documentation of [the module][self] for the interface description.
164#[derive(Eq, PartialEq)]
165#[repr(transparent)]
166pub struct WlShellSurfaceRef {
167    /// This proxy has the interface INTERFACE.
168    proxy: UntypedBorrowedProxy,
169}
170
171// SAFETY: WlShellSurface is a transparent wrapper around UntypedOwnedProxy
172unsafe impl UntypedOwnedProxyWrapper for WlShellSurface {}
173
174// SAFETY: - INTERFACE is a valid wl_interface
175//         - The only invariant is that self.proxy has a compatible interface
176unsafe impl OwnedProxy for WlShellSurface {
177    const INTERFACE: &'static str = "wl_shell_surface";
178    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
179    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
180        private::EventHandler(private::NoOpEventHandler);
181    const MAX_VERSION: u32 = 1;
182
183    type Borrowed = WlShellSurfaceRef;
184    type Api = private::ProxyApi;
185    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
186}
187
188// SAFETY: WlShellSurfaceRef is a transparent wrapper around UntypedBorrowedProxy
189unsafe impl UntypedBorrowedProxyWrapper for WlShellSurfaceRef {}
190
191// SAFETY: - The only invariant is that self.proxy has a compatible interface
192unsafe impl BorrowedProxy for WlShellSurfaceRef {
193    type Owned = WlShellSurface;
194}
195
196impl Deref for WlShellSurface {
197    type Target = WlShellSurfaceRef;
198
199    fn deref(&self) -> &Self::Target {
200        proxy::low_level::deref(self)
201    }
202}
203
204mod private {
205    pub struct ProxyApi;
206
207    #[allow(dead_code)]
208    pub struct EventHandler<H>(pub(super) H);
209
210    #[allow(dead_code)]
211    pub struct NoOpEventHandler;
212}
213
214impl Debug for WlShellSurface {
215    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
216        write!(f, "wl_shell_surface#{}", self.proxy.id())
217    }
218}
219
220impl Debug for WlShellSurfaceRef {
221    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
222        write!(f, "wl_shell_surface#{}", self.proxy.id())
223    }
224}
225
226impl PartialEq<WlShellSurfaceRef> for WlShellSurface {
227    fn eq(&self, other: &WlShellSurfaceRef) -> bool {
228        self.proxy == other.proxy
229    }
230}
231
232impl PartialEq<WlShellSurface> for WlShellSurfaceRef {
233    fn eq(&self, other: &WlShellSurface) -> bool {
234        self.proxy == other.proxy
235    }
236}
237
238#[allow(dead_code)]
239impl WlShellSurface {
240    /// Since when the pong request is available.
241    #[allow(dead_code)]
242    pub const REQ__PONG__SINCE: u32 = 1;
243
244    /// Since when the move request is available.
245    #[allow(dead_code)]
246    pub const REQ__MOVE__SINCE: u32 = 1;
247
248    /// Since when the resize request is available.
249    #[allow(dead_code)]
250    pub const REQ__RESIZE__SINCE: u32 = 1;
251
252    /// Since when the set_toplevel request is available.
253    #[allow(dead_code)]
254    pub const REQ__SET_TOPLEVEL__SINCE: u32 = 1;
255
256    /// Since when the set_transient request is available.
257    #[allow(dead_code)]
258    pub const REQ__SET_TRANSIENT__SINCE: u32 = 1;
259
260    /// Since when the set_fullscreen request is available.
261    #[allow(dead_code)]
262    pub const REQ__SET_FULLSCREEN__SINCE: u32 = 1;
263
264    /// Since when the set_popup request is available.
265    #[allow(dead_code)]
266    pub const REQ__SET_POPUP__SINCE: u32 = 1;
267
268    /// Since when the set_maximized request is available.
269    #[allow(dead_code)]
270    pub const REQ__SET_MAXIMIZED__SINCE: u32 = 1;
271
272    /// Since when the set_title request is available.
273    #[allow(dead_code)]
274    pub const REQ__SET_TITLE__SINCE: u32 = 1;
275
276    /// Since when the set_class request is available.
277    #[allow(dead_code)]
278    pub const REQ__SET_CLASS__SINCE: u32 = 1;
279}
280
281#[allow(dead_code)]
282impl WlShellSurfaceRef {
283    /// respond to a ping event
284    ///
285    /// A client must respond to a ping event with a pong request or
286    /// the client may be deemed unresponsive.
287    ///
288    /// # Arguments
289    ///
290    /// - `serial`: serial number of the ping event
291    #[inline]
292    pub fn pong(&self, serial: u32) {
293        let (arg0,) = (serial,);
294        let mut args = [wl_argument { u: arg0 }];
295        // SAFETY: - self.proxy has the interface INTERFACE
296        //         - 0 < INTERFACE.method_count = 10
297        //         - the request signature is `u`
298        unsafe {
299            self.proxy.send_request(0, &mut args);
300        }
301    }
302
303    /// start an interactive move
304    ///
305    /// Start a pointer-driven move of the surface.
306    ///
307    /// This request must be used in response to a button press event.
308    /// The server may ignore move requests depending on the state of
309    /// the surface (e.g. fullscreen or maximized).
310    ///
311    /// # Arguments
312    ///
313    /// - `seat`: seat whose pointer is used
314    /// - `serial`: serial number of the implicit grab on the pointer
315    #[inline]
316    pub fn r#move(&self, seat: &WlSeatRef, serial: u32) {
317        let (arg0, arg1) = (seat, serial);
318        let obj0_lock = proxy::lock(arg0);
319        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
320        let mut args = [wl_argument { o: obj0 }, wl_argument { u: arg1 }];
321        // SAFETY: - self.proxy has the interface INTERFACE
322        //         - 1 < INTERFACE.method_count = 10
323        //         - the request signature is `ou`
324        unsafe {
325            self.proxy.send_request(1, &mut args);
326        }
327    }
328
329    /// start an interactive resize
330    ///
331    /// Start a pointer-driven resizing of the surface.
332    ///
333    /// This request must be used in response to a button press event.
334    /// The server may ignore resize requests depending on the state of
335    /// the surface (e.g. fullscreen or maximized).
336    ///
337    /// # Arguments
338    ///
339    /// - `seat`: seat whose pointer is used
340    /// - `serial`: serial number of the implicit grab on the pointer
341    /// - `edges`: which edge or corner is being dragged
342    #[inline]
343    pub fn resize(&self, seat: &WlSeatRef, serial: u32, edges: WlShellSurfaceResize) {
344        let (arg0, arg1, arg2) = (seat, serial, edges);
345        let obj0_lock = proxy::lock(arg0);
346        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
347        let mut args = [
348            wl_argument { o: obj0 },
349            wl_argument { u: arg1 },
350            wl_argument { u: arg2.0 },
351        ];
352        // SAFETY: - self.proxy has the interface INTERFACE
353        //         - 2 < INTERFACE.method_count = 10
354        //         - the request signature is `ouu`
355        unsafe {
356            self.proxy.send_request(2, &mut args);
357        }
358    }
359
360    /// make the surface a toplevel surface
361    ///
362    /// Map the surface as a toplevel surface.
363    ///
364    /// A toplevel surface is not fullscreen, maximized or transient.
365    #[inline]
366    pub fn set_toplevel(&self) {
367        let mut args = [];
368        // SAFETY: - self.proxy has the interface INTERFACE
369        //         - 3 < INTERFACE.method_count = 10
370        //         - the request signature is ``
371        unsafe {
372            self.proxy.send_request(3, &mut args);
373        }
374    }
375
376    /// make the surface a transient surface
377    ///
378    /// Map the surface relative to an existing surface.
379    ///
380    /// The x and y arguments specify the location of the upper left
381    /// corner of the surface relative to the upper left corner of the
382    /// parent surface, in surface-local coordinates.
383    ///
384    /// The flags argument controls details of the transient behaviour.
385    ///
386    /// # Arguments
387    ///
388    /// - `parent`: parent surface
389    /// - `x`: surface-local x coordinate
390    /// - `y`: surface-local y coordinate
391    /// - `flags`: transient surface behavior
392    #[inline]
393    pub fn set_transient(
394        &self,
395        parent: &WlSurfaceRef,
396        x: i32,
397        y: i32,
398        flags: WlShellSurfaceTransient,
399    ) {
400        let (arg0, arg1, arg2, arg3) = (parent, x, y, flags);
401        let obj0_lock = proxy::lock(arg0);
402        let obj0 = check_argument_proxy("parent", obj0_lock.wl_proxy());
403        let mut args = [
404            wl_argument { o: obj0 },
405            wl_argument { i: arg1 },
406            wl_argument { i: arg2 },
407            wl_argument { u: arg3.0 },
408        ];
409        // SAFETY: - self.proxy has the interface INTERFACE
410        //         - 4 < INTERFACE.method_count = 10
411        //         - the request signature is `oiiu`
412        unsafe {
413            self.proxy.send_request(4, &mut args);
414        }
415    }
416
417    /// make the surface a fullscreen surface
418    ///
419    /// Map the surface as a fullscreen surface.
420    ///
421    /// If an output parameter is given then the surface will be made
422    /// fullscreen on that output. If the client does not specify the
423    /// output then the compositor will apply its policy - usually
424    /// choosing the output on which the surface has the biggest surface
425    /// area.
426    ///
427    /// The client may specify a method to resolve a size conflict
428    /// between the output size and the surface size - this is provided
429    /// through the method parameter.
430    ///
431    /// The framerate parameter is used only when the method is set
432    /// to "driver", to indicate the preferred framerate. A value of 0
433    /// indicates that the client does not care about framerate.  The
434    /// framerate is specified in mHz, that is framerate of 60000 is 60Hz.
435    ///
436    /// A method of "scale" or "driver" implies a scaling operation of
437    /// the surface, either via a direct scaling operation or a change of
438    /// the output mode. This will override any kind of output scaling, so
439    /// that mapping a surface with a buffer size equal to the mode can
440    /// fill the screen independent of buffer_scale.
441    ///
442    /// A method of "fill" means we don't scale up the buffer, however
443    /// any output scale is applied. This means that you may run into
444    /// an edge case where the application maps a buffer with the same
445    /// size of the output mode but buffer_scale 1 (thus making a
446    /// surface larger than the output). In this case it is allowed to
447    /// downscale the results to fit the screen.
448    ///
449    /// The compositor must reply to this request with a configure event
450    /// with the dimensions for the output on which the surface will
451    /// be made fullscreen.
452    ///
453    /// # Arguments
454    ///
455    /// - `method`: method for resolving size conflict
456    /// - `framerate`: framerate in mHz
457    /// - `output`: output on which the surface is to be fullscreen
458    #[inline]
459    pub fn set_fullscreen(
460        &self,
461        method: WlShellSurfaceFullscreenMethod,
462        framerate: u32,
463        output: Option<&WlOutputRef>,
464    ) {
465        let (arg0, arg1, arg2) = (method, framerate, output);
466        let obj2_lock = arg2.map(|arg2| proxy::lock(arg2));
467        let obj2 = obj2_lock
468            .map(|obj2_lock| check_argument_proxy("output", obj2_lock.wl_proxy()))
469            .unwrap_or(ptr::null_mut());
470        let mut args = [
471            wl_argument { u: arg0.0 },
472            wl_argument { u: arg1 },
473            wl_argument { o: obj2 },
474        ];
475        // SAFETY: - self.proxy has the interface INTERFACE
476        //         - 5 < INTERFACE.method_count = 10
477        //         - the request signature is `uu?o`
478        unsafe {
479            self.proxy.send_request(5, &mut args);
480        }
481    }
482
483    /// make the surface a popup surface
484    ///
485    /// Map the surface as a popup.
486    ///
487    /// A popup surface is a transient surface with an added pointer
488    /// grab.
489    ///
490    /// An existing implicit grab will be changed to owner-events mode,
491    /// and the popup grab will continue after the implicit grab ends
492    /// (i.e. releasing the mouse button does not cause the popup to
493    /// be unmapped).
494    ///
495    /// The popup grab continues until the window is destroyed or a
496    /// mouse button is pressed in any other client's window. A click
497    /// in any of the client's surfaces is reported as normal, however,
498    /// clicks in other clients' surfaces will be discarded and trigger
499    /// the callback.
500    ///
501    /// The x and y arguments specify the location of the upper left
502    /// corner of the surface relative to the upper left corner of the
503    /// parent surface, in surface-local coordinates.
504    ///
505    /// # Arguments
506    ///
507    /// - `seat`: seat whose pointer is used
508    /// - `serial`: serial number of the implicit grab on the pointer
509    /// - `parent`: parent surface
510    /// - `x`: surface-local x coordinate
511    /// - `y`: surface-local y coordinate
512    /// - `flags`: transient surface behavior
513    #[inline]
514    pub fn set_popup(
515        &self,
516        seat: &WlSeatRef,
517        serial: u32,
518        parent: &WlSurfaceRef,
519        x: i32,
520        y: i32,
521        flags: WlShellSurfaceTransient,
522    ) {
523        let (arg0, arg1, arg2, arg3, arg4, arg5) = (seat, serial, parent, x, y, flags);
524        let obj0_lock = proxy::lock(arg0);
525        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
526        let obj2_lock = proxy::lock(arg2);
527        let obj2 = check_argument_proxy("parent", obj2_lock.wl_proxy());
528        let mut args = [
529            wl_argument { o: obj0 },
530            wl_argument { u: arg1 },
531            wl_argument { o: obj2 },
532            wl_argument { i: arg3 },
533            wl_argument { i: arg4 },
534            wl_argument { u: arg5.0 },
535        ];
536        // SAFETY: - self.proxy has the interface INTERFACE
537        //         - 6 < INTERFACE.method_count = 10
538        //         - the request signature is `ouoiiu`
539        unsafe {
540            self.proxy.send_request(6, &mut args);
541        }
542    }
543
544    /// make the surface a maximized surface
545    ///
546    /// Map the surface as a maximized surface.
547    ///
548    /// If an output parameter is given then the surface will be
549    /// maximized on that output. If the client does not specify the
550    /// output then the compositor will apply its policy - usually
551    /// choosing the output on which the surface has the biggest surface
552    /// area.
553    ///
554    /// The compositor will reply with a configure event telling
555    /// the expected new surface size. The operation is completed
556    /// on the next buffer attach to this surface.
557    ///
558    /// A maximized surface typically fills the entire output it is
559    /// bound to, except for desktop elements such as panels. This is
560    /// the main difference between a maximized shell surface and a
561    /// fullscreen shell surface.
562    ///
563    /// The details depend on the compositor implementation.
564    ///
565    /// # Arguments
566    ///
567    /// - `output`: output on which the surface is to be maximized
568    #[inline]
569    pub fn set_maximized(&self, output: Option<&WlOutputRef>) {
570        let (arg0,) = (output,);
571        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
572        let obj0 = obj0_lock
573            .map(|obj0_lock| check_argument_proxy("output", obj0_lock.wl_proxy()))
574            .unwrap_or(ptr::null_mut());
575        let mut args = [wl_argument { o: obj0 }];
576        // SAFETY: - self.proxy has the interface INTERFACE
577        //         - 7 < INTERFACE.method_count = 10
578        //         - the request signature is `?o`
579        unsafe {
580            self.proxy.send_request(7, &mut args);
581        }
582    }
583
584    /// set surface title
585    ///
586    /// Set a short title for the surface.
587    ///
588    /// This string may be used to identify the surface in a task bar,
589    /// window list, or other user interface elements provided by the
590    /// compositor.
591    ///
592    /// The string must be encoded in UTF-8.
593    ///
594    /// # Arguments
595    ///
596    /// - `title`: surface title
597    #[inline]
598    pub fn set_title(&self, title: &str) {
599        let (arg0,) = (title,);
600        with_cstr_cache(|cache| {
601            let str0_offset = cache.len();
602            cache.extend_from_slice(arg0.as_bytes());
603            cache.push(0);
604            let str0 = cache[str0_offset..].as_ptr().cast();
605            let mut args = [wl_argument { s: str0 }];
606            // SAFETY: - self.proxy has the interface INTERFACE
607            //         - 8 < INTERFACE.method_count = 10
608            //         - the request signature is `s`
609            unsafe {
610                self.proxy.send_request(8, &mut args);
611            }
612        })
613    }
614
615    /// set surface class
616    ///
617    /// Set a class for the surface.
618    ///
619    /// The surface class identifies the general class of applications
620    /// to which the surface belongs. A common convention is to use the
621    /// file name (or the full path if it is a non-standard location) of
622    /// the application's .desktop file as the class.
623    ///
624    /// # Arguments
625    ///
626    /// - `class_`: surface class
627    #[inline]
628    pub fn set_class(&self, class_: &str) {
629        let (arg0,) = (class_,);
630        with_cstr_cache(|cache| {
631            let str0_offset = cache.len();
632            cache.extend_from_slice(arg0.as_bytes());
633            cache.push(0);
634            let str0 = cache[str0_offset..].as_ptr().cast();
635            let mut args = [wl_argument { s: str0 }];
636            // SAFETY: - self.proxy has the interface INTERFACE
637            //         - 9 < INTERFACE.method_count = 10
638            //         - the request signature is `s`
639            unsafe {
640                self.proxy.send_request(9, &mut args);
641            }
642        })
643    }
644}
645
646impl WlShellSurface {
647    /// Since when the ping event is available.
648    #[allow(dead_code)]
649    pub const EVT__PING__SINCE: u32 = 1;
650
651    /// Since when the configure event is available.
652    #[allow(dead_code)]
653    pub const EVT__CONFIGURE__SINCE: u32 = 1;
654
655    /// Since when the popup_done event is available.
656    #[allow(dead_code)]
657    pub const EVT__POPUP_DONE__SINCE: u32 = 1;
658}
659
660/// An event handler for [WlShellSurface] proxies.
661#[allow(dead_code)]
662pub trait WlShellSurfaceEventHandler {
663    type Data: 'static;
664
665    /// ping client
666    ///
667    /// Ping a client to check if it is receiving events and sending
668    /// requests. A client is expected to reply with a pong request.
669    ///
670    /// # Arguments
671    ///
672    /// - `serial`: serial number of the ping
673    #[inline]
674    fn ping(&self, _data: &mut Self::Data, _slf: &WlShellSurfaceRef, serial: u32) {
675        let _ = serial;
676    }
677
678    /// suggest resize
679    ///
680    /// The configure event asks the client to resize its surface.
681    ///
682    /// The size is a hint, in the sense that the client is free to
683    /// ignore it if it doesn't resize, pick a smaller size (to
684    /// satisfy aspect ratio or resize in steps of NxM pixels).
685    ///
686    /// The edges parameter provides a hint about how the surface
687    /// was resized. The client may use this information to decide
688    /// how to adjust its content to the new size (e.g. a scrolling
689    /// area might adjust its content position to leave the viewable
690    /// content unmoved).
691    ///
692    /// The client is free to dismiss all but the last configure
693    /// event it received.
694    ///
695    /// The width and height arguments specify the size of the window
696    /// in surface-local coordinates.
697    ///
698    /// # Arguments
699    ///
700    /// - `edges`: how the surface was resized
701    /// - `width`: new width of the surface
702    /// - `height`: new height of the surface
703    #[inline]
704    fn configure(
705        &self,
706        _data: &mut Self::Data,
707        _slf: &WlShellSurfaceRef,
708        edges: WlShellSurfaceResize,
709        width: i32,
710        height: i32,
711    ) {
712        let _ = edges;
713        let _ = width;
714        let _ = height;
715    }
716
717    /// popup interaction is done
718    ///
719    /// The popup_done event is sent out when a popup grab is broken,
720    /// that is, when the user clicks a surface that doesn't belong
721    /// to the client owning the popup surface.
722    #[inline]
723    fn popup_done(&self, _data: &mut Self::Data, _slf: &WlShellSurfaceRef) {}
724}
725
726impl WlShellSurfaceEventHandler for private::NoOpEventHandler {
727    type Data = ();
728}
729
730// SAFETY: - INTERFACE is a valid wl_interface
731//         - mutable_type always returns the same value
732unsafe impl<H> EventHandler for private::EventHandler<H>
733where
734    H: WlShellSurfaceEventHandler,
735{
736    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
737
738    #[inline]
739    fn mutable_type() -> Option<(TypeId, &'static str)> {
740        let id = TypeId::of::<H::Data>();
741        let name = std::any::type_name::<H::Data>();
742        Some((id, name))
743    }
744
745    #[allow(unused_variables)]
746    unsafe fn handle_event(
747        &self,
748        queue: &Queue,
749        data: *mut u8,
750        slf: &UntypedBorrowedProxy,
751        opcode: u32,
752        args: *mut wl_argument,
753    ) {
754        // SAFETY: This function requires that slf has the interface INTERFACE
755        let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlShellSurfaceRef>(slf) };
756        // SAFETY: This function requires that data is `&mut T` where `T`
757        //         has the type id returned by `Self::mutable_type`, i.e.,
758        //         `T = H::Data`.
759        let data: &mut H::Data = unsafe { &mut *data.cast() };
760        match opcode {
761            0 => {
762                // SAFETY: INTERFACE requires that there are 1 arguments
763                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
764                // SAFETY: - INTERFACE requires that args[0] contains a uint
765                let arg0 = unsafe { args[0].u };
766                self.0.ping(data, slf, arg0);
767            }
768            1 => {
769                // SAFETY: INTERFACE requires that there are 3 arguments
770                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
771                // SAFETY: - INTERFACE requires that args[0] contains a uint
772                let arg0 = unsafe { WlShellSurfaceResize(args[0].u) };
773                // SAFETY: - INTERFACE requires that args[1] contains an int
774                let arg1 = unsafe { args[1].i };
775                // SAFETY: - INTERFACE requires that args[2] contains an int
776                let arg2 = unsafe { args[2].i };
777                self.0.configure(data, slf, arg0, arg1, arg2);
778            }
779            2 => {
780                self.0.popup_done(data, slf);
781            }
782            _ => {
783                invalid_opcode("wl_shell_surface", opcode);
784            }
785        }
786    }
787}
788
789impl<H> CreateEventHandler<H> for private::ProxyApi
790where
791    H: WlShellSurfaceEventHandler,
792{
793    type EventHandler = private::EventHandler<H>;
794
795    #[inline]
796    fn create_event_handler(handler: H) -> Self::EventHandler {
797        private::EventHandler(handler)
798    }
799}
800
801impl WlShellSurface {
802    /// Since when the resize.none enum variant is available.
803    #[allow(dead_code)]
804    pub const ENM__RESIZE_NONE__SINCE: u32 = 1;
805    /// Since when the resize.top enum variant is available.
806    #[allow(dead_code)]
807    pub const ENM__RESIZE_TOP__SINCE: u32 = 1;
808    /// Since when the resize.bottom enum variant is available.
809    #[allow(dead_code)]
810    pub const ENM__RESIZE_BOTTOM__SINCE: u32 = 1;
811    /// Since when the resize.left enum variant is available.
812    #[allow(dead_code)]
813    pub const ENM__RESIZE_LEFT__SINCE: u32 = 1;
814    /// Since when the resize.top_left enum variant is available.
815    #[allow(dead_code)]
816    pub const ENM__RESIZE_TOP_LEFT__SINCE: u32 = 1;
817    /// Since when the resize.bottom_left enum variant is available.
818    #[allow(dead_code)]
819    pub const ENM__RESIZE_BOTTOM_LEFT__SINCE: u32 = 1;
820    /// Since when the resize.right enum variant is available.
821    #[allow(dead_code)]
822    pub const ENM__RESIZE_RIGHT__SINCE: u32 = 1;
823    /// Since when the resize.top_right enum variant is available.
824    #[allow(dead_code)]
825    pub const ENM__RESIZE_TOP_RIGHT__SINCE: u32 = 1;
826    /// Since when the resize.bottom_right enum variant is available.
827    #[allow(dead_code)]
828    pub const ENM__RESIZE_BOTTOM_RIGHT__SINCE: u32 = 1;
829
830    /// Since when the transient.inactive enum variant is available.
831    #[allow(dead_code)]
832    pub const ENM__TRANSIENT_INACTIVE__SINCE: u32 = 1;
833
834    /// Since when the fullscreen_method.default enum variant is available.
835    #[allow(dead_code)]
836    pub const ENM__FULLSCREEN_METHOD_DEFAULT__SINCE: u32 = 1;
837    /// Since when the fullscreen_method.scale enum variant is available.
838    #[allow(dead_code)]
839    pub const ENM__FULLSCREEN_METHOD_SCALE__SINCE: u32 = 1;
840    /// Since when the fullscreen_method.driver enum variant is available.
841    #[allow(dead_code)]
842    pub const ENM__FULLSCREEN_METHOD_DRIVER__SINCE: u32 = 1;
843    /// Since when the fullscreen_method.fill enum variant is available.
844    #[allow(dead_code)]
845    pub const ENM__FULLSCREEN_METHOD_FILL__SINCE: u32 = 1;
846}
847
848/// edge values for resizing
849///
850/// These values are used to indicate which edge of a surface
851/// is being dragged in a resize operation. The server may
852/// use this information to adapt its behavior, e.g. choose
853/// an appropriate cursor image.
854#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
855#[allow(dead_code)]
856pub struct WlShellSurfaceResize(pub u32);
857
858/// An iterator over the set bits in a [WlShellSurfaceResize].
859///
860/// You can construct this with the `IntoIterator` implementation of `WlShellSurfaceResize`.
861#[derive(Clone, Debug)]
862#[allow(dead_code)]
863pub struct WlShellSurfaceResizeIter(pub u32);
864
865impl WlShellSurfaceResize {
866    /// no edge
867    #[allow(dead_code)]
868    pub const NONE: Self = Self(0);
869
870    /// top edge
871    #[allow(dead_code)]
872    pub const TOP: Self = Self(1);
873
874    /// bottom edge
875    #[allow(dead_code)]
876    pub const BOTTOM: Self = Self(2);
877
878    /// left edge
879    #[allow(dead_code)]
880    pub const LEFT: Self = Self(4);
881
882    /// top and left edges
883    #[allow(dead_code)]
884    pub const TOP_LEFT: Self = Self(5);
885
886    /// bottom and left edges
887    #[allow(dead_code)]
888    pub const BOTTOM_LEFT: Self = Self(6);
889
890    /// right edge
891    #[allow(dead_code)]
892    pub const RIGHT: Self = Self(8);
893
894    /// top and right edges
895    #[allow(dead_code)]
896    pub const TOP_RIGHT: Self = Self(9);
897
898    /// bottom and right edges
899    #[allow(dead_code)]
900    pub const BOTTOM_RIGHT: Self = Self(10);
901}
902
903#[allow(dead_code)]
904impl WlShellSurfaceResize {
905    #[inline]
906    pub const fn empty() -> Self {
907        Self(0)
908    }
909
910    #[inline]
911    #[must_use]
912    pub const fn is_empty(self) -> bool {
913        self.0 == 0
914    }
915
916    #[inline]
917    #[must_use]
918    pub const fn contains(self, other: Self) -> bool {
919        self.0 & other.0 == other.0
920    }
921
922    #[inline]
923    #[must_use]
924    pub const fn intersects(self, other: Self) -> bool {
925        self.0 & other.0 != 0
926    }
927
928    #[inline]
929    pub const fn insert(&mut self, other: Self) {
930        *self = self.union(other);
931    }
932
933    #[inline]
934    pub const fn remove(&mut self, other: Self) {
935        *self = self.difference(other);
936    }
937
938    #[inline]
939    pub const fn toggle(&mut self, other: Self) {
940        *self = self.symmetric_difference(other);
941    }
942
943    #[inline]
944    pub const fn set(&mut self, other: Self, value: bool) {
945        if value {
946            self.insert(other);
947        } else {
948            self.remove(other);
949        }
950    }
951
952    #[inline]
953    #[must_use]
954    pub const fn intersection(self, other: Self) -> Self {
955        Self(self.0 & other.0)
956    }
957
958    #[inline]
959    #[must_use]
960    pub const fn union(self, other: Self) -> Self {
961        Self(self.0 | other.0)
962    }
963
964    #[inline]
965    #[must_use]
966    pub const fn difference(self, other: Self) -> Self {
967        Self(self.0 & !other.0)
968    }
969
970    #[inline]
971    #[must_use]
972    pub const fn complement(self) -> Self {
973        Self(!self.0)
974    }
975
976    #[inline]
977    #[must_use]
978    pub const fn symmetric_difference(self, other: Self) -> Self {
979        Self(self.0 ^ other.0)
980    }
981
982    #[inline]
983    pub const fn all_known() -> Self {
984        #[allow(clippy::eq_op, clippy::identity_op)]
985        Self(0 | 0 | 1 | 2 | 4 | 5 | 6 | 8 | 9 | 10)
986    }
987}
988
989impl Iterator for WlShellSurfaceResizeIter {
990    type Item = WlShellSurfaceResize;
991
992    fn next(&mut self) -> Option<Self::Item> {
993        if self.0 == 0 {
994            return None;
995        }
996        let bit = 1 << self.0.trailing_zeros();
997        self.0 &= !bit;
998        Some(WlShellSurfaceResize(bit))
999    }
1000}
1001
1002impl IntoIterator for WlShellSurfaceResize {
1003    type Item = WlShellSurfaceResize;
1004    type IntoIter = WlShellSurfaceResizeIter;
1005
1006    fn into_iter(self) -> Self::IntoIter {
1007        WlShellSurfaceResizeIter(self.0)
1008    }
1009}
1010
1011impl BitAnd for WlShellSurfaceResize {
1012    type Output = Self;
1013
1014    fn bitand(self, rhs: Self) -> Self::Output {
1015        self.intersection(rhs)
1016    }
1017}
1018
1019impl BitAndAssign for WlShellSurfaceResize {
1020    fn bitand_assign(&mut self, rhs: Self) {
1021        *self = self.intersection(rhs);
1022    }
1023}
1024
1025impl BitOr for WlShellSurfaceResize {
1026    type Output = Self;
1027
1028    fn bitor(self, rhs: Self) -> Self::Output {
1029        self.union(rhs)
1030    }
1031}
1032
1033impl BitOrAssign for WlShellSurfaceResize {
1034    fn bitor_assign(&mut self, rhs: Self) {
1035        *self = self.union(rhs);
1036    }
1037}
1038
1039impl BitXor for WlShellSurfaceResize {
1040    type Output = Self;
1041
1042    fn bitxor(self, rhs: Self) -> Self::Output {
1043        self.symmetric_difference(rhs)
1044    }
1045}
1046
1047impl BitXorAssign for WlShellSurfaceResize {
1048    fn bitxor_assign(&mut self, rhs: Self) {
1049        *self = self.symmetric_difference(rhs);
1050    }
1051}
1052
1053impl Sub for WlShellSurfaceResize {
1054    type Output = Self;
1055
1056    fn sub(self, rhs: Self) -> Self::Output {
1057        self.difference(rhs)
1058    }
1059}
1060
1061impl SubAssign for WlShellSurfaceResize {
1062    fn sub_assign(&mut self, rhs: Self) {
1063        *self = self.difference(rhs);
1064    }
1065}
1066
1067impl Not for WlShellSurfaceResize {
1068    type Output = Self;
1069
1070    fn not(self) -> Self::Output {
1071        self.complement()
1072    }
1073}
1074
1075impl Debug for WlShellSurfaceResize {
1076    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1077        let mut v = self.0;
1078        let mut first = true;
1079        if v & 1 == 1 {
1080            v &= !1;
1081            if first {
1082                first = false;
1083            } else {
1084                f.write_str(" | ")?;
1085            }
1086            f.write_str("TOP")?;
1087        }
1088        if v & 2 == 2 {
1089            v &= !2;
1090            if first {
1091                first = false;
1092            } else {
1093                f.write_str(" | ")?;
1094            }
1095            f.write_str("BOTTOM")?;
1096        }
1097        if v & 4 == 4 {
1098            v &= !4;
1099            if first {
1100                first = false;
1101            } else {
1102                f.write_str(" | ")?;
1103            }
1104            f.write_str("LEFT")?;
1105        }
1106        if v & 5 == 5 {
1107            v &= !5;
1108            if first {
1109                first = false;
1110            } else {
1111                f.write_str(" | ")?;
1112            }
1113            f.write_str("TOP_LEFT")?;
1114        }
1115        if v & 6 == 6 {
1116            v &= !6;
1117            if first {
1118                first = false;
1119            } else {
1120                f.write_str(" | ")?;
1121            }
1122            f.write_str("BOTTOM_LEFT")?;
1123        }
1124        if v & 8 == 8 {
1125            v &= !8;
1126            if first {
1127                first = false;
1128            } else {
1129                f.write_str(" | ")?;
1130            }
1131            f.write_str("RIGHT")?;
1132        }
1133        if v & 9 == 9 {
1134            v &= !9;
1135            if first {
1136                first = false;
1137            } else {
1138                f.write_str(" | ")?;
1139            }
1140            f.write_str("TOP_RIGHT")?;
1141        }
1142        if v & 10 == 10 {
1143            v &= !10;
1144            if first {
1145                first = false;
1146            } else {
1147                f.write_str(" | ")?;
1148            }
1149            f.write_str("BOTTOM_RIGHT")?;
1150        }
1151        if v != 0 {
1152            if first {
1153                first = false;
1154            } else {
1155                f.write_str(" | ")?;
1156            }
1157            write!(f, "0x{v:032x}")?;
1158        }
1159        if first {
1160            f.write_str("NONE")?;
1161        }
1162        Ok(())
1163    }
1164}
1165
1166/// details of transient behaviour
1167///
1168/// These flags specify details of the expected behaviour
1169/// of transient surfaces. Used in the set_transient request.
1170#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
1171#[allow(dead_code)]
1172pub struct WlShellSurfaceTransient(pub u32);
1173
1174/// An iterator over the set bits in a [WlShellSurfaceTransient].
1175///
1176/// You can construct this with the `IntoIterator` implementation of `WlShellSurfaceTransient`.
1177#[derive(Clone, Debug)]
1178#[allow(dead_code)]
1179pub struct WlShellSurfaceTransientIter(pub u32);
1180
1181impl WlShellSurfaceTransient {
1182    /// do not set keyboard focus
1183    #[allow(dead_code)]
1184    pub const INACTIVE: Self = Self(0x1);
1185}
1186
1187#[allow(dead_code)]
1188impl WlShellSurfaceTransient {
1189    #[inline]
1190    pub const fn empty() -> Self {
1191        Self(0)
1192    }
1193
1194    #[inline]
1195    #[must_use]
1196    pub const fn is_empty(self) -> bool {
1197        self.0 == 0
1198    }
1199
1200    #[inline]
1201    #[must_use]
1202    pub const fn contains(self, other: Self) -> bool {
1203        self.0 & other.0 == other.0
1204    }
1205
1206    #[inline]
1207    #[must_use]
1208    pub const fn intersects(self, other: Self) -> bool {
1209        self.0 & other.0 != 0
1210    }
1211
1212    #[inline]
1213    pub const fn insert(&mut self, other: Self) {
1214        *self = self.union(other);
1215    }
1216
1217    #[inline]
1218    pub const fn remove(&mut self, other: Self) {
1219        *self = self.difference(other);
1220    }
1221
1222    #[inline]
1223    pub const fn toggle(&mut self, other: Self) {
1224        *self = self.symmetric_difference(other);
1225    }
1226
1227    #[inline]
1228    pub const fn set(&mut self, other: Self, value: bool) {
1229        if value {
1230            self.insert(other);
1231        } else {
1232            self.remove(other);
1233        }
1234    }
1235
1236    #[inline]
1237    #[must_use]
1238    pub const fn intersection(self, other: Self) -> Self {
1239        Self(self.0 & other.0)
1240    }
1241
1242    #[inline]
1243    #[must_use]
1244    pub const fn union(self, other: Self) -> Self {
1245        Self(self.0 | other.0)
1246    }
1247
1248    #[inline]
1249    #[must_use]
1250    pub const fn difference(self, other: Self) -> Self {
1251        Self(self.0 & !other.0)
1252    }
1253
1254    #[inline]
1255    #[must_use]
1256    pub const fn complement(self) -> Self {
1257        Self(!self.0)
1258    }
1259
1260    #[inline]
1261    #[must_use]
1262    pub const fn symmetric_difference(self, other: Self) -> Self {
1263        Self(self.0 ^ other.0)
1264    }
1265
1266    #[inline]
1267    pub const fn all_known() -> Self {
1268        #[allow(clippy::eq_op, clippy::identity_op)]
1269        Self(0 | 0x1)
1270    }
1271}
1272
1273impl Iterator for WlShellSurfaceTransientIter {
1274    type Item = WlShellSurfaceTransient;
1275
1276    fn next(&mut self) -> Option<Self::Item> {
1277        if self.0 == 0 {
1278            return None;
1279        }
1280        let bit = 1 << self.0.trailing_zeros();
1281        self.0 &= !bit;
1282        Some(WlShellSurfaceTransient(bit))
1283    }
1284}
1285
1286impl IntoIterator for WlShellSurfaceTransient {
1287    type Item = WlShellSurfaceTransient;
1288    type IntoIter = WlShellSurfaceTransientIter;
1289
1290    fn into_iter(self) -> Self::IntoIter {
1291        WlShellSurfaceTransientIter(self.0)
1292    }
1293}
1294
1295impl BitAnd for WlShellSurfaceTransient {
1296    type Output = Self;
1297
1298    fn bitand(self, rhs: Self) -> Self::Output {
1299        self.intersection(rhs)
1300    }
1301}
1302
1303impl BitAndAssign for WlShellSurfaceTransient {
1304    fn bitand_assign(&mut self, rhs: Self) {
1305        *self = self.intersection(rhs);
1306    }
1307}
1308
1309impl BitOr for WlShellSurfaceTransient {
1310    type Output = Self;
1311
1312    fn bitor(self, rhs: Self) -> Self::Output {
1313        self.union(rhs)
1314    }
1315}
1316
1317impl BitOrAssign for WlShellSurfaceTransient {
1318    fn bitor_assign(&mut self, rhs: Self) {
1319        *self = self.union(rhs);
1320    }
1321}
1322
1323impl BitXor for WlShellSurfaceTransient {
1324    type Output = Self;
1325
1326    fn bitxor(self, rhs: Self) -> Self::Output {
1327        self.symmetric_difference(rhs)
1328    }
1329}
1330
1331impl BitXorAssign for WlShellSurfaceTransient {
1332    fn bitxor_assign(&mut self, rhs: Self) {
1333        *self = self.symmetric_difference(rhs);
1334    }
1335}
1336
1337impl Sub for WlShellSurfaceTransient {
1338    type Output = Self;
1339
1340    fn sub(self, rhs: Self) -> Self::Output {
1341        self.difference(rhs)
1342    }
1343}
1344
1345impl SubAssign for WlShellSurfaceTransient {
1346    fn sub_assign(&mut self, rhs: Self) {
1347        *self = self.difference(rhs);
1348    }
1349}
1350
1351impl Not for WlShellSurfaceTransient {
1352    type Output = Self;
1353
1354    fn not(self) -> Self::Output {
1355        self.complement()
1356    }
1357}
1358
1359impl Debug for WlShellSurfaceTransient {
1360    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1361        let mut v = self.0;
1362        let mut first = true;
1363        if v & 0x1 == 0x1 {
1364            v &= !0x1;
1365            if first {
1366                first = false;
1367            } else {
1368                f.write_str(" | ")?;
1369            }
1370            f.write_str("INACTIVE")?;
1371        }
1372        if v != 0 {
1373            if first {
1374                first = false;
1375            } else {
1376                f.write_str(" | ")?;
1377            }
1378            write!(f, "0x{v:032x}")?;
1379        }
1380        if first {
1381            f.write_str("0")?;
1382        }
1383        Ok(())
1384    }
1385}
1386
1387/// different method to set the surface fullscreen
1388///
1389/// Hints to indicate to the compositor how to deal with a conflict
1390/// between the dimensions of the surface and the dimensions of the
1391/// output. The compositor is free to ignore this parameter.
1392#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1393#[allow(dead_code)]
1394pub struct WlShellSurfaceFullscreenMethod(pub u32);
1395
1396impl WlShellSurfaceFullscreenMethod {
1397    /// no preference, apply default policy
1398    #[allow(dead_code)]
1399    pub const DEFAULT: Self = Self(0);
1400
1401    /// scale, preserve the surface's aspect ratio and center on output
1402    #[allow(dead_code)]
1403    pub const SCALE: Self = Self(1);
1404
1405    /// switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch
1406    #[allow(dead_code)]
1407    pub const DRIVER: Self = Self(2);
1408
1409    /// no upscaling, center on output and add black borders to compensate size mismatch
1410    #[allow(dead_code)]
1411    pub const FILL: Self = Self(3);
1412}
1413
1414impl Debug for WlShellSurfaceFullscreenMethod {
1415    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1416        let name = match *self {
1417            Self::DEFAULT => "DEFAULT",
1418            Self::SCALE => "SCALE",
1419            Self::DRIVER => "DRIVER",
1420            Self::FILL => "FILL",
1421            _ => return Debug::fmt(&self.0, f),
1422        };
1423        f.write_str(name)
1424    }
1425}
1426
1427/// Functional event handlers.
1428pub mod event_handlers {
1429    use super::*;
1430
1431    /// Event handler for ping events.
1432    pub struct Ping<T, F>(F, PhantomData<fn(&mut T)>);
1433    impl<T, F> WlShellSurfaceEventHandler for Ping<T, F>
1434    where
1435        T: 'static,
1436        F: Fn(&mut T, &WlShellSurfaceRef, u32),
1437    {
1438        type Data = T;
1439
1440        #[inline]
1441        fn ping(&self, _data: &mut T, _slf: &WlShellSurfaceRef, serial: u32) {
1442            self.0(_data, _slf, serial)
1443        }
1444    }
1445
1446    /// Event handler for configure events.
1447    pub struct Configure<T, F>(F, PhantomData<fn(&mut T)>);
1448    impl<T, F> WlShellSurfaceEventHandler for Configure<T, F>
1449    where
1450        T: 'static,
1451        F: Fn(&mut T, &WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1452    {
1453        type Data = T;
1454
1455        #[inline]
1456        fn configure(
1457            &self,
1458            _data: &mut T,
1459            _slf: &WlShellSurfaceRef,
1460            edges: WlShellSurfaceResize,
1461            width: i32,
1462            height: i32,
1463        ) {
1464            self.0(_data, _slf, edges, width, height)
1465        }
1466    }
1467
1468    /// Event handler for popup_done events.
1469    pub struct PopupDone<T, F>(F, PhantomData<fn(&mut T)>);
1470    impl<T, F> WlShellSurfaceEventHandler for PopupDone<T, F>
1471    where
1472        T: 'static,
1473        F: Fn(&mut T, &WlShellSurfaceRef),
1474    {
1475        type Data = T;
1476
1477        #[inline]
1478        fn popup_done(&self, _data: &mut T, _slf: &WlShellSurfaceRef) {
1479            self.0(_data, _slf)
1480        }
1481    }
1482
1483    impl WlShellSurface {
1484        /// Creates an event handler for ping events.
1485        ///
1486        /// The event handler ignores all other events.
1487        #[allow(dead_code)]
1488        pub fn on_ping<T, F>(f: F) -> Ping<T, F>
1489        where
1490            T: 'static,
1491            F: Fn(&mut T, &WlShellSurfaceRef, u32),
1492        {
1493            Ping(f, PhantomData)
1494        }
1495
1496        /// Creates an event handler for configure events.
1497        ///
1498        /// The event handler ignores all other events.
1499        #[allow(dead_code)]
1500        pub fn on_configure<T, F>(f: F) -> Configure<T, F>
1501        where
1502            T: 'static,
1503            F: Fn(&mut T, &WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1504        {
1505            Configure(f, PhantomData)
1506        }
1507
1508        /// Creates an event handler for popup_done events.
1509        ///
1510        /// The event handler ignores all other events.
1511        #[allow(dead_code)]
1512        pub fn on_popup_done<T, F>(f: F) -> PopupDone<T, F>
1513        where
1514            T: 'static,
1515            F: Fn(&mut T, &WlShellSurfaceRef),
1516        {
1517            PopupDone(f, PhantomData)
1518        }
1519    }
1520}