summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylanddisplay.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-05-15 16:24:37 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-05-28 09:27:26 +0000
commit916944807b8c54e887959eef63c542d2f16afab1 (patch)
treedec2a0ec06a53ddfb18e87f5443bc56892aeeb01 /src/client/qwaylanddisplay.cpp
parent633d4e6fd121fe128aec78bb9c137c4f2f82f1ce (diff)
Client: Move cursor theme logic into its own class, QWaylandCursorTheme
...and out of QWaylandCursor. Encapsulates the ugly details of wayland cursor themes, and presents a simple interface. A theme is created with a given size and theme name. wl_cursor_images for a theme can be acquired through: wl_cursor_image *QWaylandCursorTheme::cursorImage(Qt::CursorShape shape); Change-Id: Ia6fc6f2997133ca25c1610ecdf075ecb5c4edbfa Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/client/qwaylanddisplay.cpp')
-rw-r--r--src/client/qwaylanddisplay.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index 6a6370bf9..1cb499f5e 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -159,9 +159,7 @@ QWaylandDisplay::~QWaylandDisplay(void)
delete mDndSelectionHandler.take();
#endif
#if QT_CONFIG(cursor)
- for (auto *cursorTheme : mCursorThemesBySize)
- wl_cursor_theme_destroy(cursorTheme);
- mCursorThemesBySize.clear();
+ qDeleteAll(mCursorThemesBySize);
#endif
if (mDisplay)
wl_display_disconnect(mDisplay);
@@ -502,13 +500,9 @@ void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, co
}
}
-struct ::wl_cursor_theme *QWaylandDisplay::loadCursorTheme(qreal devicePixelRatio)
+QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(qreal devicePixelRatio)
{
- QByteArray themeName = qgetenv("XCURSOR_THEME");
- if (themeName.isEmpty())
- themeName = QByteArray("default");
-
- int cursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE");
+ static int cursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE");
if (cursorSize <= 0)
cursorSize = 32;
if (compositorVersion() >= 3) // set_buffer_scale is not supported on earlier versions
@@ -517,13 +511,12 @@ struct ::wl_cursor_theme *QWaylandDisplay::loadCursorTheme(qreal devicePixelRati
if (auto *theme = mCursorThemesBySize.value(cursorSize, nullptr))
return theme;
- struct ::wl_cursor_theme *theme = wl_cursor_theme_load(themeName, cursorSize, shm()->object());
-
- if (!theme)
- qCWarning(lcQpaWayland) << "Could not load cursor theme" << themeName;
+ if (auto *theme = QWaylandCursorTheme::create(shm(), cursorSize)) {
+ mCursorThemesBySize[cursorSize] = theme;
+ return theme;
+ }
- mCursorThemesBySize[cursorSize] = theme;
- return theme;
+ return nullptr;
}
#endif // QT_CONFIG(cursor)