summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-03-27 16:06:11 +0000
committerShawn Rutledge <shawn.rutledge@qt.io>2020-07-10 14:32:56 +0200
commit4e400369c08db251cd489fec1229398c224d02b4 (patch)
tree6279489dce7b0469d590461798deccf5d1193e29 /src/plugins/platforms/windows
parent773a6bffd78b363577d27604e17f4ee08ff07e77 (diff)
Refactor pointer event hierarchy
Some goals that have hopefully been achieved are: - make QPointerEvent and QEventPoint resemble their Qt Quick counterparts to such an extent that we can remove those wrappers and go back to delivering the original events in Qt Quick - make QEventPoint much smaller than QTouchEvent::TouchPoint, with no pimpl - remove most public setters - reduce the usage of complex constructors that take many arguments - don't repeat ourselves: move accessors and storage upwards rather than having redundant ones in subclasses - standardize the set of accessors in QPointerEvent - maintain source compatibility as much as possible: do not require modifying event-handling code in any QWidget subclass To avoid public setters we now introduce a few QMutable* subclasses. This is a bit like the Builder pattern except that it doesn't involve constructing a separate disposable object: the main event type can be cast to the mutable type at any time to enable modifications, iff the code is linked with gui-private. Therefore event classes can have less-"complete" constructors, because internal Qt code can use setters the same way it could use the ones in QTouchEvent before; and the event classes don't need many friends. Even some read-accessors can be kept private unless we are sure we want to expose them. Task-number: QTBUG-46266 Fixes: QTBUG-72173 Change-Id: I740e4e40165b7bc41223d38b200bbc2b403e07b6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowspointerhandler.cpp10
2 files changed, 11 insertions, 11 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 13dd324a09..5e2710bc28 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -601,7 +601,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QTouchPointList touchPoints;
touchPoints.reserve(winTouchPointCount);
- Qt::TouchPointStates allStates;
+ QEventPoint::States allStates;
GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(msg.lParam),
UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT));
@@ -628,15 +628,15 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
touchPoint.normalPosition = normalPosition;
if (winTouchInput.dwFlags & TOUCHEVENTF_DOWN) {
- touchPoint.state = Qt::TouchPointPressed;
+ touchPoint.state = QEventPoint::State::Pressed;
m_lastTouchPositions.insert(id, touchPoint.normalPosition);
} else if (winTouchInput.dwFlags & TOUCHEVENTF_UP) {
- touchPoint.state = Qt::TouchPointReleased;
+ touchPoint.state = QEventPoint::State::Released;
m_lastTouchPositions.remove(id);
} else {
touchPoint.state = (stationaryTouchPoint
- ? Qt::TouchPointStationary
- : Qt::TouchPointMoved);
+ ? QEventPoint::State::Stationary
+ : QEventPoint::State::Updated);
m_lastTouchPositions.insert(id, touchPoint.normalPosition);
}
@@ -648,7 +648,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(msg.lParam));
// all touch points released, forget the ids we've seen, they may not be reused
- if (allStates == Qt::TouchPointReleased)
+ if (allStates == QEventPoint::State::Released)
m_touchInputIDToTouchPointID.clear();
QWindowSystemInterface::handleTouchEvent(window,
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index 7dc2bd729a..d5c3aeacff 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -491,7 +491,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd,
<< " message=" << Qt::hex << msg.message
<< " count=" << Qt::dec << count;
- Qt::TouchPointStates allStates;
+ QEventPoint::States allStates;
for (quint32 i = 0; i < count; ++i) {
if (QWindowsContext::verbose > 1)
@@ -526,13 +526,13 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd,
touchPoint.normalPosition = normalPosition;
if (touchInfo[i].pointerInfo.pointerFlags & POINTER_FLAG_DOWN) {
- touchPoint.state = Qt::TouchPointPressed;
+ touchPoint.state = QEventPoint::State::Pressed;
m_lastTouchPositions.insert(touchPoint.id, touchPoint.normalPosition);
} else if (touchInfo[i].pointerInfo.pointerFlags & POINTER_FLAG_UP) {
- touchPoint.state = Qt::TouchPointReleased;
+ touchPoint.state = QEventPoint::State::Released;
m_lastTouchPositions.remove(touchPoint.id);
} else {
- touchPoint.state = stationaryTouchPoint ? Qt::TouchPointStationary : Qt::TouchPointMoved;
+ touchPoint.state = stationaryTouchPoint ? QEventPoint::State::Stationary : QEventPoint::State::Updated;
m_lastTouchPositions.insert(touchPoint.id, touchPoint.normalPosition);
}
allStates |= touchPoint.state;
@@ -544,7 +544,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd,
}
// all touch points released, forget the ids we've seen.
- if (allStates == Qt::TouchPointReleased)
+ if (allStates == QEventPoint::State::Released)
m_touchInputIDToTouchPointID.clear();
QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, touchPoints,