Windows: Create one QPlatformCursor per screen.
The pixmap-based cursors and some of the standard cursors we create from resource pixmaps need to be separated per screen. Use a QScopedPointer containing the per-screen cursor instead of the previously used QSharedPointer containing the cursor shared by all screens. Task-number: QTBUG-49511 Change-Id: I5203fcc4ecf5a7ff3fea833a4eaeb5300a6e6d54 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
436ad32f9f
commit
f39db6c3f8
@ -47,11 +47,12 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QScopedArrayPointer>
|
||||
|
||||
static void initResources()
|
||||
static bool initResources()
|
||||
{
|
||||
#if !defined (Q_OS_WINCE) && !defined (QT_NO_IMAGEFORMAT_PNG)
|
||||
Q_INIT_RESOURCE(cursors);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -590,9 +591,11 @@ CursorHandlePtr QWindowsCursor::pixmapWindowCursor(const QCursor &c)
|
||||
return it.value();
|
||||
}
|
||||
|
||||
QWindowsCursor::QWindowsCursor()
|
||||
QWindowsCursor::QWindowsCursor(const QPlatformScreen *screen)
|
||||
: m_screen(screen)
|
||||
{
|
||||
initResources();
|
||||
static const bool dummy = initResources();
|
||||
Q_UNUSED(dummy)
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
QPoint hotSpot;
|
||||
};
|
||||
|
||||
QWindowsCursor();
|
||||
explicit QWindowsCursor(const QPlatformScreen *screen);
|
||||
|
||||
void changeCursor(QCursor * widgetCursor, QWindow * widget) Q_DECL_OVERRIDE;
|
||||
QPoint pos() const Q_DECL_OVERRIDE;
|
||||
@ -117,6 +117,7 @@ private:
|
||||
typedef QHash<Qt::CursorShape, CursorHandlePtr> StandardCursorCache;
|
||||
typedef QHash<QWindowsPixmapCursorCacheKey, CursorHandlePtr> PixmapCursorCache;
|
||||
|
||||
const QPlatformScreen *const m_screen;
|
||||
StandardCursorCache m_standardCursorCache;
|
||||
PixmapCursorCache m_pixmapCursorCache;
|
||||
};
|
||||
|
@ -195,16 +195,6 @@ static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d)
|
||||
}
|
||||
#endif // !QT_NO_DEBUG_STREAM
|
||||
|
||||
// Return the cursor to be shared by all screens (virtual desktop).
|
||||
static inline QSharedPointer<QPlatformCursor> sharedCursor()
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
if (const QScreen *primaryScreen = QGuiApplication::primaryScreen())
|
||||
return static_cast<const QWindowsScreen *>(primaryScreen->handle())->cursorPtr();
|
||||
#endif
|
||||
return QSharedPointer<QPlatformCursor>(new QWindowsCursor);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWindowsScreen
|
||||
\brief Windows screen.
|
||||
@ -216,7 +206,7 @@ static inline QSharedPointer<QPlatformCursor> sharedCursor()
|
||||
QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) :
|
||||
m_data(data)
|
||||
#ifndef QT_NO_CURSOR
|
||||
,m_cursor(sharedCursor())
|
||||
, m_cursor(new QWindowsCursor(this))
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <qpa/qplatformscreen.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -74,7 +74,7 @@ class QWindowsScreen : public QPlatformScreen
|
||||
{
|
||||
public:
|
||||
#ifndef QT_NO_CURSOR
|
||||
typedef QSharedPointer<QPlatformCursor> CursorPtr;
|
||||
typedef QScopedPointer<QPlatformCursor> CursorPtr;
|
||||
#endif
|
||||
|
||||
explicit QWindowsScreen(const QWindowsScreenData &data);
|
||||
|
Loading…
Reference in New Issue
Block a user