From 888ce66e186e2892bc30afb5bb97918d504e0ba1 Mon Sep 17 00:00:00 2001 From: Fabrice Date: Tue, 10 Feb 2026 08:48:01 +0100 Subject: event loop --- src/wlstate.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/wlstate.cc') 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 #include -#include #include #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"); +} -- cgit v1.2.3