File indexing completed on 2024-02-18 16:19:56

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "window.h"
0013 
0014 namespace KWin
0015 {
0016 
0017 class KWIN_EXPORT Deleted : public Window
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     static Deleted *create(Window *c);
0023     // used by effects to keep the window around for e.g. fadeout effects when it's destroyed
0024     void refWindow();
0025     void unrefWindow();
0026     void discard();
0027     QMargins frameMargins() const override;
0028     int desktop() const override;
0029     QStringList activities() const override;
0030     QVector<VirtualDesktop *> desktops() const override;
0031     QPointF clientPos() const override;
0032     bool isDeleted() const override;
0033     xcb_window_t frameId() const override;
0034     void layoutDecorationRects(QRectF &left, QRectF &top, QRectF &right, QRectF &bottom) const override;
0035     Layer layer() const override
0036     {
0037         return m_layer;
0038     }
0039     bool isShade() const override
0040     {
0041         return m_shade;
0042     }
0043     bool isMinimized() const
0044     {
0045         return m_minimized;
0046     }
0047     bool isModal() const
0048     {
0049         return m_modal;
0050     }
0051     QList<Window *> mainWindows() const override
0052     {
0053         return m_mainWindows;
0054     }
0055     NET::WindowType windowType(bool direct = false, int supported_types = 0) const override;
0056     bool wasClient() const
0057     {
0058         return m_wasClient;
0059     }
0060     QString windowRole() const override;
0061 
0062     bool isFullScreen() const override
0063     {
0064         return m_fullscreen;
0065     }
0066 
0067     bool keepAbove() const
0068     {
0069         return m_keepAbove;
0070     }
0071     bool keepBelow() const
0072     {
0073         return m_keepBelow;
0074     }
0075 
0076     QString caption() const
0077     {
0078         return m_caption;
0079     }
0080 
0081     QString captionNormal() const override { return m_caption; }
0082     QString captionSuffix() const override { return {}; }
0083     bool isCloseable() const override { return false; }
0084     bool isShown() const override { return false; }
0085     bool isHiddenInternal() const override { return false; }
0086     void hideClient() override { /* nothing to do */ }
0087     void showClient() override { /* nothing to do */ }
0088     Window *findModal(bool /*allow_itself*/) override { return nullptr; }
0089     bool isResizable() const override { return false; }
0090     bool isMovable() const override { return false; }
0091     bool isMovableAcrossScreens() const override { return false; }
0092     bool takeFocus() override { return false; }
0093     bool wantsInput() const override { return false; }
0094     void killWindow() override { /* nothing to do */ }
0095     void destroyWindow() override { /* nothing to do */ }
0096     void closeWindow() override { /* nothing to do */ }
0097     bool acceptsFocus() const override { return false; }
0098     bool belongsToSameApplication(const Window *other, SameApplicationChecks /*checks*/) const override { return other == this; }
0099     void moveResizeInternal(const QRectF & /*rect*/, KWin::Window::MoveResizeMode /*mode*/) override
0100     { /* nothing to do */
0101     }
0102     void updateCaption() override { /* nothing to do */ }
0103     QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &) override
0104     { /* nothing to do */
0105         return geometry;
0106     }
0107     std::unique_ptr<WindowItem> createItem(Scene *scene) override;
0108 
0109     /**
0110      * Returns whether the client was a popup.
0111      *
0112      * @returns @c true if the client was a popup, @c false otherwise.
0113      */
0114     bool isPopupWindow() const override
0115     {
0116         return m_wasPopupWindow;
0117     }
0118 
0119     QVector<uint> x11DesktopIds() const;
0120 
0121     /**
0122      * Whether this Deleted represents the outline.
0123      */
0124     bool isOutline() const override
0125     {
0126         return m_wasOutline;
0127     }
0128     bool isLockScreen() const override
0129     {
0130         return m_wasLockScreen;
0131     }
0132 
0133 private Q_SLOTS:
0134     void mainWindowClosed(KWin::Window *window);
0135 
0136 private:
0137     Deleted(); // use create()
0138     void copyToDeleted(Window *c);
0139     ~Deleted() override; // deleted only using unrefWindow()
0140 
0141     QMargins m_frameMargins;
0142 
0143     int delete_refcount;
0144     int desk;
0145     QStringList activityList;
0146     QRectF contentsRect; // for clientPos()/clientSize()
0147     xcb_window_t m_frame;
0148     QVector<VirtualDesktop *> m_desktops;
0149 
0150     QRectF decoration_left;
0151     QRectF decoration_right;
0152     QRectF decoration_top;
0153     QRectF decoration_bottom;
0154     Layer m_layer;
0155     bool m_shade;
0156     bool m_minimized;
0157     bool m_modal;
0158     QList<Window *> m_mainWindows;
0159     bool m_wasClient;
0160     NET::WindowType m_type = NET::Unknown;
0161     QString m_windowRole;
0162     bool m_fullscreen;
0163     bool m_keepAbove;
0164     bool m_keepBelow;
0165     QString m_caption;
0166     bool m_wasPopupWindow;
0167     bool m_wasOutline;
0168     bool m_wasLockScreen;
0169 };
0170 
0171 inline void Deleted::refWindow()
0172 {
0173     ++delete_refcount;
0174 }
0175 
0176 } // namespace
0177 
0178 Q_DECLARE_METATYPE(KWin::Deleted *)