Fall back to breeze_cursors if neither configured nor default can be loaded

Try harder to get some cursor theme loaded, otherwise the cursor is
invisible, which also makes it hard to fix the configuration.

Also add some warnings instead of failing silently.
This commit is contained in:
Fabian Vogt 2024-04-16 09:49:03 +02:00
parent 98747246cd
commit 01d224fa22
3 changed files with 19 additions and 0 deletions

View file

@ -345,6 +345,11 @@ int Cursor::defaultThemeSize()
return 24;
}
QString Cursor::fallbackThemeName()
{
return QStringLiteral("breeze_cursors");
}
QList<QByteArray> CursorShape::alternatives(const QByteArray &name)
{
static const QHash<QByteArray, QList<QByteArray>> alternatives = {

View file

@ -149,6 +149,10 @@ public:
* Returns the default Xcursor theme size.
*/
static int defaultThemeSize();
/**
* Returns the fallback Xcursor theme name.
*/
static QString fallbackThemeName();
/**
* Returns the current cursor position. This method does an update of the mouse position if

View file

@ -1139,7 +1139,17 @@ void WaylandCursorImage::updateCursorTheme()
m_cursorTheme = KXcursorTheme(pointerCursor->themeName(), pointerCursor->themeSize(), targetDevicePixelRatio);
if (m_cursorTheme.isEmpty()) {
qCWarning(KWIN_CORE) << "Failed to load cursor theme" << pointerCursor->themeName();
m_cursorTheme = KXcursorTheme(Cursor::defaultThemeName(), Cursor::defaultThemeSize(), targetDevicePixelRatio);
if (m_cursorTheme.isEmpty()) {
qCWarning(KWIN_CORE) << "Failed to load cursor theme" << Cursor::defaultThemeName();
m_cursorTheme = KXcursorTheme(Cursor::fallbackThemeName(), Cursor::defaultThemeSize(), targetDevicePixelRatio);
}
}
if (m_cursorTheme.isEmpty()) {
qCWarning(KWIN_CORE) << "Unable to load any cursor theme";
}
Q_EMIT themeChanged();