Wayland: Avoid infinite timer fires if arrow cursor is animated
This commit is contained in:
parent
196a0b6b7e
commit
ad27452275
17
glfw/wl_window.c
vendored
17
glfw/wl_window.c
vendored
@ -683,7 +683,7 @@ static bool createXdgSurface(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setCursorImage(_GLFWwindow* window, _GLFWcursorWayland* cursorWayland)
|
setCursorImage(_GLFWwindow* window, _GLFWcursorWayland* cursorWayland, bool is_stack_cursor)
|
||||||
{
|
{
|
||||||
struct wl_cursor_image* image = NULL;
|
struct wl_cursor_image* image = NULL;
|
||||||
struct wl_buffer* buffer = NULL;
|
struct wl_buffer* buffer = NULL;
|
||||||
@ -695,9 +695,9 @@ setCursorImage(_GLFWwindow* window, _GLFWcursorWayland* cursorWayland)
|
|||||||
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, 0);
|
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, 0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if(cursorWayland->scale != scale) {
|
if (cursorWayland->scale != scale) {
|
||||||
struct wl_cursor *newCursor = _glfwLoadCursor(cursorWayland->shape, window->wl.cursorTheme);
|
struct wl_cursor *newCursor = _glfwLoadCursor(cursorWayland->shape, window->wl.cursorTheme);
|
||||||
if(newCursor != NULL) {
|
if (newCursor != NULL) {
|
||||||
cursorWayland->cursor = newCursor;
|
cursorWayland->cursor = newCursor;
|
||||||
cursorWayland->scale = scale;
|
cursorWayland->scale = scale;
|
||||||
} else {
|
} else {
|
||||||
@ -708,7 +708,7 @@ setCursorImage(_GLFWwindow* window, _GLFWcursorWayland* cursorWayland)
|
|||||||
return;
|
return;
|
||||||
image = cursorWayland->cursor->images[cursorWayland->currentImage];
|
image = cursorWayland->cursor->images[cursorWayland->currentImage];
|
||||||
buffer = wl_cursor_image_get_buffer(image);
|
buffer = wl_cursor_image_get_buffer(image);
|
||||||
if (image->delay) {
|
if (image->delay && !is_stack_cursor) {
|
||||||
changeTimerInterval(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, ms_to_monotonic_t(image->delay));
|
changeTimerInterval(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, ms_to_monotonic_t(image->delay));
|
||||||
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, 1);
|
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, 1);
|
||||||
} else {
|
} else {
|
||||||
@ -744,7 +744,7 @@ incrementCursorImage(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
cursor->wl.currentImage += 1;
|
cursor->wl.currentImage += 1;
|
||||||
cursor->wl.currentImage %= cursor->wl.cursor->image_count;
|
cursor->wl.currentImage %= cursor->wl.cursor->image_count;
|
||||||
setCursorImage(window, &cursor->wl);
|
setCursorImage(window, &cursor->wl, false);
|
||||||
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, cursor->wl.cursor->image_count > 1);
|
toggleTimer(&_glfw.wl.eventLoopData, _glfw.wl.cursorAnimationTimer, cursor->wl.cursor->image_count > 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1494,12 +1494,11 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
|||||||
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
||||||
{
|
{
|
||||||
if (cursor)
|
if (cursor)
|
||||||
setCursorImage(window, &cursor->wl);
|
setCursorImage(window, &cursor->wl, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_GLFWcursorWayland cursorWayland = {0};
|
_GLFWcursorWayland cursorWayland = {.shape = GLFW_ARROW_CURSOR};
|
||||||
cursorWayland.shape = GLFW_ARROW_CURSOR;
|
setCursorImage(window, &cursorWayland, true);
|
||||||
setCursorImage(window, &cursorWayland);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
else if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user