From fe745177e0f524abb72e1025fedb3d1031aa9c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 16 Mar 2016 11:06:53 +0100 Subject: [PATCH] [plugins/qpa] Add a roundtrip platform function Summary: Mostly intended for plugins loaded into KWin and wanting to use KWayland::Client::ConnectionThread::roundtrip(). By providing this function we can ensure that KWin does not block and nevertheless perform the required roundtrip. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1153 --- plugins/qpa/nativeinterface.cpp | 21 +++++++++++++++++++++ plugins/qpa/nativeinterface.h | 1 + 2 files changed, 22 insertions(+) diff --git a/plugins/qpa/nativeinterface.cpp b/plugins/qpa/nativeinterface.cpp index c3cb175994..fc7ab3b29f 100644 --- a/plugins/qpa/nativeinterface.cpp +++ b/plugins/qpa/nativeinterface.cpp @@ -79,5 +79,26 @@ void *NativeInterface::nativeResourceForWindow(const QByteArray &resource, QWind return nullptr; } +static void roundtrip() +{ + if (!waylandServer()) { + return; + } + auto c = waylandServer()->internalClientConection(); + if (!c) { + return; + } + c->flush(); + waylandServer()->dispatch(); +} + +QFunctionPointer NativeInterface::platformFunction(const QByteArray &function) const +{ + if (qstrcmp(function.toLower(), "roundtrip") == 0) { + return &roundtrip; + } + return nullptr; +} + } } diff --git a/plugins/qpa/nativeinterface.h b/plugins/qpa/nativeinterface.h index b36ee1bb35..4a9f8e3988 100644 --- a/plugins/qpa/nativeinterface.h +++ b/plugins/qpa/nativeinterface.h @@ -35,6 +35,7 @@ public: explicit NativeInterface(Integration *integration); void *nativeResourceForIntegration(const QByteArray &resource) override; void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) override; + QFunctionPointer platformFunction(const QByteArray &function) const override; private: Integration *m_integration;