Commit 2bd45acf authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix Qt patches for Qt 5.12.3

I just reapplied original patches on newer Qt with 'git am'. Current
patches were duplicating some hunks, therefore they didn't apply.
parent c06107d6
From 9081571e58ceeaa4c623c83ecb41b04dfc7d90f9 Mon Sep 17 00:00:00 2001
From 0cda446fe4dea3046cb0cea820b9934164df8f19 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Tue, 21 Jun 2016 14:50:07 +0300
Subject: [PATCH 2/4] Don't request the MIME image every time Windows asks for
the list of supported types
Subject: [PATCH 01/27] Don't request the MIME image every time Windows asks
for the list of supported types
Change-Id: I05516d83dc4e0f192bc94f92cefc722f25dae4d4
---
......@@ -10,7 +10,7 @@ Change-Id: I05516d83dc4e0f192bc94f92cefc722f25dae4d4
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index ff0dccb0d9..a702a2a90f 100644
index 96e34fb4..ca6e0925 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -1082,12 +1082,15 @@ bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *p
......@@ -33,5 +33,5 @@ index ff0dccb0d9..a702a2a90f 100644
bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const
--
2.20.1.windows.1
2.22.0.windows.1
From 6ce23924948d9697e07681bef44f0a47f9fd0d09 Mon Sep 17 00:00:00 2001
From 025be9d8f4adcdccbc1fd4be329771cf2ef95942 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Tue, 21 Jun 2016 14:50:47 +0300
Subject: [PATCH 3/4] Hack: always return we support DIBV5
Subject: [PATCH 02/27] Hack: always return we support DIBV5
Asking for the entire image may be too expensive
......@@ -11,7 +11,7 @@ Change-Id: I44c38fad73f1bb5859eb58b941054eeb6c3c6b66
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index a702a2a90f..03f8948a86 100644
index ca6e0925..cff89586 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -1055,9 +1055,7 @@ QVector<FORMATETC> QWindowsMimeImage::formatsForMime(const QString &mimeType, co
......@@ -26,5 +26,5 @@ index a702a2a90f..03f8948a86 100644
}
if (!formatetcs.isEmpty())
--
2.20.1.windows.1
2.22.0.windows.1
From 4c1e4e693307c3169c6db488ad6bf6cff6aae864 Mon Sep 17 00:00:00 2001
From 50ec48b6622f07550d71c694d037131c7b0a8c7b Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Mon, 11 Feb 2019 18:07:20 +0300
Subject: [PATCH 4/4] Fix debug on openGL ES
Subject: [PATCH 03/27] Fix debug on openGL ES
Change-Id: I08d1adf87b305c380a0f2177edf4ff9de109e4d6
---
......@@ -9,7 +9,7 @@ Change-Id: I08d1adf87b305c380a0f2177edf4ff9de109e4d6
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp
index 2e628a2bd5..9f1bb76869 100644
index 2e628a2b..9f1bb768 100644
--- a/src/gui/opengl/qopengldebug.cpp
+++ b/src/gui/opengl/qopengldebug.cpp
@@ -1366,7 +1366,7 @@ bool QOpenGLDebugLogger::initialize()
......@@ -22,5 +22,5 @@ index 2e628a2bd5..9f1bb76869 100644
GET_DEBUG_PROC_ADDRESS(glDebugMessageControl);
--
2.20.1.windows.1
2.22.0.windows.1
This source diff could not be displayed because it is too large. You can view the blob instead.
From 37be272df1fac2bc4633fbddafd3662d1f0921b9 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Mon, 11 Mar 2019 13:18:06 +0300
Subject: [PATCH 10/27] Synthesize Enter/LeaveEvent for accepted QTabletEvent
When the tablet event is accepted, then Qt doesn't synthesize a mouse
event, it means that QApplicationPrivate::sendMouseEvent() will not be
called, and, therefore, enter/leave events will not be dispatched.
The patch looks a bit hackish. Ideally, the synthesize should happen
in QGuiApplicationPrivate::processTabletEvent(), which takes the decision
about synthesizing mouse events. But there is not enough information
on this level: neither qt_last_mouse_receiver nor the receiver widget
are known at this stage.
On Windows and other platforms where there is a parallel stream of
mouse events synthesized by the platform, we shouldn't generate these
events manually.
Change-Id: Ifbad6284483ee282ad129db54606f5d0d9ddd633
---
src/widgets/kernel/qwidgetwindow.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index fbc71cd0e..729a7f701 100644
index fbc71cd0..729a7f70 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -1051,6 +1051,18 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
......@@ -21,3 +45,6 @@ index fbc71cd0e..729a7f701 100644
if (event->type() == QEvent::TabletRelease && event->buttons() == Qt::NoButton)
qt_tablet_target = 0;
}
--
2.22.0.windows.1
From cd8b94f7d7b47e2b4c1181a2cd2911937ef344a6 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Sat, 30 Mar 2019 23:14:07 +0300
Subject: [PATCH 11/27] Fix generation of Leave events when using tablet
devices
When both mouse and tablet events are handled by QWindowsPointerHandler,
m_currentWindow variable is shared among the two event streams, therefore
each stream should ensure it does euqivalent operations, when changing it.
Here we should subscribe to the Leave events, when we emit Enter event
from the inside of the tablet events flow. Without whis subscription,
the cursor may stuck into "resize" state when crossing the window's
frame multiple times.
Change-Id: I88df4a42ae86243e10ecd4a4cedf87639c96d169
---
src/plugins/platforms/windows/qwindowspointerhandler.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index 9a8b5d512..a83289de7 100644
index 9a8b5d51..a83289de 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -614,7 +614,12 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
......@@ -15,3 +35,6 @@ index 9a8b5d512..a83289de7 100644
m_currentWindow = window;
if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(target))
wumPlatformWindow->applyCursor();
--
2.22.0.windows.1
From 880c9387d5e889e52e0db22f629443c1006988f0 Mon Sep 17 00:00:00 2001
From 52dd12d4e4eeb64864fe5708e2a3fb775c20c743 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Wed, 3 Apr 2019 18:37:56 +0300
Subject: [PATCH] Implement a switch for tablet API on Windows
Subject: [PATCH 12/27] Implement a switch for tablet API on Windows
Qt has support for two tablet APIs: WinTab and Windows Pointer API.
The former one is used in professional graphical tablet devices,
......@@ -69,5 +69,5 @@ index 2c90b048..c415cf28 100644
m_context.setTabletAbsoluteRange(tabletAbsoluteRange);
}
--
2.20.1.windows.1
2.22.0.windows.1
From f62b528cbc9e3ef75584839d995e4b7369ad3ff8 Mon Sep 17 00:00:00 2001
From 7d4d465771854cfa860b7cd2eb09f91cfdb8b5cd Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Sat, 13 Apr 2019 18:08:33 +0300
Subject: [PATCH] Fetch stylus button remapping from WinTab driver
Subject: [PATCH 13/27] Fetch stylus button remapping from WinTab driver
The user can remap the stylus buttons using tablet driver settings.
This information is available to the application via CSR_SYSBTNMAP
......@@ -133,5 +133,5 @@ index d91701d6..5b1ddb52 100644
#ifndef QT_NO_DEBUG_STREAM
--
2.20.1.windows.1
2.22.0.windows.1
From 7c66490d5579828540c410275c0f8e8d72dae3f5 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Sat, 13 Apr 2019 20:29:14 +0300
Subject: [PATCH 14/27] Disable tablet relative mode in Qt
---
src/plugins/platforms/windows/qwindowstabletsupport.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index fa209f09c..d31998825 100644
index 31655101..3e35b146 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -497,6 +497,11 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
@@ -562,6 +562,11 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
m_state = PenDown;
m_mode = (mouseLocation - globalPosF).manhattanLength() > m_absoluteRange
? MouseMode : PenMode;
......@@ -14,3 +23,6 @@ index fa209f09c..d31998825 100644
qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:"
<< globalPosF << "mouse:" << mouseLocation;
}
--
2.22.0.windows.1
From b33666c064dc255e3d39a0646684445ab907d299 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Sat, 13 Apr 2019 23:24:01 +0300
Subject: [PATCH 15/27] Fetch mapped screen size from the Wintab driver
Some devices, like Microsoft Surface Pro 5, don't map tablet's
input range to the entire virtual screen area, but map it to
the primary display that has actual built-in tablet sensor.
In such cases we should fetch actualy mapped aread from Wintab's
lcSys{Org,Ext}{X,Y} fields and use it for cursor mapping.
If one wants to fall back to the old screen size detection method,
then an environment variable can be set:
QT_IGNORE_WINTAB_MAPPING=1
When the variable is set, the scaling is done via virtual desktop
area only.
If the tablet driver is broken (e.g. Microsoft SP5, when primary
display is set to an external monitor) the user might want to override
mapping completely. Then the following variable can be used:
QT_WINTAB_DESKTOP_RECT=x;y;width;height
---
.../windows/qwindowstabletsupport.cpp | 89 ++++++++++++++++++-
.../platforms/windows/qwindowstabletsupport.h | 13 ++-
2 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 3e35b1464..11e6769c8 100644
index 3e35b146..11e6769c 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -53,6 +53,7 @@
......@@ -127,7 +157,7 @@ index 3e35b1464..11e6769c8 100644
if (QWindowsContext::verbose > 1) {
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing" << packetCount
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index 5b1ddb529..59c996cd3 100644
index 5b1ddb52..e8b0c01b 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -45,7 +45,9 @@
......@@ -140,16 +170,15 @@ index 5b1ddb529..59c996cd3 100644
#include <wintab.h>
@@ -55,7 +57,7 @@ QT_BEGIN_NAMESPACE
@@ -56,6 +58,7 @@ QT_BEGIN_NAMESPACE
class QDebug;
class QWindow;
-class QRect;
class QRect;
+class QScreen;
struct QWindowsWinTab32DLL
{
@@ -108,7 +110,7 @@ struct QWindowsTabletDeviceData
@@ -108,7 +111,7 @@ struct QWindowsTabletDeviceData
QDebug operator<<(QDebug d, const QWindowsTabletDeviceData &t);
#endif
......@@ -158,7 +187,7 @@ index 5b1ddb529..59c996cd3 100644
{
Q_DISABLE_COPY(QWindowsTabletSupport)
@@ -141,9 +143,14 @@ public:
@@ -141,9 +144,14 @@ public:
int absoluteRange() const { return m_absoluteRange; }
void setAbsoluteRange(int a) { m_absoluteRange = a; }
......@@ -173,7 +202,7 @@ index 5b1ddb529..59c996cd3 100644
static QWindowsWinTab32DLL m_winTab32DLL;
const HWND m_window;
@@ -154,6 +161,9 @@ private:
@@ -154,6 +162,9 @@ private:
int m_currentDevice = -1;
Mode m_mode = PenMode;
State m_state = PenUp;
......@@ -183,3 +212,6 @@ index 5b1ddb529..59c996cd3 100644
};
QT_END_NAMESPACE
--
2.22.0.windows.1
From ebfe32b8fe8ff7ce8b8e4330af1191c16b0a8be0 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Wed, 17 Apr 2019 17:39:10 +0300
Subject: [PATCH 16/27] Switch stylus pointer type when the tablet is in the
tablet proximity
Some convertible tablet devices have a special stylus button that
converts the stylus into an eraser. Such button can be pressed right
when the stylus is in tablet surface proximity, so we should check
that not only during proximity event handling, but also while parsing
normal wintab packets.
https://bugs.kde.org/show_bug.cgi?id=405747
---
.../windows/qwindowstabletsupport.cpp | 23 ++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 11e6769c8..b04312769 100644
index 11e6769c..b0431276 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -604,7 +604,6 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
......@@ -39,143 +56,6 @@ index 11e6769c8..b04312769 100644
const int z = currentDevice == QTabletEvent::FourDMouse ? int(packet.pkZ) : 0;
QPointF globalPosF =
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp.orig b/src/plugins/platforms/windows/qwindowstabletsupport.cpp.orig
index 316551014..11e6769c8 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp.orig
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp.orig
@@ -53,6 +53,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qmath.h>
+#include <QtCore/qregularexpression.h>
#include <private/qguiapplication_p.h>
#include <QtCore/private/qsystemlibrary_p.h>
@@ -216,6 +217,10 @@ QWindowsTabletSupport::QWindowsTabletSupport(HWND window, HCTX context)
// Some tablets don't support tilt, check if it is possible,
if (QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEVICES, DVC_ORIENTATION, &orientation))
m_tiltSupport = orientation[0].axResolution && orientation[1].axResolution;
+
+ connect(qGuiApp, &QGuiApplication::primaryScreenChanged,
+ this, QWindowsTabletSupport::slotPrimaryScreenChanged);
+ slotScreenGeometryChanged();
}
QWindowsTabletSupport::~QWindowsTabletSupport()
@@ -394,6 +399,84 @@ QWindowsTabletDeviceData QWindowsTabletSupport::tabletInit(qint64 uniqueId, UINT
return result;
}
+void QWindowsTabletSupport::slotPrimaryScreenChanged(QScreen *screen)
+{
+ if (m_connectedScreen)
+ disconnect(m_connectedScreen, 0, this, 0);
+
+ m_connectedScreen = screen;
+
+ if (m_connectedScreen)
+ connect(m_connectedScreen, &QScreen::virtualGeometryChanged,
+ this, &QWindowsTabletSupport::slotScreenGeometryChanged);
+
+ slotScreenGeometryChanged();
+}
+
+void QWindowsTabletSupport::slotScreenGeometryChanged()
+{
+ /**
+ * Some Wintab implementations map the tablet area to the entire
+ * virtual screen, but others (e.g. Microsoft SP5) don't. They
+ * may input range to a single (built-in) screen. The logic is
+ * quite obvious: when the screen has integrated tablet device,
+ * one cannot map this tablet device to another display.
+ *
+ * For such devices, we should always request mapped area from
+ * lcSys{Org,Ext}{X,Y} fields and use it accordingly.
+ */
+
+ LOGCONTEXT lc;
+ QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_DEFSYSCTX, 0, &lc);
+ m_wintabScreenGeometry = QRect(lc.lcSysOrgX, lc.lcSysOrgY, lc.lcSysExtX, lc.lcSysExtY);
+
+ qCDebug(lcQpaTablet) << "Updated tablet mapping: " << m_wintabScreenGeometry;
+ if (QGuiApplication::primaryScreen()) {
+ qCDebug(lcQpaTablet) << " real desktop geometry: " << QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
+ }
+}
+
+void QWindowsTabletSupport::updateEffectiveScreenGeometry()
+{
+ QRect customGeometry;
+ bool dontUseWintabDesktopRect = false;
+
+ const QString geometry = qEnvironmentVariable("QT_WINTAB_DESKTOP_RECT");
+ if (!geometry.isEmpty()) {
+ QString tmp = QString::fromLatin1("([+-]?\\d+);([+-]?\\d+);(\\d+);(\\d+)");
+
+ QRegularExpression rex(tmp);
+ QRegularExpressionMatch match = rex.match(geometry);
+
+ if (match.hasMatch()) {
+ customGeometry.setRect(match.captured(1).toInt(),
+ match.captured(2).toInt(),
+ match.captured(3).toInt(),
+ match.captured(4).toInt());
+
+ qCDebug(lcQpaTablet) << "apply QT_WINTAB_DESKTOP_RECT:" << customGeometry;
+ } else {
+ qCWarning(lcQpaTablet) << "failed to parse QT_WINTAB_DESKTOP_RECT:" << geometry;
+ }
+ }
+
+ if (qEnvironmentVariableIsSet("QT_IGNORE_WINTAB_MAPPING")) {
+ if (!customGeometry.isValid()) {
+ qCDebug(lcQpaTablet) << "fallback mapping is requested via QT_IGNORE_WINTAB_MAPPING";
+ } else {
+ qCWarning(lcQpaTablet) << "ignoring QT_IGNORE_WINTAB_MAPPING, because QT_WINTAB_DESKTOP_RECT is set";
+ }
+ dontUseWintabDesktopRect = true;
+ }
+
+ m_effectiveScreenGeometry =
+ !customGeometry.isValid() ?
+ (dontUseWintabDesktopRect ?
+ QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle()) :
+ m_wintabScreenGeometry) :
+ customGeometry;
+}
+
bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, LPARAM lParam)
{
PACKET proximityBuffer[1]; // we are only interested in the first packet in this case
@@ -421,6 +504,8 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
if (!totalPacks)
return false;
+ updateEffectiveScreenGeometry();
+
const UINT currentCursor = proximityBuffer[0].pkCursor;
UINT physicalCursorId;
QWindowsTabletSupport::m_winTab32DLL.wTInfo(WTI_CURSORS + currentCursor, CSR_PHYSID, &physicalCursorId);
@@ -535,8 +620,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
// in which case we snap the position to the mouse position.
// It seems there is no way to find out the mode programmatically, the LOGCONTEXT orgX/Y/Ext
// area is always the virtual desktop.
- const QRect virtualDesktopArea =
- QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
+
+ const QRect virtualDesktopArea = m_effectiveScreenGeometry;
if (QWindowsContext::verbose > 1) {
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing" << packetCount
@@ -562,6 +647,11 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
m_state = PenDown;
m_mode = (mouseLocation - globalPosF).manhattanLength() > m_absoluteRange
? MouseMode : PenMode;
+
+ // Krita doesn't support mouse mode. And this code may break
+ // normal painting, so we just disable it.
+ m_mode = PenMode;
+
qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:"
<< globalPosF << "mouse:" << mouseLocation;
}
--
2.22.0.windows.1
From a354a9a7f0cf081aae223dfff3f1734add050b18 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Thu, 18 Apr 2019 15:42:17 +0300
Subject: [PATCH 17/27] Fix updating tablet pressure resolution on every
proximity enter event
The user can switch pressure sensitivity level in the driver,
which will make our saved values invalid (this option is
provided by Wacom drivers for compatibility reasons, and
it can be adjusted on the fly)
See the bug: https://bugs.kde.org/show_bug.cgi?id=391054
---
src/plugins/platforms/windows/qwindowstabletsupport.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index b0431276..2de87758 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -519,6 +519,14 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
if (m_currentDevice < 0) {
m_currentDevice = m_devices.size();
m_devices.push_back(tabletInit(uniqueId, cursorType));
+ } else {
+ /**
+ * The user can switch pressure sensitivity level in the driver,
+ * which will make our saved values invalid (this option is
+ * provided by Wacom drivers for compatibility reasons, and
+ * it can be adjusted on the fly)
+ */
+ m_devices[m_currentDevice] = tabletInit(uniqueId, cursorType);
}
/**
--
2.22.0.windows.1
From 676320297d7e5654cbe66fe4bd86125824e05840 Mon Sep 17 00:00:00 2001
From 44d40db1bd8a101ee28414edd27f4fa7e73fbc97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io>
Date: Mon, 25 Apr 2016 09:27:48 +0200
Subject: [PATCH 31/36] Compute logical DPI on a per-screen basis
Subject: [PATCH 22/27] Compute logical DPI on a per-screen basis
The logical DPI reported to applications is the platform screen
logical DPI divided by the platform screen scale factor.
......@@ -21,7 +21,7 @@ Change-Id: I0f62b5878c37e3488e9a8cc48aef183ff822d0c4
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 22e46e0851..541d4f12af 100644
index 22e46e08..541d4f12 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -224,7 +224,6 @@ bool QHighDpiScaling::m_usePixelDensity = false; // use scale factor from platfo
......@@ -67,7 +67,7 @@ index 22e46e0851..541d4f12af 100644
qreal QHighDpiScaling::factor(const QScreen *screen)
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 83fc9452c5..ecd9ed6515 100644
index 83fc9452..ecd9ed65 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -85,7 +85,7 @@ public:
......@@ -80,7 +80,7 @@ index 83fc9452c5..ecd9ed6515 100644
private:
static qreal screenSubfactor(const QPlatformScreen *screen);
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index f208eb02be..82ee62e6b4 100644
index f208eb02..82ee62e6 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -279,7 +279,7 @@ qreal QScreen::logicalDotsPerInchX() const
......@@ -111,5 +111,5 @@ index f208eb02be..82ee62e6b4 100644
}
--
2.18.0.windows.1
2.22.0.windows.1
From 0735b61f7e0868ab2272838ef52fe34aed0dfe25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io>
Date: Mon, 25 Apr 2016 11:31:34 +0200
Subject: [PATCH 23/27] Update Dpi and scale factor computation
Remove pixelScale() in favor of logicalBaseDpi(). Compute scale factor
based on logical DPI and logical base DPI, or optionally based on the
physical DPI.
Add policies for running the scale factor and adjusting the logical
DPI reported to the application. The policies are set via environment
variables:
QT_SCALE_FACTOR_ROUNDING_POLICY=Round|Ceil|Floor|RoundPreferFloor|PassThrough
QT_DPI_ADJUSTMENT_POLICY=AdjustDpi|DontAdjustDpi|AdjustUpOnly
QT_USE_PHYSICAL_DPI=0|1
Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io>
Task-number: QTBUG-53022
Change-Id: I4846f223186df665eb0a9c827eaef0a96d1f458f
---
src/gui/kernel/qhighdpiscaling.cpp | 234 ++++++++++++++++--
src/gui/kernel/qhighdpiscaling_p.h | 29 +++
src/gui/kernel/qplatformscreen.cpp | 14 ++
src/gui/kernel/qplatformscreen.h | 1 +
.../android/qandroidplatformscreen.cpp | 8 +-
.../android/qandroidplatformscreen.h | 2 +-
src/plugins/platforms/cocoa/qcocoascreen.h | 1 +
.../platforms/windows/qwindowsscreen.cpp | 9 -
.../platforms/windows/qwindowsscreen.h | 2 +-
src/plugins/platforms/xcb/qxcbscreen.cpp | 11 -
src/plugins/platforms/xcb/qxcbscreen.h | 3 +-
tests/manual/highdpi/highdpi.pro | 1 +
12 files changed, 264 insertions(+), 51 deletions(-)
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 22e46e085..cdf6c8669 100644
index 541d4f12..ae531569 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -44,6 +44,9 @@
......@@ -31,7 +66,7 @@ index 22e46e085..cdf6c8669 100644
static inline qreal initialGlobalScaleFactor()
{
@@ -248,6 +263,191 @@ static inline bool usePixelDensity()
@@ -247,6 +262,191 @@ static inline bool usePixelDensity()
qgetenv(legacyDevicePixelEnvVar).compare("auto", Qt::CaseInsensitive) == 0);
}
......@@ -223,7 +258,7 @@ index 22e46e085..cdf6c8669 100644
void QHighDpiScaling::initHighDpiScaling()
{
// Determine if there is a global scale factor set.
@@ -258,8 +458,6 @@ void QHighDpiScaling::initHighDpiScaling()
@@ -257,8 +457,6 @@ void QHighDpiScaling::initHighDpiScaling()
m_pixelDensityScalingActive = false; //set in updateHighDpiScaling below
......@@ -232,7 +267,16 @@ index 22e46e085..cdf6c8669 100644
m_active = m_globalScalingActive || m_usePixelDensity;
}
@@ -380,22 +578,8 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
@@ -310,7 +508,7 @@ void QHighDpiScaling::updateHighDpiScaling()
++i;
}
}
- m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
+ m_active = m_globalScalingActive || m_usePixelDensity;
}
/*
@@ -371,22 +569,8 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
{
qreal factor = qreal(1.0);
if (screen) {
......@@ -257,8 +301,29 @@ index 22e46e085..cdf6c8669 100644
if (m_screenFactorSet) {
QVariant screenFactor = screen->screen()->property(scaleFactorProperty);
if (screenFactor.isValid())
@@ -399,13 +583,15 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
QDpi QHighDpiScaling::logicalDpi(const QScreen *screen)
{
// (Note: m_active test is performed at call site.)
- if (!screen)
+ if (!screen || !screen->handle())
return QDpi(96, 96);
- qreal platformScreenfactor = screenSubfactor(screen->handle());
- QDpi platformScreenDpi = screen->handle()->logicalDpi();
- return QDpi(platformScreenDpi.first / platformScreenfactor,
- platformScreenDpi.second / platformScreenfactor);
+ if (!m_usePixelDensity)
+ return screen->handle()->logicalDpi();
+
+ const qreal scaleFactor = rawScaleFactor(screen->handle());
+ const qreal roundedScaleFactor = roundScaleFactor(scaleFactor);
+ return effectiveLogicalDpi(screen->handle(), scaleFactor, roundedScaleFactor);
}
qreal QHighDpiScaling::factor(const QScreen *screen)
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 83fc9452c..c664693a0 100644
index ecd9ed65..55bddfeb 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -71,7 +71,33 @@ typedef QPair<qreal, qreal> QDpi;
......@@ -296,7 +361,7 @@ index 83fc9452c..c664693a0 100644
static void updateHighDpiScaling();
static void setGlobalFactor(qreal factor);
@@ -88,6 +114,9 @@ public:
static QDpi logicalDpi();
static QDpi logicalDpi(const QScreen *screen);
private:
+ static qreal rawScaleFactor(const QPlatformScreen *screen);
......@@ -306,7 +371,7 @@ index 83fc9452c..c664693a0 100644
static qreal m_factor;
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index 21ae75ba8..ff76528a0 100644
index 21ae75ba..ff76528a 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -197,6 +197,20 @@ QDpi QPlatformScreen::logicalDpi() const
......@@ -331,7 +396,7 @@ index 21ae75ba8..ff76528a0 100644
Reimplement this function in subclass to return the device pixel ratio
for the screen. This is the ratio between physical pixels and the
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index e9d64c8a2..63b5d5a4a 100644
index e9d64c8a..63b5d5a4 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -113,6 +113,7 @@ public:
......@@ -343,7 +408,7 @@ index e9d64c8a2..63b5d5a4a 100644
virtual qreal pixelDensity() const;
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index 7dc8bb808..80757c213 100644
index 7dc8bb80..80757c21 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -401,15 +401,17 @@ void QAndroidPlatformScreen::doRedraw()
......@@ -368,7 +433,7 @@ index 7dc8bb808..80757c213 100644
Qt::ScreenOrientation QAndroidPlatformScreen::orientation() const
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h
index f15aeae3f..5dc158e35 100644
index f15aeae3..5dc158e3 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.h
+++ b/src/plugins/platforms/android/qandroidplatformscreen.h
@@ -103,7 +103,7 @@ protected:
......@@ -381,7 +446,7 @@ index f15aeae3f..5dc158e35 100644
Qt::ScreenOrientation nativeOrientation() const override;
void surfaceChanged(JNIEnv *env, jobject surface, int w, int h) override;
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h
index 9ded98df3..a73b97c77 100644
index 9ded98df..a73b97c7 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.h
+++ b/src/plugins/platforms/cocoa/qcocoascreen.h
@@ -64,6 +64,7 @@ public:
......@@ -393,7 +458,7 @@ index 9ded98df3..a73b97c77 100644
QString name() const override { return m_name; }
QPlatformCursor *cursor() const override { return m_cursor; }
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 0520f8893..9b7b4630f 100644
index b70b0bbe..e34a8e3c 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -254,15 +254,6 @@ QWindow *QWindowsScreen::windowAt(const QPoint &screenPoint, unsigned flags)
......@@ -413,7 +478,7 @@ index 0520f8893..9b7b4630f 100644
\brief Determine siblings in a virtual desktop system.
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h