diff --git a/events.cpp b/events.cpp --- a/events.cpp +++ b/events.cpp @@ -63,7 +63,6 @@ #endif #include "composite.h" -#include "killwindow.h" #include "x11eventfilter.h" #include "wayland_server.h" @@ -253,12 +252,6 @@ && (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE)) return false; // let Qt process it, it'll be intercepted again in eventFilter() - if (!m_windowKiller.isNull() && m_windowKiller->isActive() && m_windowKiller->isResponsibleForEvent(eventType)) { - m_windowKiller->processEvent(e); - // filter out the event - return true; - } - if (eventType == XCB_PROPERTY_NOTIFY || eventType == XCB_CLIENT_MESSAGE) { NET::Properties dirtyProtocols; NET::Properties2 dirtyProtocols2; diff --git a/killwindow.h b/killwindow.h --- a/killwindow.h +++ b/killwindow.h @@ -23,12 +23,14 @@ #ifndef KWIN_KILLWINDOW_H #define KWIN_KILLWINDOW_H +#include "x11eventfilter.h" + #include namespace KWin { -class KillWindow +class KillWindow : public X11EventFilter { public: @@ -39,9 +41,10 @@ bool isActive() const { return m_active; } - bool isResponsibleForEvent(int eventType) const; void processEvent(xcb_generic_event_t *event); + bool event(xcb_generic_event_t *event) override; + private: xcb_cursor_t createCursor(); void release(); diff --git a/killwindow.cpp b/killwindow.cpp --- a/killwindow.cpp +++ b/killwindow.cpp @@ -35,7 +35,17 @@ { KillWindow::KillWindow() - : m_active(false) + : X11EventFilter(QVector{XCB_BUTTON_PRESS, + XCB_BUTTON_RELEASE, + XCB_MOTION_NOTIFY, + XCB_ENTER_NOTIFY, + XCB_LEAVE_NOTIFY, + XCB_KEY_PRESS, + XCB_KEY_RELEASE, + XCB_FOCUS_IN, + XCB_FOCUS_OUT + }) + , m_active(false) { } @@ -89,24 +99,6 @@ return cursor; } -bool KillWindow::isResponsibleForEvent(int eventType) const -{ - switch (eventType) { - case XCB_BUTTON_PRESS: - case XCB_BUTTON_RELEASE: - case XCB_MOTION_NOTIFY: - case XCB_ENTER_NOTIFY: - case XCB_LEAVE_NOTIFY: - case XCB_KEY_PRESS: - case XCB_KEY_RELEASE: - case XCB_FOCUS_IN: - case XCB_FOCUS_OUT: - return true; - default: - return false; - } -} - void KillWindow::processEvent(xcb_generic_event_t *event) { if (event->response_type == XCB_BUTTON_RELEASE) { @@ -118,6 +110,16 @@ } } +bool KillWindow::event(xcb_generic_event_t *event) +{ + if (!m_active) { + return false; + } + processEvent(event); + + return true; +} + void KillWindow::handleButtonRelease(xcb_button_t button, xcb_window_t window) { if (button == XCB_BUTTON_INDEX_3) {