From 37d5aaa4b42f9c837f0d27edb9da2185971d02be Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 11 Jun 2020 09:24:12 +0200 Subject: Change QWindow/QWidget::map(To/From)(Global/Parent) to operate in float Change the functions to operate in float and add the QPoint versions as overload calling them. This is more in-line with the event accessors using float and allows for removing some workarounds using a delta when converting touch points. Leave QPlatformWindow::map(To/From)Global() as is for now and add helpers for float. Change-Id: I2d46b8dbda8adff26539e358074b55073dc80b6f Reviewed-by: Shawn Rutledge Reviewed-by: Volker Hilsheimer --- src/gui/kernel/qguiapplication.cpp | 16 ++------ src/gui/kernel/qhighdpiscaling.cpp | 20 +++++----- src/gui/kernel/qhighdpiscaling_p.h | 4 +- src/gui/kernel/qplatformwindow.cpp | 14 +++++++ src/gui/kernel/qplatformwindow.h | 2 + src/gui/kernel/qsimpledrag.cpp | 2 +- src/gui/kernel/qwindow.cpp | 35 ++++++++++++----- src/gui/kernel/qwindow.h | 2 + src/widgets/kernel/qapplication.cpp | 9 ++--- src/widgets/kernel/qwidget.cpp | 76 ++++++++++++++++++++++++++++++------ src/widgets/kernel/qwidget.h | 6 +++ src/widgets/kernel/qwidgetwindow.cpp | 10 ++--- src/widgets/util/qflickgesture.cpp | 4 +- src/widgets/widgets/qmenu.cpp | 6 +-- 14 files changed, 144 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index fbfce44767..2a4b286a05 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2191,8 +2191,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo window = currentMousePressWindow; currentMousePressWindow = nullptr; } - QPointF delta = globalPoint - globalPoint.toPoint(); - localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; + localPoint = window->mapFromGlobal(globalPoint); } } @@ -2285,10 +2284,8 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh if (e->nullWindow()) { window = QGuiApplication::topLevelAt(globalPoint.toPoint()); - if (window) { - QPointF delta = globalPoint - globalPoint.toPoint(); - localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; - } + if (window) + localPoint = window->mapFromGlobal(globalPoint); } if (!window) @@ -2962,12 +2959,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To for (QEventPoint &pt : touchEvent.touchPoints()) { auto &touchPoint = QMutableEventPoint::from(pt); - - // preserve the sub-pixel resolution - const QPointF screenPos = touchPoint.globalPosition(); - const QPointF delta = screenPos - screenPos.toPoint(); - - touchPoint.setPosition(w->mapFromGlobal(screenPos.toPoint()) + delta); + touchPoint.setPosition(w->mapFromGlobal(touchPoint.globalPosition())); } QGuiApplication::sendSpontaneousEvent(w, &touchEvent); diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 496cae7c26..7107e37e40 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -599,9 +599,9 @@ QPoint QHighDpiScaling::mapPositionFromNative(const QPoint &pos, const QPlatform return (pos - topLeft) / scaleFactor + topLeft; } -QPoint QHighDpiScaling::mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window) +QPointF QHighDpiScaling::mapPositionToGlobal(const QPointF &pos, const QPoint &windowGlobalPosition, const QWindow *window) { - QPoint globalPosCandidate = pos + windowGlobalPosition; + QPointF globalPosCandidate = pos + QPointF(windowGlobalPosition); if (QGuiApplicationPrivate::screen_list.size() <= 1) return globalPosCandidate; @@ -609,18 +609,18 @@ QPoint QHighDpiScaling::mapPositionToGlobal(const QPoint &pos, const QPoint &win // in cases where a window spans screens. Detect this case and map via // native coordinates to the correct screen. auto currentScreen = window->screen(); - if (currentScreen && !currentScreen->geometry().contains(globalPosCandidate)) { - auto nativeGlobalPos = QHighDpi::toNativePixels(globalPosCandidate, currentScreen); - if (auto actualPlatformScreen = currentScreen->handle()->screenForPosition(nativeGlobalPos)) + if (currentScreen && !currentScreen->geometry().contains(globalPosCandidate.toPoint())) { + QPointF nativeGlobalPos = QHighDpi::toNativePixels(globalPosCandidate, currentScreen); + if (auto actualPlatformScreen = currentScreen->handle()->screenForPosition(nativeGlobalPos.toPoint())) return QHighDpi::fromNativePixels(nativeGlobalPos, actualPlatformScreen->screen()); } return globalPosCandidate; } -QPoint QHighDpiScaling::mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window) +QPointF QHighDpiScaling::mapPositionFromGlobal(const QPointF &pos, const QPoint &windowGlobalPosition, const QWindow *window) { - QPoint windowPosCandidate = pos - windowGlobalPosition; + QPointF windowPosCandidate = pos - QPointF(windowGlobalPosition); if (QGuiApplicationPrivate::screen_list.size() <= 1 || window->handle() == nullptr) return windowPosCandidate; @@ -629,10 +629,10 @@ QPoint QHighDpiScaling::mapPositionFromGlobal(const QPoint &pos, const QPoint &w // position-to-be-mapped may not work in cases where a window spans multiple screens. // Map both positions to native global space (using the correct screens), subtract there, // and then map the difference back using the scale factor for the window. - QScreen *posScreen = QGuiApplication::screenAt(pos); + QScreen *posScreen = QGuiApplication::screenAt(pos.toPoint()); if (posScreen && posScreen != window->screen()) { - QPoint nativePos = QHighDpi::toNativePixels(pos, posScreen); - QPoint windowNativePos = window->handle()->geometry().topLeft(); + QPointF nativePos = QHighDpi::toNativePixels(pos, posScreen); + QPointF windowNativePos = window->handle()->geometry().topLeft(); return QHighDpi::fromNativeLocalPosition(nativePos - windowNativePos, window); } diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 2248a7f6a1..1fee8564d9 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -112,8 +112,8 @@ public: static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen); static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); - static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); - static QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); + static QPointF mapPositionToGlobal(const QPointF &pos, const QPoint &windowGlobalPosition, const QWindow *window); + static QPointF mapPositionFromGlobal(const QPointF &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QDpi logicalDpi(const QScreen *screen); private: diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index c6e6afcc91..4b7d7f5b7e 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -266,6 +266,20 @@ QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const return result; } +QPointF QPlatformWindow::mapToGlobalF(const QPointF &pos) const +{ + const QPoint posPt = pos.toPoint(); + const QPointF delta = pos - posPt; + return mapToGlobal(posPt) + delta; +} + +QPointF QPlatformWindow::mapFromGlobalF(const QPointF &pos) const +{ + const QPoint posPt = pos.toPoint(); + const QPointF delta = pos - posPt; + return mapFromGlobal(posPt) + delta; +} + /*! Translates the global screen coordinate \a pos to window coordinates using native methods. This is required for embedded windows, diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index e6f087ebd0..8d2f4b3fbd 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -113,7 +113,9 @@ public: virtual bool isEmbedded() const; virtual bool isForeignWindow() const { return false; } virtual QPoint mapToGlobal(const QPoint &pos) const; + QPointF mapToGlobalF(const QPointF &pos) const; virtual QPoint mapFromGlobal(const QPoint &pos) const; + QPointF mapFromGlobalF(const QPointF &pos) const; virtual void propagateSizeHints(); diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 20aacbdd16..a02efd5a7a 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -180,7 +180,7 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e) qCDebug(lcDnd) << "mouse released over" << releaseWindow << "after drag from" << m_sourceWindow << "globalPos" << release->globalPosition().toPoint(); if (!releaseWindow) releaseWindow = m_sourceWindow; - QPoint releaseWindowPos = (releaseWindow ? releaseWindow->mapFromGlobal(release->globalPosition().toPoint()) : release->globalPosition().toPoint()); + QPointF releaseWindowPos = (releaseWindow ? releaseWindow->mapFromGlobal(release->globalPosition()) : release->globalPosition()); QMouseEvent *newRelease = new QMouseEvent(release->type(), releaseWindowPos, releaseWindowPos, release->globalPosition(), release->button(), release->buttons(), diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 9e11156c26..1ba81387a9 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2631,51 +2631,68 @@ bool QWindow::nativeEvent(const QByteArray &eventType, void *message, long *resu } /*! - \fn QPoint QWindow::mapToGlobal(const QPoint &pos) const + \fn QPointF QWindow::mapToGlobal(const QPointF &pos) const Translates the window coordinate \a pos to global screen - coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give + coordinates. For example, \c{mapToGlobal(QPointF(0,0))} would give the global coordinates of the top-left pixel of the window. \sa mapFromGlobal() + \since 6.0 */ -QPoint QWindow::mapToGlobal(const QPoint &pos) const +QPointF QWindow::mapToGlobal(const QPointF &pos) const { Q_D(const QWindow); // QTBUG-43252, prefer platform implementation for foreign windows. if (d->platformWindow && (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) { - return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this); + return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobalF(QHighDpi::toNativeLocalPosition(pos, this)), this); } if (QHighDpiScaling::isActive()) return QHighDpiScaling::mapPositionToGlobal(pos, d->globalPosition(), this); - return pos + d->globalPosition(); + return pos + QPointF(d->globalPosition()); } +/*! + \overload +*/ +QPoint QWindow::mapToGlobal(const QPoint &pos) const +{ + return mapToGlobal(QPointF(pos)).toPoint(); +} /*! - \fn QPoint QWindow::mapFromGlobal(const QPoint &pos) const + \fn QPointF QWindow::mapFromGlobal(const QPointF &pos) const Translates the global screen coordinate \a pos to window coordinates. \sa mapToGlobal() + \since 6.0 */ -QPoint QWindow::mapFromGlobal(const QPoint &pos) const +QPointF QWindow::mapFromGlobal(const QPointF &pos) const { Q_D(const QWindow); // QTBUG-43252, prefer platform implementation for foreign windows. if (d->platformWindow && (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) { - return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this); + return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobalF(QHighDpi::toNativeLocalPosition(pos, this)), this); } if (QHighDpiScaling::isActive()) return QHighDpiScaling::mapPositionFromGlobal(pos, d->globalPosition(), this); - return pos - d->globalPosition(); + return pos - QPointF(d->globalPosition()); +} + +/*! + \overload +*/ +QPoint QWindow::mapFromGlobal(const QPoint &pos) const +{ + return QWindow::mapFromGlobal(QPointF(pos)).toPoint(); } QPoint QWindowPrivate::globalPosition() const diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 2cca039883..02759a20ed 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -260,6 +260,8 @@ public: virtual QAccessibleInterface *accessibleRoot() const; virtual QObject *focusObject() const; + QPointF mapToGlobal(const QPointF &pos) const; + QPointF mapFromGlobal(const QPointF &pos) const; QPoint mapToGlobal(const QPoint &pos) const; QPoint mapFromGlobal(const QPoint &pos) const; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f19801f511..951fc9cd67 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3207,7 +3207,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } if (w->isWindow()) break; - dragEvent->p = w->mapToParent(dragEvent->p.toPoint()); + dragEvent->p = w->mapToParent(dragEvent->p); w = w->parentWidget(); } } @@ -3232,7 +3232,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QDropEvent *dragEvent = static_cast(e); QWidget *origReciver = static_cast(receiver); while (origReciver && w != origReciver) { - dragEvent->p = origReciver->mapToParent(dragEvent->p.toPoint()); + dragEvent->p = origReciver->mapToParent(dragEvent->p); origReciver = origReciver->parentWidget(); } } @@ -3942,11 +3942,8 @@ bool QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEven bool containsPress = false; for (QEventPoint &pt : QMutableTouchEvent::from(touchEvent)->touchPoints()) { - // preserve the sub-pixel resolution const QPointF screenPos = pt.globalPosition(); - const QPointF delta = screenPos - screenPos.toPoint(); - - QMutableEventPoint::from(pt).setPosition(widget->mapFromGlobal(screenPos.toPoint()) + delta); + QMutableEventPoint::from(pt).setPosition(widget->mapFromGlobal(screenPos)); if (pt.state() == QEventPoint::State::Pressed) containsPress = true; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index dcebc5e5df..01755e01c7 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4029,15 +4029,16 @@ void QWidget::setFixedHeight(int h) of the calling widget. \sa mapFrom(), mapToParent(), mapToGlobal(), underMouse() + \since 6.0 */ -QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const +QPointF QWidget::mapTo(const QWidget *parent, const QPointF &pos) const { - QPoint p = pos; + QPointF p = pos; if (parent) { const QWidget * w = this; while (w != parent) { - Q_ASSERT_X(w, "QWidget::mapTo(const QWidget *parent, const QPoint &pos)", + Q_ASSERT_X(w, "QWidget::mapTo(const QWidget *parent, const QPointF &pos)", "parent must be in parent hierarchy"); p = w->mapToParent(p); w = w->parentWidget(); @@ -4046,6 +4047,13 @@ QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const return p; } +/*! + \overload +*/ +QPoint QWidget::mapTo(const QWidget *parent, const QPoint &pos) const +{ + return mapTo(parent, QPointF(pos)).toPoint(); +} /*! Translates the widget coordinate \a pos from the coordinate system @@ -4053,11 +4061,12 @@ QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const must not be \nullptr and must be a parent of the calling widget. \sa mapTo(), mapFromParent(), mapFromGlobal(), underMouse() + \since 6.0 */ -QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const +QPointF QWidget::mapFrom(const QWidget *parent, const QPointF &pos) const { - QPoint p(pos); + QPointF p(pos); if (parent) { const QWidget * w = this; while (w != parent) { @@ -4071,6 +4080,13 @@ QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const return p; } +/*! + \overload +*/ +QPoint QWidget::mapFrom(const QWidget *parent, const QPoint &pos) const +{ + return mapFrom(parent, QPointF(pos)).toPoint(); +} /*! Translates the widget coordinate \a pos to a coordinate in the @@ -4079,8 +4095,17 @@ QPoint QWidget::mapFrom(const QWidget * parent, const QPoint & pos) const Same as mapToGlobal() if the widget has no parent. \sa mapFromParent(), mapTo(), mapToGlobal(), underMouse() + \since 6.0 */ +QPointF QWidget::mapToParent(const QPointF &pos) const +{ + return pos + QPointF(data->crect.topLeft()); +} + +/*! + \overload +*/ QPoint QWidget::mapToParent(const QPoint &pos) const { return pos + data->crect.topLeft(); @@ -4093,8 +4118,17 @@ QPoint QWidget::mapToParent(const QPoint &pos) const Same as mapFromGlobal() if the widget has no parent. \sa mapToParent(), mapFrom(), mapFromGlobal(), underMouse() + \since 6.0 */ +QPointF QWidget::mapFromParent(const QPointF &pos) const +{ + return pos - QPointF(data->crect.topLeft()); +} + +/*! + \overload +*/ QPoint QWidget::mapFromParent(const QPoint &pos) const { return pos - data->crect.topLeft(); @@ -12177,36 +12211,54 @@ static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w) } /*! - \fn QPoint QWidget::mapToGlobal(const QPoint &pos) const + \fn QPointF QWidget::mapToGlobal(const QPointF &pos) const Translates the widget coordinate \a pos to global screen - coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give + coordinates. For example, \c{mapToGlobal(QPointF(0,0))} would give the global coordinates of the top-left pixel of the widget. \sa mapFromGlobal(), mapTo(), mapToParent() + \since 6.0 */ -QPoint QWidget::mapToGlobal(const QPoint &pos) const +QPointF QWidget::mapToGlobal(const QPointF &pos) const { const MapToGlobalTransformResult t = mapToGlobalTransform(this); - const QPoint g = t.transform.map(pos); + const QPointF g = t.transform.map(pos); return t.window ? t.window->mapToGlobal(g) : g; } /*! - \fn QPoint QWidget::mapFromGlobal(const QPoint &pos) const + \overload +*/ +QPoint QWidget::mapToGlobal(const QPoint &pos) const +{ + return mapToGlobal(QPointF(pos)).toPoint(); +} + +/*! + \fn QPointF QWidget::mapFromGlobal(const QPointF &pos) const Translates the global screen coordinate \a pos to widget coordinates. \sa mapToGlobal(), mapFrom(), mapFromParent() + \since 6.0 */ -QPoint QWidget::mapFromGlobal(const QPoint &pos) const +QPointF QWidget::mapFromGlobal(const QPointF &pos) const { const MapToGlobalTransformResult t = mapToGlobalTransform(this); - const QPoint windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos; + const QPointF windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos; return t.transform.inverted().map(windowLocal); } +/*! + \overload +*/ +QPoint QWidget::mapFromGlobal(const QPoint &pos) const +{ + return mapFromGlobal(QPointF(pos)).toPoint(); +} + QWidget *qt_pressGrab = nullptr; QWidget *qt_mouseGrb = nullptr; static bool mouseGrabWithCursor = false; diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 0d2c2913f9..2bfff96252 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -295,11 +295,17 @@ public: // Widget coordinate mapping + QPointF mapToGlobal(const QPointF &) const; QPoint mapToGlobal(const QPoint &) const; + QPointF mapFromGlobal(const QPointF &) const; QPoint mapFromGlobal(const QPoint &) const; + QPointF mapToParent(const QPointF &) const; QPoint mapToParent(const QPoint &) const; + QPointF mapFromParent(const QPointF &) const; QPoint mapFromParent(const QPoint &) const; + QPointF mapTo(const QWidget *, const QPointF &) const; QPoint mapTo(const QWidget *, const QPoint &) const; + QPointF mapFrom(const QWidget *, const QPointF &) const; QPoint mapFrom(const QWidget *, const QPoint &) const; QWidget *window() const; diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 05bf43d669..32d89dbb44 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -845,25 +845,25 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) return; QWidget *rootWidget = m_widget; - QPoint pos = event->position().toPoint(); + QPointF pos = event->position(); // Use proper popup window for wheel event. Some QPA sends the wheel // event to the root menu, so redirect it to the proper popup window. QWidget *activePopupWidget = QApplication::activePopupWidget(); if (activePopupWidget && activePopupWidget != m_widget) { rootWidget = activePopupWidget; - pos = rootWidget->mapFromGlobal(event->globalPosition().toPoint()); + pos = rootWidget->mapFromGlobal(event->globalPosition()); } // which child should have it? - QWidget *widget = rootWidget->childAt(pos); + QWidget *widget = rootWidget->childAt(pos.toPoint()); if (!widget) widget = rootWidget; - QPoint mapped = widget->mapFrom(rootWidget, pos); + QPointF mapped = widget->mapFrom(rootWidget, pos); - QWheelEvent translated(QPointF(mapped), event->globalPosition(), event->pixelDelta(), event->angleDelta(), + QWheelEvent translated(mapped, event->globalPosition(), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), event->inverted(), event->source(), event->pointingDevice()); translated.setTimestamp(event->timestamp()); diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 7d12350c9a..3b4af0fe8f 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -297,8 +297,8 @@ protected: #endif // QT_CONFIG(graphicsview) if (me) { - QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPosition().toPoint()), - mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPosition().toPoint()), me->globalPosition(), + QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPosition()), + mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPosition()), me->globalPosition(), me->button(), me->buttons(), me->modifiers(), me->source()); qt_sendSpontaneousEvent(mouseTarget, ©); } diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 5edc480949..74420ecb2c 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1356,14 +1356,14 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) for(QWidget *caused = causedPopup.widget; caused;) { bool passOnEvent = false; QWidget *next_widget = nullptr; - QPoint cpos = caused->mapFromGlobal(e->globalPosition().toPoint()); + QPointF cpos = caused->mapFromGlobal(e->globalPosition()); #if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(caused)) { - passOnEvent = mb->rect().contains(cpos); + passOnEvent = mb->rect().contains(cpos.toPoint()); } else #endif if (QMenu *m = qobject_cast(caused)) { - passOnEvent = m->rect().contains(cpos); + passOnEvent = m->rect().contains(cpos.toPoint()); next_widget = m->d_func()->causedPopup.widget; } if (passOnEvent) { -- cgit v1.2.3