mirror of
https://github.com/glfw/glfw.git
synced 2025-01-19 06:25:54 +00:00
Wayland: Add a timerfd for animated cursors
This commit is contained in:
parent
685f2a5f91
commit
dede6d6886
@ -1068,6 +1068,7 @@ int _glfwPlatformInit(void)
|
|||||||
}
|
}
|
||||||
_glfw.wl.cursorSurface =
|
_glfw.wl.cursorSurface =
|
||||||
wl_compositor_create_surface(_glfw.wl.compositor);
|
wl_compositor_create_surface(_glfw.wl.compositor);
|
||||||
|
_glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -1145,6 +1146,8 @@ void _glfwPlatformTerminate(void)
|
|||||||
|
|
||||||
if (_glfw.wl.timerfd >= 0)
|
if (_glfw.wl.timerfd >= 0)
|
||||||
close(_glfw.wl.timerfd);
|
close(_glfw.wl.timerfd);
|
||||||
|
if (_glfw.wl.cursorTimerfd >= 0)
|
||||||
|
close(_glfw.wl.cursorTimerfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* _glfwPlatformGetVersionString(void)
|
const char* _glfwPlatformGetVersionString(void)
|
||||||
|
@ -241,6 +241,7 @@ typedef struct _GLFWlibraryWayland
|
|||||||
|
|
||||||
struct wl_cursor_theme* cursorTheme;
|
struct wl_cursor_theme* cursorTheme;
|
||||||
struct wl_surface* cursorSurface;
|
struct wl_surface* cursorSurface;
|
||||||
|
int cursorTimerfd;
|
||||||
uint32_t pointerSerial;
|
uint32_t pointerSerial;
|
||||||
|
|
||||||
int32_t keyboardRepeatRate;
|
int32_t keyboardRepeatRate;
|
||||||
|
@ -697,6 +697,7 @@ handleEvents(int timeout)
|
|||||||
struct pollfd fds[] = {
|
struct pollfd fds[] = {
|
||||||
{ wl_display_get_fd(display), POLLIN },
|
{ wl_display_get_fd(display), POLLIN },
|
||||||
{ _glfw.wl.timerfd, POLLIN },
|
{ _glfw.wl.timerfd, POLLIN },
|
||||||
|
{ _glfw.wl.cursorTimerfd, POLLIN },
|
||||||
};
|
};
|
||||||
ssize_t read_ret;
|
ssize_t read_ret;
|
||||||
uint64_t repeats, i;
|
uint64_t repeats, i;
|
||||||
@ -719,7 +720,7 @@ handleEvents(int timeout)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (poll(fds, 2, timeout) > 0)
|
if (poll(fds, 3, timeout) > 0)
|
||||||
{
|
{
|
||||||
if (fds[0].revents & POLLIN)
|
if (fds[0].revents & POLLIN)
|
||||||
{
|
{
|
||||||
@ -742,6 +743,15 @@ handleEvents(int timeout)
|
|||||||
_glfw.wl.keyboardLastScancode, GLFW_REPEAT,
|
_glfw.wl.keyboardLastScancode, GLFW_REPEAT,
|
||||||
_glfw.wl.xkb.modifiers);
|
_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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user