Commit f7d6e4af authored by Martin Flöser's avatar Martin Flöser

[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
parent 6f99b577
......@@ -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()) {
......
......@@ -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();
......
......@@ -37,18 +37,6 @@ X11Filter::X11Filter()
{
}
template <typename T>
static bool passToEffects(T *e)
{
const auto tab = TabBox::TabBox::self();
if (!tab->isShown() && tab->isDisplayed()) {
if (effects && static_cast<EffectsHandlerImpl*>(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<xcb_button_press_event_t*>(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<EffectsHandlerImpl*>(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<xcb_motion_notify_event_t*>(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)
......
......@@ -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);
};
......
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