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 <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
3c8cf55074
commit
1d03ed3f2b
@ -80,6 +80,15 @@ void * QPlatformNativeInterface::nativeResourceForBackingStore(const QByteArray
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
void *QPlatformNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor)
|
||||
{
|
||||
Q_UNUSED(resource);
|
||||
Q_UNUSED(cursor);
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
#endif // !QT_NO_CURSOR
|
||||
|
||||
QPlatformNativeInterface::NativeResourceForIntegrationFunction QPlatformNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
|
||||
{
|
||||
Q_UNUSED(resource);
|
||||
|
@ -65,6 +65,9 @@ public:
|
||||
virtual void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen);
|
||||
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
|
||||
virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore);
|
||||
#ifndef QT_NO_CURSOR
|
||||
virtual void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor);
|
||||
#endif
|
||||
|
||||
typedef void * (*NativeResourceForIntegrationFunction)();
|
||||
typedef void * (*NativeResourceForContextFunction)(QOpenGLContext *context);
|
||||
|
@ -780,6 +780,21 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
|
||||
return m_ignoreDragCursor;
|
||||
}
|
||||
|
||||
HCURSOR QWindowsCursor::hCursor(const QCursor &c) const
|
||||
{
|
||||
const Qt::CursorShape shape = c.shape();
|
||||
if (shape == Qt::BitmapCursor) {
|
||||
const auto pit = m_pixmapCursorCache.constFind(QWindowsPixmapCursorCacheKey(c));
|
||||
if (pit != m_pixmapCursorCache.constEnd())
|
||||
return pit.value()->handle();
|
||||
} else {
|
||||
const auto sit = m_standardCursorCache.constFind(shape);
|
||||
if (sit != m_standardCursorCache.constEnd())
|
||||
return sit.value()->handle();
|
||||
}
|
||||
return HCURSOR(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWindowsWindowCursor
|
||||
\brief Per-Window cursor. Contains a QCursor and manages its associated system
|
||||
|
@ -115,6 +115,8 @@ public:
|
||||
|
||||
QPixmap dragDefaultCursor(Qt::DropAction action) const;
|
||||
|
||||
HCURSOR hCursor(const QCursor &c) const;
|
||||
|
||||
private:
|
||||
typedef QHash<Qt::CursorShape, CursorHandlePtr> StandardCursorCache;
|
||||
typedef QHash<QWindowsPixmapCursorCacheKey, CursorHandlePtr> PixmapCursorCache;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "qwindowsnativeinterface.h"
|
||||
#include "qwindowswindow.h"
|
||||
#include "qwindowscontext.h"
|
||||
#include "qwindowscursor.h"
|
||||
#include "qwindowsfontdatabase.h"
|
||||
#include "qwindowsopenglcontext.h"
|
||||
#include "qwindowsopengltester.h"
|
||||
@ -42,6 +43,8 @@
|
||||
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
#include <QtGui/QScreen>
|
||||
#include <qpa/qplatformscreen.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -102,6 +105,19 @@ void *QWindowsNativeInterface::nativeResourceForWindow(const QByteArray &resourc
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
void *QWindowsNativeInterface::nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor)
|
||||
{
|
||||
if (resource == QByteArrayLiteral("hcursor")) {
|
||||
if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) {
|
||||
if (const QPlatformCursor *pCursor= primaryScreen->handle()->cursor())
|
||||
return static_cast<const QWindowsCursor *>(pCursor)->hCursor(cursor);
|
||||
}
|
||||
}
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
#endif // !QT_NO_CURSOR
|
||||
|
||||
static const char customMarginPropertyC[] = "WindowsCustomMargins";
|
||||
|
||||
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
|
||||
|
@ -66,7 +66,9 @@ public:
|
||||
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) Q_DECL_OVERRIDE;
|
||||
#endif
|
||||
void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) Q_DECL_OVERRIDE;
|
||||
|
||||
#ifndef QT_NO_CURSOR
|
||||
void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) Q_DECL_OVERRIDE;
|
||||
#endif
|
||||
Q_INVOKABLE void *createMessageWindow(const QString &classNameTemplate,
|
||||
const QString &windowName,
|
||||
void *eventProc) const;
|
||||
|
@ -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<QXcbCursorCacheKey, xcb_cursor_t> CursorHash;
|
||||
|
@ -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<const QXcbCursor *>(pCursor)->xcbCursor(cursor);
|
||||
return reinterpret_cast<void *>(quintptr(xcbCursor));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
#endif // !QT_NO_CURSOR
|
||||
|
||||
QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user