diff --git a/plugins/qpa/nativeinterface.cpp b/plugins/qpa/nativeinterface.cpp index c3cb17599..fc7ab3b29 100644 --- a/plugins/qpa/nativeinterface.cpp +++ b/plugins/qpa/nativeinterface.cpp @@ -1,83 +1,104 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 Martin Gräßlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "nativeinterface.h" #include "integration.h" #include "window.h" #include "../../wayland_server.h" #include #include #include #include namespace KWin { namespace QPA { static const QByteArray s_displayKey = QByteArrayLiteral("display"); static const QByteArray s_wlDisplayKey = QByteArrayLiteral("wl_display"); static const QByteArray s_compositorKey = QByteArrayLiteral("compositor"); static const QByteArray s_surfaceKey = QByteArrayLiteral("surface"); NativeInterface::NativeInterface(Integration *integration) : QPlatformNativeInterface() , m_integration(integration) { } void *NativeInterface::nativeResourceForIntegration(const QByteArray &resource) { const QByteArray r = resource.toLower(); if (r == s_displayKey || r == s_wlDisplayKey) { if (!waylandServer() || !waylandServer()->internalClientConection()) { return nullptr; } return waylandServer()->internalClientConection()->display(); } if (r == s_compositorKey) { return static_cast(*m_integration->compositor()); } return nullptr; } void *NativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { const QByteArray r = resource.toLower(); if (r == s_displayKey || r == s_wlDisplayKey) { if (!waylandServer() || !waylandServer()->internalClientConection()) { return nullptr; } return waylandServer()->internalClientConection()->display(); } if (r == s_compositorKey) { return static_cast(*m_integration->compositor()); } if (r == s_surfaceKey && window) { if (auto handle = window->handle()) { return static_cast(*static_cast(handle)->surface()); } } 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 b36ee1bb3..4a9f8e398 100644 --- a/plugins/qpa/nativeinterface.h +++ b/plugins/qpa/nativeinterface.h @@ -1,46 +1,47 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 Martin Gräßlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #ifndef KWIN_QPA_NATIVEINTERFACE_H #define KWIN_QPA_NATIVEINTERFACE_H #include namespace KWin { namespace QPA { class Integration; class NativeInterface : public QPlatformNativeInterface { 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; }; } } #endif