wlroots 0.4.0

Wayland compositor framework
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
use std::{ptr::NonNull, cell::Cell, rc::{Rc, Weak}};

use libc::{self, size_t, int16_t, uint16_t};

use wayland_sys::server::WAYLAND_SERVER_HANDLE;
use wlroots_sys::{pid_t, wl_event_source, wlr_xwayland_surface, xcb_atom_t, xcb_window_t,
                  wlr_xwayland_surface_configure, wlr_xwayland_surface_activate};

use {area::{Area, Size, Origin},
     compositor,
     surface::{self, InternalState},
     xwayland,
     utils::{self, HandleErr, HandleResult, Handleable, c_to_rust_string}};
pub use xwayland::hints::{Hints, SizeHints};

pub type Handle = utils::Handle<(), wlr_xwayland_surface, Surface>;

#[allow(unused_variables)]
pub trait Handler {
    /// Called when the XWayland surface is destroyed (e.g by the user).
    fn destroyed(&mut self,
                 compositor_handle: compositor::Handle,
                 surface_handle: Option<surface::Handle>,
                 xwayland_surface_handle: Handle) {}

    /// Called when the XWayland surface wants to be configured.
    fn on_configure(&mut self,
                    compositor_handle: compositor::Handle,
                    surface_handle: Option<surface::Handle>,
                    xwayland_surface_handle: Handle,
                    configure: &xwayland::event::Configure) {
    }

    /// Called when the XWayland surface wants to move.
    fn on_move(&mut self,
               compositor_handle: compositor::Handle,
               surface_handle: Option<surface::Handle>,
               xwayland_surface_handle: Handle,
               event: &xwayland::event::Move) {}

    /// Called when the XWayland surface wants to be resized.
    fn on_resize(&mut self,
                 compositor_handle: compositor::Handle,
                 surface_handle: Option<surface::Handle>,
                 xwayland_surface_handle: Handle,
                 event: &xwayland::event::Resize) {}

    /// Called when the XWayland surface wants to be maximized.
    fn on_maximize(&mut self, compositor_handle: compositor::Handle,
                   surface_handle: Option<surface::Handle>,
                   xwayland_surface_handle: Handle) {}

    /// Called when the XWayland surface wants to be fullscreen.
    fn on_fullscreen(&mut self,
                     compositor_handle: compositor::Handle,
                     surface_handle: Option<surface::Handle>,
                     xwayland_surface_handle: Handle) {}

    fn on_map(&mut self,
              compositor_handle: compositor::Handle,
              surface_handle: Option<surface::Handle>,
              xwayland_surface_handle: Handle)
              -> Option<Box<surface::Handler>> { None }

    fn on_unmap(&mut self,
                compositor_handle: compositor::Handle,
                surface_handle: Option<surface::Handle>,
                xwayland_surface_handle: Handle) {}

    /// Called when the title has been set on the XWayland surface.
    fn title_set(&mut self,
                 compositor_handle: compositor::Handle,
                 surface_handle: Option<surface::Handle>,
                 xwayland_surface_handle: Handle) {}

    /// Called when the class has been set on the XWayland surface.
    fn class_set(&mut self,
                 compositor_handle: compositor::Handle,
                 surface_handle: Option<surface::Handle>,
                 xwayland_surface_handle: Handle) {}

    /// Called when the parent has been set on the XWayland surface.
    fn parent_set(&mut self,
                  compositor_handle: compositor::Handle,
                  surface_handle: Option<surface::Handle>,
                  xwayland_surface_handle: Handle) {}

    /// Called when the PID has been set on the XWayland surface.
    fn pid_set(&mut self,
               compositor_handle: compositor::Handle,
               surface_handle: Option<surface::Handle>,
               xwayland_surface_handle: Handle) {}

    /// Called when the window type has been set on the XWayland surface.
    fn window_type_set(&mut self,
                       compositor_handle: compositor::Handle,
                       surface_handle: Option<surface::Handle>,
                       xwayland_surface_handle: Handle) {}

    /// Called when the ping request timed out.
    ///
    /// This usually indicates something is wrong with the client.
    fn ping_timeout(&mut self,
                    compositor_handle: compositor::Handle,
                    surface_handle: Option<surface::Handle>,
                    xwayland_surface_handle: Handle) {}
}

