diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/events.h | 19 | ||||
| -rw-r--r-- | src/vec.h | 5 |
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; @@ -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) { |
