autotests: Use ShapeCursorSource to load reference cursor images in testPointerInput

This commit is contained in:
Vlad Zahorodnii 2024-02-02 18:45:05 +02:00
parent a472c90327
commit b1908949d0

View file

@ -38,17 +38,6 @@
namespace KWin namespace KWin
{ {
static PlatformCursorImage loadReferenceThemeCursor_helper(const KXcursorTheme &theme,
const QByteArray &name)
{
const QList<KXcursorSprite> sprites = theme.shape(name);
if (sprites.isEmpty()) {
return PlatformCursorImage();
}
return PlatformCursorImage(sprites.constFirst().data(), sprites.constFirst().hotspot());
}
static PlatformCursorImage loadReferenceThemeCursor(const QByteArray &name) static PlatformCursorImage loadReferenceThemeCursor(const QByteArray &name)
{ {
const Cursor *pointerCursor = Cursors::self()->mouse(); const Cursor *pointerCursor = Cursors::self()->mouse();
@ -58,20 +47,11 @@ static PlatformCursorImage loadReferenceThemeCursor(const QByteArray &name)
return PlatformCursorImage(); return PlatformCursorImage();
} }
PlatformCursorImage platformCursorImage = loadReferenceThemeCursor_helper(theme, name); ShapeCursorSource source;
if (!platformCursorImage.isNull()) { source.setShape(name);
return platformCursorImage; source.setTheme(theme);
}
const QList<QByteArray> alternativeNames = Cursor::cursorAlternativeNames(name); return PlatformCursorImage(source.image(), source.hotspot());
for (const QByteArray &alternativeName : alternativeNames) {
platformCursorImage = loadReferenceThemeCursor_helper(theme, alternativeName);
if (!platformCursorImage.isNull()) {
break;
}
}
return platformCursorImage;
} }
static PlatformCursorImage loadReferenceThemeCursor(const CursorShape &shape) static PlatformCursorImage loadReferenceThemeCursor(const CursorShape &shape)