diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-09-01 11:13:35 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2011-09-01 13:27:37 +0200 |
commit | c2aea75c220984953c53c3813717713437649999 (patch) | |
tree | e710906642169baf9213c047329d511e673bb98a /src/widgets/kernel/qapplication.cpp | |
parent | cf5e669a06ec1d8bd08a4db9c2849c5d7ea9fec4 (diff) |
Refactor QMouseEvent to contain the position inside the window
Rename the default accessors for positions to localPos, windowPos
and screenPos, to be explicit about their use.
Introduce a QT_NO_INTEGER_EVENT_COORDINATES define so one can make sure
to always use the float based coordinates.
Fixup all Qt code to use the correct constructor that specifies all
three coordinates.
Change-Id: If4bb93b8d1e2eb2440260d99680c468706cfe68f
Reviewed-on: http://codereview.qt.nokia.com/4058
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ca44bfa848..af49b658be 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3054,16 +3054,15 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) return; // Mouse cursor not inside the widget's top-level. const QPoint globalPos(QCursor::pos()); - QPoint pos = tlw->mapFromGlobal(globalPos); + QPoint windowPos = tlw->mapFromGlobal(globalPos); // Find the current widget under the mouse. If this function was called from // the widget's destructor, we have to make sure childAt() doesn't take into // account widgets that are about to be destructed. - QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(pos, widget->data->in_destructor); + QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(windowPos, widget->data->in_destructor); if (!widgetUnderCursor) widgetUnderCursor = tlw; - else - pos = widgetUnderCursor->mapFrom(tlw, pos); + QPoint pos = widgetUnderCursor->mapFrom(tlw, windowPos); if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor)) return; // Mouse cursor not inside the widget or any of its children. @@ -3072,7 +3071,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) qt_button_down = 0; // Send enter/leave events followed by a mouse move on the entered widget. - QMouseEvent e(QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QMouseEvent e(QEvent::MouseMove, pos, windowPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver); #endif // QT_NO_CURSOR } @@ -3788,7 +3787,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QPointer<QWidget> pw = w; while (w) { - QMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->buttons(), + QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), mouse->button(), mouse->buttons(), mouse->modifiers()); me.spont = mouse->spontaneous(); // throw away any mouse-tracking-only mouse events |