diff --git a/src/wl_init.c b/src/wl_init.c index 820a9142..52ae7716 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1068,6 +1068,7 @@ int _glfwPlatformInit(void) } _glfw.wl.cursorSurface = wl_compositor_create_surface(_glfw.wl.compositor); + _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); } return GLFW_TRUE; @@ -1145,6 +1146,8 @@ void _glfwPlatformTerminate(void) if (_glfw.wl.timerfd >= 0) close(_glfw.wl.timerfd); + if (_glfw.wl.cursorTimerfd >= 0) + close(_glfw.wl.cursorTimerfd); } const char* _glfwPlatformGetVersionString(void) diff --git a/src/wl_platform.h b/src/wl_platform.h index ef8419e7..010d749f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -241,6 +241,7 @@ typedef struct _GLFWlibraryWayland struct wl_cursor_theme* cursorTheme; struct wl_surface* cursorSurface; + int cursorTimerfd; uint32_t pointerSerial; int32_t keyboardRepeatRate; diff --git a/src/wl_window.c b/src/wl_window.c index c165ba73..b453e17a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -697,6 +697,7 @@ handleEvents(int timeout) struct pollfd fds[] = { { wl_display_get_fd(display), POLLIN }, { _glfw.wl.timerfd, POLLIN }, + { _glfw.wl.cursorTimerfd, POLLIN }, }; ssize_t read_ret; uint64_t repeats, i; @@ -719,7 +720,7 @@ handleEvents(int timeout) return; } - if (poll(fds, 2, timeout) > 0) + if (poll(fds, 3, timeout) > 0) { if (fds[0].revents & POLLIN) { @@ -742,6 +743,15 @@ handleEvents(int timeout) _glfw.wl.keyboardLastScancode, GLFW_REPEAT, _glfw.wl.xkb.modifiers); } + + if (fds[2].revents & POLLIN) + { + read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)); + if (read_ret != 8) + return; + + // TODO: implement! + } } else {