Warning, /graphics/krita/3rdparty/ext_qt/0052-WinInk-Synthesize-mouse-events-for-full-pen-stroke.patch is written in an unsupported language. File is not indexed.

0001 From c27f07dbca61e292639b4806d168de26daf44a5b Mon Sep 17 00:00:00 2001
0002 From: Alvin Wong <alvin@alvinhc.com>
0003 Date: Thu, 9 Sep 2021 21:23:52 +0800
0004 Subject: [PATCH] WinInk: Synthesize mouse events for full pen stroke
0005 
0006 When synthesizing mouse events for handled WM_POINTERDOWN, keep track of
0007 the pointer so that we also synthesize mouse events for the subsequent
0008 WM_POINTERUPDATE and WM_POINTERUP to complete the full stroke.
0009 
0010 See bug: https://bugs.kde.org/show_bug.cgi?id=439774
0011 ---
0012  .../windows/qwindowspointerhandler.cpp        | 38 ++++++++++++++++---
0013  1 file changed, 33 insertions(+), 5 deletions(-)
0014 
0015 diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
0016 index 07a5722de9..9e518a262f 100644
0017 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
0018 +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
0019 @@ -60,6 +60,7 @@
0020  #include <QtCore/qloggingcategory.h>
0021  #include <QtCore/qoperatingsystemversion.h>
0022  #include <QtCore/qqueue.h>
0023 +#include <QtCore/qset.h>
0024  
0025  #include <algorithm>
0026  
0027 @@ -602,6 +603,10 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
0028      if (et & QtWindows::NonClientEventFlag)
0029          return false; // Let DefWindowProc() handle Non Client messages.
0030  
0031 +    // Used to track whether a particular pointer is being handled so we can synthesize the mouse events.
0032 +    // Stores the pointerId of pointers that are being handled.
0033 +    static QSet<int> penPointersBeingHandled;
0034 +
0035      POINTER_PEN_INFO *penInfo = static_cast<POINTER_PEN_INFO *>(vPenInfo);
0036  
0037      RECT pRect, dRect;
0038 @@ -687,7 +692,7 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
0039  
0040          const Qt::MouseButtons oldButtons = QGuiApplicationPrivate::tabletDevicePoint(sourceDevice).state;
0041  
0042 -        const bool accepted =
0043 +        bool accepted =
0044              QWindowSystemInterface::handleTabletEvent(target, localPos, hiResGlobalPos, device, type, mouseButtons,
0045                                                        pressure, xTilt, yTilt, tangentialPressure, rotation, z,
0046                                                        sourceDevice, keyModifiers);
0047 @@ -707,10 +712,33 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
0048              }
0049          }
0050  
0051 -        if (accepted && pressedButton != Qt::NoButton &&
0052 -            (msg.message == WM_POINTERDOWN || msg.message == WM_POINTERUP)) {
0053 -
0054 -            QEvent::Type type = (msg.message == WM_POINTERDOWN) ? QEvent::TabletPress : QEvent::TabletRelease;
0055 +        if (msg.message == WM_POINTERDOWN) {
0056 +            if (accepted) {
0057 +                penPointersBeingHandled.insert(penInfo->pointerInfo.pointerId);
0058 +            } else {
0059 +                penPointersBeingHandled.remove(penInfo->pointerInfo.pointerId);
0060 +            }
0061 +        } else if (msg.message == WM_POINTERUPDATE) {
0062 +            accepted = penPointersBeingHandled.contains(penInfo->pointerInfo.pointerId);
0063 +        } else if (msg.message == WM_POINTERUP) {
0064 +            accepted = penPointersBeingHandled.remove(penInfo->pointerInfo.pointerId);
0065 +        }
0066 +        if (accepted && (
0067 +            msg.message == WM_POINTERUPDATE ||
0068 +            (
0069 +                pressedButton != Qt::NoButton &&
0070 +                (msg.message == WM_POINTERDOWN || msg.message == WM_POINTERUP)
0071 +            )
0072 +        )) {
0073 +
0074 +            QEvent::Type type;
0075 +            if (msg.message == WM_POINTERDOWN) {
0076 +                type = QEvent::TabletPress;
0077 +            } else if (msg.message == WM_POINTERUP) {
0078 +                type = QEvent::TabletRelease;
0079 +            } else {
0080 +                type = QEvent::TabletMove;
0081 +            }
0082  
0083              synthesizeMouseEvent(type, pressedButton, *penInfo);
0084              return true;
0085 -- 
0086 2.24.1.windows.2
0087