From 064aa3a1501a62cff114797efe604b0b32f79e69 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 Jun 2020 07:57:08 +0530 Subject: [PATCH] Wayland: Ensure cursor theme is loaded before trying to set cursor --- glfw/wl_window.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index a05edde6e..085d175b4 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -41,6 +41,12 @@ #include #include +static void +load_cursor_theme(_GLFWwindow* window) { + window->wl.cursorTheme = _wlCursorThemeManage( + _glfw.wl.cursorThemeManager, window->wl.cursorTheme, _wlCursorPxFromScale(window->wl.scale)); +} + static void setCursorImage(_GLFWwindow* window) { @@ -57,6 +63,7 @@ setCursorImage(_GLFWwindow* window) } else { if (cursorWayland->scale != scale) { + if (!window->wl.cursorTheme) load_cursor_theme(window); struct wl_cursor *newCursor = _glfwLoadCursor(cursorWayland->shape, window->wl.cursorTheme); if (newCursor != NULL) { cursorWayland->cursor = newCursor; @@ -125,9 +132,7 @@ static bool checkScaleChange(_GLFWwindow* window) { window->wl.scale = scale; wl_surface_set_buffer_scale(window->wl.surface, scale); - window->wl.cursorTheme = _wlCursorThemeManage(_glfw.wl.cursorThemeManager, - window->wl.cursorTheme, - _wlCursorPxFromScale(scale)); + load_cursor_theme(window); setCursorImage(window); return true; } @@ -838,6 +843,7 @@ try_cursor_names(struct wl_cursor_theme* theme, int arg_count, ...) { struct wl_cursor* _glfwLoadCursor(GLFWCursorShape shape, struct wl_cursor_theme* theme) { static bool warnings[GLFW_INVALID_CURSOR] = {0}; + if (!theme) return NULL; #define NUMARGS(...) (sizeof((const char*[]){__VA_ARGS__})/sizeof(const char*)) #define C(name, ...) case name: { \ ans = try_cursor_names(theme, NUMARGS(__VA_ARGS__), __VA_ARGS__); \