diff --git a/docs/changelog.rst b/docs/changelog.rst index b6f47f238..1dca3091a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,8 @@ To update |kitty|, :doc:`follow the instructions `. :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] -------------------- diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index dcfa23b06..7b2191bdf 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -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. */ diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 3cebcabfe..58d474035 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -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) {