diff --git a/README.md b/README.md index 388415f..7ced1f4 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,5 @@ ninja -C build ``` ```bash -./build/wayland_test_client +WAYLAND_DISPLAY=wayland-1 ./build/wayland_test_client ``` diff --git a/src/client/main.c b/src/client/main.c index bd9ac65..1ba7e1d 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -1,6 +1,28 @@ +#include #include #include +static void +registry_handle_global(void *data, struct wl_registry *registry, + uint32_t name, const char *interface, uint32_t version) +{ + printf("interface: '%s', version: %d, name: %d\n", + interface, version, name); +} + +static void +registry_handle_global_remove(void *data, struct wl_registry *registry, + uint32_t name) +{ + // This space deliberately left blank +} + +static const struct wl_registry_listener +registry_listener = { + .global = registry_handle_global, + .global_remove = registry_handle_global_remove, +}; + int main(int argc, char *argv[]) { struct wl_display *display = wl_display_connect(NULL); @@ -8,6 +30,11 @@ int main(int argc, char *argv[]) fprintf(stderr, "Failed to connect to Wayland display.\n"); return 1; } + + struct wl_registry *registry = wl_display_get_registry(display); + wl_registry_add_listener(registry, ®istry_listener, NULL); + wl_display_roundtrip(display); + fprintf(stderr, "Connection established!\n"); while (wl_display_dispatch(display) != -1) {