wayland_listener!(pub(crate) Shell, (Surface, Option<Box<Handler>>), [
    destroy_listener => destroy_notify: |this: &mut Shell, data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.destroyed(compositor, surface, shell_surface.weak_reference());
        let surface_ptr = data as *mut wlr_xwayland_surface;
        let shell_state_ptr = (*surface_ptr).data as *mut State;
        if let Some(shell_ptr) = (*shell_state_ptr).shell {
            Box::from_raw(shell_ptr.as_ptr());
        }
    };
    request_configure_listener => request_configure_notify: |this: &mut Shell,
                                                             data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        let event = xwayland::event::Configure::from_ptr(data as *mut _);
        manager.on_configure(compositor,
                             surface,
                             shell_surface.weak_reference(),
                             &event);
    };
    request_move_listener => request_move_notify: |this: &mut Shell,
                                                   data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        let event = xwayland::event::Move::from_ptr(data as *mut _);
        manager.on_move(compositor,
                             surface,
                             shell_surface.weak_reference(),
                             &event);
    };
    request_resize_listener => request_resize_notify: |this: &mut Shell,
                                                       data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        let event = xwayland::event::Resize::from_ptr(data as *mut _);
        manager.on_resize(compositor,
                             surface,
                             shell_surface.weak_reference(),
                             &event);
    };
    request_maximize_listener => request_maximize_notify: |this: &mut Shell,
                                                           _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.on_maximize(compositor,
                             surface,
                             shell_surface.weak_reference());
    };
    request_fullscreen_listener => request_fullscreen_notify: |this: &mut Shell,
                                                               _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.on_fullscreen(compositor,
                            surface,
                            shell_surface.weak_reference());
    };
    map_listener => map_notify: |this: &mut Shell, _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        let surface_handler = manager.on_map(compositor,
                                             surface,
                                             shell_surface.weak_reference());

        if let Some(surface_handler) = surface_handler {
            let surface_state = (*(*shell_surface.shell_surface.as_ptr()).surface).data as *mut InternalState;
            (*(*surface_state).surface.unwrap().as_ptr()).data().1 = surface_handler;
        }

    };
    unmap_listener => unmap_notify: |this: &mut Shell, _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.on_unmap(compositor,
                       surface,
                       shell_surface.weak_reference());
    };
    set_title_listener => set_title_notify: |this: &mut Shell, _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.title_set(compositor,
                       surface,
                       shell_surface.weak_reference());
    };
    set_class_listener => set_class_notify: |this: &mut Shell, _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.class_set(compositor,
                       surface,
                       shell_surface.weak_reference());
    };
    set_parent_listener => set_parent_notify: |this: &mut Shell, _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.parent_set(compositor,
                       surface,
                       shell_surface.weak_reference());
    };
    set_pid_listener => set_pid_notify: |this: &mut Shell, _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.pid_set(compositor,
                       surface,
                       shell_surface.weak_reference());
    };
    set_window_type_listener => set_window_type_notify: |this: &mut Shell,
                                                         _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.window_type_set(compositor,
                       surface,
                       shell_surface.weak_reference());
    };
    ping_timeout_listener => ping_timeout_notify: |this: &mut Shell,
                                                   _data: *mut libc::c_void,|
    unsafe {
        let (ref mut shell_surface, ref mut manager) = match &mut this.data {
            (_, None) => return,
            (ss, Some(manager)) => (ss, manager)
        };
        let surface = shell_surface.surface();
        let compositor = match compositor::handle() {
            Some(handle) => handle,
            None => return
        };
        manager.ping_timeout(compositor,
                             surface,
                             shell_surface.weak_reference());
    };
]);

pub(crate) struct State {
    pub(crate) shell: Option<NonNull<Shell>>,
    handle: Weak<Cell<bool>>
}

/// An Xwayland user interface component. It has an absolute position in
/// layout-local coordinates.
///
/// When a surface is ready to be displayed, the `map` event is emitted. When a
/// surface should no longer be displayed, the `unmap` event is emitted.
///
/// The `unmap` event is guaranteed to be emitted before the `destroy` event if the
/// view is destroyed when mapped.
#[derive(Debug)]
pub struct Surface {
    liveliness: Rc<Cell<bool>>,
    shell_surface: NonNull<wlr_xwayland_surface>
}

impl Surface {
    pub(crate) unsafe fn new(shell_surface: *mut wlr_xwayland_surface) -> Self {
        let shell_surface = NonNull::new(shell_surface)
            .expect("Shell Surface pointer was null");
        if !(*shell_surface.as_ptr()).data.is_null() {
            panic!("Shell surface has already been created");
        }
        let liveliness = Rc::new(Cell::new(false));
        let state = Box::new(State { shell: None, handle: Rc::downgrade(&liveliness) });
        (*shell_surface.as_ptr()).data = Box::into_raw(state) as *mut _;
        Surface { liveliness,
                  shell_surface }
    }

