summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-02-10 11:40:59 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-02-10 11:40:59 +0100
commit0d62b836f33bd7029e769ffe1a823d7fcec0a8ff (patch)
tree312dce9c8359639951af4171e186f2872214b66a
parent12a4aa2963369680fbc2df4a13731a1aed20db92 (diff)
use type decl
-rw-r--r--src/events.h19
-rw-r--r--src/vec.h5
2 files changed, 16 insertions, 8 deletions
diff --git a/src/events.h b/src/events.h
index db66571..16bf1d3 100644
--- a/src/events.h
+++ b/src/events.h
@@ -14,18 +14,25 @@ struct event_kind_resize_s {
i32 width, height;
};
+union event_kind_data_u {
+ struct event_kind_resize_s resize;
+};
+
struct event_s {
enum event_kind_e kind;
struct window_s *window;
- union {
- struct event_kind_resize_s resize;
- };
+ union event_kind_data_u data;
};
-#define WAYC_EVENT_INIT(kind, window, ...) {kind, window, __VA_ARGS__}
-#define WAYC_EVENT_CLOSE(window) WAYC_EVENT_INIT(EVENT_KIND_CLOSE, window, {})
+#define WAYC_EVENT_INIT(kind, window, ...) \
+ event_s { kind, window, __VA_ARGS__ }
+
+#define WAYC_EVENT_CLOSE(window) \
+ WAYC_EVENT_INIT(EVENT_KIND_CLOSE, window, event_kind_data_u{})
+
#define WAYC_EVENT_RESIZE(window, width, height) \
- WAYC_EVENT_INIT(EVENT_KIND_RESIZE, window, {{width, height}})
+ WAYC_EVENT_INIT(EVENT_KIND_RESIZE, window, \
+ event_kind_data_u{event_kind_resize_s{width, height}})
struct eventloop_s;
diff --git a/src/vec.h b/src/vec.h
index 5cef8a3..6224574 100644
--- a/src/vec.h
+++ b/src/vec.h
@@ -11,7 +11,7 @@ struct raw_vec_s {
usize len, cap;
};
-#define WAYC_RAW_VEC_INIT(size) {nullptr, size, 0, 0}
+#define WAYC_RAW_VEC_INIT(size) raw_vec_s{nullptr, size, 0, 0}
void wayc_raw_vec_push(raw_vec_s *vec, const u8 *at);
bool wayc_raw_vec_pop(raw_vec_s *vec, u8 *out);
@@ -21,7 +21,8 @@ template <typename T> struct vec_s {
raw_vec_s raw;
};
-#define WAYC_VEC_INIT(type) {WAYC_RAW_VEC_INIT(sizeof(type))}
+#define WAYC_VEC_INIT(type) \
+ vec_s<type> { WAYC_RAW_VEC_INIT(sizeof(type)) }
template <typename T>
static inline void wayc_vec_push(vec_s<T> *vec, const T *at) {