Finish 5.1 part

This commit is contained in:
Florian RICHER 2024-06-06 22:04:30 +02:00
parent d441d856d7
commit 67c20d47dd
2 changed files with 28 additions and 1 deletions

View file

@ -24,5 +24,5 @@ ninja -C build
```
```bash
./build/wayland_test_client
WAYLAND_DISPLAY=wayland-1 ./build/wayland_test_client
```

View file

@ -1,6 +1,28 @@
#include <stdint.h>
#include <stdio.h>
#include <wayland-client.h>
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, &registry_listener, NULL);
wl_display_roundtrip(display);
fprintf(stderr, "Connection established!\n");
while (wl_display_dispatch(display) != -1) {