-
Notifications
You must be signed in to change notification settings - Fork 0
/
wl-globals.c
34 lines (27 loc) · 849 Bytes
/
wl-globals.c
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
#include <stdio.h>
#include <wayland-client.h>
void registry_receive(void *data, struct wl_registry *reg, uint32_t name,
const char *iface, uint32_t ver) {
(void)data;
(void)name;
(void)reg;
printf("%s version %d\n", iface, ver);
}
void noop() {}
static struct wl_registry_listener reg_impl = {
.global = registry_receive,
.global_remove = noop,
};
int main() {
struct wl_display *display = wl_display_connect(NULL);
struct wl_registry *reg = wl_display_get_registry(display);
wl_registry_add_listener(reg, ®_impl, NULL);
// Register globals and callbacks
wl_display_roundtrip(display);
// Receive callbacks.
// Without this, there is memory leak.
wl_display_roundtrip(display);
wl_registry_destroy(reg);
wl_display_disconnect(display);
return 0;
}