From 3f94a2afc75c04c7352deeeda7f44328415281e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 18 May 2015 11:09:48 +0200 Subject: [PATCH] [wayland] Ensure QWindowSystemInterface::sendWindowSystemEvents gets called in EventDispatcher KWin used the wrong event dispatcher: QEventDispatcherUNIX insted of QUnixEventDispatcherQPA. This caused QWindow related events never to be send to their destination. Which is one of the reasons why KWin's own windows are not shown at all. As we cannot easily use QUnixEventDispatcherQPA we do the same as that class. Inherit from QEventDispatcherUNIX and call into QWindowSystemInterface::sendWindowSystemEvents. --- CMakeLists.txt | 1 + main_wayland.cpp | 22 ++++++++++++++++++++-- main_wayland.h | 12 ++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96526218e2..291d0bc539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -610,6 +610,7 @@ install(TARGETS kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} ) if(HAVE_WAYLAND) include_directories(${Qt5Core_PRIVATE_INCLUDE_DIRS}) + include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) kf5_add_kdeinit_executable(kwin_wayland main_wayland.cpp) target_link_libraries(kdeinit_kwin_wayland kwin) diff --git a/main_wayland.cpp b/main_wayland.cpp index b196872f9e..fad16d8ae1 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -38,7 +38,7 @@ along with this program. If not, see . #include #include #include -#include +#include #include #include #include @@ -314,6 +314,24 @@ static void readDisplay(int pipe) close(pipe); } +EventDispatcher::EventDispatcher(QObject *parent) + : QEventDispatcherUNIX(parent) +{ +} + +EventDispatcher::~EventDispatcher() = default; + +bool EventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) +{ + const bool didSendEvents = QEventDispatcherUNIX::processEvents(flags); + return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents; +} + +bool EventDispatcher::hasPendingEvents() +{ + return QEventDispatcherUNIX::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued(); +} + } // namespace extern "C" @@ -335,7 +353,7 @@ KWIN_EXPORT int kdemain(int argc, char * argv[]) } // set our own event dispatcher to be able to dispatch events before the event loop is started - QAbstractEventDispatcher *eventDispatcher = new QEventDispatcherUNIX(); + QAbstractEventDispatcher *eventDispatcher = new KWin::EventDispatcher(); QCoreApplication::setEventDispatcher(eventDispatcher); KWin::WaylandServer *server = KWin::WaylandServer::create(nullptr); server->init(waylandSocket); diff --git a/main_wayland.h b/main_wayland.h index 9189f92565..4f52e55b79 100644 --- a/main_wayland.h +++ b/main_wayland.h @@ -20,6 +20,7 @@ along with this program. If not, see . #ifndef KWIN_MAIN_WAYLAND_H #define KWIN_MAIN_WAYLAND_H #include "main.h" +#include namespace KWin { @@ -52,6 +53,17 @@ private: QStringList m_applicationsToStart; }; +class EventDispatcher : public QEventDispatcherUNIX +{ + Q_OBJECT +public: + explicit EventDispatcher(QObject *parent = nullptr); + virtual ~EventDispatcher(); + + bool processEvents(QEventLoop::ProcessEventsFlags flags) override; + bool hasPendingEvents() override; +}; + } #endif