    /// Get the window id for this surface.
    pub fn window_id(&self) -> xcb_window_t {
        unsafe { (*self.shell_surface.as_ptr()).window_id }
    }

    /// Get the surface id for this surface.
    pub fn surface_id(&self) -> u32 {
        unsafe { (*self.shell_surface.as_ptr()).surface_id }
    }

    /// Get the Wayland surface associated with this Surface. If the shell surface is not
    /// mapped, then it has no surface, and this will return None.
    pub fn surface(&self) -> Option<surface::Handle> {
        unsafe {
            let surface = (*self.shell_surface.as_ptr()).surface;

            if surface.is_null() {
                None
            } else {
                Some(surface::Handle::from_ptr((*self.shell_surface.as_ptr()).surface))
            }
        }
    }

    /// Get the coordinates of the window.
    ///
    /// Return format is (x, y)
    pub fn coords(&self) -> (int16_t, int16_t) {
        unsafe { ((*self.shell_surface.as_ptr()).x, (*self.shell_surface.as_ptr()).y) }
    }

    /// Get the dimensions the XWayland surface.
    ///
    /// Return format is (width, height).
    pub fn dimensions(&self) -> (uint16_t, uint16_t) {
        unsafe { ((*self.shell_surface.as_ptr()).width, (*self.shell_surface.as_ptr()).height) }
    }

    /// TODO What does this represent?
    ///
    /// Return format is (width, height)
    pub fn saved_dimensions(&self) -> (uint16_t, uint16_t) {
        unsafe { ((*self.shell_surface.as_ptr()).saved_width, (*self.shell_surface.as_ptr()).saved_height) }
    }

    /// TODO What does this represent?
    pub fn override_redirect(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).override_redirect }
    }

    pub fn mapped(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).mapped }
    }

    /// Get the title of the client, if there is one.
    pub fn title(&self) -> Option<String> {
        unsafe { c_to_rust_string((*self.shell_surface.as_ptr()).title) }
    }

    /// Get the class of the client, if there is one.
    pub fn class(&self) -> Option<String> {
        unsafe { c_to_rust_string((*self.shell_surface.as_ptr()).class) }
    }

    /// Get the instance of the client, if there is one.
    pub fn instance(&self) -> Option<String> {
        unsafe { c_to_rust_string((*self.shell_surface.as_ptr()).instance) }
    }

    /// Get the PID associated with the client.
    pub fn pid(&self) -> pid_t {
        unsafe { (*self.shell_surface.as_ptr()).pid }
    }

    // TODO
    //pub fn has_utf8_title(&self) -> bool {
    //    unsafe { (*self.shell_surface.as_ptr()).has_utf8_title }
    //}

    /// Get the parent surface if there is one.
    pub fn parent(&self) -> Option<Handle> {
        unsafe {
            let parent_ptr = (*self.shell_surface.as_ptr()).parent;
            if parent_ptr.is_null() {
                None
            } else {
                Some(Handle::from_ptr(parent_ptr))
            }
        }
    }

    /// Get the list of children surfaces.
    pub fn children(&self) -> Vec<Handle> {
        unsafe {
            let mut result = Vec::new();
            wl_list_for_each!((*self.shell_surface.as_ptr()).children,
                              parent_link,
                              (child: wlr_xwayland_surface) => {
                                  result.push(Handle::from_ptr(child))
                              });
            result
        }
    }

    /// Get the type of the window from xcb.
    pub unsafe fn window_type(&self) -> *mut xcb_atom_t {
        (*self.shell_surface.as_ptr()).window_type
    }

    /// Get the length of the window_type ptr
    pub unsafe fn window_type_len(&self) -> size_t {
        (*self.shell_surface.as_ptr()).window_type_len
    }

    /// Get the protocols of the client.
    pub unsafe fn protocols(&self) -> *mut xcb_atom_t {
        (*self.shell_surface.as_ptr()).protocols
    }

    /// Get the length of the protocols ptr.
    pub unsafe fn protocols_len(&self) -> size_t {
        (*self.shell_surface.as_ptr()).protocols_len
    }

    /// Get the decorations on this XWayland client.
    pub fn decorations(&self) -> u32 {
        unsafe { (*self.shell_surface.as_ptr()).decorations }
    }

    /// Get any surface hints the client is providing.
    pub fn hints<'surface>(&'surface self) -> xwayland::surface::Hints<'surface> {
        unsafe { xwayland::surface::Hints::from_ptr((*self.shell_surface.as_ptr()).hints) }
    }

    /// Get any size hints the client is providing.
    pub fn size_hints<'surface>(&'surface self) -> xwayland::surface::SizeHints<'surface> {
        unsafe { xwayland::surface::SizeHints::from_ptr((*self.shell_surface.as_ptr()).size_hints) }
    }

    /// Get the urgency of the hints.
    pub fn hints_urgency(&self) -> u32 {
        unsafe { (*self.shell_surface.as_ptr()).hints_urgency }
    }

    pub fn pinging(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).pinging }
    }

    pub unsafe fn ping_timer(&self) -> *mut wl_event_source {
        (*self.shell_surface.as_ptr()).ping_timer
    }

    /// Determine if the client is fullscreen or not.
    pub fn fullscreen(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).fullscreen }
    }

    /// Determine if the client is maximized vertically.
    pub fn maximized_vert(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).maximized_vert }
    }

    /// Determine if the client is maximized horizontally.
    pub fn maximized_horz(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).maximized_horz }
    }

    /// Determine if the client has an alpha channel.
    pub fn has_alpha(&self) -> bool {
        unsafe { (*self.shell_surface.as_ptr()).has_alpha }
    }

    /// Geometry of the surface in layout-local coordinates
    pub fn geometry(&self) -> Area {
        let (x, y, width, height) = unsafe {
            (
                (*self.shell_surface.as_ptr()).x as i32,
                (*self.shell_surface.as_ptr()).y as i32,
                (*self.shell_surface.as_ptr()).width as i32,
                (*self.shell_surface.as_ptr()).height as i32
            )
        };
        Area {
            origin: Origin { x, y },
            size: Size { width, height }
        }
    }

    /// Send the surface a configure request, requesting the new position and dimensions
    pub fn configure(&self, x: i16, y: i16, width: u16, height: u16) {
        unsafe {
            wlr_xwayland_surface_configure(self.shell_surface.as_ptr(), x, y, width, height);
        }
    }

    /// Tell the window whether it is the foucsed window
    pub fn set_activated(&self, active: bool) {
        unsafe { wlr_xwayland_surface_activate(self.shell_surface.as_ptr(), active); }
    }
}

