Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:thiagomacieira:branches:openSUSE:Factory
libqt5-qtbase
3004-QHighDpi-global-geometry-scaling-functions...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 3004-QHighDpi-global-geometry-scaling-functions.patch of Package libqt5-qtbase
From 4485fc7ead55d3d808b6b507d05a2c206c57f599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> Date: Wed, 27 May 2020 01:03:52 +0200 Subject: [PATCH 3004/3009] QHighDpi: global geometry scaling functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add functions for scaling global coordinates: toNativeGlobalPosition() fromNativeGlobalPosition() These correctly handle the cases where a window spans several screens. Change-Id: I268762499cd8d86a3c417342ddaf2fb6dab4dd20 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry-picked from commit 73a93981ca6bd641f2c75faf3cdce1fa0711fbb5) --- src/gui/kernel/qhighdpiscaling_p.h | 16 ++++++++++++++ src/gui/kernel/qwindowsysteminterface.cpp | 27 +++++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 3208415298..2797ad590e 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -263,6 +263,22 @@ T toNativeLocalPosition(const T &value, const C *context) return scale(value, QHighDpiScaling::factor(context)); } +template <typename T, typename C> +T fromNativeGlobalPosition(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = + QHighDpiScaling::scaleAndOrigin(context, position(value, QHighDpiScaling::Point::Native)); + return scale(value, qreal(1) / so.factor, so.origin); +} + +template <typename T, typename C> +T toNativeGlobalPosition(const T &value, const C *context) +{ + QHighDpiScaling::ScaleAndOrigin so = + QHighDpiScaling::scaleAndOrigin(context, position(value, QHighDpiScaling::Point::DeviceIndependent)); + return scale(value, so.factor, so.origin); +} + template <typename T> inline T fromNative(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0)) { diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 600cd9a7a5..de0a199b87 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -221,7 +221,7 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleEnterEvent, QWindow *window, const QPoin { if (window) { QWindowSystemInterfacePrivate::EnterEvent *e - = new QWindowSystemInterfacePrivate::EnterEvent(window, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window)); + = new QWindowSystemInterfacePrivate::EnterEvent(window, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window)); QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } } @@ -410,7 +410,7 @@ QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong times "QWindowSystemInterface::handleMouseEvent", "QTBUG-71263: Native double clicks are not implemented."); auto localPos = QHighDpi::fromNativeLocalPosition(local, window); - auto globalPos = QHighDpi::fromNativePixels(global, window); + auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window); QWindowSystemInterfacePrivate::MouseEvent *e = new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp, localPos, globalPos, @@ -437,7 +437,7 @@ bool QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, ulong t Qt::MouseEventSource source) { auto localPos = QHighDpi::fromNativeLocalPosition(local, window); - auto globalPos = QHighDpi::fromNativePixels(global, window); + auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window); QWindowSystemInterfacePrivate::MouseEvent *e = new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp, localPos, globalPos, @@ -588,15 +588,15 @@ bool QWindowSystemInterface::handleWheelEvent(QWindow *window, ulong timestamp, // Simple case: vertical deltas only: if (angleDelta.y() != 0 && angleDelta.x() == 0) { - e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window), pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, - mods, phase, source, invertedScrolling); - + e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window), + pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling); return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } // Simple case: horizontal deltas only: if (angleDelta.y() == 0 && angleDelta.x() != 0) { - e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window), pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling); + e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window), + pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling); return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } @@ -605,12 +605,14 @@ bool QWindowSystemInterface::handleWheelEvent(QWindow *window, ulong timestamp, // Both horizontal and vertical deltas: Send two wheel events. // The first event contains the Qt 5 pixel and angle delta as points, // and in addition the Qt 4 compatibility vertical angle delta. - e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window), pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling); + e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window), + pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling); acceptVert = QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); // The second event contains null pixel and angle points and the // Qt 4 compatibility horizontal angle delta. - e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativePixels(global, window), QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling); + e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window), + QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling); acceptHorz = QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); return acceptVert || acceptHorz; } @@ -980,7 +982,7 @@ bool QWindowSystemInterface::handleTabletEvent(QWindow *window, ulong timestamp, QWindowSystemInterfacePrivate::TabletEvent *e = new QWindowSystemInterfacePrivate::TabletEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), - QHighDpi::fromNativePixels(global, window), + QHighDpi::fromNativeGlobalPosition(global, window), device, pointerType, buttons, pressure, xTilt, yTilt, tangentialPressure, rotation, z, uid, modifiers); return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); @@ -1207,9 +1209,10 @@ Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *window, const QPointF &local, con Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods, int timestamp) { - const qreal factor = QHighDpiScaling::factor(window); + QPointF nativeLocal = QHighDpi::toNativeLocalPosition(local, window); + QPointF nativeGlobal = QHighDpi::toNativeGlobalPosition(global, window); QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>(window, - timestamp, local * factor, global * factor, state, button, type, mods); + timestamp, nativeLocal, nativeGlobal, state, button, type, mods); } // Wrapper for compatibility with Qt < 5.11 -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor