From f885ce3796559fcb67eff61f77af1392bd0ac354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 20 May 2015 13:11:17 +0200 Subject: [PATCH] [wayland] Implement notify in ApplicationWayland If we get an Expose event for any QWindow we need to ensure that all wayland events on both client (Qt) and server (KWin) side are dispatched. Otherwise it could happen that Qt starts rendering although the last frame callback has not yet been emitted, causing the main gui thread to be blocked. --- main_wayland.cpp | 13 +++++++++++++ main_wayland.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/main_wayland.cpp b/main_wayland.cpp index e7b2b43c85..664ffe7149 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -251,6 +251,19 @@ void ApplicationWayland::createX11Connection() setX11RootWindow(defaultScreen()->root); } +bool ApplicationWayland::notify(QObject *o, QEvent *e) +{ + if (qobject_cast< QWindow* >(o)) { + if (e->type() == QEvent::Expose) { + // ensure all Wayland events both on client and server side are dispatched + // otherwise it is possible that Qt starts rendering and blocks the main gui thread + // as it waits for the callback of the last frame + waylandServer()->dispatch(); + } + } + return Application::notify(o, e); +} + /** * Starts the Xwayland-Server. * The new process is started by forking into it. diff --git a/main_wayland.h b/main_wayland.h index 4f52e55b79..dc5257239f 100644 --- a/main_wayland.h +++ b/main_wayland.h @@ -39,6 +39,8 @@ public: m_applicationsToStart = applications; } + bool notify(QObject *o, QEvent *e) override; + protected: void performStartup() override;