From 3ed314ca46286c0e4f54b124d145704277592ddd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 25 Aug 2011 14:19:58 +0200 Subject: [PATCH] Fix compilation/use correct data type for qt_lastx,y. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I6fdc8dcfb19d7498a1eb8013f75113537ce7a213 Reviewed-on: http://codereview.qt.nokia.com/3594 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/gui/kernel/qcursor_qpa.cpp | 5 ++--- src/gui/kernel/qguiapplication.cpp | 20 ++++++++------------ src/gui/kernel/qguiapplication_p.h | 2 ++ src/gui/kernel/qplatformcursor_qpa.cpp | 6 ++---- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/gui/kernel/qcursor_qpa.cpp b/src/gui/kernel/qcursor_qpa.cpp index 65d5b0f..40a1531 100644 --- a/src/gui/kernel/qcursor_qpa.cpp +++ b/src/gui/kernel/qcursor_qpa.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -108,11 +109,9 @@ void QCursorData::update() #endif //QT_NO_CURSOR -extern qreal qt_last_x,qt_last_y; - QPoint QCursor::pos() { - return QPointF(qt_last_x, qt_last_y).toPoint(); + return QGuiApplicationPrivate::lastCursorPosition.toPoint(); } void QCursor::setPos(int x, int y) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a9af27a..7ab098e 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -84,6 +84,7 @@ Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; int QGuiApplicationPrivate::keyboard_input_time = 400; int QGuiApplicationPrivate::mouse_double_click_time = 400; +QPointF QGuiApplicationPrivate::lastCursorPosition(0.0, 0.0); QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; @@ -91,9 +92,6 @@ bool QGuiApplicationPrivate::app_do_modal = false; QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette -qreal qt_last_x = 0; -qreal qt_last_y = 0; - Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton; ulong QGuiApplicationPrivate::mousePressTime = 0; Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; @@ -554,7 +552,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo QEvent::Type type; // move first Qt::MouseButtons stateChange = e->buttons ^ buttons; - if (e->globalPos != QPointF(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) { + if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) { QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent = new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->localPos, e->globalPos, e->buttons); QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop @@ -568,10 +566,9 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo Qt::MouseButton button = Qt::NoButton; - if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) { + if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) { type = QEvent::MouseMove; - qt_last_x = globalPoint.x(); - qt_last_y = globalPoint.y(); + QGuiApplicationPrivate::lastCursorPosition = globalPoint; if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance|| qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance) mousePressButton = Qt::NoButton; @@ -599,8 +596,9 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo type = QEvent::MouseButtonPress; mousePressTime = e->timestamp; mousePressButton = button; - mousePressX = qt_last_x; - mousePressY = qt_last_y; + const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint(); + mousePressX = point.x(); + mousePressY = point.y(); } } else @@ -630,9 +628,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh return; QPointF globalPoint = e->globalPos; - - qt_last_x = globalPoint.x(); - qt_last_y = globalPoint.y(); + QGuiApplicationPrivate::lastCursorPosition = globalPoint; QWindow *window = e->window.data(); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index f7fa512..1591ed8 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -44,6 +44,7 @@ #include +#include #include #include @@ -156,6 +157,7 @@ public: static int mousePressX; static int mousePressY; static int mouse_double_click_distance; + static QPointF lastCursorPosition; #ifndef QT_NO_CLIPBOARD static QClipboard *qt_clipboard; diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp index ed103a5..56d2847 100644 --- a/src/gui/kernel/qplatformcursor_qpa.cpp +++ b/src/gui/kernel/qplatformcursor_qpa.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -98,13 +99,10 @@ QPlatformCursor::QPlatformCursor(QPlatformScreen *scr ) QPlatformCursorPrivate::instances.append(this); } -extern int qt_last_x; -extern int qt_last_y; - QPoint QPlatformCursor::pos() const { // As a fallback return the last mouse position seen by QGuiApplication. - return QPoint(qt_last_x, qt_last_y); + return QGuiApplicationPrivate::lastCursorPosition.toPoint(); } void QPlatformCursor::setPos(const QPoint &pos) -- 2.7.4