Try alternative cursor names in WaylandCursorTheme::get

If resolving a cursor fails, let's also try the alternative cursor
names.
This commit is contained in:
Martin Gräßlin 2016-02-22 13:19:01 +01:00
parent 72a25aa9ff
commit 5b945d2b1c

View file

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wayland_cursor_theme.h" #include "wayland_cursor_theme.h"
#include "cursor.h" #include "cursor.h"
#include "wayland_server.h" #include "wayland_server.h"
// Qt
#include <QVector>
// KWayland // KWayland
#include <KWayland/Client/shm_pool.h> #include <KWayland/Client/shm_pool.h>
#include <KWayland/Server/display.h> #include <KWayland/Server/display.h>
@ -85,10 +87,22 @@ wl_cursor_image *WaylandCursorTheme::get(Qt::CursorShape shape)
// loading cursor failed // loading cursor failed
return nullptr; 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) { if (!c || c->image_count <= 0) {
return nullptr; return nullptr;
} }
// TODO: who deletes c?
return c->images[0]; return c->images[0];
} }