effects: Use unique device for replaying events to QQuickView
When a new mouse event is made it updates the global position of that device. This causes issues if a mouse event is forwarded with an adjusted position then used afterwards. `QPointingDevice::primaryPointingDevice` creates a new pointer device internally if the seat name does not exist. It is then shared between future usages. BUG: 480864
This commit is contained in:
parent
d0e07ba3e8
commit
862dae455a
1 changed files with 5 additions and 3 deletions
|
@ -271,13 +271,15 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e)
|
||||||
if (!d->m_visible) {
|
if (!d->m_visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto replayDevice = QPointingDevice::primaryPointingDevice("mouseReplayDevice");
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::MouseButtonRelease: {
|
case QEvent::MouseButtonRelease: {
|
||||||
QMouseEvent *me = static_cast<QMouseEvent *>(e);
|
QMouseEvent *me = static_cast<QMouseEvent *>(e);
|
||||||
const QPoint widgetPos = d->m_view->mapFromGlobal(me->pos());
|
const QPoint widgetPos = d->m_view->mapFromGlobal(me->pos());
|
||||||
QMouseEvent cloneEvent(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers());
|
|
||||||
|
QMouseEvent cloneEvent(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers(), replayDevice);
|
||||||
cloneEvent.setAccepted(false);
|
cloneEvent.setAccepted(false);
|
||||||
QCoreApplication::sendEvent(d->m_view.get(), &cloneEvent);
|
QCoreApplication::sendEvent(d->m_view.get(), &cloneEvent);
|
||||||
e->setAccepted(cloneEvent.isAccepted());
|
e->setAccepted(cloneEvent.isAccepted());
|
||||||
|
@ -289,7 +291,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e)
|
||||||
d->lastMousePressButton = me->button();
|
d->lastMousePressButton = me->button();
|
||||||
if (doubleClick) {
|
if (doubleClick) {
|
||||||
d->lastMousePressButton = Qt::NoButton;
|
d->lastMousePressButton = Qt::NoButton;
|
||||||
QMouseEvent doubleClickEvent(QEvent::MouseButtonDblClick, me->localPos(), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
|
QMouseEvent doubleClickEvent(QEvent::MouseButtonDblClick, me->localPos(), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers(), replayDevice);
|
||||||
QCoreApplication::sendEvent(d->m_view.get(), &doubleClickEvent);
|
QCoreApplication::sendEvent(d->m_view.get(), &doubleClickEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,7 +314,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e)
|
||||||
QWheelEvent *we = static_cast<QWheelEvent *>(e);
|
QWheelEvent *we = static_cast<QWheelEvent *>(e);
|
||||||
const QPointF widgetPos = d->m_view->mapFromGlobal(we->position().toPoint());
|
const QPointF widgetPos = d->m_view->mapFromGlobal(we->position().toPoint());
|
||||||
QWheelEvent cloneEvent(widgetPos, we->globalPosition(), we->pixelDelta(), we->angleDelta(), we->buttons(),
|
QWheelEvent cloneEvent(widgetPos, we->globalPosition(), we->pixelDelta(), we->angleDelta(), we->buttons(),
|
||||||
we->modifiers(), we->phase(), we->inverted());
|
we->modifiers(), we->phase(), we->inverted(), Qt::MouseEventNotSynthesized, replayDevice);
|
||||||
cloneEvent.setAccepted(false);
|
cloneEvent.setAccepted(false);
|
||||||
QCoreApplication::sendEvent(d->m_view.get(), &cloneEvent);
|
QCoreApplication::sendEvent(d->m_view.get(), &cloneEvent);
|
||||||
e->setAccepted(cloneEvent.isAccepted());
|
e->setAccepted(cloneEvent.isAccepted());
|
||||||
|
|
Loading…
Reference in a new issue