File indexing completed on 2025-03-23 11:14:10
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/item.h" 0010 0011 namespace KDecoration2 0012 { 0013 class Decoration; 0014 } 0015 0016 namespace KWin 0017 { 0018 class Window; 0019 class DecorationItem; 0020 class Deleted; 0021 class InternalWindow; 0022 class Shadow; 0023 class ShadowItem; 0024 class SurfaceItem; 0025 0026 /** 0027 * The WindowItem class represents a window in the scene. 0028 * 0029 * A WindowItem is made of a surface with client contents and optionally a server-side frame 0030 * and a drop-shadow. 0031 */ 0032 class KWIN_EXPORT WindowItem : public Item 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 enum { 0038 PAINT_DISABLED_BY_HIDDEN = 1 << 0, 0039 PAINT_DISABLED_BY_DELETE = 1 << 1, 0040 PAINT_DISABLED_BY_DESKTOP = 1 << 2, 0041 PAINT_DISABLED_BY_MINIMIZE = 1 << 3, 0042 PAINT_DISABLED_BY_ACTIVITY = 1 << 5 0043 }; 0044 0045 ~WindowItem() override; 0046 0047 SurfaceItem *surfaceItem() const; 0048 DecorationItem *decorationItem() const; 0049 ShadowItem *shadowItem() const; 0050 Window *window() const; 0051 0052 void refVisible(int reason); 0053 void unrefVisible(int reason); 0054 0055 protected: 0056 explicit WindowItem(Window *window, Scene *scene, Item *parent = nullptr); 0057 void updateSurfaceItem(SurfaceItem *surfaceItem); 0058 0059 private Q_SLOTS: 0060 void handleWindowClosed(Window *original, Deleted *deleted); 0061 void updateDecorationItem(); 0062 void updateShadowItem(); 0063 void updateSurfacePosition(); 0064 void updateSurfaceVisibility(); 0065 void updatePosition(); 0066 void updateOpacity(); 0067 void addSurfaceItemDamageConnects(Item *item); 0068 0069 private: 0070 bool computeVisibility() const; 0071 void updateVisibility(); 0072 void markDamaged(); 0073 0074 Window *m_window; 0075 std::unique_ptr<SurfaceItem> m_surfaceItem; 0076 std::unique_ptr<DecorationItem> m_decorationItem; 0077 std::unique_ptr<ShadowItem> m_shadowItem; 0078 int m_forceVisibleByHiddenCount = 0; 0079 int m_forceVisibleByDeleteCount = 0; 0080 int m_forceVisibleByDesktopCount = 0; 0081 int m_forceVisibleByMinimizeCount = 0; 0082 int m_forceVisibleByActivityCount = 0; 0083 }; 0084 0085 /** 0086 * The WindowItemX11 class represents an X11 window (both on X11 and Wayland sessions). 0087 * 0088 * Note that Xwayland windows and Wayland surfaces are associated asynchronously. This means 0089 * that the surfaceItem() function can return @c null until the window is fully initialized. 0090 */ 0091 class KWIN_EXPORT WindowItemX11 : public WindowItem 0092 { 0093 Q_OBJECT 0094 0095 public: 0096 explicit WindowItemX11(Window *window, Scene *scene, Item *parent = nullptr); 0097 0098 private Q_SLOTS: 0099 void initialize(); 0100 }; 0101 0102 /** 0103 * The WindowItemWayland class represents a Wayland window. 0104 */ 0105 class KWIN_EXPORT WindowItemWayland : public WindowItem 0106 { 0107 Q_OBJECT 0108 0109 public: 0110 explicit WindowItemWayland(Window *window, Scene *scene, Item *parent = nullptr); 0111 }; 0112 0113 /** 0114 * The WindowItemInternal class represents a window created by the compositor, for 0115 * example, the task switcher, etc. 0116 */ 0117 class KWIN_EXPORT WindowItemInternal : public WindowItem 0118 { 0119 Q_OBJECT 0120 0121 public: 0122 explicit WindowItemInternal(InternalWindow *window, Scene *scene, Item *parent = nullptr); 0123 }; 0124 0125 } // namespace KWin