From 5b945d2b1c548e81c15cd765406ea979e54a1a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 22 Feb 2016 13:19:01 +0100 Subject: [PATCH] Try alternative cursor names in WaylandCursorTheme::get If resolving a cursor fails, let's also try the alternative cursor names. --- wayland_cursor_theme.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wayland_cursor_theme.cpp b/wayland_cursor_theme.cpp index 292ab8038f..dbd781213f 100644 --- a/wayland_cursor_theme.cpp +++ b/wayland_cursor_theme.cpp @@ -20,6 +20,8 @@ along with this program. If not, see . #include "wayland_cursor_theme.h" #include "cursor.h" #include "wayland_server.h" +// Qt +#include // KWayland #include #include @@ -85,10 +87,22 @@ wl_cursor_image *WaylandCursorTheme::get(Qt::CursorShape shape) // loading cursor failed return nullptr; } - wl_cursor *c = wl_cursor_theme_get_cursor(m_theme, Cursor::self()->cursorName(shape).constData()); + const QByteArray name = Cursor::self()->cursorName(shape); + wl_cursor *c = wl_cursor_theme_get_cursor(m_theme, name.constData()); + if (!c || c->image_count <= 0) { + const auto &names = Cursor::self()->cursorAlternativeNames(name); + for (auto it = names.begin(), end = names.end(); it != end; it++) { + c = wl_cursor_theme_get_cursor(m_theme, (*it).constData()); + if (c && c->image_count > 0) { + break; + } + } + return nullptr; + } if (!c || c->image_count <= 0) { return nullptr; } + // TODO: who deletes c? return c->images[0]; }