File indexing completed on 2025-04-20 10:58: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 <xcb/damage.h> 0012 #include <xcb/xfixes.h> 0013 0014 namespace KWin 0015 { 0016 0017 class Deleted; 0018 0019 /** 0020 * The SurfaceItemX11 class represents an X11 surface in the scene. 0021 */ 0022 class KWIN_EXPORT SurfaceItemX11 : public SurfaceItem 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit SurfaceItemX11(Window *window, Scene *scene, Item *parent = nullptr); 0028 ~SurfaceItemX11() override; 0029 0030 Window *window() const; 0031 0032 void preprocess() override; 0033 0034 void processDamage(); 0035 bool fetchDamage(); 0036 void waitForDamage(); 0037 void destroyDamage(); 0038 0039 QVector<QRectF> shape() const override; 0040 QRegion opaque() const override; 0041 0042 private Q_SLOTS: 0043 void handleBufferGeometryChanged(Window *window, const QRectF &old); 0044 void handleGeometryShapeChanged(); 0045 void handleWindowClosed(Window *original, Deleted *deleted); 0046 0047 protected: 0048 std::unique_ptr<SurfacePixmap> createPixmap() override; 0049 0050 private: 0051 Window *m_window; 0052 xcb_damage_damage_t m_damageHandle = XCB_NONE; 0053 xcb_xfixes_fetch_region_cookie_t m_damageCookie; 0054 bool m_isDamaged = false; 0055 bool m_havePendingDamageRegion = false; 0056 }; 0057 0058 class KWIN_EXPORT SurfacePixmapX11 final : public SurfacePixmap 0059 { 0060 Q_OBJECT 0061 0062 public: 0063 explicit SurfacePixmapX11(SurfaceItemX11 *item, QObject *parent = nullptr); 0064 ~SurfacePixmapX11() override; 0065 0066 xcb_pixmap_t pixmap() const; 0067 xcb_visualid_t visual() const; 0068 0069 void create() override; 0070 bool isValid() const override; 0071 0072 private: 0073 SurfaceItemX11 *m_item; 0074 xcb_pixmap_t m_pixmap = XCB_PIXMAP_NONE; 0075 }; 0076 0077 } // namespace KWaylandServer