effects: Set timestamp for input events

Set the time for mouse and touch events. This is especially important
for the mouse is as the timestamp will be used to discriminate between
single and double click. Previously this was always sending the double
click event, making buttons work only every other click.

BUG: 454275
BUG: 449907
This commit is contained in:
Marco Martin 2022-06-24 17:54:55 +00:00 committed by Nate Graham
parent 66d1278794
commit 66a54d38d4
2 changed files with 4 additions and 2 deletions

View file

@ -63,6 +63,7 @@ bool EffectsMouseInterceptionX11Filter::event(xcb_generic_event_t *event)
}
QWheelEvent ev(QPoint(me->event_x, me->event_y), QCursor::pos(), QPoint(), angleDelta, buttons, modifiers, Qt::NoScrollPhase, false);
ev.setTimestamp(me->time);
return m_effects->checkInputWindowEvent(&ev);
}
const Qt::MouseButton button = x11ToQtMouseButton(me->detail);
@ -75,6 +76,7 @@ bool EffectsMouseInterceptionX11Filter::event(xcb_generic_event_t *event)
}
QMouseEvent ev(type, QPoint(me->event_x, me->event_y), QPoint(me->root_x, me->root_y),
button, buttons, x11ToQtKeyboardModifiers(me->state));
ev.setTimestamp(me->time);
return m_effects->checkInputWindowEvent(&ev);
}
} else if (eventType == XCB_MOTION_NOTIFY) {
@ -82,6 +84,7 @@ bool EffectsMouseInterceptionX11Filter::event(xcb_generic_event_t *event)
if (m_window == me->event) {
QMouseEvent ev(QEvent::MouseMove, QPoint(me->event_x, me->event_y), QPoint(me->root_x, me->root_y),
Qt::NoButton, x11ToQtMouseButtons(me->state), x11ToQtKeyboardModifiers(me->state));
ev.setTimestamp(me->time);
return m_effects->checkInputWindowEvent(&ev);
}
}

View file

@ -369,8 +369,6 @@ void OffscreenQuickView::forwardKeyEvent(QKeyEvent *keyEvent)
bool OffscreenQuickView::forwardTouchDown(qint32 id, const QPointF &pos, quint32 time)
{
Q_UNUSED(time)
d->updateTouchState(Qt::TouchPointPressed, id, pos);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -378,6 +376,7 @@ bool OffscreenQuickView::forwardTouchDown(qint32 id, const QPointF &pos, quint32
#else
QTouchEvent event(QEvent::TouchBegin, d->touchDevice, Qt::NoModifier, d->touchPoints);
#endif
event.setTimestamp(time);
QCoreApplication::sendEvent(d->m_view, &event);
return event.isAccepted();