summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandcursor_p.h
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/qwaylandcursor_p.h
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/qwaylandcursor_p.h')
-rw-r--r--src/client/qwaylandcursor_p.h41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/client/qwaylandcursor_p.h b/src/client/qwaylandcursor_p.h
index 532e46c19..71f9cd1b8 100644
--- a/src/client/qwaylandcursor_p.h
+++ b/src/client/qwaylandcursor_p.h
@@ -68,19 +68,15 @@ namespace QtWaylandClient {
class QWaylandBuffer;
class QWaylandDisplay;
class QWaylandScreen;
+class QWaylandShm;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandCursor : public QPlatformCursor
+class Q_WAYLAND_CLIENT_EXPORT QWaylandCursorTheme
{
public:
- QWaylandCursor(QWaylandScreen *screen);
-
- void changeCursor(QCursor *cursor, QWindow *window) override;
- void pointerEvent(const QMouseEvent &event) override;
- QPoint pos() const override;
- void setPos(const QPoint &pos) override;
-
+ static QWaylandCursorTheme *create(QWaylandShm *shm, int size);
+ static QWaylandCursorTheme *create(QWaylandShm *shm, int size, const QString &themeName);
+ ~QWaylandCursorTheme();
struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
- QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
private:
enum WaylandCursor {
@@ -106,6 +102,7 @@ private:
DragCopyCursor,
DragMoveCursor,
DragLinkCursor,
+ // The following are used for cursors that don't have equivalents in Qt
ResizeNorthCursor = Qt::CustomCursor + 1,
ResizeSouthCursor,
ResizeEastCursor,
@@ -116,13 +113,29 @@ private:
ResizeSouthWestCursor
};
- struct wl_cursor* requestCursor(WaylandCursor shape);
- void initCursorMap();
+ explicit QWaylandCursorTheme(struct ::wl_cursor_theme *theme) : m_theme(theme) {}
+ struct ::wl_cursor *requestCursor(WaylandCursor shape);
+ struct ::wl_cursor_theme *m_theme = nullptr;
+ QMap<WaylandCursor, wl_cursor *> m_cursors;
+};
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandCursor : public QPlatformCursor
+{
+public:
+ QWaylandCursor(QWaylandScreen *screen);
+
+ void changeCursor(QCursor *cursor, QWindow *window) override;
+ void pointerEvent(const QMouseEvent &event) override;
+ QPoint pos() const override;
+ void setPos(const QPoint &pos) override;
+
+ QSharedPointer<QWaylandBuffer> cursorBitmapImage(const QCursor *cursor);
+ struct wl_cursor_image *cursorImage(Qt::CursorShape shape);
+
+private:
QWaylandDisplay *mDisplay = nullptr;
- struct wl_cursor_theme *mCursorTheme = nullptr;
+ QWaylandCursorTheme *mCursorTheme = nullptr;
QPoint mLastPos;
- QMap<WaylandCursor, wl_cursor *> mCursors;
- QMultiMap<WaylandCursor, QByteArray> mCursorNamesMap;
};
}