Commit 0f66ae41 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Add patches for Qt's WinInk implementation and make it activated by default

TODO: we should still implement switching between Wintab and Winink
implementations in Qt.
parent bf535aef
......@@ -60,9 +60,13 @@ if (MINGW)
else (DEFINED ENV{WindowsSdkDir})
message(FATAL_ERROR "Environment variable 'WindowsSdkDir' not set! Please set it to path of Windows 10 SDK or disable QT_ENABLE_DYNAMIC_OPENGL")
endif ()
endif ()
endif ()
endif (MINGW)
if (WIN32)
option(USE_QT_TABLET_WINDOWS "Do not use Krita's forked Wintab and Windows Ink support on Windows, but leave everything to Qt." ON)
endif ()
set(SECURITY_EXE_LINKER_FLAGS "")
set(SECURITY_SHARED_LINKER_FLAGS "")
set(SECURITY_MODULE_LINKER_FLAGS "")
......
From bf5a6693654afedd05a36d9605fce95f69b70e23 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Mon, 11 Mar 2019 13:18:06 +0300
Subject: [PATCH 20/22] 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 e9b749d7c2..00c1e8e92f 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -1053,6 +1053,18 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
event->setAccepted(ev.isAccepted());
}
+ /**
+ * Synthesize Enter/Leave events if it is requested by the system and user
+ */
+ if (widget != qt_last_mouse_receiver &&
+ event->isAccepted() &&
+ !QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse &&
+ qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents)) {
+
+ QApplicationPrivate::dispatchEnterLeave(widget, qt_last_mouse_receiver, event->globalPos());
+ qt_last_mouse_receiver = widget;
+ }
+
if (event->type() == QEvent::TabletRelease && event->buttons() == Qt::NoButton)
qt_tablet_target = 0;
}
--
2.20.1.windows.1
From a2d7fa13fadddf5a18e555694c0b6774e654d793 Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Thu, 28 Mar 2019 18:33:44 +0300
Subject: [PATCH 21/22] Fix QTabletEvent::uniqueId() when Qt uses WinInk
A new 'pointerId' is assigned to the stylus every time it enters
tablet's proximity. But applications expect this ID be constant,
at least during one application run. Therefore, it needs to use
'sourceDevice' instead.
Basically, WinInk doesn't have an ability to distinguich two
different styluses connected to the same tablet. We cannot do
anything about it, it is supported only in WinTab.
Task-number: QTBUG-74700
Change-Id: I8328f1e5102b037b370082e69e965ab68b487882
---
.../platforms/windows/qwindowspointerhandler.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index f1960f1585..f37bec935c 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -531,7 +531,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
if (!QWindowsContext::user32dll.getPointerDeviceRects(penInfo->pointerInfo.sourceDevice, &pRect, &dRect))
return false;
- const quint32 pointerId = penInfo->pointerInfo.pointerId;
+ const qint64 sourceDevice = (qint64)penInfo->pointerInfo.sourceDevice;
const QPoint globalPos = QPoint(penInfo->pointerInfo.ptPixelLocation.x, penInfo->pointerInfo.ptPixelLocation.y);
const QPoint localPos = QWindowsGeometryHint::mapFromGlobal(hwnd, globalPos);
const QPointF hiResGlobalPos = QPointF(dRect.left + qreal(penInfo->pointerInfo.ptHimetricLocation.x - pRect.left)
@@ -547,7 +547,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
if (QWindowsContext::verbose > 1)
qCDebug(lcQpaEvents).noquote().nospace() << showbase
- << __FUNCTION__ << " pointerId=" << pointerId
+ << __FUNCTION__ << " sourceDevice=" << sourceDevice
<< " globalPos=" << globalPos << " localPos=" << localPos << " hiResGlobalPos=" << hiResGlobalPos
<< " message=" << hex << msg.message
<< " flags=" << hex << penInfo->pointerInfo.pointerFlags;
@@ -570,7 +570,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
switch (msg.message) {
case WM_POINTERENTER: {
- QWindowSystemInterface::handleTabletEnterProximityEvent(device, type, pointerId);
+ QWindowSystemInterface::handleTabletEnterProximityEvent(device, type, sourceDevice);
m_windowUnderPointer = window;
// The local coordinates may fall outside the window.
// Wait until the next update to send the enter event.
@@ -583,12 +583,12 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
m_windowUnderPointer = nullptr;
m_currentWindow = nullptr;
}
- QWindowSystemInterface::handleTabletLeaveProximityEvent(device, type, pointerId);
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(device, type, sourceDevice);
break;
case WM_POINTERDOWN:
case WM_POINTERUP:
case WM_POINTERUPDATE: {
- QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(pointerId).target; // Pass to window that grabbed it.
+ QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(sourceDevice).target; // Pass to window that grabbed it.
if (!target && m_windowUnderPointer)
target = m_windowUnderPointer;
if (!target)
@@ -607,7 +607,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
QWindowSystemInterface::handleTabletEvent(target, localPos, hiResGlobalPos, device, type, mouseButtons,
pressure, xTilt, yTilt, tangentialPressure, rotation, z,
- pointerId, keyModifiers);
+ sourceDevice, keyModifiers);
return false; // Allow mouse messages to be generated.
}
}
--
2.20.1.windows.1
From 0749bda24a02db33812978e167ffac356f74526b Mon Sep 17 00:00:00 2001
From: Dmitry Kazakov <dimula73@gmail.com>
Date: Sat, 30 Mar 2019 23:14:07 +0300
Subject: [PATCH 22/22] 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 f37bec935c..190fb208d9 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -597,7 +597,12 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
if (m_needsEnterOnPointerUpdate) {
m_needsEnterOnPointerUpdate = false;
if (window != m_currentWindow) {
+
+ // make sure we subscribe to leave events for this window
+ trackLeave(hwnd);
+
QWindowSystemInterface::handleEnterEvent(window, localPos, globalPos);
+
m_currentWindow = window;
if (QWindowsWindow *wumPlatformWindow = QWindowsWindow::windowsWindowOf(target))
wumPlatformWindow->applyCursor();
--
2.20.1.windows.1
......@@ -30,18 +30,32 @@ if (WIN32)
list(APPEND _QT_conf -opengl desktop -no-angle)
endif (QT_ENABLE_DYNAMIC_OPENGL)
ExternalProject_Add(
ext_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://download.qt.io/archive/qt/5.12/5.12.2/single/qt-everywhere-src-5.12.2.tar.xz
URL_MD5 99c2eb46e533371798b4ca2d1458e065
PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-disable-wintab.patch
if (NOT USE_QT_TABLET_WINDOWS)
set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-disable-wintab.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/disable-winink.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Don-t-request-the-MIME-image-every-time-Windows-asks.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0003-Hack-always-return-we-support-DIBV5.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0004-Fix-debug-on-openGL-ES.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0005-cumulative-patch-for-hdr.patch
)
else()
set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Don-t-request-the-MIME-image-every-time-Windows-asks.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0003-Hack-always-return-we-support-DIBV5.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0004-Fix-debug-on-openGL-ES.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0005-cumulative-patch-for-hdr.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0020-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0021-Fix-QTabletEvent-uniqueId-when-Qt-uses-WinInk.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0022-Fix-generation-of-Leave-events-when-using-tablet-dev.patch
)
endif()
ExternalProject_Add(
ext_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://download.qt.io/archive/qt/5.12/5.12.2/single/qt-everywhere-src-5.12.2.tar.xz
URL_MD5 99c2eb46e533371798b4ca2d1458e065
PATCH_COMMAND ${ext_qt_PATCH_COMMAND}
INSTALL_DIR ${EXTPREFIX_qt}
CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat ${_QT_conf}
......
......@@ -307,7 +307,7 @@ find_package(Qt5 ${MIN_QT_VERSION}
)
if (WIN32)
option(USE_QT_TABLET_WINDOWS "Do not use Krita's forked Wintab and Windows Ink support on Windows, but leave everything to Qt." OFF)
option(USE_QT_TABLET_WINDOWS "Do not use Krita's forked Wintab and Windows Ink support on Windows, but leave everything to Qt." ON)
add_feature_info("Use Qt's Windows Tablet Support" USE_QT_TABLET_WINDOWS "Do not use Krita's forked Wintab and Windows Ink support on Windows, but leave everything to Qt.")
configure_file(config_use_qt_tablet_windows.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_use_qt_tablet_windows.h)
endif ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment