effect/offscreenquickview: ensure the view that accepts touch down also gets touch up

If another window accepts the touch up, that can seriously mess up the touch state and
cause for example the overview effect to misbehave when we have 2 screens.
wilder/Plasma/6.3
Xaver Hugl 1 year ago
parent 8676141067
commit 4595e41b4e
  1. 17
      src/effect/offscreenquickview.cpp

@ -55,6 +55,7 @@ public:
bool m_automaticRepaint = true;
QList<QEventPoint> touchPoints;
QSet<uint32_t> acceptedTouchPoints;
QPointingDevice *touchDevice;
ulong lastMousePressTime = 0;
@ -344,13 +345,21 @@ bool OffscreenQuickView::forwardTouchDown(qint32 id, const QPointF &pos, std::ch
event.setAccepted(false);
QCoreApplication::sendEvent(d->m_view.get(), &event);
return event.isAccepted();
const bool ret = event.isAccepted();
if (ret) {
d->acceptedTouchPoints.insert(id);
}
return ret;
}
bool OffscreenQuickView::forwardTouchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time)
{
d->updateTouchState(Qt::TouchPointMoved, id, pos);
if (!d->acceptedTouchPoints.contains(id)) {
return false;
}
QTouchEvent event(QEvent::TouchUpdate, d->touchDevice, Qt::NoModifier, d->touchPoints);
event.setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(time).count());
event.setAccepted(false);
@ -363,11 +372,17 @@ bool OffscreenQuickView::forwardTouchUp(qint32 id, std::chrono::microseconds tim
{
d->updateTouchState(Qt::TouchPointReleased, id, QPointF{});
if (!d->acceptedTouchPoints.contains(id)) {
return false;
}
QTouchEvent event(QEvent::TouchEnd, d->touchDevice, Qt::NoModifier, d->touchPoints);
event.setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(time).count());
event.setAccepted(false);
QCoreApplication::sendEvent(d->m_view.get(), &event);
d->acceptedTouchPoints.remove(id);
return event.isAccepted();
}

Loading…
Cancel
Save