Commit aedc9e62 authored by David Edmundson's avatar David Edmundson
Browse files

[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
parent 20a202b1
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment