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