summaryrefslogtreecommitdiff
path: root/globals.c
blob: 66c5bfbc592b58a04aea2c13b83879de8006dc2d (plain) (blame)
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
#include <stdio.h>
#include <stdint.h>
#include <wayland-client.h>

void plog(char *type, char *fmt, ...);
static void
registry_handle_global(void *data, struct wl_registry *registry,
		       uint32_t name, const char *interface, uint32_t version);
static void
registry_handle_global_remove(void *data, struct wl_registry *registry,
			      uint32_t name);

static const struct wl_registry_listener
registry_listener = {
	.global = registry_handle_global,
	.global_remove = registry_handle_global_remove,
};

static void
registry_handle_global(void *data, struct wl_registry *registry,
		       uint32_t name, const char *interface, uint32_t version)
{
	plog("info", "interface: %s, version: %d, name: %d", interface,
			version, name);
}

static void
registry_handle_global_remove(void *data, struct wl_registry *registry,
			      uint32_t name)
{
	plog("info", "interface with name %d removed", name);
}

void plog(char *type, char *fmt, ...)
{
	va_list args;

	va_start(args, fmt);
	fprintf(stderr, "%s",type);
	fprintf(stderr, ": ");
	vfprintf(stderr, fmt, args);
	putc('\n', stderr);
	va_end(args);
}

int main(void)
{
	struct wl_display *display;
	struct wl_registry *registry;

	display = wl_display_connect(NULL);
	if (!display) {
		plog("eror", "Unable to connect to wayland display");
		return 1;
	}
	plog("info", "Running wayland display");

	registry = wl_display_get_registry(display);
	wl_registry_add_listener(registry, &registry_listener, NULL);
	wl_display_roundtrip(display);

	wl_display_disconnect(display);
	return 0;
}