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
use decorated_surface::{self, DecoratedSurface, Handler as UserHandler};
use wayland_client::EventQueueHandle;
use wayland_client::protocol::wl_shell_surface;

////////////////////////////////////////
// wl_shell `Handler` implementations //
////////////////////////////////////////


impl<H> wl_shell_surface::Handler for DecoratedSurface<H>
    where H: UserHandler,
{
    fn ping(
        &mut self,
        _: &mut EventQueueHandle,
        me: &wl_shell_surface::WlShellSurface,
        serial: u32,
    ) {
        me.pong(serial);
    }

    fn configure(
        &mut self,
        evqh: &mut EventQueueHandle,
        _: &wl_shell_surface::WlShellSurface,
        edges: wl_shell_surface::Resize,
        width: i32,
        height: i32,
    ) {
        if let Some(handler) = decorated_surface::handler_mut(self) {
            let (w, h) = decorated_surface::subtract_borders(width, height);
            let configure = super::Configure::Wl(edges);
            handler.configure(evqh, configure, w, h)
        }
    }
}

declare_handler!(DecoratedSurface<H: [UserHandler]>, wl_shell_surface::Handler, wl_shell_surface::WlShellSurface);