[effects] Forward wheel events
Summary: Effects::checkInputWindowEvent(QWheelEvent *e) existed but it was not hooked up to anything and would never be called. This patch adds the relevant handling in the wayland filter, X filter so the existing method gets called. EffectQuickView is updated to handle wheel events. Test Plan: Used a ListView via an EffectQuickView in an effect. I can now scroll with the mouse. Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25292
This commit is contained in:
parent
20a202b11a
commit
aedc9e62e6
3 changed files with 52 additions and 0 deletions
|
@ -411,6 +411,12 @@ public:
|
|||
}
|
||||
return static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(event);
|
||||
}
|
||||
bool wheelEvent(QWheelEvent *event) override {
|
||||
if (!effects) {
|
||||
return false;
|
||||
}
|
||||
return static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(event);
|
||||
}
|
||||
bool keyEvent(QKeyEvent *event) override {
|
||||
if (!effects || !static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()) {
|
||||
return false;
|
||||
|
|
|
@ -226,6 +226,16 @@ void EffectQuickView::forwardMouseEvent(QEvent *e)
|
|||
e->setAccepted(cloneEvent.isAccepted());
|
||||
return;
|
||||
}
|
||||
case QEvent::Wheel:
|
||||
{
|
||||
QWheelEvent *we = static_cast<QWheelEvent *>(e);
|
||||
const QPointF widgetPos = d->m_view->mapFromGlobal(we->pos());
|
||||
QWheelEvent cloneEvent(widgetPos, we->globalPosF(), we->pixelDelta(), we->angleDelta(), we->buttons(),
|
||||
we->modifiers(), we->phase(), we->inverted());
|
||||
QCoreApplication::sendEvent(d->m_view, &cloneEvent);
|
||||
e->setAccepted(cloneEvent.isAccepted());
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,42 @@ bool EffectsMouseInterceptionX11Filter::event(xcb_generic_event_t *event)
|
|||
if (eventType == XCB_BUTTON_PRESS || eventType == XCB_BUTTON_RELEASE) {
|
||||
auto *me = reinterpret_cast<xcb_button_press_event_t*>(event);
|
||||
if (m_window == me->event) {
|
||||
const bool isWheel = me->detail >= 4 || me->detail <= 7;
|
||||
if (isWheel) {
|
||||
if (eventType != XCB_BUTTON_PRESS) {
|
||||
return false;
|
||||
}
|
||||
QPoint angleDelta;
|
||||
switch (me->detail) {
|
||||
case 4:
|
||||
angleDelta.setY(120);
|
||||
break;
|
||||
case 5:
|
||||
angleDelta.setY(-120);
|
||||
break;
|
||||
case 6:
|
||||
angleDelta.setX(120);
|
||||
break;
|
||||
case 7:
|
||||
angleDelta.setX(-120);
|
||||
break;
|
||||
}
|
||||
|
||||
const Qt::MouseButtons buttons = x11ToQtMouseButtons(me->state);
|
||||
const Qt::KeyboardModifiers modifiers = x11ToQtKeyboardModifiers(me->state);
|
||||
|
||||
if (modifiers & Qt::AltModifier) {
|
||||
angleDelta = angleDelta.transposed();
|
||||
}
|
||||
|
||||
if (angleDelta.y()) {
|
||||
QWheelEvent ev(QPoint(me->event_x, me->event_y), angleDelta.y(), buttons, modifiers, Qt::Vertical);
|
||||
return m_effects->checkInputWindowEvent(&ev);
|
||||
} else if (angleDelta.x()) {
|
||||
QWheelEvent ev(QPoint(me->event_x, me->event_y), angleDelta.x(), buttons, modifiers, Qt::Horizontal);
|
||||
return m_effects->checkInputWindowEvent(&ev);
|
||||
}
|
||||
}
|
||||
const Qt::MouseButton button = x11ToQtMouseButton(me->detail);
|
||||
Qt::MouseButtons buttons = x11ToQtMouseButtons(me->state);
|
||||
const QEvent::Type type = (eventType == XCB_BUTTON_PRESS) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
|
||||
|
|
Loading…
Reference in a new issue