impl Drop for Surface {
    fn drop(&mut self) {
        if Rc::strong_count(&self.liveliness) > 1 {
            return
        }
        unsafe {
            Box::from_raw((*self.shell_surface.as_ptr()).data as *mut State);
        }
    }
}

impl Handleable<(), wlr_xwayland_surface> for Surface {
    #[doc(hidden)]
    unsafe fn from_ptr(shell_surface: *mut wlr_xwayland_surface) -> Option<Self> {
        let shell_surface = NonNull::new(shell_surface)?;
        let data = (*shell_surface.as_ptr()).data as *mut State;
        let liveliness = (*data).handle.upgrade().unwrap();
        Some(Surface { liveliness, shell_surface })
    }

    #[doc(hidden)]
    unsafe fn as_ptr(&self) -> *mut wlr_xwayland_surface {
        self.shell_surface.as_ptr()
    }

    #[doc(hidden)]
    unsafe fn from_handle(handle: &Handle) -> HandleResult<Self> {
        let liveliness = handle.handle
            .upgrade()
            .ok_or_else(|| HandleErr::AlreadyDropped)?;
        Ok(Surface { liveliness,
                     shell_surface: handle.as_non_null() })
    }

    /// Creates a weak reference to an `Surface`.
    fn weak_reference(&self) -> Handle {
        Handle { ptr: self.shell_surface,
                 handle: Rc::downgrade(&self.liveliness),
                 _marker: std::marker::PhantomData,
                 data: Some(()) }
    }
}

impl Drop for Shell {
    fn drop(&mut self) {
        unsafe {
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.destroy_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.request_configure_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.request_move_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.request_resize_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.request_maximize_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.request_fullscreen_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.map_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.unmap_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.set_title_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.set_class_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.set_parent_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.set_pid_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.set_window_type_listener() as *mut _ as _);
            ffi_dispatch!(WAYLAND_SERVER_HANDLE,
                          wl_list_remove,
                          self.ping_timeout_listener() as *mut _ as _);
        }
    }
}