diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-06-07 15:38:45 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-06-08 14:47:22 +0200 |
commit | 4469de4ce7a72ab6824629bfe8483131aaf22137 (patch) | |
tree | cc5b1c11c0681975e972f2d6aeab80e106d328c8 /src/gui/kernel/qcursor_qpa.cpp | |
parent | 88f3b059a935d1ce7735a5ae082c256619eea8c1 (diff) |
Cursor support in xcb plug-in.
Custom cursor pixmaps with depth greater than 1 are not yet supported
and will be converted to monochrome always.
Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/gui/kernel/qcursor_qpa.cpp')
-rw-r--r-- | src/gui/kernel/qcursor_qpa.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gui/kernel/qcursor_qpa.cpp b/src/gui/kernel/qcursor_qpa.cpp index c0b27bebd8..a2927601a9 100644 --- a/src/gui/kernel/qcursor_qpa.cpp +++ b/src/gui/kernel/qcursor_qpa.cpp @@ -41,6 +41,7 @@ #include <qcursor.h> #include <private/qcursor_p.h> +#include <qplatformcursor_qpa.h> #include <qbitmap.h> QT_BEGIN_NAMESPACE @@ -107,21 +108,39 @@ void QCursorData::update() #endif //QT_NO_CURSOR -extern int qt_last_x,qt_last_y; +extern int qt_last_x; +extern int qt_last_y; QPoint QCursor::pos() { + QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances(); + int cursorCount = cursors.count(); + for (int i = 0; i < cursorCount; ++i) { + const QWeakPointer<QPlatformCursor> &cursor(cursors.at(i)); + if (cursor) + return cursor.data()->pos(); + } return QPoint(qt_last_x, qt_last_y); } void QCursor::setPos(int x, int y) { + QPoint target(x, y); + // Need to check, since some X servers generate null mouse move // events, causing looping in applications which call setPos() on // every mouse move event. // - if (pos() == QPoint(x, y)) + if (pos() == target) return; + + QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances(); + int cursorCount = cursors.count(); + for (int i = 0; i < cursorCount; ++i) { + const QWeakPointer<QPlatformCursor> &cursor(cursors.at(i)); + if (cursor) + cursor.data()->setPos(target); + } } QT_END_NAMESPACE |