diff --git a/events.cpp b/events.cpp index 0c5d8fcda..bdb9d65c8 100644 --- a/events.cpp +++ b/events.cpp @@ -72,10 +72,11 @@ extern int currentRefreshRate(); // **************************************** /*! - Handles workspace specific XEvents + Handles workspace specific XCB event */ -bool Workspace::workspaceEvent(XEvent * e) +bool Workspace::workspaceEvent(xcb_generic_event_t *e) { +#if KWIN_QT5_PORTING if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab() && (e->type == KeyPress || e->type == KeyRelease)) return false; // let Qt process it, it'll be intercepted again in eventFilter() @@ -349,6 +350,7 @@ bool Workspace::workspaceEvent(XEvent * e) } break; } +#endif return false; } diff --git a/main.cpp b/main.cpp index 95b8a15a9..593074c07 100644 --- a/main.cpp +++ b/main.cpp @@ -305,6 +305,7 @@ int Application::crashes = 0; Application::Application() : KApplication() , owner(screen_number) + , m_eventFilter(new XcbEventFilter()) { if (KCmdLineArgs::parsedArgs("qt")->isSet("sync")) { kwin_sync = true; @@ -360,6 +361,7 @@ Application::Application() QTimer::singleShot(15 * 1000, this, SLOT(resetCrashesCount())); initting = true; // Startup... + installNativeEventFilter(m_eventFilter.data()); // first load options - done internally by a different thread options = new Options; @@ -444,6 +446,19 @@ void Application::resetCrashesCount() crashes = 0; } +bool XcbEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long int *result) +{ + Q_UNUSED(result) + if (!Workspace::self()) { + // Workspace not yet created + return false; + } + if (eventType != "xcb_generic_event_t") { + return false; + } + return Workspace::self()->workspaceEvent(static_cast(message)); +} + } // namespace static const char version[] = KDE_VERSION_STRING; diff --git a/main.h b/main.h index 4c317b9f8..35d438c50 100644 --- a/main.h +++ b/main.h @@ -24,10 +24,18 @@ along with this program. If not, see . #include #include +// Qt +#include namespace KWin { +class XcbEventFilter : public QAbstractNativeEventFilter +{ +public: + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override; +}; + class KWinSelectionOwner : public KSelectionOwner { @@ -60,6 +68,7 @@ private Q_SLOTS: private: KWinSelectionOwner owner; + QScopedPointer m_eventFilter; static int crashes; }; diff --git a/workspace.h b/workspace.h index 991f7b3bd..cb27a9cbc 100644 --- a/workspace.h +++ b/workspace.h @@ -68,7 +68,7 @@ public: return _self; } - bool workspaceEvent(XEvent*); + bool workspaceEvent(xcb_generic_event_t*); bool workspaceEvent(QEvent*); bool hasClient(const Client*);