summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-02-10 07:41:11 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-02-10 07:41:11 +0100
commit5b5eb5a16969afc4862fac387940818efc26780a (patch)
treeb33d699e7c0d780d88b015f3f605cebc46258210 /src/utils.h
parent0a158275020e94d9395fadaec1db34a1031fe87c (diff)
how are we going to do this
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..a89f498
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <cstdio>
+#include <cstdlib>
+#include <stdint.h>
+
+extern "C" {
+#include "xdg-shell.h"
+#include <wayland-client.h>
+}
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+typedef int8_t i8;
+typedef int16_t i16;
+typedef int32_t i32;
+typedef int64_t i64;
+
+typedef struct wl_display *wl_display_t;
+typedef struct wl_registry *wl_registry_t;
+typedef struct wl_compositor *wl_compositor_t;
+typedef struct wl_surface *wl_surface_t;
+
+typedef struct xdg_wm_base *xdg_wm_base_t;
+typedef struct xdg_surface *xdg_surface_t;
+typedef struct xdg_toplevel *xdg_toplevel_t;
+
+[[noreturn]] static inline void wayc_panic_impl(const char *file, int line,
+ const char *func,
+ const char *fmt, ...) {
+ fprintf(stderr, "Panic at %s:%d in %s: ", file, line, func);
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ exit(EXIT_FAILURE);
+}
+
+#define wayc_panic(...) \
+ wayc_panic_impl(__FILE__, __LINE__, __func__, __VA_ARGS__)
+
+#define wayc_assert(expr) \
+ do { \
+ if (!(expr)) \
+ wayc_panic("Assertion failed: %s", #expr); \
+ } while (0)