#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, ®istry_listener, NULL);
wl_display_roundtrip(display);
wl_display_disconnect(display);
return 0;
}