From 8b023ac628a2411b6c798c32ac65d0fec31efd84 Mon Sep 17 00:00:00 2001 From: itycodes Date: Tue, 1 Oct 2024 04:09:34 +0200 Subject: [PATCH] Initial commit --- Makefile | 16 ++++++++++++++++ main.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Makefile create mode 100644 main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..efc6db5 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: all clean + +CC = gcc +CLIBS = -lwayland-client +CFLAGS = $(CLIBS) + +SRC = main.c +OUT = wl-globals + +all: $(OUT) + +clean: + rm -f $(OUT) + +$(OUT): $(SRC) + $(CC) $(SRC) $(CFLAGS) -o $(OUT) diff --git a/main.c b/main.c new file mode 100644 index 0000000..9eba009 --- /dev/null +++ b/main.c @@ -0,0 +1,41 @@ +#include +#include + +#include + +#define ASSERT(cond, msg)\ + if(!(cond)) {\ + fprintf(stderr, "Runtime assertion %s at %s:%d failed: %s\n", #cond, __FILE__, __LINE__, msg);\ + exit(-1);\ + } + +void handle_global( + void* data, + struct wl_registry* registry, + uint32_t name, + const char* interface, + uint32_t version) { + printf("%s\n", interface); +} + +void handle_global_remove( + void* data, + struct wl_registry* registry, + uint32_t name) { + // Who cares +} + +const struct wl_registry_listener reg_callbacks = { + .global = handle_global, + .global_remove = handle_global_remove, +}; + +int main() { + struct wl_display* dpy = wl_display_connect(NULL); + ASSERT(dpy != NULL, "Unable to connect to Wayland"); + + struct wl_registry* registry = wl_display_get_registry(dpy); + wl_registry_add_listener(registry, ®_callbacks, NULL); + wl_display_roundtrip(dpy); + return 0; +}