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