Wayland: Fix a crash when using animated mouse cursors

Fixes #2810
This commit is contained in:
Kovid Goyal
2020-06-29 08:03:25 +05:30
parent a9e739e08d
commit c68516ca8d
3 changed files with 6 additions and 2 deletions

2
glfw/wl_platform.h vendored
View File

@@ -287,7 +287,7 @@ typedef struct _GLFWcursorWayland
struct wl_buffer* buffer;
int width, height;
int xhot, yhot;
int currentImage;
unsigned int currentImage;
/** The scale of the cursor, or 0 if the cursor should be loaded late, or -1 if the cursor variable itself is unused. */
int scale;
/** Cursor shape stored to allow late cursor loading in setCursorImage. */

4
glfw/wl_window.c vendored
View File

@@ -68,12 +68,14 @@ setCursorImage(_GLFWwindow* window)
if (newCursor != NULL) {
cursorWayland->cursor = newCursor;
cursorWayland->scale = scale;
cursorWayland->currentImage = 0;
} else {
_glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: late cursor load failed; proceeding with existing cursor");
}
}
if (!cursorWayland->cursor)
if (!cursorWayland->cursor || !cursorWayland->cursor->image_count)
return;
if (cursorWayland->currentImage >= cursorWayland->cursor->image_count) cursorWayland->currentImage = 0;
image = cursorWayland->cursor->images[cursorWayland->currentImage];
buffer = wl_cursor_image_get_buffer(image);
if (image->delay && window->cursor) {