Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandcursor_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QWAYLANDCURSOR_H
6#define QWAYLANDCURSOR_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qpa/qplatformcursor.h>
20#include <QtCore/QMap>
21#include <QtWaylandClient/qtwaylandclientglobal.h>
22#include <QtWaylandClient/private/qwayland-cursor-shape-v1.h>
23#include <QtCore/private/qglobal_p.h>
24
25#if QT_CONFIG(cursor)
26
27#include <memory>
28
29struct wl_cursor;
30struct wl_cursor_image;
31struct wl_cursor_theme;
32
33QT_BEGIN_NAMESPACE
34
35namespace QtWaylandClient {
36
37class QWaylandBuffer;
38class QWaylandDisplay;
39class QWaylandScreen;
40class QWaylandShm;
41
42class Q_WAYLANDCLIENT_EXPORT QWaylandCursorTheme
43{
44public:
45 static std::unique_ptr<QWaylandCursorTheme> create(QWaylandShm *shm, int size, const QString &themeName);
46 ~QWaylandCursorTheme();
47 ::wl_cursor *cursor(Qt::CursorShape shape);
48
49protected:
50 enum WaylandCursor {
51 ArrowCursor = Qt::ArrowCursor,
52 UpArrowCursor,
53 CrossCursor,
54 WaitCursor,
55 IBeamCursor,
56 SizeVerCursor,
57 SizeHorCursor,
58 SizeBDiagCursor,
59 SizeFDiagCursor,
60 SizeAllCursor,
61 BlankCursor,
62 SplitVCursor,
63 SplitHCursor,
64 PointingHandCursor,
65 ForbiddenCursor,
66 WhatsThisCursor,
67 BusyCursor,
68 OpenHandCursor,
69 ClosedHandCursor,
70 DragCopyCursor,
71 DragMoveCursor,
72 DragLinkCursor,
73 // The following are used for cursors that don't have equivalents in Qt
74 ResizeNorthCursor = Qt::CustomCursor + 1,
75 ResizeSouthCursor,
76 ResizeEastCursor,
77 ResizeWestCursor,
78 ResizeNorthWestCursor,
79 ResizeSouthEastCursor,
80 ResizeNorthEastCursor,
81 ResizeSouthWestCursor,
82
83 NumWaylandCursors
84 };
85
86 explicit QWaylandCursorTheme(struct ::wl_cursor_theme *theme) : m_theme(theme) {}
87 struct ::wl_cursor *requestCursor(WaylandCursor shape);
88 struct ::wl_cursor_theme *m_theme = nullptr;
89 wl_cursor *m_cursors[NumWaylandCursors] = {};
90};
91
92class Q_WAYLANDCLIENT_EXPORT QWaylandCursorShape : public QtWayland::wp_cursor_shape_device_v1
93{
94public:
95 QWaylandCursorShape(struct ::wp_cursor_shape_device_v1 *object);
96 ~QWaylandCursorShape();
97 void setShape(uint32_t serial, Qt::CursorShape shape);
98};
99
100class Q_WAYLANDCLIENT_EXPORT QWaylandCursor : public QPlatformCursor
101{
102public:
103 explicit QWaylandCursor(QWaylandDisplay *display);
104
105 void changeCursor(QCursor *cursor, QWindow *window) override;
106 void pointerEvent(const QMouseEvent &event) override;
107 QPoint pos() const override;
108 void setPos(const QPoint &pos) override;
109 void setPosFromEnterEvent(const QPoint &pos);
110
111 QSize size() const override;
112
113 static QSharedPointer<QWaylandBuffer> cursorBitmapBuffer(QWaylandDisplay *display, const QCursor *cursor);
114
115protected:
116 QWaylandDisplay *mDisplay = nullptr;
117 QPoint mLastPos;
118};
119
120}
121
122QT_END_NAMESPACE
123
124#endif // cursor
125#endif // QWAYLANDCURSOR_H
static QtWayland::wp_cursor_shape_device_v1::shape qtCursorShapeToWaylandShape(Qt::CursorShape cursorShape)