Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qxcbcursor.h
Go to the documentation of this file.
1// Copyright (C) 2022 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
4#ifndef QXCBCURSOR_H
5#define QXCBCURSOR_H
6
7#include <qpa/qplatformcursor.h>
8#include "qxcbscreen.h"
9#include <xcb/xcb_cursor.h>
10
11#include <QtCore/QCache>
12
14
15#ifndef QT_NO_CURSOR
16
18{
19 explicit QXcbCursorCacheKey(const QCursor &c);
22
26};
27
28inline 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
33inline size_t qHash(const QXcbCursorCacheKey &k, size_t seed) noexcept
34{
35 return (size_t(k.shape) + size_t(k.bitmapCacheKey) + size_t(k.maskCacheKey)) ^ seed;
36}
37
38#endif // !QT_NO_CURSOR
39
41{
42public:
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 void updateContext();
52
53 static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = nullptr);
54
55#ifndef QT_NO_CURSOR
56 xcb_cursor_t xcbCursor(const QCursor &c) const
57 { return m_cursorHash.value(QXcbCursorCacheKey(c), xcb_cursor_t(0)); }
58#endif
59
60private:
61
62#ifndef QT_NO_CURSOR
64
65 struct CachedCursor
66 {
67 explicit CachedCursor(xcb_connection_t *conn, xcb_cursor_t c)
68 : cursor(c), connection(conn) {}
69 ~CachedCursor() { xcb_free_cursor(connection, cursor); }
70 xcb_cursor_t cursor;
71 xcb_connection_t *connection;
72 };
73 typedef QCache<QXcbCursorCacheKey, CachedCursor> BitmapCursorCache;
74
75 xcb_cursor_t createFontCursor(int cshape);
76 xcb_cursor_t createBitmapCursor(QCursor *cursor);
77 xcb_cursor_t createNonStandardCursor(int cshape);
78#endif
79
80 QXcbScreen *m_screen;
81 xcb_cursor_context_t *m_cursorContext;
82#ifndef QT_NO_CURSOR
83 CursorHash m_cursorHash;
84 BitmapCursorCache m_bitmapCache;
85#endif
86 static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen,
87 const QByteArray &name,
88 const QVariant &property,
89 void *handle);
90 bool m_callbackForPropertyRegistered;
91};
92
94
95#endif
\inmodule QtCore
Definition qbytearray.h:57
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
\inmodule QtCore
Definition qhash.h:818
T value(const Key &key) const noexcept
Definition qhash.h:1044
The QPlatformCursor class provides information about pointer device events (movement,...
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore
Definition qvariant.h:64
\inmodule QtGui
Definition qwindow.h:63
void updateContext()
xcb_cursor_t xcbCursor(const QCursor &c) const
Definition qxcbcursor.h:56
void changeCursor(QCursor *cursor, QWindow *window) override
This method is called by Qt whenever the cursor graphic should be changed.
QPoint pos() const override
static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask=nullptr)
void setPos(const QPoint &pos) override
QCursor cursor
Combined button and popup list for selecting options.
CursorShape
DBusConnection * connection
GLuint64 GLenum void * handle
GLuint name
const GLubyte * c
GLdouble s
[6]
Definition qopenglext.h:235
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
#define k1
QScreen * screen
[1]
Definition main.cpp:29
long long qint64
Definition qtypes.h:55
const char property[13]
Definition qwizard.cpp:101
bool operator==(const QXcbCursorCacheKey &k1, const QXcbCursorCacheKey &k2)
Definition qxcbcursor.h:28
size_t qHash(const QXcbCursorCacheKey &k, size_t seed) noexcept
Definition qxcbcursor.h:33
aWidget window() -> setWindowTitle("New Window Title")
[2]
Qt::CursorShape shape
Definition qxcbcursor.h:23
QXcbCursorCacheKey(Qt::CursorShape s)
Definition qxcbcursor.h:20