From f7d6e4affd22a241828983f339f0e5e75257220b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sat, 16 Sep 2017 11:30:37 +0200 Subject: [PATCH] [tabbox] Drop the passing to Effects in X11 Filter Summary: If an Effect has replaced the TabBox and wants to react on mouse events the EffectsHandlerImpl also has an X11Filter, so we only need to make sure the events go to that filter. Motion: TabBox did not filter out, so events will go to the Effects filter. Press/Release: TabBox should not operate if Effects take the events. The events are filtered out by Effects if there is a grab, so just check for that and go out. Effects will take care. Test Plan: Compiles Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7846 --- effects.cpp | 35 ----------------------------------- effects.h | 2 -- tabbox/x11_filter.cpp | 29 +++++++++-------------------- tabbox/x11_filter.h | 2 +- 4 files changed, 10 insertions(+), 58 deletions(-) diff --git a/effects.cpp b/effects.cpp index 4cc2c4e56e..a53ce1b8a1 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1230,41 +1230,6 @@ void EffectsHandlerImpl::defineCursor(Qt::CursorShape shape) } } -bool EffectsHandlerImpl::checkInputWindowEvent(xcb_button_press_event_t *e) -{ - if (m_grabbedMouseEffects.isEmpty() || m_mouseInterceptionWindow != e->event) { - return false; - } - for (Effect *effect : m_grabbedMouseEffects) { - Qt::MouseButton button = x11ToQtMouseButton(e->detail); - Qt::MouseButtons buttons = x11ToQtMouseButtons(e->state); - const QEvent::Type type = ((e->response_type & ~0x80) == XCB_BUTTON_PRESS) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; - if (type == QEvent::MouseButtonPress) { - buttons |= button; - } else { - buttons &= ~button; - } - QMouseEvent ev(type, - QPoint(e->event_x, e->event_y), QPoint(e->root_x, e->root_y), - button, buttons, x11ToQtKeyboardModifiers(e->state)); - effect->windowInputMouseEvent(&ev); - } - return true; // eat event -} - -bool EffectsHandlerImpl::checkInputWindowEvent(xcb_motion_notify_event_t *e) -{ - if (m_grabbedMouseEffects.isEmpty() || m_mouseInterceptionWindow != e->event) { - return false; - } - for (Effect *effect : m_grabbedMouseEffects) { - QMouseEvent ev(QEvent::MouseMove, QPoint(e->event_x, e->event_y), QPoint(e->root_x, e->root_y), - Qt::NoButton, x11ToQtMouseButtons(e->state), x11ToQtKeyboardModifiers(e->state)); - effect->windowInputMouseEvent(&ev); - } - return true; // eat event -} - bool EffectsHandlerImpl::checkInputWindowEvent(QMouseEvent *e) { if (m_grabbedMouseEffects.isEmpty()) { diff --git a/effects.h b/effects.h index bf5b9bfa97..ab0e68cff8 100644 --- a/effects.h +++ b/effects.h @@ -165,8 +165,6 @@ public: WindowQuadType newWindowQuadType() override; void defineCursor(Qt::CursorShape shape) override; - bool checkInputWindowEvent(xcb_button_press_event_t *e); - bool checkInputWindowEvent(xcb_motion_notify_event_t *e); bool checkInputWindowEvent(QMouseEvent *e); bool checkInputWindowEvent(QWheelEvent *e); void checkInputWindowStacking(); diff --git a/tabbox/x11_filter.cpp b/tabbox/x11_filter.cpp index 337ed4700c..fda9223aaf 100644 --- a/tabbox/x11_filter.cpp +++ b/tabbox/x11_filter.cpp @@ -37,18 +37,6 @@ X11Filter::X11Filter() { } -template -static bool passToEffects(T *e) -{ - const auto tab = TabBox::TabBox::self(); - if (!tab->isShown() && tab->isDisplayed()) { - if (effects && static_cast(effects)->checkInputWindowEvent(e)) { - return true; - } - } - return false; -} - bool X11Filter::event(xcb_generic_event_t *event) { if (!TabBox::TabBox::self()->isGrabbed()) { @@ -60,8 +48,12 @@ bool X11Filter::event(xcb_generic_event_t *event) case XCB_BUTTON_RELEASE: { auto e = reinterpret_cast(event); xcb_allow_events(connection(), XCB_ALLOW_ASYNC_POINTER, XCB_CURRENT_TIME); - if (passToEffects(e)) { - return true; + const auto tab = TabBox::TabBox::self(); + if (!tab->isShown() && tab->isDisplayed()) { + if (effects && static_cast(effects)->isMouseInterception()) { + // pass on to effects, effects will filter out the event + return false; + } } if (eventType == XCB_BUTTON_PRESS) { return buttonPress(e); @@ -69,7 +61,8 @@ bool X11Filter::event(xcb_generic_event_t *event) return false; } case XCB_MOTION_NOTIFY: { - return motion(event); + motion(event); + break; } case XCB_KEY_PRESS: { keyPress(event); @@ -103,17 +96,13 @@ bool X11Filter::buttonPress(xcb_button_press_event_t *event) return false; } -bool X11Filter::motion(xcb_generic_event_t *event) +void X11Filter::motion(xcb_generic_event_t *event) { auto *mouseEvent = reinterpret_cast(event); const QPoint rootPos(mouseEvent->root_x, mouseEvent->root_y); // TODO: this should be in ScreenEdges directly ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(xTime()), true); xcb_allow_events(connection(), XCB_ALLOW_ASYNC_POINTER, XCB_CURRENT_TIME); - if (passToEffects(mouseEvent)) { - return true; - } - return false; } void X11Filter::keyPress(xcb_generic_event_t *event) diff --git a/tabbox/x11_filter.h b/tabbox/x11_filter.h index 10154fc594..9411b44ab9 100644 --- a/tabbox/x11_filter.h +++ b/tabbox/x11_filter.h @@ -35,7 +35,7 @@ public: private: bool buttonPress(xcb_button_press_event_t *event); - bool motion(xcb_generic_event_t *event); + void motion(xcb_generic_event_t *event); void keyPress(xcb_generic_event_t *event); void keyRelease(xcb_generic_event_t *event); };