7#include <qpa/qplatformcursor.h>
9#include <xcb/xcb_cursor.h>
11#include <QtCore/QCache>
17struct QXcbCursorCacheKey
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) {}
23 Qt::CursorShape shape;
24 qint64 bitmapCacheKey;
35inline bool operator==(
const QXcbCursorCacheKey &k1,
const QXcbCursorCacheKey &k2)
37 return k1.shape == k2.shape &&
38 k1.bitmapCacheKey == k2.bitmapCacheKey &&
39 k1.maskCacheKey == k2.maskCacheKey &&
40 k1.hotspotCacheKey.hashKey == k2.hotspotCacheKey.hashKey;
43inline size_t qHash(
const QXcbCursorCacheKey &k, size_t seed)
noexcept
45 return (size_t(k.shape) + size_t(k.bitmapCacheKey) + size_t(k.maskCacheKey)) ^ seed;
53 QXcbCursor(QXcbConnection *conn, QXcbScreen *screen);
56 void changeCursor(QCursor *cursor, QWindow *window)
override;
59 void setPos(
const QPoint &pos)
override;
69 {
return m_cursorHash.value(QXcbCursorCacheKey(c), xcb_cursor_t(0)); }
75 typedef QHash<QXcbCursorCacheKey, xcb_cursor_t> CursorHash;
79 explicit CachedCursor(xcb_connection_t *conn, xcb_cursor_t c)
80 : cursor(c), connection(conn) {}
81 ~CachedCursor() { xcb_free_cursor(connection, cursor); }
83 xcb_connection_t *connection;
85 typedef QCache<QXcbCursorCacheKey, CachedCursor> BitmapCursorCache;
87 xcb_cursor_t createFontCursor(
int cshape);
88 xcb_cursor_t createBitmapCursor(QCursor *cursor);
89 xcb_cursor_t createNonStandardCursor(
int cshape);
93 xcb_cursor_context_t *m_cursorContext;
95 CursorHash m_cursorHash;
96 BitmapCursorCache m_bitmapCache;
99 const QByteArray &name,
100 const QVariant &property,
102 bool m_callbackForPropertyRegistered;
xcb_cursor_t xcbCursor(const QCursor &c) const
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.
xcb_visualid_t visualId()
void requestSystemTrayWindowDock(xcb_window_t window) const
void notifyManagerClientMessageEvent(const xcb_client_message_event_t *)
void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *) override
xcb_window_t trayWindow()
QXcbWMSupport(QXcbConnection *c)
const QList< xcb_window_t > & virtualRoots() const
bool isSupportedByWM(xcb_atom_t atom) const
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
#define HANDLE_KEYBOARD_EVENT(event_t, handler)
const char * xcb_protocol_request_codes[]
#define CASE_PRINT_AND_RETURN(name)
static Qt::MouseButtons translateMouseButtons(int s)
const char * xcb_errors[]
#define PRINT_AND_RETURN(name)
#define XI_PRINT_AND_RETURN(name)
#define XI_CASE_PRINT_AND_RETURN(name)
#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler)
#define Q_XCB_REPLY(call,...)
bool operator==(const QXcbCursorCacheKey &k1, const QXcbCursorCacheKey &k2)
size_t qHash(const QXcbCursorCacheKey &k, size_t seed) noexcept