diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-10 08:48:01 +0100 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-02-10 08:48:01 +0100 |
| commit | 888ce66e186e2892bc30afb5bb97918d504e0ba1 (patch) | |
| tree | d4aca9ebdfc04b00e6aa0f206c44c0794d6fd7d0 /src/wlstate.cc | |
| parent | d2e732c507c53ddca4c60a7aff650971545d7520 (diff) | |
event loop
Diffstat (limited to 'src/wlstate.cc')
| -rw-r--r-- | src/wlstate.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/wlstate.cc b/src/wlstate.cc index 9232843..1a02b5b 100644 --- a/src/wlstate.cc +++ b/src/wlstate.cc @@ -1,8 +1,8 @@ #include "wlstate.h" #include "utils.h" #include "xdg-shell.h" +#include <poll.h> #include <string.h> -#include <wayland-client-core.h> #include <wayland-client-protocol.h> #define WAYC_VERSION 1 @@ -91,3 +91,24 @@ void wayc_wl_state_deinit(struct wl_state_s *state) { wl_display_disconnect(state->display); } + +void wayc_wl_state_update(struct wl_state_s *state) { + wayc_assert(state != NULL); + + struct pollfd pfd = { + (i32)state->eventfd, + POLLIN, + 0, + }; + + i32 rc = poll(&pfd, 1, 0); + if (rc == -1) + wayc_panic("Failed to poll Wayland eventfd"); + + if (!(pfd.revents & POLLIN)) + return; + + rc = wl_display_dispatch(state->display); + if (rc == -1) + wayc_panic("Failed to dispatch Wayland events"); +} |
