diff options
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"); +} |
