File indexing completed on 2024-05-19 05:32:21

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 #include <unordered_map>
0012 
0013 namespace KWin
0014 {
0015 
0016 class GraphicsBuffer;
0017 class SubSurfaceInterface;
0018 class SurfaceInterface;
0019 class X11Window;
0020 
0021 /**
0022  * The SurfaceItemWayland class represents a Wayland surface in the scene.
0023  */
0024 class KWIN_EXPORT SurfaceItemWayland : public SurfaceItem
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     explicit SurfaceItemWayland(SurfaceInterface *surface, Scene *scene, Item *parent = nullptr);
0030 
0031     QList<QRectF> shape() const override;
0032     QRegion opaque() const override;
0033     ContentType contentType() const override;
0034     void freeze() override;
0035 
0036     SurfaceInterface *surface() const;
0037 
0038 private Q_SLOTS:
0039     void handleSurfaceCommitted();
0040     void handleSurfaceSizeChanged();
0041     void handleBufferSizeChanged();
0042     void handleBufferSourceBoxChanged();
0043     void handleBufferTransformChanged();
0044 
0045     void handleChildSubSurfaceRemoved(SubSurfaceInterface *child);
0046     void handleChildSubSurfacesChanged();
0047     void handleSubSurfacePositionChanged();
0048     void handleSubSurfaceMappedChanged();
0049     void handleColorDescriptionChanged();
0050     void handlePresentationModeHintChanged();
0051 
0052 protected:
0053     std::unique_ptr<SurfacePixmap> createPixmap() override;
0054 
0055 private:
0056     SurfaceItemWayland *getOrCreateSubSurfaceItem(SubSurfaceInterface *s);
0057 
0058     QPointer<SurfaceInterface> m_surface;
0059     std::unordered_map<SubSurfaceInterface *, std::unique_ptr<SurfaceItemWayland>> m_subsurfaces;
0060 };
0061 
0062 class KWIN_EXPORT SurfacePixmapWayland final : public SurfacePixmap
0063 {
0064     Q_OBJECT
0065 
0066 public:
0067     explicit SurfacePixmapWayland(SurfaceItemWayland *item, QObject *parent = nullptr);
0068 
0069     void create() override;
0070     void update() override;
0071     bool isValid() const override;
0072 
0073 private:
0074     SurfaceItemWayland *m_item;
0075 };
0076 
0077 /**
0078  * The SurfaceItemXwayland class represents an Xwayland surface in the scene.
0079  */
0080 class KWIN_EXPORT SurfaceItemXwayland : public SurfaceItemWayland
0081 {
0082     Q_OBJECT
0083 
0084 public:
0085     explicit SurfaceItemXwayland(X11Window *window, Scene *scene, Item *parent = nullptr);
0086 
0087     QRegion opaque() const override;
0088     QList<QRectF> shape() const override;
0089 
0090 private:
0091     X11Window *m_window;
0092 };
0093 
0094 } // namespace KWin