diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-05-15 16:24:37 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-05-28 09:27:26 +0000 |
commit | 916944807b8c54e887959eef63c542d2f16afab1 (patch) | |
tree | dec2a0ec06a53ddfb18e87f5443bc56892aeeb01 /src/client/qwaylanddisplay.cpp | |
parent | 633d4e6fd121fe128aec78bb9c137c4f2f82f1ce (diff) | |
download | qtwayland-916944807b8c54e887959eef63c542d2f16afab1.tar.gz |
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.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 6a6370bf..1cb499f5 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) |