From abb9bf13556f461d3f9a1b52e875d3a0fe91a739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 20 Aug 2015 14:31:13 +0200 Subject: [PATCH] [wayland] Create event dispatcher in QPA plugin We no longer need to have the event dispatcher created before starting the QApplication, thus we can leave it to the QPA plugin to creat it. Also we don't need to implement our own dispatcher any more but can use one from Qt5PlatformSupport as we link it anyways. The special need for dispatching the WaylandServer is no longer needed as we can explicitly dispatch it from the QPA plugin if needed. --- CMakeLists.txt | 2 -- main_wayland.cpp | 25 +------------------------ main_wayland.h | 12 ------------ plugins/qpa/integration.cpp | 4 ++-- 4 files changed, 3 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7acd53c5a3..44a423cb72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -555,8 +555,6 @@ install(TARGETS kwin ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELIN install(TARGETS kdeinit_kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(TARGETS kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} ) -include_directories(${Qt5Core_PRIVATE_INCLUDE_DIRS}) -include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) add_executable(kwin_wayland main_wayland.cpp) target_link_libraries(kwin_wayland kwin) diff --git a/main_wayland.cpp b/main_wayland.cpp index 3d11457a9b..de2e5d2799 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -34,11 +34,11 @@ along with this program. If not, see . #include // Qt #include +#include #include #include #include #include -#include #include #include #include @@ -316,25 +316,6 @@ static void readDisplay(int pipe) close(pipe); } -EventDispatcher::EventDispatcher(QObject *parent) - : QEventDispatcherUNIX(parent) -{ -} - -EventDispatcher::~EventDispatcher() = default; - -bool EventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - waylandServer()->dispatch(); - const bool didSendEvents = QEventDispatcherUNIX::processEvents(flags); - return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents; -} - -bool EventDispatcher::hasPendingEvents() -{ - return QEventDispatcherUNIX::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued(); -} - static const QString s_waylandPlugin = QStringLiteral("KWinWaylandWaylandBackend"); static const QString s_x11Plugin = QStringLiteral("KWinWaylandX11Backend"); static const QString s_fbdevPlugin = QStringLiteral("KWinWaylandFbdevBackend"); @@ -368,10 +349,6 @@ static QString automaticBackendSelection() int main(int argc, char * argv[]) { - // set our own event dispatcher to be able to dispatch events before the event loop is started - QAbstractEventDispatcher *eventDispatcher = new KWin::EventDispatcher(); - QCoreApplication::setEventDispatcher(eventDispatcher); - KWin::Application::setupMalloc(); KWin::Application::setupLocalizedString(); diff --git a/main_wayland.h b/main_wayland.h index 23daf12927..fd95bd7481 100644 --- a/main_wayland.h +++ b/main_wayland.h @@ -20,7 +20,6 @@ along with this program. If not, see . #ifndef KWIN_MAIN_WAYLAND_H #define KWIN_MAIN_WAYLAND_H #include "main.h" -#include #include class QProcess; @@ -70,17 +69,6 @@ private: QProcessEnvironment m_environment; }; -class EventDispatcher : public QEventDispatcherUNIX -{ - Q_OBJECT -public: - explicit EventDispatcher(QObject *parent = nullptr); - virtual ~EventDispatcher(); - - bool processEvents(QEventLoop::ProcessEventsFlags flags) override; - bool hasPendingEvents() override; -}; - } #endif diff --git a/plugins/qpa/integration.cpp b/plugins/qpa/integration.cpp index 41b773388f..abcd3e8434 100644 --- a/plugins/qpa/integration.cpp +++ b/plugins/qpa/integration.cpp @@ -43,6 +43,7 @@ along with this program. If not, see . #include #include #include +#include namespace KWin { @@ -90,8 +91,7 @@ void Integration::initialize() QAbstractEventDispatcher *Integration::createEventDispatcher() const { - // TODO: add our own event dispatcher - return new QEventDispatcherUNIX; + return new QUnixEventDispatcherQPA; } QPlatformBackingStore *Integration::createPlatformBackingStore(QWindow *window) const