1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#pragma once
#include <stdint.h>
#include <wayland-client.h>
#include <cstdio>
#include <cstdlib>
#include "xdg-shell.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;
#if UINT64_MAX == UINTPTR_MAX
typedef u64 usize;
typedef i64 isize;
#elif UINT32_MAX == UINTPTR_MAX
typedef u32 usize;
typedef i32 isize;
#else
#error "Unsupported pointer size"
#endif
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;
static inline u32 wayc_min(u32 a, u32 b) { return a > b ? a : b; }
[[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)
#define wayc_notnull(expr) wayc_assert(expr != NULL)
|