File indexing completed on 2024-05-19 16:34:47
0001 /* 0002 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "scene/surfaceitem.h" 0010 0011 namespace KWaylandServer 0012 { 0013 class ClientBuffer; 0014 class SubSurfaceInterface; 0015 class SurfaceInterface; 0016 } 0017 0018 namespace KWin 0019 { 0020 0021 class Deleted; 0022 0023 /** 0024 * The SurfaceItemWayland class represents a Wayland surface in the scene. 0025 */ 0026 class KWIN_EXPORT SurfaceItemWayland : public SurfaceItem 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit SurfaceItemWayland(KWaylandServer::SurfaceInterface *surface, Scene *scene, Item *parent = nullptr); 0032 0033 QVector<QRectF> shape() const override; 0034 QRegion opaque() const override; 0035 ContentType contentType() const override; 0036 0037 KWaylandServer::SurfaceInterface *surface() const; 0038 0039 private Q_SLOTS: 0040 void handleSurfaceToBufferMatrixChanged(); 0041 void handleSurfaceCommitted(); 0042 void handleSurfaceSizeChanged(); 0043 0044 void handleChildSubSurfaceRemoved(KWaylandServer::SubSurfaceInterface *child); 0045 void handleChildSubSurfacesChanged(); 0046 void handleSubSurfacePositionChanged(); 0047 void handleSubSurfaceMappedChanged(); 0048 0049 protected: 0050 std::unique_ptr<SurfacePixmap> createPixmap() override; 0051 0052 private: 0053 SurfaceItemWayland *getOrCreateSubSurfaceItem(KWaylandServer::SubSurfaceInterface *s); 0054 0055 QPointer<KWaylandServer::SurfaceInterface> m_surface; 0056 QHash<KWaylandServer::SubSurfaceInterface *, SurfaceItemWayland *> m_subsurfaces; 0057 }; 0058 0059 class KWIN_EXPORT SurfacePixmapWayland final : public SurfacePixmap 0060 { 0061 Q_OBJECT 0062 0063 public: 0064 explicit SurfacePixmapWayland(SurfaceItemWayland *item, QObject *parent = nullptr); 0065 ~SurfacePixmapWayland() override; 0066 0067 SurfaceItemWayland *item() const; 0068 KWaylandServer::SurfaceInterface *surface() const; 0069 KWaylandServer::ClientBuffer *buffer() const; 0070 0071 void create() override; 0072 void update() override; 0073 bool isValid() const override; 0074 0075 private: 0076 void setBuffer(KWaylandServer::ClientBuffer *buffer); 0077 0078 SurfaceItemWayland *m_item; 0079 KWaylandServer::ClientBuffer *m_buffer = nullptr; 0080 }; 0081 0082 /** 0083 * The SurfaceItemXwayland class represents an Xwayland surface in the scene. 0084 */ 0085 class KWIN_EXPORT SurfaceItemXwayland : public SurfaceItemWayland 0086 { 0087 Q_OBJECT 0088 0089 public: 0090 explicit SurfaceItemXwayland(Window *window, Scene *scene, Item *parent = nullptr); 0091 0092 QVector<QRectF> shape() const override; 0093 0094 private: 0095 void handleWindowClosed(Window *original, Deleted *deleted); 0096 0097 Window *m_window; 0098 }; 0099 0100 } // namespace KWin