diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-10 11:38:04 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-10 11:38:04 +0100 |
| commit | 12a4aa2963369680fbc2df4a13731a1aed20db92 (patch) | |
| tree | 9c352a9bc3abc4fc3ff4da875afa335895b1fe52 | |
| parent | e833a9d2318625eb641cff2edca9b5ca56594ce5 (diff) | |
emitting resize event
| -rw-r--r-- | src/events.h | 14 | ||||
| -rw-r--r-- | src/window.cc | 12 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/events.h b/src/events.h index c2820c5..db66571 100644 --- a/src/events.h +++ b/src/events.h @@ -6,16 +6,26 @@ #include "wlstate.h" enum event_kind_e { + EVENT_KIND_RESIZE, EVENT_KIND_CLOSE, }; +struct event_kind_resize_s { + i32 width, height; +}; + struct event_s { enum event_kind_e kind; struct window_s *window; + union { + struct event_kind_resize_s resize; + }; }; -#define WAYC_EVENT_INIT(kind, window) {kind, window} -#define WAYC_EVENT_CLOSE(window) WAYC_EVENT_INIT(EVENT_KIND_CLOSE, window) +#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_RESIZE(window, width, height) \ + WAYC_EVENT_INIT(EVENT_KIND_RESIZE, window, {{width, height}}) struct eventloop_s; diff --git a/src/window.cc b/src/window.cc index 99b168e..c0c8cd1 100644 --- a/src/window.cc +++ b/src/window.cc @@ -16,11 +16,17 @@ static void wayc_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel, i32 width, i32 height, struct wl_array *states) { - (void)data; (void)xdg_toplevel; - (void)width; - (void)height; (void)states; + + struct window_s *window = (struct window_s *)data; + wayc_notnull(window); + + struct eventloop_s *loop = window->loop; + wayc_notnull(loop); + + struct event_s event = WAYC_EVENT_RESIZE(window, width, height); + wayc_vec_push(&loop->events, &event); } static void wayc_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) { |
