[libkwineffects] Construct correct mouse event when forwarding to QtQuickView
Summary: Original code (copied from Aurorae) created a QMouseEvent for QHoverEvents. Whilst it apparently worked, it's technically wrong. It's safer to have an explicit type check given we come from a downcast QEvent* and then build the correct event. Test Plan: Hovered some icons Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25207
This commit is contained in:
parent
6dfb7ba1ce
commit
20a202b11a
1 changed files with 28 additions and 6 deletions
|
@ -201,12 +201,34 @@ void EffectQuickView::forwardMouseEvent(QEvent *e)
|
|||
if (!d->m_visible) {
|
||||
return;
|
||||
}
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(e);
|
||||
const QPoint widgetPos = d->m_view->mapFromGlobal(me->pos());
|
||||
|
||||
QMouseEvent cloneEvent(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers());
|
||||
QCoreApplication::sendEvent(d->m_view, &cloneEvent);
|
||||
e->setAccepted(cloneEvent.isAccepted());
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseMove:
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseButtonDblClick:
|
||||
{
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(e);
|
||||
const QPoint widgetPos = d->m_view->mapFromGlobal(me->pos());
|
||||
QMouseEvent cloneEvent(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers());
|
||||
QCoreApplication::sendEvent(d->m_view, &cloneEvent);
|
||||
e->setAccepted(cloneEvent.isAccepted());
|
||||
return;
|
||||
}
|
||||
case QEvent::HoverEnter:
|
||||
case QEvent::HoverLeave:
|
||||
case QEvent::HoverMove:
|
||||
{
|
||||
QHoverEvent *he = static_cast<QHoverEvent *>(e);
|
||||
const QPointF widgetPos = d->m_view->mapFromGlobal(he->pos());
|
||||
const QPointF oldWidgetPos = d->m_view->mapFromGlobal(he->oldPos());
|
||||
QHoverEvent cloneEvent(he->type(), widgetPos, oldWidgetPos, he->modifiers());
|
||||
QCoreApplication::sendEvent(d->m_view, &cloneEvent);
|
||||
e->setAccepted(cloneEvent.isAccepted());
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void EffectQuickView::forwardKeyEvent(QKeyEvent *keyEvent)
|
||||
|
|
Loading…
Reference in a new issue