summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-03-05 14:42:42 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-07 22:43:43 +0100
commitb319d44798fe4c5aa8b859966d64f28b08be28dd (patch)
treefc24d20ebff32b89f02e0390950fc33f38f7e972 /src/plugins
parentb7915a4d0d97a60fc30e55eb4cc1b10e7fe9ce2f (diff)
QCursor: Associate cursor with screen.
- Introduce cursor() accessor to QPlatformScreen. - Remove screen member of QPlatformCursor (a cursor can be shared by multiple screens of a virtual desktop). - Add QCursor::pos()/ QCursor::setPos() taking a QScreen-parameter, use primaryScreen() for old overloads. QCursor::pos() can then query the platform cursor for the position and return the position even if the mouse position is outside the windows owned by the Qt application. - Fix tests Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com> Task-number: QTBUG-22457 Task-number: QTBUG-22565 Task-number: QTBUG-20753 Change-Id: Ia69f37343f95772e934eab1cd806bd54cbdbbe51 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm2
-rw-r--r--src/plugins/platforms/directfb/qdirectfbcursor.cpp4
-rw-r--r--src/plugins/platforms/directfb/qdirectfbcursor.h1
-rw-r--r--src/plugins/platforms/directfb/qdirectfbscreen.h1
-rw-r--r--src/plugins/platforms/kms/qkmscursor.cpp2
-rw-r--r--src/plugins/platforms/kms/qkmsscreen.cpp5
-rw-r--r--src/plugins/platforms/kms/qkmsscreen.h1
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp5
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h9
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp5
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h1
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.cpp8
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.h5
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.cpp5
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.h1
22 files changed, 49 insertions, 28 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h
index bccaa1e06b..85892ee820 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.h
+++ b/src/plugins/platforms/cocoa/qcocoacursor.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QCocoaCursor : public QPlatformCursor
{
public:
- explicit QCocoaCursor(QPlatformScreen *);
+ QCocoaCursor();
virtual void changeCursor(QCursor * widgetCursor, QWindow * widget);
virtual QPoint pos() const;
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index bddfaa752e..56f0dcf72e 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -47,8 +47,7 @@
QT_BEGIN_NAMESPACE
-QCocoaCursor::QCocoaCursor(QPlatformScreen *s) :
- QPlatformCursor(s)
+QCocoaCursor::QCocoaCursor()
{
// release cursors
QHash<Qt::CursorShape, NSCursor *>::const_iterator i = m_cursors.constBegin();
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index aa0c933fab..bf54915365 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -63,6 +63,7 @@ public:
int depth() const { return m_depth; }
QImage::Format format() const { return m_format; }
QSizeF physicalSize() const { return m_physicalSize; }
+ QPlatformCursor *cursor() const { return m_cursor; }
public:
NSScreen *m_screen;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 7921cc6ae7..8411a795c1 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -79,7 +79,7 @@ QCocoaScreen::QCocoaScreen(int screenIndex)
const qreal inch = 25.4;
m_physicalSize = QSizeF(m_geometry.size()) * inch / dpi;
- m_cursor = new QCocoaCursor(this);
+ m_cursor = new QCocoaCursor;
};
QCocoaScreen::~QCocoaScreen()
diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.cpp b/src/plugins/platforms/directfb/qdirectfbcursor.cpp
index e1660a998a..a63bc48133 100644
--- a/src/plugins/platforms/directfb/qdirectfbcursor.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbcursor.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QDirectFBCursor::QDirectFBCursor(QPlatformScreen *screen)
- : QPlatformCursor(screen)
+ : m_screen(screen)
{
m_image.reset(new QPlatformCursorImage(0, 0, 0, 0, 0, 0));
}
@@ -70,7 +70,7 @@ void QDirectFBCursor::changeCursor(QCursor *cursor, QWindow *)
}
DFBResult res;
- IDirectFBDisplayLayer *layer = toDfbLayer(screen);
+ IDirectFBDisplayLayer *layer = toDfbLayer(m_screen);
IDirectFBSurface* surface(QDirectFbConvenience::dfbSurfaceForPlatformPixmap(map.handle()));
res = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.h b/src/plugins/platforms/directfb/qdirectfbcursor.h
index 3cc2825b28..f28e225dc7 100644
--- a/src/plugins/platforms/directfb/qdirectfbcursor.h
+++ b/src/plugins/platforms/directfb/qdirectfbcursor.h
@@ -60,6 +60,7 @@ public:
private:
QScopedPointer<QPlatformCursorImage> m_image;
+ QPlatformScreen *m_screen;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbscreen.h b/src/plugins/platforms/directfb/qdirectfbscreen.h
index ad80576c8f..8535239088 100644
--- a/src/plugins/platforms/directfb/qdirectfbscreen.h
+++ b/src/plugins/platforms/directfb/qdirectfbscreen.h
@@ -61,6 +61,7 @@ public:
int depth() const { return m_depth; }
QImage::Format format() const { return m_format; }
QSizeF physicalSize() const { return m_physicalSize; }
+ QPlatformCursor *cursor() const { return m_cursor.data(); }
// DirectFb helpers
IDirectFBDisplayLayer *dfbLayer() const;
diff --git a/src/plugins/platforms/kms/qkmscursor.cpp b/src/plugins/platforms/kms/qkmscursor.cpp
index a38f66bd02..37817af39d 100644
--- a/src/plugins/platforms/kms/qkmscursor.cpp
+++ b/src/plugins/platforms/kms/qkmscursor.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
QKmsCursor::QKmsCursor(QKmsScreen *screen)
- : QPlatformCursor(screen), m_screen(screen),
+ : m_screen(screen),
m_graphicsBufferManager(screen->device()->gbmDevice())
{
gbm_bo *bo = gbm_bo_create(m_graphicsBufferManager, 64, 64,
diff --git a/src/plugins/platforms/kms/qkmsscreen.cpp b/src/plugins/platforms/kms/qkmsscreen.cpp
index f1b9baf120..76b9bce28f 100644
--- a/src/plugins/platforms/kms/qkmsscreen.cpp
+++ b/src/plugins/platforms/kms/qkmsscreen.cpp
@@ -96,6 +96,11 @@ QSizeF QKmsScreen::physicalSize() const
return m_physicalSize;
}
+QPlatformCursor *QKmsScreen::cursor() const
+{
+ return m_cursor;
+}
+
GLuint QKmsScreen::framebufferObject() const
{
return m_bufferManager.framebufferObject();
diff --git a/src/plugins/platforms/kms/qkmsscreen.h b/src/plugins/platforms/kms/qkmsscreen.h
index 4cb547b424..058314a515 100644
--- a/src/plugins/platforms/kms/qkmsscreen.h
+++ b/src/plugins/platforms/kms/qkmsscreen.h
@@ -61,6 +61,7 @@ public:
int depth() const;
QImage::Format format() const;
QSizeF physicalSize() const;
+ QPlatformCursor *cursor() const;
GLuint framebufferObject() const;
quint32 crtcId() const { return m_crtcId; }
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index f75cbeb078..337ba9ab27 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -72,11 +72,6 @@ Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap);
\sa QWindowsWindowCursor
*/
-QWindowsCursor::QWindowsCursor(QPlatformScreen *s) :
- QPlatformCursor(s)
-{
-}
-
HCURSOR QWindowsCursor::createPixmapCursor(const QPixmap &pixmap, int hotX, int hotY)
{
HCURSOR cur = 0;
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index a03c77a3b6..61c43dc4d2 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -70,7 +70,7 @@ private:
class QWindowsCursor : public QPlatformCursor
{
public:
- explicit QWindowsCursor(QPlatformScreen *);
+ QWindowsCursor() {}
virtual void changeCursor(QCursor * widgetCursor, QWindow * widget);
virtual QPoint pos() const { return mousePosition(); }
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 1dc5175515..2476e15169 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -147,6 +147,14 @@ static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d)
return dbg;
}
+// Return the cursor to be shared by all screens (virtual desktop).
+static inline QSharedPointer<QWindowsCursor> sharedCursor()
+{
+ if (const QScreen *primaryScreen = QGuiApplication::primaryScreen())
+ return static_cast<const QWindowsScreen *>(primaryScreen->handle())->windowsCursor();
+ return QSharedPointer<QWindowsCursor>(new QWindowsCursor);
+}
+
/*!
\class QWindowsScreen
\brief Windows screen.
@@ -155,7 +163,7 @@ static QDebug operator<<(QDebug dbg, const QWindowsScreenData &d)
*/
QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) :
- m_data(data), m_cursor(this)
+ m_data(data), m_cursor(sharedCursor())
{
}
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 77a327a62a..5b9a50b2ab 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -46,6 +46,7 @@
#include <QtCore/QList>
#include <QtCore/QPair>
+#include <QtCore/QSharedPointer>
#include <QtGui/QPlatformScreen>
QT_BEGIN_NAMESPACE
@@ -74,6 +75,8 @@ struct QWindowsScreenData
class QWindowsScreen : public QPlatformScreen
{
public:
+ typedef QSharedPointer<QWindowsCursor> WindowsCursorPtr;
+
explicit QWindowsScreen(const QWindowsScreenData &data);
static QWindowsScreen *screenOf(const QWindow *w = 0);
@@ -98,14 +101,14 @@ public:
inline void handleChanges(const QWindowsScreenData &newData);
- const QWindowsCursor &cursor() const { return m_cursor; }
- QWindowsCursor &cursor() { return m_cursor; }
+ QPlatformCursor *cursor() const { return m_cursor.data(); }
+ const WindowsCursorPtr &windowsCursor() const { return m_cursor; }
const QWindowsScreenData &data() const { return m_data; }
private:
QWindowsScreenData m_data;
- QWindowsCursor m_cursor;
+ const WindowsCursorPtr m_cursor;
};
class QWindowsScreenManager
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index f5cac4d4f0..1edb243f4e 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -618,7 +618,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
m_windowState(aWindow->windowState()),
m_opacity(1.0),
m_mouseGrab(false),
- m_cursor(QWindowsScreen::screenOf(aWindow)->cursor().standardWindowCursor()),
+ m_cursor(QWindowsScreen::screenOf(aWindow)->windowsCursor()->standardWindowCursor()),
m_dropTarget(0),
m_savedStyle(0)
{
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index ed7c22b1e6..7e1b66829a 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -261,7 +261,7 @@ static const char * const cursorNames[] = {
};
QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
- : QXcbObject(conn), QPlatformCursor(screen), m_screen(screen)
+ : QXcbObject(conn), m_screen(screen)
{
if (cursorCount++)
return;
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 15ffc5b8ff..8b66ef4603 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -237,6 +237,11 @@ QSizeF QXcbScreen::physicalSize() const
return QSizeF(m_screen->width_in_millimeters, m_screen->height_in_millimeters);
}
+QPlatformCursor *QXcbScreen::cursor() const
+{
+ return m_cursor;
+}
+
int QXcbScreen::screenNumber() const
{
return m_number;
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index 870d4d5662..ac4ecb1c8d 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -68,6 +68,7 @@ public:
int depth() const;
QImage::Format format() const;
QSizeF physicalSize() const;
+ QPlatformCursor *cursor() const;
int screenNumber() const;
diff --git a/src/plugins/platforms/xlib/qxlibcursor.cpp b/src/plugins/platforms/xlib/qxlibcursor.cpp
index 8ab40e31ef..a714f82371 100644
--- a/src/plugins/platforms/xlib/qxlibcursor.cpp
+++ b/src/plugins/platforms/xlib/qxlibcursor.cpp
@@ -52,8 +52,7 @@
QT_BEGIN_NAMESPACE
-QXlibCursor::QXlibCursor(QXlibScreen *screen)
- : QPlatformCursor(screen)
+QXlibCursor::QXlibCursor(QXlibScreen *screen) : m_screen(screen)
{
}
@@ -191,9 +190,4 @@ Cursor QXlibCursor::createCursorShape(int cshape)
return cursor;
}
-QXlibScreen * QXlibCursor::testLiteScreen() const
-{
- return static_cast<QXlibScreen *>(screen);
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibcursor.h b/src/plugins/platforms/xlib/qxlibcursor.h
index 92e42ac7a1..0056aa9554 100644
--- a/src/plugins/platforms/xlib/qxlibcursor.h
+++ b/src/plugins/platforms/xlib/qxlibcursor.h
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-class QXlibCursor : QPlatformCursor
+class QXlibCursor : public QPlatformCursor
{
public:
QXlibCursor(QXlibScreen *screen);
@@ -59,8 +59,9 @@ private:
Cursor createCursorBitmap(QCursor * cursor);
Cursor createCursorShape(int cshape);
- QXlibScreen *testLiteScreen() const;
+ QXlibScreen *testLiteScreen() const { return m_screen; }
QMap<int, Cursor> cursorMap;
+ QXlibScreen *m_screen;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp
index fc903708b3..62c80b6ad4 100644
--- a/src/plugins/platforms/xlib/qxlibscreen.cpp
+++ b/src/plugins/platforms/xlib/qxlibscreen.cpp
@@ -241,6 +241,11 @@ QXlibScreen::~QXlibScreen()
delete mDisplay;
}
+QPlatformCursor *QXlibScreen::cursor() const
+{
+ return mCursor;
+}
+
Window QXlibScreen::rootWindow()
{
return RootWindow(mDisplay->nativeDisplay(), mScreen);
diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h
index c6672c3540..5bb6cc7735 100644
--- a/src/plugins/platforms/xlib/qxlibscreen.h
+++ b/src/plugins/platforms/xlib/qxlibscreen.h
@@ -63,6 +63,7 @@ public:
int depth() const { return mDepth; }
QImage::Format format() const { return mFormat; }
QSizeF physicalSize() const { return mPhysicalSize; }
+ QPlatformCursor *cursor() const;
Window rootWindow();
unsigned long blackPixel();