Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.12.8/qxcbcursor.h

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5 #ifndef QXCBCURSOR_H
6 #define QXCBCURSOR_H
7
8 #include <qpa/qplatformcursor.h>
9 #include "qxcbscreen.h"
10
11 #include <QtCore/QCache>
12
13 QT_BEGIN_NAMESPACE
14
15 #ifndef QT_NO_CURSOR
16
17 struct QXcbCursorCacheKey
18 {
19 explicit QXcbCursorCacheKey(const QCursor &c);
20 explicit QXcbCursorCacheKey(Qt::CursorShape s) : shape(s), bitmapCacheKey(0), maskCacheKey(0) {}
21 QXcbCursorCacheKey() : shape(Qt::CustomCursor), bitmapCacheKey(0), maskCacheKey(0) {}
22
23 Qt::CursorShape shape;
24 qint64 bitmapCacheKey;
25 qint64 maskCacheKey;
26 };
27
28 inline bool operator==(const QXcbCursorCacheKey &k1, const QXcbCursorCacheKey &k2)
29 {
30 return k1.shape == k2.shape && k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey;
31 }
32
33 inline uint qHash(const QXcbCursorCacheKey &k, uint seed) Q_DECL_NOTHROW
34 {
35 return (uint(k.shape) + uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed;
36 }
37
38 #endif // !QT_NO_CURSOR
39
40 class QXcbCursor : public QXcbObject, public QPlatformCursor
41 {
42 public:
43 QXcbCursor(QXcbConnection *conn, QXcbScreen *screen);
44 ~QXcbCursor();
45 #ifndef QT_NO_CURSOR
46 void changeCursor(QCursor *cursor, QWindow *window) override;
47 #endif
48 QPoint pos() const override;
49 void setPos(const QPoint &pos) override;
50
51 static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = 0);
52
53 #ifndef QT_NO_CURSOR
54 xcb_cursor_t xcbCursor(const QCursor &c) const
55 { return m_cursorHash.value(QXcbCursorCacheKey(c), xcb_cursor_t(0)); }
56 #endif
57
58 private:
59
60 #ifndef QT_NO_CURSOR
61 typedef QHash<QXcbCursorCacheKey, xcb_cursor_t> CursorHash;
62
63 struct CachedCursor
64 {
65 explicit CachedCursor(xcb_connection_t *conn, xcb_cursor_t c)
66 : cursor(c), connection(conn) {}
67 ~CachedCursor() { xcb_free_cursor(connection, cursor); }
68 xcb_cursor_t cursor;
69 xcb_connection_t *connection;
70 };
71 typedef QCache<QXcbCursorCacheKey, CachedCursor> BitmapCursorCache;
72
73 xcb_cursor_t createFontCursor(int cshape);
74 xcb_cursor_t createBitmapCursor(QCursor *cursor);
75 xcb_cursor_t createNonStandardCursor(int cshape);
76 #endif
77
78 QXcbScreen *m_screen;
79 #ifndef QT_NO_CURSOR
80 CursorHash m_cursorHash;
81 BitmapCursorCache m_bitmapCache;
82 #endif
83 #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
84 static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen,
85 const QByteArray &name,
86 const QVariant &property,
87 void *handle);
88 #endif
89 bool m_gtkCursorThemeInitialized;
90 };
91
92 QT_END_NAMESPACE
93
94 #endif