Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.6.2/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 QT_BEGIN_NAMESPACE
12
13 #ifndef QT_NO_CURSOR
14
15 struct QXcbCursorCacheKey
16 {
17 explicit QXcbCursorCacheKey(const QCursor &c);
18 explicit QXcbCursorCacheKey(Qt::CursorShape s) : shape(s), bitmapCacheKey(0), maskCacheKey(0) {}
19 QXcbCursorCacheKey() : shape(Qt::CustomCursor), bitmapCacheKey(0), maskCacheKey(0) {}
20
21 Qt::CursorShape shape;
22 qint64 bitmapCacheKey;
23 qint64 maskCacheKey;
24 };
25
26 inline bool operator==(const QXcbCursorCacheKey &k1, const QXcbCursorCacheKey &k2)
27 {
28 return k1.shape == k2.shape && k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey;
29 }
30
31 inline uint qHash(const QXcbCursorCacheKey &k, uint seed) Q_DECL_NOTHROW
32 {
33 return (uint(k.shape) + uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed;
34 }
35
36 #endif // !QT_NO_CURSOR
37
38 class QXcbCursor : public QXcbObject, public QPlatformCursor
39 {
40 public:
41 QXcbCursor(QXcbConnection *conn, QXcbScreen *screen);
42 ~QXcbCursor();
43 #ifndef QT_NO_CURSOR
44 void changeCursor(QCursor *cursor, QWindow *widget) Q_DECL_OVERRIDE;
45 #endif
46 QPoint pos() const Q_DECL_OVERRIDE;
47 void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
48
49 static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = 0);
50
51 private:
52 #ifndef QT_NO_CURSOR
53 typedef QHash<QXcbCursorCacheKey, xcb_cursor_t> CursorHash;
54
55 xcb_cursor_t createFontCursor(int cshape);
56 xcb_cursor_t createBitmapCursor(QCursor *cursor);
57 xcb_cursor_t createNonStandardCursor(int cshape);
58 #endif
59
60 QXcbScreen *m_screen;
61 #ifndef QT_NO_CURSOR
62 CursorHash m_cursorHash;
63 #endif
64 #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY)
65 static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen,
66 const QByteArray &name,
67 const QVariant &property,
68 void *handle);
69 #endif
70 bool m_gtkCursorThemeInitialized;
71 };
72
73 QT_END_NAMESPACE
74
75 #endif