diff --git a/src/wl_init.c b/src/wl_init.c index cdbfcf1e7..aac6c5057 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -1152,6 +1153,8 @@ int _glfwPlatformInit(void) if (_glfw.wl.seatVersion >= 4) _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + _glfw.wl.eventfd = eventfd(0, 0); + if (!_glfw.wl.wmBase) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1288,6 +1291,8 @@ void _glfwPlatformTerminate(void) if (_glfw.wl.timerfd >= 0) close(_glfw.wl.timerfd); + if (_glfw.wl.eventfd >= 0) + close(_glfw.wl.eventfd); if (_glfw.wl.cursorTimerfd >= 0) close(_glfw.wl.cursorTimerfd); diff --git a/src/wl_platform.h b/src/wl_platform.h index 13f4ab31e..b85140d81 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -259,6 +259,7 @@ typedef struct _GLFWlibraryWayland char* clipboardSendString; size_t clipboardSendSize; int timerfd; + int eventfd; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; diff --git a/src/wl_window.c b/src/wl_window.c index 5c7011fdb..1db23c848 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -709,6 +710,7 @@ static void handleEvents(int timeout) { wl_display_get_fd(display), POLLIN }, { _glfw.wl.timerfd, POLLIN }, { _glfw.wl.cursorTimerfd, POLLIN }, + { _glfw.wl.eventfd, POLLIN }, }; ssize_t read_ret; uint64_t repeats, i; @@ -731,7 +733,7 @@ static void handleEvents(int timeout) return; } - if (poll(fds, 3, timeout) > 0) + if (poll(fds, 4, timeout) > 0) { if (fds[0].revents & POLLIN) { @@ -763,6 +765,11 @@ static void handleEvents(int timeout) incrementCursorImage(_glfw.wl.pointerFocus); } + + if (fds[3].revents & POLLIN) + { + read_ret = read(_glfw.wl.eventfd, &repeats, sizeof(repeats)); + } } else { @@ -1176,7 +1183,8 @@ void _glfwPlatformWaitEventsTimeout(double timeout) void _glfwPlatformPostEmptyEvent(void) { - wl_display_sync(_glfw.wl.display); + uint64_t value = 1; + write(_glfw.wl.eventfd, &value, sizeof value); } void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)