From 837d75eed500bd0138d78c60edc54d0dd75967cf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Feb 2016 13:24:05 +0100 Subject: qt_handleTouchEvent(): Scale coordinates when converting touch points. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove outdated static functions to convert touch points and use QWindowSystemInterfacePrivate::fromNativeTouchPoints(). Fix tst_QWidget::underMouse() to pass when High DPI scaling is in effect. .\tst_qwidget.cpp(9000) : failure location FAIL! : tst_QWidget::underMouse() 'childWidget1.underMouse()' returned FALSE. () .\tst_qwidget.cpp(10161) : failure location Task-number: QTBUG-46615 Change-Id: Ie73dba610da357e7be396f2ea0229987f7503462 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindowsysteminterface.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'src/gui/kernel/qwindowsysteminterface.cpp') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index e10ddf22a7..b0772e7a96 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -906,36 +906,14 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int #endif } -static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt) -{ - QWindowSystemInterface::TouchPoint p; - p.id = pt.id(); - p.flags = pt.flags(); - p.normalPosition = pt.normalizedPos(); - p.area = pt.screenRect(); - p.pressure = pt.pressure(); - p.state = pt.state(); - p.velocity = pt.velocity(); - p.rawPositions = pt.rawScreenPositions(); - return p; -} -static QList touchPointList(const QList& pointList) -{ - QList newList; - - Q_FOREACH (QTouchEvent::TouchPoint p, pointList) - newList.append(touchPoint(p)); - - return newList; -} - Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device, const QList &points, Qt::KeyboardModifiers mods = Qt::NoModifier) { bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents; QWindowSystemInterface::setSynchronousWindowSystemEvents(true); - QWindowSystemInterface::handleTouchEvent(w, device, touchPointList(points), mods); + QWindowSystemInterface::handleTouchEvent(w, device, + QWindowSystemInterfacePrivate::toNativeTouchPoints(points, w), mods); QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous); } -- cgit v1.2.3 From defd302f64f213a8764875a88788dbcea76d66f0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 26 Feb 2016 13:22:36 +0100 Subject: qt_handleMouseEvent(): Scale coordinates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix tst_qwindow::testInputEvents() to pass when High DPI scaling is in effect. FAIL! : tst_QWindow::testInputEvents() Compared values are not the same Actual (window.mousePressLocalPos): QPointF(6,17) Expected (local) : QPointF(12,34) .\tst_qwindow.cpp(771) : failure location Task-number: QTBUG-46615 Change-Id: I1ccacc807f3390b6ab26a369d13fd7896e64cbca Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindowsysteminterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel/qwindowsysteminterface.cpp') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index b0772e7a96..841e4f8f41 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -857,7 +857,9 @@ Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QP { bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents; QWindowSystemInterface::setSynchronousWindowSystemEvents(true); - QWindowSystemInterface::handleMouseEvent(w, timestamp, local, global, b, mods); + const qreal factor = QHighDpiScaling::factor(w); + QWindowSystemInterface::handleMouseEvent(w, timestamp, local * factor, + global * factor, b, mods); QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous); } -- cgit v1.2.3 From d5fde514106f5479f9c929c8a165aced4a1b2c84 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 1 Mar 2016 13:17:13 +0100 Subject: QWheelEvent: make NoScrollPhase opt-in The fix for QTBUG-50199 involves adding an undocumented enum value which can be returned from QWheelEvent::phase(). This will be quite unexpected for applications that use it, which work fine with 5.6.0 and then start receiving this new phase value in 5.6.1. So it should not happen by default. Set the env variable QT_ENABLE_MOUSE_WHEEL_TRACKING to enable this functionality. In 5.7 it will be default behavior. But in 5.6 the default behavior is as it was before: if you use a conventional mouse wheel, the phase stays at ScrollUpdate continuously. [ChangeLog][QtCore] QWheelEvent::phase() returns 0 rather than Qt::ScrollUpdate when the wheel event comes from an actual non-emulated mouse wheel and the environment variable QT_ENABLE_MOUSE_WHEEL_TRACKING is set. In Qt 5.6, this is required to enable the fix for QTBUG-50199. Change-Id: Ieb2152ff767df24c42730d201235d1225aaec832 Reviewed-by: Gabriel de Dietrich Reviewed-by: Shawn Rutledge Reviewed-by: Alex Blasche --- src/gui/kernel/qwindowsysteminterface.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/gui/kernel/qwindowsysteminterface.cpp') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 841e4f8f41..cae976098c 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -311,6 +311,9 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource source) { + if (!QGuiApplicationPrivate::scrollNoPhaseAllowed && phase == Qt::NoScrollPhase) + phase = Qt::ScrollUpdate; + // Qt 4 sends two separate wheel events for horizontal and vertical // deltas. For Qt 5 we want to send the deltas in one event, but at the // same time preserve source and behavior compatibility with Qt 4. @@ -930,5 +933,13 @@ bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowS return true; } +QWindowSystemInterfacePrivate::WheelEvent::WheelEvent(QWindow *w, ulong time, const QPointF &local, const QPointF &global, QPoint pixelD, + QPoint angleD, int qt4D, Qt::Orientation qt4O, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource src) + : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), + qt4Orientation(qt4O), localPos(local), globalPos(global), + phase(!QGuiApplicationPrivate::scrollNoPhaseAllowed && phase == Qt::NoScrollPhase ? Qt::ScrollUpdate : phase), + source(src) +{ +} QT_END_NAMESPACE -- cgit v1.2.3