From 1d03ed3f2b6cdad2719b66b056c4c6be2018c460 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Nov 2015 16:30:05 +0100 Subject: Make native cursor handles accessible. Add QWindowsNativeInterface::nativeResourceForCursor() and implement for Windows (returning the HCURSOR) and XCB (returning the xcb_cursor). Task-number: QTBUG-49386 Change-Id: I963869f6e8741449822ecbe6489f9c42a786c7a6 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/xcb/qxcbcursor.h | 5 +++++ src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 15 +++++++++++++++ src/plugins/platforms/xcb/qxcbnativeinterface.h | 3 +++ 3 files changed, 23 insertions(+) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index 3c6dece1f2..f6c1d9db90 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -77,6 +77,11 @@ public: static void queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask = 0); +#ifndef QT_NO_CURSOR + xcb_cursor_t xcbCursor(const QCursor &c) const + { return m_cursorHash.value(QXcbCursorCacheKey(c), xcb_cursor_t(0)); } +#endif + private: #ifndef QT_NO_CURSOR typedef QHash CursorHash; diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 374eaa4d6e..8a47fe1b43 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -33,6 +33,7 @@ #include "qxcbnativeinterface.h" +#include "qxcbcursor.h" #include "qxcbscreen.h" #include "qxcbwindow.h" #include "qxcbintegration.h" @@ -288,6 +289,20 @@ void *QXcbNativeInterface::nativeResourceForBackingStore(const QByteArray &resou return result; } +#ifndef QT_NO_CURSOR +void *QXcbNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) +{ + if (resource == QByteArrayLiteral("xcbcursor")) { + if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) { + if (const QPlatformCursor *pCursor= primaryScreen->handle()->cursor()) { + xcb_cursor_t xcbCursor = static_cast(pCursor)->xcbCursor(cursor); + return reinterpret_cast(quintptr(xcbCursor)); + } + } + } + return Q_NULLPTR; +} +#endif // !QT_NO_CURSOR QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource) { diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index f88b710864..c823b474ab 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -78,6 +78,9 @@ public: void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE; void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) Q_DECL_OVERRIDE; void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) Q_DECL_OVERRIDE; +#ifndef QT_NO_CURSOR + void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) Q_DECL_OVERRIDE; +#endif NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE; NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE; -- cgit v1.2.3