commit
8b023ac628
@ -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)
|
@ -0,0 +1,41 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in new issue