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
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
:option:`kitty --single-instance` using the :option:`kitty --override` command line
argument (:iss:`2806`)
- Wayland: Fix a crash when using animated mouse cursors (:iss:`2810`)
0.18.1 [2020-06-23]
--------------------

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