File indexing completed on 2024-05-19 05:32:47
0001 /* 0002 SPDX-FileCopyrightText: 2017 Marco Martin <notmart@gmail.com> 0003 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 #pragma once 0008 0009 #include "kwin_export.h" 0010 0011 #include <QObject> 0012 0013 namespace KWin 0014 { 0015 class Display; 0016 class SurfaceInterface; 0017 class XdgForeignV2InterfacePrivate; 0018 0019 class KWIN_EXPORT XdgExportedSurface : public QObject 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 XdgExportedSurface(SurfaceInterface *surface); 0025 0026 QString handle() const; 0027 SurfaceInterface *surface() const; 0028 0029 private: 0030 void handleSurfaceDestroyed(); 0031 0032 const QString m_handle; 0033 SurfaceInterface *m_surface; 0034 }; 0035 0036 /** 0037 * This class encapsulates the server side logic of the XdgForeign protocol. 0038 * a process can export a surface to be identifiable by a server-wide unique 0039 * string handle, and another process can in turn import that surface, and set it 0040 * as transient parent for one of its own surfaces. 0041 * This parent relationship is traced by the transientChanged signal and the 0042 * transientFor method. 0043 */ 0044 class KWIN_EXPORT XdgForeignV2Interface : public QObject 0045 { 0046 Q_OBJECT 0047 public: 0048 XdgForeignV2Interface(Display *display, QObject *parent = nullptr); 0049 ~XdgForeignV2Interface() override; 0050 0051 /** 0052 * If a client did import a surface and set one of its own as child of the 0053 * imported one, this returns the mapping. 0054 * @param surface the child surface we want to search an imported transientParent for. 0055 * @returns the transient parent of the surface, if found, nullptr otherwise. 0056 */ 0057 SurfaceInterface *transientFor(SurfaceInterface *surface); 0058 0059 /** 0060 * Exports the given surface without creating a Wayland interface object. 0061 * @param surface The surface to export 0062 * @return The handle, this can then be passed to other clients. 0063 */ 0064 XdgExportedSurface *exportSurface(SurfaceInterface *surface); 0065 0066 Q_SIGNALS: 0067 /** 0068 * A surface got a new imported transient parent 0069 * @param parent is the surface exported by one client and imported into another, which will act as parent. 0070 * @param child is the surface that the importer client did set as child of the surface 0071 * that it imported. 0072 * If one of the two paramenters is nullptr, it means that a previously relation is not 0073 * valid anymore and either one of the surfaces has been unmapped, or the parent surface 0074 * is not exported anymore. 0075 */ 0076 void transientChanged(KWin::SurfaceInterface *child, KWin::SurfaceInterface *parent); 0077 0078 private: 0079 friend class XdgExporterV2Interface; 0080 friend class XdgImporterV2Interface; 0081 std::unique_ptr<XdgForeignV2InterfacePrivate> d; 0082 }; 0083 0084 }