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
use wayland_sys::server::*;
use event_loop::{create_event_loop, EventLoop};
pub struct Display {
ptr: *mut wl_display,
}
pub fn create_display() -> (Display, EventLoop) {
unsafe {
let ptr = ffi_dispatch!(
WAYLAND_SERVER_HANDLE,
wl_display_create,
);
let el_ptr = ffi_dispatch!(
WAYLAND_SERVER_HANDLE,
wl_display_get_event_loop,
ptr
);
(Display { ptr: ptr }, create_event_loop(el_ptr, Some(ptr)))
}
}
impl Display {
pub fn flush_clients(&self) {
unsafe { ffi_dispatch!(
WAYLAND_SERVER_HANDLE,
wl_display_flush_clients,
self.ptr
)};
}
}
impl Drop for Display {
fn drop(&mut self) {
unsafe {
ffi_dispatch!(
WAYLAND_SERVER_HANDLE,
wl_display_destroy,
self.ptr
);
}
}
}