summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2012-11-07 16:23:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-10 20:08:28 +0100
commit2d07d3b4e3036179667a822aa40285d071b76b9e (patch)
tree715e5c6a92426f1ac1cd4cd585e02cf8cab05002 /src
parent1fe0c2c25dc96e9af6f442cf059ad627d45f10fa (diff)
Add a QEnterEvent containing the mouse position.
Enter handling requires knowledge of the mouse position. Extend the enter handling of QWindowSystemInterface to receive the position (implemented for Windows, XCB and Mac), passing it on to QEnterEvent. Dispatch QEnterEvent from widgets code. Change-Id: I49c07d2b1f46310c877017dd55d4cd7d636bdbce Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/gui/kernel/qevent.cpp34
-rw-r--r--src/gui/kernel/qevent.h22
-rw-r--r--src/gui/kernel/qguiapplication.cpp2
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp8
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h6
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm23
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/widgets/kernel/qapplication.cpp40
-rw-r--r--src/widgets/kernel/qapplication_p.h2
-rw-r--r--src/widgets/kernel/qapplication_qpa.cpp3
-rw-r--r--src/widgets/kernel/qwidget.cpp2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp6
16 files changed, 124 insertions, 46 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index c0292ee984..b9136b5335 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -121,7 +121,7 @@ QT_BEGIN_NAMESPACE
\value Drop A drag and drop operation is completed (QDropEvent).
\value DynamicPropertyChange A dynamic property was added, changed, or removed from the object.
\value EnabledChange Widget's enabled state has changed.
- \value Enter Mouse enters widget's boundaries.
+ \value Enter Mouse enters widget's boundaries (QEnterEvent).
\value EnterEditFocus An editor widget gains focus for editing. QT_KEYPAD_NAVIGATION must be defined.
\value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode.
\value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store.
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 3dbef228a5..66434f9a53 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -56,6 +56,40 @@
QT_BEGIN_NAMESPACE
/*!
+ \class QEnterEvent
+ \ingroup events
+
+ \brief The QEnterEvent class contains parameters that describe an enter event.
+
+ Enter events occur when the mouse cursor enters a window or a widget.
+
+ \since 5.0
+*/
+
+/*!
+ Constructs an enter event object.
+
+ The points \a localPos, \a windowPos and \a screenPos specify the
+ mouse cursor's position relative to the receiving widget or item,
+ window, and screen, respectively.
+*/
+
+QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos)
+ : QEvent(QEvent::Enter)
+ , l(localPos)
+ , w(windowPos)
+ , s(screenPos)
+{
+}
+
+/*!
+ \internal
+*/
+QEnterEvent::~QEnterEvent()
+{
+}
+
+/*!
\class QInputEvent
\ingroup events
\inmodule QtGui
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index b35dd88c2a..82d22aec05 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -83,6 +83,28 @@ protected:
ulong ts;
};
+class Q_GUI_EXPORT QEnterEvent : public QEvent
+{
+public:
+ QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos);
+ ~QEnterEvent();
+
+#ifndef QT_NO_INTEGER_EVENT_COORDINATES
+ inline QPoint pos() const { return l.toPoint(); }
+ inline QPoint globalPos() const { return s.toPoint(); }
+ inline int x() const { return qRound(l.x()); }
+ inline int y() const { return qRound(l.y()); }
+ inline int globalX() const { return qRound(s.x()); }
+ inline int globalY() const { return qRound(s.y()); }
+#endif
+ const QPointF &localPos() const { return l; }
+ const QPointF &windowPos() const { return w; }
+ const QPointF &screenPos() const { return s; }
+
+protected:
+ QPointF l, w, s;
+};
+
class Q_GUI_EXPORT QMouseEvent : public QInputEvent
{
public:
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index ca9d60fcdf..4c4e75c4f6 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1424,7 +1424,7 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En
currentMouseWindow = e->enter;
- QEvent event(QEvent::Enter);
+ QEnterEvent event(e->localPos, e->localPos, e->globalPos);
QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
}
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 6fb10b6c75..acc6eace99 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -75,10 +75,10 @@ extern QPointer<QWindow> qt_last_mouse_receiver;
until sendWindowSystemEvents() is called by the event dispatcher.
*/
-void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
+void QWindowSystemInterface::handleEnterEvent(QWindow *tlw, const QPointF &local, const QPointF &global)
{
if (tlw) {
- QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
+ QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw, local, global);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
}
@@ -96,13 +96,13 @@ void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
determine where mouse went and act accordingly. E.g. QWidgetWindow needs to know if mouse
cursor moves between windows in same window hierarchy.
*/
-void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave)
+void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local, const QPointF& global)
{
bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowsSystemEvents;
if (wasSynchronous)
setSynchronousWindowsSystemEvents(false);
handleLeaveEvent(leave);
- handleEnterEvent(enter);
+ handleEnterEvent(enter, local, global);
if (wasSynchronous) {
flushWindowSystemEvents();
setSynchronousWindowsSystemEvents(true);
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index b4b2e845fc..a3d2f1b000 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -134,9 +134,9 @@ public:
static void handleGeometryChange(QWindow *w, const QRect &newRect);
static void handleCloseEvent(QWindow *w);
- static void handleEnterEvent(QWindow *w);
+ static void handleEnterEvent(QWindow *w, const QPointF &local = QPointF(), const QPointF& global = QPointF());
static void handleLeaveEvent(QWindow *w);
- static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave);
+ static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
static void handleWindowActivated(QWindow *w);
static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 5867337de6..b174fd0ca2 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -119,10 +119,12 @@ public:
class EnterEvent : public WindowSystemEvent {
public:
- explicit EnterEvent(QWindow *enter)
- : WindowSystemEvent(Enter), enter(enter)
+ explicit EnterEvent(QWindow *enter, const QPointF &local, const QPointF &global)
+ : WindowSystemEvent(Enter), enter(enter), localPos(local), globalPos(global)
{ }
QPointer<QWindow> enter;
+ const QPointF localPos;
+ const QPointF globalPos;
};
class LeaveEvent : public WindowSystemEvent {
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index bbd74dd58b..4fb099341e 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -340,7 +340,7 @@ static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy
return YES;
}
-- (void)handleMouseEvent:(NSEvent *)theEvent
+- (void)convertFromEvent:(NSEvent *)event toWindowPoint:(QPoint *)qtWindowPoint andScreenPoint:(QPoint *)qtScreenPoint
{
// Calculate the mouse position in the QWindow and Qt screen coordinate system,
// starting from coordinates in the NSWindow coordinate system.
@@ -360,25 +360,29 @@ static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy
// NSView and QWindow are equal coordinate systems: the QWindow covers the
// entire NSView, and we've set the NSView's isFlipped property to true.
- NSPoint nsWindowPoint = [theEvent locationInWindow]; // NSWindow coordinates
+ NSPoint nsWindowPoint = [event locationInWindow]; // NSWindow coordinates
NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates
- QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
-
- QPoint qtScreenPoint;
+ *qtWindowPoint = QPoint(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
NSWindow *window = [self window];
// Use convertRectToScreen if available (added in 10.7).
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if ([window respondsToSelector:@selector(convertRectToScreen:)]) {
NSRect screenRect = [window convertRectToScreen : NSMakeRect(nsWindowPoint.x, nsWindowPoint.y, 0, 0)]; // OS X screen coordinates
- qtScreenPoint = QPoint(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates
+ *qtScreenPoint = QPoint(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates
} else
#endif
{
NSPoint screenPoint = [window convertBaseToScreen : NSMakePoint(nsWindowPoint.x, nsWindowPoint.y)];
- qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
+ *qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
}
+}
+
+- (void)handleMouseEvent:(NSEvent *)theEvent
+{
+ QPoint qtWindowPoint, qtScreenPoint;
+ [self convertFromEvent:theEvent toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000;
QCocoaDrag* nativeDrag = static_cast<QCocoaDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
@@ -463,8 +467,9 @@ static CGImageRef qt_mac_toCGImage(QImage *qImage, bool isMask, uchar **dataCopy
- (void)mouseEntered:(NSEvent *)theEvent
{
- Q_UNUSED(theEvent);
- QWindowSystemInterface::handleEnterEvent(m_window);
+ QPoint windowPoint, screenPoint;
+ [self convertFromEvent:theEvent toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
+ QWindowSystemInterface::handleEnterEvent(m_window, windowPoint, screenPoint);
}
- (void)mouseExited:(NSEvent *)theEvent
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 024a273022..0fb67d0e98 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -291,7 +291,9 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
if (QWindowsContext::verboseEvents)
qDebug() << "Entering " << currentWindowUnderMouse;
QWindowsWindow::baseWindowOf(currentWindowUnderMouse)->applyCursor();
- QWindowSystemInterface::handleEnterEvent(currentWindowUnderMouse);
+ QWindowSystemInterface::handleEnterEvent(currentWindowUnderMouse,
+ currentWindowUnderMouse->mapFromGlobal(globalPosition),
+ globalPosition);
}
}
m_windowUnderMouse = currentWindowUnderMouse;
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 81ab3fe4ee..b6bbbdcc30 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -1529,7 +1529,9 @@ void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event)
return;
}
- QWindowSystemInterface::handleEnterEvent(window());
+ const QPoint local(event->event_x, event->event_y);
+ const QPoint global(event->root_x, event->root_y);
+ QWindowSystemInterface::handleEnterEvent(window(), local, global);
}
void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 762f93f55b..289f9919ef 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -267,7 +267,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
}
if (!lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0);
+ QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
lastWidgetUnderMouse = receiver;
}
@@ -293,7 +293,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
else // released on the frame our outside the item, or doesn't accept hover events.
lastWidgetUnderMouse = 0;
- QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber);
+ QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
embeddedMouseGrabber = 0;
#ifndef QT_NO_CURSOR
@@ -1142,7 +1142,7 @@ void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_D(QGraphicsProxyWidget);
// If hoverMove was compressed away, make sure we update properly here.
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
d->lastWidgetUnderMouse = 0;
}
}
@@ -1159,7 +1159,7 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
// Ignore events on the window frame.
if (!d->widget || !rect().contains(event->pos())) {
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
+ QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
d->lastWidgetUnderMouse = 0;
}
return;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index aeceba1886..d62b8ef146 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2114,20 +2114,23 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
}
/*!
- \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
+ \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
\internal
Creates the proper Enter/Leave event when widget \a enter is entered and
widget \a leave is left.
*/
-void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
+void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF)
+{
+ const QPoint globalPos = globalPosF.toPoint();
#if 0
if (leave) {
QEvent e(QEvent::Leave);
QApplication::sendEvent(leave, & e);
}
if (enter) {
- QEvent e(QEvent::Enter);
+ const QPoint windowPos = enter->window()->mapFromGlobal(globalPos);
+ QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos);
QApplication::sendEvent(enter, & e);
}
return;
@@ -2205,17 +2208,20 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
}
}
}
- QPoint posEnter = QCursor::pos();
- QEvent enterEvent(QEvent::Enter);
- for (int i = 0; i < enterList.size(); ++i) {
- w = enterList.at(i);
- if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
- QApplication::sendEvent(w, &enterEvent);
- if (w->testAttribute(Qt::WA_Hover) &&
- (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1),
- QApplication::keyboardModifiers());
- qApp->d_func()->notify_helper(w, &he);
+ if (!enterList.isEmpty()) {
+ const QPoint windowPos = enterList.front()->window()->mapFromGlobal(globalPos);
+ for (int i = 0; i < enterList.size(); ++i) {
+ w = enterList.at(i);
+ if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
+ const QPointF localPos = w->mapFromGlobal(globalPos);
+ QEnterEvent enterEvent(localPos, windowPos, globalPosF);
+ QApplication::sendEvent(w, &enterEvent);
+ if (w->testAttribute(Qt::WA_Hover) &&
+ (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
+ QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1),
+ QApplication::keyboardModifiers());
+ qApp->d_func()->notify_helper(w, &he);
+ }
}
}
}
@@ -2506,9 +2512,9 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
|| (isAlien(lastMouseReceiver) && !alienWidget)) {
if (activePopupWidget) {
if (!QWidget::mouseGrabber())
- dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver);
+ dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->screenPos());
} else {
- dispatchEnterLeave(receiver, lastMouseReceiver);
+ dispatchEnterLeave(receiver, lastMouseReceiver, event->screenPos());
}
}
@@ -2540,7 +2546,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
enter = alienGuard ? alienWidget : nativeWidget;
else // The receiver is typically deleted on mouse release with drag'n'drop.
enter = QApplication::widgetAt(event->globalPos());
- dispatchEnterLeave(enter, leaveAfterRelease);
+ dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos());
leaveAfterRelease = 0;
lastMouseReceiver = enter;
} else if (!wasLeaveAfterRelease) {
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 5682d794cf..5b3493f478 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -135,7 +135,7 @@ public:
void createEventDispatcher();
- static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
+ static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF);
//modality
bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const Q_DECL_OVERRIDE;
diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp
index 5dc68e47e0..e8db364473 100644
--- a/src/widgets/kernel/qapplication_qpa.cpp
+++ b/src/widgets/kernel/qapplication_qpa.cpp
@@ -253,7 +253,8 @@ void QApplicationPrivate::openPopup(QWidget *popup)
// Dispatch leave for last mouse receiver to update undermouse states
if (qt_last_mouse_receiver && !QWidget::mouseGrabber()) {
- QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver.data());
+ QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver.data(),
+ QGuiApplicationPrivate::lastCursorPosition);
qt_last_mouse_receiver = 0;
}
}
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2feb797985..be2a5f36cd 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8563,6 +8563,8 @@ void QWidget::enterEvent(QEvent *)
{
}
+// ### Qt 6: void QWidget::enterEvent(QEnterEvent *).
+
/*!
\fn void QWidget::leaveEvent(QEvent *event)
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 1cabb095ec..c11e36312f 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -230,6 +230,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
QWindowSystemInterfacePrivate::EnterEvent *systemEvent =
static_cast<QWindowSystemInterfacePrivate::EnterEvent *>
(QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter));
+ const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition;
if (systemEvent) {
if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter))
{
@@ -255,11 +256,12 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
QWidget *leave = m_widget;
if (qt_last_mouse_receiver && !qt_last_mouse_receiver->internalWinId())
leave = qt_last_mouse_receiver.data();
- QApplicationPrivate::dispatchEnterLeave(enter, leave);
+ QApplicationPrivate::dispatchEnterLeave(enter, leave, globalPosF);
qt_last_mouse_receiver = enter;
}
} else {
- QApplicationPrivate::dispatchEnterLeave(m_widget, 0);
+ const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
+ QApplicationPrivate::dispatchEnterLeave(m_widget, 0, ee->screenPos());
qt_last_mouse_receiver = m_widget;
}
}