Wayland: Add a timerfd for animated cursors

This commit is contained in:
Emmanuel Gil Peyrot 2018-09-08 20:01:04 +02:00 committed by linkmauve
parent 685f2a5f91
commit dede6d6886
3 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -241,6 +241,7 @@ typedef struct _GLFWlibraryWayland
struct wl_cursor_theme* cursorTheme;
struct wl_surface* cursorSurface;
int cursorTimerfd;
uint32_t pointerSerial;
int32_t keyboardRepeatRate;

View File

@ -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
{