From 317908e72a6ea0b4ca179690539cb352bbf60832 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 16 Jan 2018 14:29:40 +0100 Subject: Use localPos for windowPos when passing mouse events to QQuickWidget QQuickWidget thinks of itself as a toplevel window, so it cannot process the offsets in a parent window. Amends 41293196b4db1aa7a0c616af312875c484639644. Task-number: QTBUG-65800 Change-Id: I8c5dcb8f44a6cbdb58bcc956d8263e68d8180bec Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- src/quickwidgets/qquickwidget.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/quickwidgets/qquickwidget.cpp') diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index fd1ae52298..b15df88112 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1246,11 +1246,11 @@ void QQuickWidget::mouseMoveEvent(QMouseEvent *e) Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseMove, e->localPos().x(), e->localPos().y()); - // Use the constructor taking localPos and screenPos. That puts localPos into the - // event's localPos and windowPos, and screenPos into the event's screenPos. This way - // the windowPos in e is ignored and is replaced by localPos. This is necessary - // because QQuickWindow thinks of itself as a top-level window always. - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + // Put localPos into the event's localPos and windowPos, and screenPos into the + // event's screenPos. This way the windowPos in e is ignored and is replaced by + // localPos. This is necessary because QQuickWindow thinks of itself as a + // top-level window always. + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); e->setAccepted(mappedEvent.isAccepted()); @@ -1265,11 +1265,11 @@ void QQuickWidget::mouseDoubleClickEvent(QMouseEvent *e) // As the second mouse press is suppressed in widget windows we emulate it here for QML. // See QTBUG-25831 - QMouseEvent pressEvent(QEvent::MouseButtonPress, e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent pressEvent(QEvent::MouseButtonPress, e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &pressEvent); e->setAccepted(pressEvent.isAccepted()); - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); } @@ -1330,7 +1330,7 @@ void QQuickWidget::mousePressEvent(QMouseEvent *e) Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMousePress, e->button(), e->buttons()); - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); e->setAccepted(mappedEvent.isAccepted()); @@ -1343,7 +1343,7 @@ void QQuickWidget::mouseReleaseEvent(QMouseEvent *e) Q_QUICK_INPUT_PROFILE(QQuickProfiler::Mouse, QQuickProfiler::InputMouseRelease, e->button(), e->buttons()); - QMouseEvent mappedEvent(e->type(), e->localPos(), e->windowPos(), e->screenPos(), + QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); e->setAccepted(mappedEvent.isAccepted()); -- cgit v1.2.3