File indexing completed on 2024-05-19 16:35:28
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2020 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 0008 #pragma once 0009 0010 #include "kwin_export.h" 0011 0012 #include <QObject> 0013 #include <memory> 0014 0015 struct wl_resource; 0016 0017 namespace KWaylandServer 0018 { 0019 class Display; 0020 class SubCompositorInterfacePrivate; 0021 class SurfaceInterface; 0022 class SubSurfaceInterface; 0023 class SubSurfaceInterfacePrivate; 0024 0025 /** 0026 * The SubCompositorInterface compositor extension provides applications a way to offload 0027 * compositing work within a window from clients to the compositor. This may reduce the power 0028 * usage for applications such as video players, etc. 0029 * 0030 * The SubCompositorInterface corresponds to the Wayland interface @c wl_subcompositor. 0031 */ 0032 class KWIN_EXPORT SubCompositorInterface : public QObject 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit SubCompositorInterface(Display *display, QObject *parent = nullptr); 0038 ~SubCompositorInterface() override; 0039 0040 Q_SIGNALS: 0041 /** 0042 * This signal is emitted when a new sub-surface @subsurface has been created. 0043 */ 0044 void subSurfaceCreated(KWaylandServer::SubSurfaceInterface *subsurface); 0045 0046 private: 0047 std::unique_ptr<SubCompositorInterfacePrivate> d; 0048 }; 0049 0050 /** 0051 * The SubSurfaceInterface corresponds to the Wayland interface @c wl_subsurface. 0052 */ 0053 class KWIN_EXPORT SubSurfaceInterface : public QObject 0054 { 0055 Q_OBJECT 0056 0057 public: 0058 ~SubSurfaceInterface() override; 0059 0060 /** 0061 * Returns the position of the sub-surface relative to the upper-left corner of its parent. 0062 */ 0063 QPoint position() const; 0064 0065 /** 0066 * This enum type is used to specify the commit behavior for a subsurface. 0067 */ 0068 enum class Mode { 0069 Synchronized, 0070 Desynchronized, 0071 }; 0072 0073 /** 0074 * Returns the current commit mode. 0075 * 0076 * @see isSynchronized 0077 */ 0078 Mode mode() const; 0079 0080 /** 0081 * Returns @c true if the sub-surface is in synchronized mode; otherwise returns @c false. 0082 * 0083 * This method checks whether this sub-surface or any of its ancestors is in the synchronized 0084 * mode. Note that this function is not equivalent to calling mode() and checking whether 0085 * the return value is Mode::Synchronized. 0086 * 0087 * @see mode 0088 */ 0089 bool isSynchronized() const; 0090 0091 /** 0092 * Returns the SurfaceInterface for this SubSurfaceInterface. This function never returns a 0093 * @c null. 0094 */ 0095 SurfaceInterface *surface() const; 0096 0097 /** 0098 * Returns the parent surface for this SubSurfaceInterface. This function may return @c null. 0099 */ 0100 SurfaceInterface *parentSurface() const; 0101 0102 /** 0103 * Returns the main surface for the sub-surface tree, that is the first surface without a parent 0104 */ 0105 SurfaceInterface *mainSurface() const; 0106 0107 Q_SIGNALS: 0108 /** 0109 * This signal is emitted when the position of the sub-surface has changed. 0110 */ 0111 void positionChanged(const QPoint &position); 0112 /** 0113 * This signal is emitted when the commit mode of the sub-surface has changed. 0114 */ 0115 void modeChanged(KWaylandServer::SubSurfaceInterface::Mode mode); 0116 0117 private: 0118 SubSurfaceInterface(SurfaceInterface *surface, SurfaceInterface *parent, wl_resource *resource); 0119 std::unique_ptr<SubSurfaceInterfacePrivate> d; 0120 friend class SubSurfaceInterfacePrivate; 0121 friend class SubCompositorInterfacePrivate; 0122 }; 0123 0124 } // namespace KWaylandServer 0125 0126 Q_DECLARE_METATYPE(KWaylandServer::SubSurfaceInterface::Mode)