Skip to main content

get_registry/common/protocols/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    /// ping client
664    ///
665    /// Ping a client to check if it is receiving events and sending
666    /// requests. A client is expected to reply with a pong request.
667    ///
668    /// # Arguments
669    ///
670    /// - `serial`: serial number of the ping
671    #[inline]
672    fn ping(&self, _slf: &WlShellSurfaceRef, serial: u32) {
673        let _ = serial;
674    }
675
676    /// suggest resize
677    ///
678    /// The configure event asks the client to resize its surface.
679    ///
680    /// The size is a hint, in the sense that the client is free to
681    /// ignore it if it doesn't resize, pick a smaller size (to
682    /// satisfy aspect ratio or resize in steps of NxM pixels).
683    ///
684    /// The edges parameter provides a hint about how the surface
685    /// was resized. The client may use this information to decide
686    /// how to adjust its content to the new size (e.g. a scrolling
687    /// area might adjust its content position to leave the viewable
688    /// content unmoved).
689    ///
690    /// The client is free to dismiss all but the last configure
691    /// event it received.
692    ///
693    /// The width and height arguments specify the size of the window
694    /// in surface-local coordinates.
695    ///
696    /// # Arguments
697    ///
698    /// - `edges`: how the surface was resized
699    /// - `width`: new width of the surface
700    /// - `height`: new height of the surface
701    #[inline]
702    fn configure(
703        &self,
704        _slf: &WlShellSurfaceRef,
705        edges: WlShellSurfaceResize,
706        width: i32,
707        height: i32,
708    ) {
709        let _ = edges;
710        let _ = width;
711        let _ = height;
712    }
713
714    /// popup interaction is done
715    ///
716    /// The popup_done event is sent out when a popup grab is broken,
717    /// that is, when the user clicks a surface that doesn't belong
718    /// to the client owning the popup surface.
719    #[inline]
720    fn popup_done(&self, _slf: &WlShellSurfaceRef) {}
721}
722
723impl WlShellSurfaceEventHandler for private::NoOpEventHandler {}
724
725// SAFETY: - INTERFACE is a valid wl_interface
726unsafe impl<H> EventHandler for private::EventHandler<H>
727where
728    H: WlShellSurfaceEventHandler,
729{
730    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
731
732    #[allow(unused_variables)]
733    unsafe fn handle_event(
734        &self,
735        queue: &Queue,
736        data: *mut u8,
737        slf: &UntypedBorrowedProxy,
738        opcode: u32,
739        args: *mut wl_argument,
740    ) {
741        // SAFETY: This function requires that slf has the interface INTERFACE
742        let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlShellSurfaceRef>(slf) };
743        match opcode {
744            0 => {
745                // SAFETY: INTERFACE requires that there are 1 arguments
746                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
747                // SAFETY: - INTERFACE requires that args[0] contains a uint
748                let arg0 = unsafe { args[0].u };
749                self.0.ping(slf, arg0);
750            }
751            1 => {
752                // SAFETY: INTERFACE requires that there are 3 arguments
753                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
754                // SAFETY: - INTERFACE requires that args[0] contains a uint
755                let arg0 = unsafe { WlShellSurfaceResize(args[0].u) };
756                // SAFETY: - INTERFACE requires that args[1] contains an int
757                let arg1 = unsafe { args[1].i };
758                // SAFETY: - INTERFACE requires that args[2] contains an int
759                let arg2 = unsafe { args[2].i };
760                self.0.configure(slf, arg0, arg1, arg2);
761            }
762            2 => {
763                self.0.popup_done(slf);
764            }
765            _ => {
766                invalid_opcode("wl_shell_surface", opcode);
767            }
768        }
769    }
770}
771
772impl<H> CreateEventHandler<H> for private::ProxyApi
773where
774    H: WlShellSurfaceEventHandler,
775{
776    type EventHandler = private::EventHandler<H>;
777
778    #[inline]
779    fn create_event_handler(handler: H) -> Self::EventHandler {
780        private::EventHandler(handler)
781    }
782}
783
784impl WlShellSurface {
785    /// Since when the resize.none enum variant is available.
786    #[allow(dead_code)]
787    pub const ENM__RESIZE_NONE__SINCE: u32 = 1;
788    /// Since when the resize.top enum variant is available.
789    #[allow(dead_code)]
790    pub const ENM__RESIZE_TOP__SINCE: u32 = 1;
791    /// Since when the resize.bottom enum variant is available.
792    #[allow(dead_code)]
793    pub const ENM__RESIZE_BOTTOM__SINCE: u32 = 1;
794    /// Since when the resize.left enum variant is available.
795    #[allow(dead_code)]
796    pub const ENM__RESIZE_LEFT__SINCE: u32 = 1;
797    /// Since when the resize.top_left enum variant is available.
798    #[allow(dead_code)]
799    pub const ENM__RESIZE_TOP_LEFT__SINCE: u32 = 1;
800    /// Since when the resize.bottom_left enum variant is available.
801    #[allow(dead_code)]
802    pub const ENM__RESIZE_BOTTOM_LEFT__SINCE: u32 = 1;
803    /// Since when the resize.right enum variant is available.
804    #[allow(dead_code)]
805    pub const ENM__RESIZE_RIGHT__SINCE: u32 = 1;
806    /// Since when the resize.top_right enum variant is available.
807    #[allow(dead_code)]
808    pub const ENM__RESIZE_TOP_RIGHT__SINCE: u32 = 1;
809    /// Since when the resize.bottom_right enum variant is available.
810    #[allow(dead_code)]
811    pub const ENM__RESIZE_BOTTOM_RIGHT__SINCE: u32 = 1;
812
813    /// Since when the transient.inactive enum variant is available.
814    #[allow(dead_code)]
815    pub const ENM__TRANSIENT_INACTIVE__SINCE: u32 = 1;
816
817    /// Since when the fullscreen_method.default enum variant is available.
818    #[allow(dead_code)]
819    pub const ENM__FULLSCREEN_METHOD_DEFAULT__SINCE: u32 = 1;
820    /// Since when the fullscreen_method.scale enum variant is available.
821    #[allow(dead_code)]
822    pub const ENM__FULLSCREEN_METHOD_SCALE__SINCE: u32 = 1;
823    /// Since when the fullscreen_method.driver enum variant is available.
824    #[allow(dead_code)]
825    pub const ENM__FULLSCREEN_METHOD_DRIVER__SINCE: u32 = 1;
826    /// Since when the fullscreen_method.fill enum variant is available.
827    #[allow(dead_code)]
828    pub const ENM__FULLSCREEN_METHOD_FILL__SINCE: u32 = 1;
829}
830
831/// edge values for resizing
832///
833/// These values are used to indicate which edge of a surface
834/// is being dragged in a resize operation. The server may
835/// use this information to adapt its behavior, e.g. choose
836/// an appropriate cursor image.
837#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
838#[allow(dead_code)]
839pub struct WlShellSurfaceResize(pub u32);
840
841/// An iterator over the set bits in a [WlShellSurfaceResize].
842///
843/// You can construct this with the `IntoIterator` implementation of `WlShellSurfaceResize`.
844#[derive(Clone, Debug)]
845#[allow(dead_code)]
846pub struct WlShellSurfaceResizeIter(pub u32);
847
848impl WlShellSurfaceResize {
849    /// no edge
850    #[allow(dead_code)]
851    pub const NONE: Self = Self(0);
852
853    /// top edge
854    #[allow(dead_code)]
855    pub const TOP: Self = Self(1);
856
857    /// bottom edge
858    #[allow(dead_code)]
859    pub const BOTTOM: Self = Self(2);
860
861    /// left edge
862    #[allow(dead_code)]
863    pub const LEFT: Self = Self(4);
864
865    /// top and left edges
866    #[allow(dead_code)]
867    pub const TOP_LEFT: Self = Self(5);
868
869    /// bottom and left edges
870    #[allow(dead_code)]
871    pub const BOTTOM_LEFT: Self = Self(6);
872
873    /// right edge
874    #[allow(dead_code)]
875    pub const RIGHT: Self = Self(8);
876
877    /// top and right edges
878    #[allow(dead_code)]
879    pub const TOP_RIGHT: Self = Self(9);
880
881    /// bottom and right edges
882    #[allow(dead_code)]
883    pub const BOTTOM_RIGHT: Self = Self(10);
884}
885
886#[allow(dead_code)]
887impl WlShellSurfaceResize {
888    #[inline]
889    pub const fn empty() -> Self {
890        Self(0)
891    }
892
893    #[inline]
894    #[must_use]
895    pub const fn is_empty(self) -> bool {
896        self.0 == 0
897    }
898
899    #[inline]
900    #[must_use]
901    pub const fn contains(self, other: Self) -> bool {
902        self.0 & other.0 == other.0
903    }
904
905    #[inline]
906    #[must_use]
907    pub const fn intersects(self, other: Self) -> bool {
908        self.0 & other.0 != 0
909    }
910
911    #[inline]
912    pub const fn insert(&mut self, other: Self) {
913        *self = self.union(other);
914    }
915
916    #[inline]
917    pub const fn remove(&mut self, other: Self) {
918        *self = self.difference(other);
919    }
920
921    #[inline]
922    pub const fn toggle(&mut self, other: Self) {
923        *self = self.symmetric_difference(other);
924    }
925
926    #[inline]
927    pub const fn set(&mut self, other: Self, value: bool) {
928        if value {
929            self.insert(other);
930        } else {
931            self.remove(other);
932        }
933    }
934
935    #[inline]
936    #[must_use]
937    pub const fn intersection(self, other: Self) -> Self {
938        Self(self.0 & other.0)
939    }
940
941    #[inline]
942    #[must_use]
943    pub const fn union(self, other: Self) -> Self {
944        Self(self.0 | other.0)
945    }
946
947    #[inline]
948    #[must_use]
949    pub const fn difference(self, other: Self) -> Self {
950        Self(self.0 & !other.0)
951    }
952
953    #[inline]
954    #[must_use]
955    pub const fn complement(self) -> Self {
956        Self(!self.0)
957    }
958
959    #[inline]
960    #[must_use]
961    pub const fn symmetric_difference(self, other: Self) -> Self {
962        Self(self.0 ^ other.0)
963    }
964
965    #[inline]
966    pub const fn all_known() -> Self {
967        #[allow(clippy::eq_op, clippy::identity_op)]
968        Self(0 | 0 | 1 | 2 | 4 | 5 | 6 | 8 | 9 | 10)
969    }
970}
971
972impl Iterator for WlShellSurfaceResizeIter {
973    type Item = WlShellSurfaceResize;
974
975    fn next(&mut self) -> Option<Self::Item> {
976        if self.0 == 0 {
977            return None;
978        }
979        let bit = 1 << self.0.trailing_zeros();
980        self.0 &= !bit;
981        Some(WlShellSurfaceResize(bit))
982    }
983}
984
985impl IntoIterator for WlShellSurfaceResize {
986    type Item = WlShellSurfaceResize;
987    type IntoIter = WlShellSurfaceResizeIter;
988
989    fn into_iter(self) -> Self::IntoIter {
990        WlShellSurfaceResizeIter(self.0)
991    }
992}
993
994impl BitAnd for WlShellSurfaceResize {
995    type Output = Self;
996
997    fn bitand(self, rhs: Self) -> Self::Output {
998        self.intersection(rhs)
999    }
1000}
1001
1002impl BitAndAssign for WlShellSurfaceResize {
1003    fn bitand_assign(&mut self, rhs: Self) {
1004        *self = self.intersection(rhs);
1005    }
1006}
1007
1008impl BitOr for WlShellSurfaceResize {
1009    type Output = Self;
1010
1011    fn bitor(self, rhs: Self) -> Self::Output {
1012        self.union(rhs)
1013    }
1014}
1015
1016impl BitOrAssign for WlShellSurfaceResize {
1017    fn bitor_assign(&mut self, rhs: Self) {
1018        *self = self.union(rhs);
1019    }
1020}
1021
1022impl BitXor for WlShellSurfaceResize {
1023    type Output = Self;
1024
1025    fn bitxor(self, rhs: Self) -> Self::Output {
1026        self.symmetric_difference(rhs)
1027    }
1028}
1029
1030impl BitXorAssign for WlShellSurfaceResize {
1031    fn bitxor_assign(&mut self, rhs: Self) {
1032        *self = self.symmetric_difference(rhs);
1033    }
1034}
1035
1036impl Sub for WlShellSurfaceResize {
1037    type Output = Self;
1038
1039    fn sub(self, rhs: Self) -> Self::Output {
1040        self.difference(rhs)
1041    }
1042}
1043
1044impl SubAssign for WlShellSurfaceResize {
1045    fn sub_assign(&mut self, rhs: Self) {
1046        *self = self.difference(rhs);
1047    }
1048}
1049
1050impl Not for WlShellSurfaceResize {
1051    type Output = Self;
1052
1053    fn not(self) -> Self::Output {
1054        self.complement()
1055    }
1056}
1057
1058impl Debug for WlShellSurfaceResize {
1059    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1060        let mut v = self.0;
1061        let mut first = true;
1062        if v & 1 == 1 {
1063            v &= !1;
1064            if first {
1065                first = false;
1066            } else {
1067                f.write_str(" | ")?;
1068            }
1069            f.write_str("TOP")?;
1070        }
1071        if v & 2 == 2 {
1072            v &= !2;
1073            if first {
1074                first = false;
1075            } else {
1076                f.write_str(" | ")?;
1077            }
1078            f.write_str("BOTTOM")?;
1079        }
1080        if v & 4 == 4 {
1081            v &= !4;
1082            if first {
1083                first = false;
1084            } else {
1085                f.write_str(" | ")?;
1086            }
1087            f.write_str("LEFT")?;
1088        }
1089        if v & 5 == 5 {
1090            v &= !5;
1091            if first {
1092                first = false;
1093            } else {
1094                f.write_str(" | ")?;
1095            }
1096            f.write_str("TOP_LEFT")?;
1097        }
1098        if v & 6 == 6 {
1099            v &= !6;
1100            if first {
1101                first = false;
1102            } else {
1103                f.write_str(" | ")?;
1104            }
1105            f.write_str("BOTTOM_LEFT")?;
1106        }
1107        if v & 8 == 8 {
1108            v &= !8;
1109            if first {
1110                first = false;
1111            } else {
1112                f.write_str(" | ")?;
1113            }
1114            f.write_str("RIGHT")?;
1115        }
1116        if v & 9 == 9 {
1117            v &= !9;
1118            if first {
1119                first = false;
1120            } else {
1121                f.write_str(" | ")?;
1122            }
1123            f.write_str("TOP_RIGHT")?;
1124        }
1125        if v & 10 == 10 {
1126            v &= !10;
1127            if first {
1128                first = false;
1129            } else {
1130                f.write_str(" | ")?;
1131            }
1132            f.write_str("BOTTOM_RIGHT")?;
1133        }
1134        if v != 0 {
1135            if first {
1136                first = false;
1137            } else {
1138                f.write_str(" | ")?;
1139            }
1140            write!(f, "0x{v:032x}")?;
1141        }
1142        if first {
1143            f.write_str("NONE")?;
1144        }
1145        Ok(())
1146    }
1147}
1148
1149/// details of transient behaviour
1150///
1151/// These flags specify details of the expected behaviour
1152/// of transient surfaces. Used in the set_transient request.
1153#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
1154#[allow(dead_code)]
1155pub struct WlShellSurfaceTransient(pub u32);
1156
1157/// An iterator over the set bits in a [WlShellSurfaceTransient].
1158///
1159/// You can construct this with the `IntoIterator` implementation of `WlShellSurfaceTransient`.
1160#[derive(Clone, Debug)]
1161#[allow(dead_code)]
1162pub struct WlShellSurfaceTransientIter(pub u32);
1163
1164impl WlShellSurfaceTransient {
1165    /// do not set keyboard focus
1166    #[allow(dead_code)]
1167    pub const INACTIVE: Self = Self(0x1);
1168}
1169
1170#[allow(dead_code)]
1171impl WlShellSurfaceTransient {
1172    #[inline]
1173    pub const fn empty() -> Self {
1174        Self(0)
1175    }
1176
1177    #[inline]
1178    #[must_use]
1179    pub const fn is_empty(self) -> bool {
1180        self.0 == 0
1181    }
1182
1183    #[inline]
1184    #[must_use]
1185    pub const fn contains(self, other: Self) -> bool {
1186        self.0 & other.0 == other.0
1187    }
1188
1189    #[inline]
1190    #[must_use]
1191    pub const fn intersects(self, other: Self) -> bool {
1192        self.0 & other.0 != 0
1193    }
1194
1195    #[inline]
1196    pub const fn insert(&mut self, other: Self) {
1197        *self = self.union(other);
1198    }
1199
1200    #[inline]
1201    pub const fn remove(&mut self, other: Self) {
1202        *self = self.difference(other);
1203    }
1204
1205    #[inline]
1206    pub const fn toggle(&mut self, other: Self) {
1207        *self = self.symmetric_difference(other);
1208    }
1209
1210    #[inline]
1211    pub const fn set(&mut self, other: Self, value: bool) {
1212        if value {
1213            self.insert(other);
1214        } else {
1215            self.remove(other);
1216        }
1217    }
1218
1219    #[inline]
1220    #[must_use]
1221    pub const fn intersection(self, other: Self) -> Self {
1222        Self(self.0 & other.0)
1223    }
1224
1225    #[inline]
1226    #[must_use]
1227    pub const fn union(self, other: Self) -> Self {
1228        Self(self.0 | other.0)
1229    }
1230
1231    #[inline]
1232    #[must_use]
1233    pub const fn difference(self, other: Self) -> Self {
1234        Self(self.0 & !other.0)
1235    }
1236
1237    #[inline]
1238    #[must_use]
1239    pub const fn complement(self) -> Self {
1240        Self(!self.0)
1241    }
1242
1243    #[inline]
1244    #[must_use]
1245    pub const fn symmetric_difference(self, other: Self) -> Self {
1246        Self(self.0 ^ other.0)
1247    }
1248
1249    #[inline]
1250    pub const fn all_known() -> Self {
1251        #[allow(clippy::eq_op, clippy::identity_op)]
1252        Self(0 | 0x1)
1253    }
1254}
1255
1256impl Iterator for WlShellSurfaceTransientIter {
1257    type Item = WlShellSurfaceTransient;
1258
1259    fn next(&mut self) -> Option<Self::Item> {
1260        if self.0 == 0 {
1261            return None;
1262        }
1263        let bit = 1 << self.0.trailing_zeros();
1264        self.0 &= !bit;
1265        Some(WlShellSurfaceTransient(bit))
1266    }
1267}
1268
1269impl IntoIterator for WlShellSurfaceTransient {
1270    type Item = WlShellSurfaceTransient;
1271    type IntoIter = WlShellSurfaceTransientIter;
1272
1273    fn into_iter(self) -> Self::IntoIter {
1274        WlShellSurfaceTransientIter(self.0)
1275    }
1276}
1277
1278impl BitAnd for WlShellSurfaceTransient {
1279    type Output = Self;
1280
1281    fn bitand(self, rhs: Self) -> Self::Output {
1282        self.intersection(rhs)
1283    }
1284}
1285
1286impl BitAndAssign for WlShellSurfaceTransient {
1287    fn bitand_assign(&mut self, rhs: Self) {
1288        *self = self.intersection(rhs);
1289    }
1290}
1291
1292impl BitOr for WlShellSurfaceTransient {
1293    type Output = Self;
1294
1295    fn bitor(self, rhs: Self) -> Self::Output {
1296        self.union(rhs)
1297    }
1298}
1299
1300impl BitOrAssign for WlShellSurfaceTransient {
1301    fn bitor_assign(&mut self, rhs: Self) {
1302        *self = self.union(rhs);
1303    }
1304}
1305
1306impl BitXor for WlShellSurfaceTransient {
1307    type Output = Self;
1308
1309    fn bitxor(self, rhs: Self) -> Self::Output {
1310        self.symmetric_difference(rhs)
1311    }
1312}
1313
1314impl BitXorAssign for WlShellSurfaceTransient {
1315    fn bitxor_assign(&mut self, rhs: Self) {
1316        *self = self.symmetric_difference(rhs);
1317    }
1318}
1319
1320impl Sub for WlShellSurfaceTransient {
1321    type Output = Self;
1322
1323    fn sub(self, rhs: Self) -> Self::Output {
1324        self.difference(rhs)
1325    }
1326}
1327
1328impl SubAssign for WlShellSurfaceTransient {
1329    fn sub_assign(&mut self, rhs: Self) {
1330        *self = self.difference(rhs);
1331    }
1332}
1333
1334impl Not for WlShellSurfaceTransient {
1335    type Output = Self;
1336
1337    fn not(self) -> Self::Output {
1338        self.complement()
1339    }
1340}
1341
1342impl Debug for WlShellSurfaceTransient {
1343    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1344        let mut v = self.0;
1345        let mut first = true;
1346        if v & 0x1 == 0x1 {
1347            v &= !0x1;
1348            if first {
1349                first = false;
1350            } else {
1351                f.write_str(" | ")?;
1352            }
1353            f.write_str("INACTIVE")?;
1354        }
1355        if v != 0 {
1356            if first {
1357                first = false;
1358            } else {
1359                f.write_str(" | ")?;
1360            }
1361            write!(f, "0x{v:032x}")?;
1362        }
1363        if first {
1364            f.write_str("0")?;
1365        }
1366        Ok(())
1367    }
1368}
1369
1370/// different method to set the surface fullscreen
1371///
1372/// Hints to indicate to the compositor how to deal with a conflict
1373/// between the dimensions of the surface and the dimensions of the
1374/// output. The compositor is free to ignore this parameter.
1375#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1376#[allow(dead_code)]
1377pub struct WlShellSurfaceFullscreenMethod(pub u32);
1378
1379impl WlShellSurfaceFullscreenMethod {
1380    /// no preference, apply default policy
1381    #[allow(dead_code)]
1382    pub const DEFAULT: Self = Self(0);
1383
1384    /// scale, preserve the surface's aspect ratio and center on output
1385    #[allow(dead_code)]
1386    pub const SCALE: Self = Self(1);
1387
1388    /// switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch
1389    #[allow(dead_code)]
1390    pub const DRIVER: Self = Self(2);
1391
1392    /// no upscaling, center on output and add black borders to compensate size mismatch
1393    #[allow(dead_code)]
1394    pub const FILL: Self = Self(3);
1395}
1396
1397impl Debug for WlShellSurfaceFullscreenMethod {
1398    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1399        let name = match *self {
1400            Self::DEFAULT => "DEFAULT",
1401            Self::SCALE => "SCALE",
1402            Self::DRIVER => "DRIVER",
1403            Self::FILL => "FILL",
1404            _ => return Debug::fmt(&self.0, f),
1405        };
1406        f.write_str(name)
1407    }
1408}
1409
1410/// Functional event handlers.
1411pub mod event_handlers {
1412    use super::*;
1413
1414    /// Event handler for ping events.
1415    pub struct Ping<F>(F);
1416    impl<F> WlShellSurfaceEventHandler for Ping<F>
1417    where
1418        F: Fn(&WlShellSurfaceRef, u32),
1419    {
1420        #[inline]
1421        fn ping(&self, _slf: &WlShellSurfaceRef, serial: u32) {
1422            self.0(_slf, serial)
1423        }
1424    }
1425
1426    /// Event handler for configure events.
1427    pub struct Configure<F>(F);
1428    impl<F> WlShellSurfaceEventHandler for Configure<F>
1429    where
1430        F: Fn(&WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1431    {
1432        #[inline]
1433        fn configure(
1434            &self,
1435            _slf: &WlShellSurfaceRef,
1436            edges: WlShellSurfaceResize,
1437            width: i32,
1438            height: i32,
1439        ) {
1440            self.0(_slf, edges, width, height)
1441        }
1442    }
1443
1444    /// Event handler for popup_done events.
1445    pub struct PopupDone<F>(F);
1446    impl<F> WlShellSurfaceEventHandler for PopupDone<F>
1447    where
1448        F: Fn(&WlShellSurfaceRef),
1449    {
1450        #[inline]
1451        fn popup_done(&self, _slf: &WlShellSurfaceRef) {
1452            self.0(_slf)
1453        }
1454    }
1455
1456    impl WlShellSurface {
1457        /// Creates an event handler for ping events.
1458        ///
1459        /// The event handler ignores all other events.
1460        #[allow(dead_code)]
1461        pub fn on_ping<F>(f: F) -> Ping<F>
1462        where
1463            F: Fn(&WlShellSurfaceRef, u32),
1464        {
1465            Ping(f)
1466        }
1467
1468        /// Creates an event handler for configure events.
1469        ///
1470        /// The event handler ignores all other events.
1471        #[allow(dead_code)]
1472        pub fn on_configure<F>(f: F) -> Configure<F>
1473        where
1474            F: Fn(&WlShellSurfaceRef, WlShellSurfaceResize, i32, i32),
1475        {
1476            Configure(f)
1477        }
1478
1479        /// Creates an event handler for popup_done events.
1480        ///
1481        /// The event handler ignores all other events.
1482        #[allow(dead_code)]
1483        pub fn on_popup_done<F>(f: F) -> PopupDone<F>
1484        where
1485            F: Fn(&WlShellSurfaceRef),
1486        {
1487            PopupDone(f)
1488        }
1489    }
1490}