Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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 QSize size() const override;
52
53 void updateContext();
54
55 static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = nullptr);
56
57#ifndef QT_NO_CURSOR
58 xcb_cursor_t xcbCursor(const QCursor &c) const
59 { return m_cursorHash.value(QXcbCursorCacheKey(c), xcb_cursor_t(0)); }
60#endif
61
62private:
63
64#ifndef QT_NO_CURSOR
65 typedef QHash<QXcbCursorCacheKey, xcb_cursor_t> CursorHash;
66
67 struct CachedCursor
68 {
69 explicit CachedCursor(xcb_connection_t *conn, xcb_cursor_t c)
70 : cursor(c), connection(conn) {}
71 ~CachedCursor() { xcb_free_cursor(connection, cursor); }
72 xcb_cursor_t cursor;
73 xcb_connection_t *connection;
74 };
75 typedef QCache<QXcbCursorCacheKey, CachedCursor> BitmapCursorCache;
76
77 xcb_cursor_t createFontCursor(int cshape);
78 xcb_cursor_t createBitmapCursor(QCursor *cursor);
79 xcb_cursor_t createNonStandardCursor(int cshape);
80#endif
81
82 QXcbScreen *m_screen;
83 xcb_cursor_context_t *m_cursorContext;
84#ifndef QT_NO_CURSOR
85 CursorHash m_cursorHash;
86 BitmapCursorCache m_bitmapCache;
87#endif
88 static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen,
89 const QByteArray &name,
90 const QVariant &property,
91 void *handle);
92 bool m_callbackForPropertyRegistered;
93};
94
96
97#endif
\inmodule QtCore
Definition qbytearray.h:57
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
T value(const Key &key) const noexcept
Definition qhash.h:1054
The QPlatformCursor class provides information about pointer device events (movement,...
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
Definition qvariant.h:65
\inmodule QtGui
Definition qwindow.h:63
void updateContext()
xcb_cursor_t xcbCursor(const QCursor &c) const
Definition qxcbcursor.h:58
void changeCursor(QCursor *cursor, QWindow *window) override
This method is called by Qt whenever the cursor graphic should be changed.
QPoint pos() const override
QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask=nullptr)
void setPos(const QPoint &pos) override
QSize size() const override
Returns the size of the cursor, in native pixels.
QCursor cursor
Combined button and popup list for selecting options.
Definition qcompare.h:63
CursorShape
GLuint64 GLenum void * handle
GLuint name
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
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:60
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