File indexing completed on 2024-04-28 16:49:09

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
0006     SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 #pragma once
0011 
0012 #include "cursor.h"
0013 #include "options.h"
0014 #include "rules.h"
0015 #include "utils/common.h"
0016 #include "utils/xcbutils.h"
0017 
0018 #include <functional>
0019 #include <memory>
0020 
0021 #include <NETWM>
0022 
0023 #include <QElapsedTimer>
0024 #include <QIcon>
0025 #include <QKeySequence>
0026 #include <QMatrix4x4>
0027 #include <QObject>
0028 #include <QPointer>
0029 #include <QRectF>
0030 #include <QTimer>
0031 #include <QUuid>
0032 
0033 class QMouseEvent;
0034 class QOpenGLFramebufferObject;
0035 
0036 namespace KWaylandServer
0037 {
0038 class PlasmaWindowInterface;
0039 class SurfaceInterface;
0040 }
0041 
0042 namespace KDecoration2
0043 {
0044 class Decoration;
0045 }
0046 
0047 namespace KWin
0048 {
0049 class Group;
0050 class Output;
0051 class ClientMachine;
0052 class Deleted;
0053 class EffectWindowImpl;
0054 class Tile;
0055 class Scene;
0056 class Shadow;
0057 class SurfaceItem;
0058 class VirtualDesktop;
0059 class WindowItem;
0060 
0061 /**
0062  * Enum to describe the reason why a Window has to be released.
0063  */
0064 enum class ReleaseReason {
0065     Release, ///< Normal Release after e.g. an Unmap notify event (window still valid)
0066     Destroyed, ///< Release after an Destroy notify event (window no longer valid)
0067     KWinShutsDown ///< Release on KWin Shutdown (window still valid)
0068 };
0069 
0070 namespace TabBox
0071 {
0072 class TabBoxClientImpl;
0073 }
0074 
0075 namespace Decoration
0076 {
0077 class DecoratedClientImpl;
0078 class DecorationPalette;
0079 }
0080 
0081 class KWIN_EXPORT Window : public QObject
0082 {
0083     Q_OBJECT
0084 
0085     /**
0086      * This property holds rectangle that the pixmap or buffer of this Window
0087      * occupies on the screen. This rectangle includes invisible portions of the
0088      * window, e.g. client-side drop shadows, etc.
0089      */
0090     Q_PROPERTY(QRectF bufferGeometry READ bufferGeometry)
0091 
0092     /**
0093      * This property holds the position of the Window's frame geometry.
0094      */
0095     Q_PROPERTY(QPointF pos READ pos)
0096 
0097     /**
0098      * This property holds the size of the Window's frame geometry.
0099      */
0100     Q_PROPERTY(QSizeF size READ size)
0101 
0102     /**
0103      * This property holds the x position of the Window's frame geometry.
0104      */
0105     Q_PROPERTY(qreal x READ x NOTIFY frameGeometryChanged)
0106 
0107     /**
0108      * This property holds the y position of the Window's frame geometry.
0109      */
0110     Q_PROPERTY(qreal y READ y NOTIFY frameGeometryChanged)
0111 
0112     /**
0113      * This property holds the width of the Window's frame geometry.
0114      */
0115     Q_PROPERTY(qreal width READ width NOTIFY frameGeometryChanged)
0116 
0117     /**
0118      * This property holds the height of the Window's frame geometry.
0119      */
0120     Q_PROPERTY(qreal height READ height NOTIFY frameGeometryChanged)
0121 
0122     Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
0123 
0124     /**
0125      * The screen where the window center is on
0126      */
0127     Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
0128 
0129     /**
0130      * The output (screen) where the window center is on
0131      */
0132     Q_PROPERTY(KWin::Output *output READ output NOTIFY screenChanged)
0133 
0134     Q_PROPERTY(QRectF rect READ rect)
0135     Q_PROPERTY(QString resourceName READ resourceName NOTIFY windowClassChanged)
0136     Q_PROPERTY(QString resourceClass READ resourceClass NOTIFY windowClassChanged)
0137     Q_PROPERTY(QString windowRole READ windowRole NOTIFY windowRoleChanged)
0138 
0139     /**
0140      * Returns whether the window is a desktop background window (the one with wallpaper).
0141      * See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0142      */
0143     Q_PROPERTY(bool desktopWindow READ isDesktop CONSTANT)
0144 
0145     /**
0146      * Returns whether the window is a dock (i.e. a panel).
0147      * See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0148      */
0149     Q_PROPERTY(bool dock READ isDock CONSTANT)
0150 
0151     /**
0152      * Returns whether the window is a standalone (detached) toolbar window.
0153      * See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0154      */
0155     Q_PROPERTY(bool toolbar READ isToolbar CONSTANT)
0156 
0157     /**
0158      * Returns whether the window is a torn-off menu.
0159      * See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0160      */
0161     Q_PROPERTY(bool menu READ isMenu CONSTANT)
0162 
0163     /**
0164      * Returns whether the window is a "normal" window, i.e. an application or any other window
0165      * for which none of the specialized window types fit.
0166      * See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0167      */
0168     Q_PROPERTY(bool normalWindow READ isNormalWindow CONSTANT)
0169 
0170     /**
0171      * Returns whether the window is a dialog window.
0172      * See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0173      */
0174     Q_PROPERTY(bool dialog READ isDialog CONSTANT)
0175 
0176     /**
0177      * Returns whether the window is a splashscreen. Note that many (especially older) applications
0178      * do not support marking their splash windows with this type.
0179      * See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0180      */
0181     Q_PROPERTY(bool splash READ isSplash CONSTANT)
0182 
0183     /**
0184      * Returns whether the window is a utility window, such as a tool window.
0185      * See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0186      */
0187     Q_PROPERTY(bool utility READ isUtility CONSTANT)
0188 
0189     /**
0190      * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open
0191      * from the applications menubar).
0192      * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0193      */
0194     Q_PROPERTY(bool dropdownMenu READ isDropdownMenu CONSTANT)
0195 
0196     /**
0197      * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu).
0198      * See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0199      */
0200     Q_PROPERTY(bool popupMenu READ isPopupMenu CONSTANT)
0201 
0202     /**
0203      * Returns whether the window is a tooltip.
0204      * See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0205      */
0206     Q_PROPERTY(bool tooltip READ isTooltip CONSTANT)
0207 
0208     /**
0209      * Returns whether the window is a window with a notification.
0210      * See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0211      */
0212     Q_PROPERTY(bool notification READ isNotification CONSTANT)
0213 
0214     /**
0215      * Returns whether the window is a window with a critical notification.
0216      */
0217     Q_PROPERTY(bool criticalNotification READ isCriticalNotification CONSTANT)
0218 
0219     /**
0220      * Returns whether the window is an applet popup.
0221      */
0222     Q_PROPERTY(bool appletPopup READ isAppletPopup CONSTANT)
0223 
0224     /**
0225      * Returns whether the window is an On Screen Display.
0226      */
0227     Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay CONSTANT)
0228 
0229     /**
0230      * Returns whether the window is a combobox popup.
0231      * See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0232      */
0233     Q_PROPERTY(bool comboBox READ isComboBox CONSTANT)
0234 
0235     /**
0236      * Returns whether the window is a Drag&Drop icon.
0237      * See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0238      */
0239     Q_PROPERTY(bool dndIcon READ isDNDIcon CONSTANT)
0240 
0241     /**
0242      * Returns the NETWM window type
0243      * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0244      */
0245     Q_PROPERTY(int windowType READ windowType CONSTANT)
0246 
0247     /**
0248      * Whether this Window is managed by KWin (it has control over its placement and other
0249      * aspects, as opposed to override-redirect windows that are entirely handled by the application).
0250      */
0251     Q_PROPERTY(bool managed READ isClient CONSTANT)
0252 
0253     /**
0254      * Whether this Window represents an already deleted window and only kept for the compositor for animations.
0255      */
0256     Q_PROPERTY(bool deleted READ isDeleted CONSTANT)
0257 
0258     /**
0259      * Whether the window has an own shape
0260      */
0261     Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged)
0262 
0263     /**
0264      * Whether the window does not want to be animated on window close.
0265      * There are legit reasons for this like a screenshot application which does not want it's
0266      * window being captured.
0267      */
0268     Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation WRITE setSkipCloseAnimation NOTIFY skipCloseAnimationChanged)
0269 
0270     /**
0271      * Whether the window is a popup.
0272      */
0273     Q_PROPERTY(bool popupWindow READ isPopupWindow)
0274 
0275     /**
0276      * Whether this Window represents the outline.
0277      *
0278      * @note It's always @c false if compositing is turned off.
0279      */
0280     Q_PROPERTY(bool outline READ isOutline)
0281 
0282     /**
0283      * This property holds a UUID to uniquely identify this Window.
0284      */
0285     Q_PROPERTY(QUuid internalId READ internalId CONSTANT)
0286 
0287     /**
0288      * The pid of the process owning this window.
0289      *
0290      * @since 5.20
0291      */
0292     Q_PROPERTY(int pid READ pid CONSTANT)
0293 
0294     /**
0295      * The position of this window within Workspace's window stack.
0296      */
0297     Q_PROPERTY(int stackingOrder READ stackingOrder NOTIFY stackingOrderChanged)
0298 
0299     /**
0300      * Whether this Window is fullScreen. A Window might either be fullScreen due to the _NET_WM property
0301      * or through a legacy support hack. The fullScreen state can only be changed if the Window does not
0302      * use the legacy hack. To be sure whether the state changed, connect to the notify signal.
0303      */
0304     Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
0305 
0306     /**
0307      * Whether the Window can be set to fullScreen. The property is evaluated each time it is invoked.
0308      * Because of that there is no notify signal.
0309      */
0310     Q_PROPERTY(bool fullScreenable READ isFullScreenable)
0311 
0312     /**
0313      * Whether this Window is active or not. Use Workspace::activateWindow() to activate a Window.
0314      * @see Workspace::activateWindow
0315      */
0316     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
0317 
0318     /**
0319      * The desktop this Window is on. If the Window is on all desktops the property has value -1.
0320      * This is a legacy property, use x11DesktopIds instead
0321      *
0322      * @deprecated Use the desktops property instead.
0323      */
0324     Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
0325 
0326     /**
0327      * The virtual desktops this client is on. If it's on all desktops, the list is empty.
0328      */
0329     Q_PROPERTY(QVector<KWin::VirtualDesktop *> desktops READ desktops WRITE setDesktops NOTIFY desktopChanged)
0330 
0331     /**
0332      * Whether the Window is on all desktops. That is desktop is -1.
0333      */
0334     Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops WRITE setOnAllDesktops NOTIFY desktopChanged)
0335 
0336     /**
0337      * The activities this client is on. If it's on all activities the property is empty.
0338      */
0339     Q_PROPERTY(QStringList activities READ activities WRITE setOnActivities NOTIFY activitiesChanged)
0340 
0341     /**
0342      * The x11 ids for all desktops this client is in. On X11 this list will always have a length of 1
0343      *
0344      * @deprecated prefer using apis that use VirtualDesktop objects
0345      */
0346     Q_PROPERTY(QVector<uint> x11DesktopIds READ x11DesktopIds NOTIFY x11DesktopIdsChanged)
0347 
0348     /**
0349      * Indicates that the window should not be included on a taskbar.
0350      */
0351     Q_PROPERTY(bool skipTaskbar READ skipTaskbar WRITE setSkipTaskbar NOTIFY skipTaskbarChanged)
0352 
0353     /**
0354      * Indicates that the window should not be included on a Pager.
0355      */
0356     Q_PROPERTY(bool skipPager READ skipPager WRITE setSkipPager NOTIFY skipPagerChanged)
0357 
0358     /**
0359      * Whether the Window should be excluded from window switching effects.
0360      */
0361     Q_PROPERTY(bool skipSwitcher READ skipSwitcher WRITE setSkipSwitcher NOTIFY skipSwitcherChanged)
0362 
0363     /**
0364      * Whether the window can be closed by the user.
0365      */
0366     Q_PROPERTY(bool closeable READ isCloseable NOTIFY closeableChanged)
0367 
0368     Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
0369 
0370     /**
0371      * Whether the Window is set to be kept above other windows.
0372      */
0373     Q_PROPERTY(bool keepAbove READ keepAbove WRITE setKeepAbove NOTIFY keepAboveChanged)
0374 
0375     /**
0376      * Whether the Window is set to be kept below other windows.
0377      */
0378     Q_PROPERTY(bool keepBelow READ keepBelow WRITE setKeepBelow NOTIFY keepBelowChanged)
0379 
0380     /**
0381      * Whether the Window can be shaded. The property is evaluated each time it is invoked.
0382      * Because of that there is no notify signal.
0383      */
0384     Q_PROPERTY(bool shadeable READ isShadeable NOTIFY shadeableChanged)
0385 
0386     /**
0387      * Whether the Window is shaded.
0388      */
0389     Q_PROPERTY(bool shade READ isShade WRITE setShade NOTIFY shadeChanged)
0390 
0391     /**
0392      * Whether the Window can be minimized. The property is evaluated each time it is invoked.
0393      * Because of that there is no notify signal.
0394      */
0395     Q_PROPERTY(bool minimizable READ isMinimizable)
0396 
0397     /**
0398      * Whether the Window is minimized.
0399      */
0400     Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged)
0401 
0402     /**
0403      * The optional geometry representing the minimized Window in e.g a taskbar.
0404      * See _NET_WM_ICON_GEOMETRY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
0405      * The value is evaluated each time the getter is called.
0406      * Because of that no changed signal is provided.
0407      */
0408     Q_PROPERTY(QRectF iconGeometry READ iconGeometry)
0409 
0410     /**
0411      * Returns whether the window is any of special windows types (desktop, dock, splash, ...),
0412      * i.e. window types that usually don't have a window frame and the user does not use window
0413      * management (moving, raising,...) on them.
0414      * The value is evaluated each time the getter is called.
0415      * Because of that no changed signal is provided.
0416      */
0417     Q_PROPERTY(bool specialWindow READ isSpecialWindow)
0418 
0419     /**
0420      * Whether window state _NET_WM_STATE_DEMANDS_ATTENTION is set. This state indicates that some
0421      * action in or with the window happened. For example, it may be set by the Window Manager if
0422      * the window requested activation but the Window Manager refused it, or the application may set
0423      * it if it finished some work. This state may be set by both the Window and the Window Manager.
0424      * It should be unset by the Window Manager when it decides the window got the required attention
0425      * (usually, that it got activated).
0426      */
0427     Q_PROPERTY(bool demandsAttention READ isDemandingAttention WRITE demandAttention NOTIFY demandsAttentionChanged)
0428 
0429     /**
0430      * The Caption of the Window. Read from WM_NAME property together with a suffix for hostname and shortcut.
0431      * To read only the caption as provided by WM_NAME, use the getter with an additional @c false value.
0432      */
0433     Q_PROPERTY(QString caption READ caption NOTIFY captionChanged)
0434 
0435     /**
0436      * Minimum size as specified in WM_NORMAL_HINTS
0437      */
0438     Q_PROPERTY(QSizeF minSize READ minSize)
0439 
0440     /**
0441      * Maximum size as specified in WM_NORMAL_HINTS
0442      */
0443     Q_PROPERTY(QSizeF maxSize READ maxSize)
0444 
0445     /**
0446      * Whether the Window can accept keyboard focus.
0447      * The value is evaluated each time the getter is called.
0448      * Because of that no changed signal is provided.
0449      */
0450     Q_PROPERTY(bool wantsInput READ wantsInput)
0451 
0452     /**
0453      * Whether the Window is a transient Window to another Window.
0454      * @see transientFor
0455      */
0456     Q_PROPERTY(bool transient READ isTransient NOTIFY transientChanged)
0457 
0458     /**
0459      * The Window to which this Window is a transient if any.
0460      */
0461     Q_PROPERTY(KWin::Window *transientFor READ transientFor NOTIFY transientChanged)
0462 
0463     /**
0464      * Whether the Window represents a modal window.
0465      */
0466     Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged)
0467 
0468     /**
0469      * The geometry of this Window. Be aware that depending on resize mode the frameGeometryChanged
0470      * signal might be emitted at each resize step or only at the end of the resize operation.
0471      *
0472      * @deprecated Use frameGeometry
0473      */
0474     Q_PROPERTY(QRectF geometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)
0475 
0476     /**
0477      * The geometry of this Window. Be aware that depending on resize mode the frameGeometryChanged
0478      * signal might be emitted at each resize step or only at the end of the resize operation.
0479      */
0480     Q_PROPERTY(QRectF frameGeometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)
0481 
0482     /**
0483      * Whether the Window is currently being moved by the user.
0484      * Notify signal is emitted when the Window starts or ends move/resize mode.
0485      */
0486     Q_PROPERTY(bool move READ isInteractiveMove NOTIFY moveResizedChanged)
0487 
0488     /**
0489      * Whether the Window is currently being resized by the user.
0490      * Notify signal is emitted when the Window starts or ends move/resize mode.
0491      */
0492     Q_PROPERTY(bool resize READ isInteractiveResize NOTIFY moveResizedChanged)
0493 
0494     /**
0495      * Whether the decoration is currently using an alpha channel.
0496      */
0497     Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
0498 
0499     /**
0500      * Whether the window has a decoration or not.
0501      * This property is not allowed to be set by applications themselves.
0502      * The decision whether a window has a border or not belongs to the window manager.
0503      * If this property gets abused by application developers, it will be removed again.
0504      */
0505     Q_PROPERTY(bool noBorder READ noBorder WRITE setNoBorder)
0506 
0507     /**
0508      * Whether the Window provides context help. Mostly needed by decorations to decide whether to
0509      * show the help button or not.
0510      */
0511     Q_PROPERTY(bool providesContextHelp READ providesContextHelp CONSTANT)
0512 
0513     /**
0514      * Whether the Window can be maximized both horizontally and vertically.
0515      * The property is evaluated each time it is invoked.
0516      * Because of that there is no notify signal.
0517      */
0518     Q_PROPERTY(bool maximizable READ isMaximizable)
0519 
0520     /**
0521      * Whether the Window is moveable. Even if it is not moveable, it might be possible to move
0522      * it to another screen. The property is evaluated each time it is invoked.
0523      * Because of that there is no notify signal.
0524      * @see moveableAcrossScreens
0525      */
0526     Q_PROPERTY(bool moveable READ isMovable)
0527 
0528     /**
0529      * Whether the Window can be moved to another screen. The property is evaluated each time it is invoked.
0530      * Because of that there is no notify signal.
0531      * @see moveable
0532      */
0533     Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens)
0534 
0535     /**
0536      * Whether the Window can be resized. The property is evaluated each time it is invoked.
0537      * Because of that there is no notify signal.
0538      */
0539     Q_PROPERTY(bool resizeable READ isResizable)
0540 
0541     /**
0542      * The desktop file name of the application this Window belongs to.
0543      *
0544      * This is either the base name without full path and without file extension of the
0545      * desktop file for the window's application (e.g. "org.kde.foo").
0546      *
0547      * The application's desktop file name can also be the full path to the desktop file
0548      * (e.g. "/opt/kde/share/org.kde.foo.desktop") in case it's not in a standard location.
0549      */
0550     Q_PROPERTY(QString desktopFileName READ desktopFileName NOTIFY desktopFileNameChanged)
0551 
0552     /**
0553      * Whether an application menu is available for this Window
0554      */
0555     Q_PROPERTY(bool hasApplicationMenu READ hasApplicationMenu NOTIFY hasApplicationMenuChanged)
0556 
0557     /**
0558      * Whether the application menu for this Window is currently opened
0559      */
0560     Q_PROPERTY(bool applicationMenuActive READ applicationMenuActive NOTIFY applicationMenuActiveChanged)
0561 
0562     /**
0563      * Whether this window is unresponsive.
0564      *
0565      * When an application failed to react on a ping request in time, it is
0566      * considered unresponsive. This usually indicates that the application froze or crashed.
0567      */
0568     Q_PROPERTY(bool unresponsive READ unresponsive NOTIFY unresponsiveChanged)
0569 
0570     /**
0571      * The color scheme set on this window
0572      * Absolute file path, or name of palette in the user's config directory following KColorSchemes format.
0573      * An empty string indicates the default palette from kdeglobals is used.
0574      * @note this indicates the colour scheme requested, which might differ from the theme applied if the colorScheme cannot be found
0575      */
0576     Q_PROPERTY(QString colorScheme READ colorScheme NOTIFY colorSchemeChanged)
0577 
0578     Q_PROPERTY(KWin::Layer layer READ layer)
0579 
0580     /**
0581      * Whether this window is hidden. It's usually the case with auto-hide panels.
0582      */
0583     Q_PROPERTY(bool hidden READ isHiddenInternal NOTIFY hiddenChanged)
0584 
0585     /**
0586      * The Tile this window is associated to, if any
0587      */
0588     Q_PROPERTY(KWin::Tile *tile READ tile WRITE setTile NOTIFY tileChanged)
0589 
0590 public:
0591     ~Window() override;
0592 
0593     virtual xcb_window_t frameId() const;
0594     xcb_window_t window() const;
0595     /**
0596      * Returns the geometry of the pixmap or buffer attached to this Window.
0597      *
0598      * For X11 windows, this method returns server-side geometry of the Window.
0599      *
0600      * For Wayland windows, this method returns rectangle that the main surface
0601      * occupies on the screen, in global screen coordinates.
0602      */
0603     QRectF bufferGeometry() const;
0604     /**
0605      * Returns the geometry of the Window, excluding invisible portions, e.g.
0606      * server-side and client-side drop shadows, etc.
0607      */
0608     QRectF frameGeometry() const;
0609     /**
0610      * Returns the geometry of the client window, in global screen coordinates.
0611      */
0612     QRectF clientGeometry() const;
0613     /**
0614      * Returns the extents of the server-side decoration.
0615      *
0616      * Note that the returned margins object will have all margins set to 0 if
0617      * the window doesn't have a server-side decoration.
0618      *
0619      * Default implementation returns a margins object with all margins set to 0.
0620      */
0621     virtual QMargins frameMargins() const;
0622     /**
0623      * The geometry of the Window which accepts input events. This might be larger
0624      * than the actual geometry, e.g. to support resizing outside the window.
0625      *
0626      * Default implementation returns same as geometry.
0627      */
0628     virtual QRectF inputGeometry() const;
0629     QSizeF size() const;
0630     QPointF pos() const;
0631     QRectF rect() const;
0632     qreal x() const;
0633     qreal y() const;
0634     qreal width() const;
0635     qreal height() const;
0636     bool isOnOutput(Output *output) const;
0637     bool isOnActiveOutput() const;
0638     int screen() const;
0639     Output *output() const;
0640     void setOutput(Output *output);
0641     virtual QPointF clientPos() const
0642     {
0643         return QPointF(borderLeft(), borderTop());
0644     }; // inside of geometry()
0645     QSizeF clientSize() const;
0646     /**
0647      * Returns a rectangle that the window occupies on the screen, including drop-shadows.
0648      */
0649     QRectF visibleGeometry() const;
0650     virtual bool isClient() const;
0651     virtual bool isDeleted() const;
0652     virtual bool isUnmanaged() const;
0653 
0654     /**
0655      * Maps the specified @a point from the global screen coordinates to the frame coordinates.
0656      */
0657     QPointF mapToFrame(const QPointF &point) const;
0658     /**
0659      * Maps the specified @a point from the global screen coordinates to the surface-local
0660      * coordinates of the main surface. For X11 windows, this function maps the specified point
0661      * from the global screen coordinates to the buffer-local coordinates.
0662      */
0663     QPointF mapToLocal(const QPointF &point) const;
0664     QPointF mapFromLocal(const QPointF &point) const;
0665 
0666     // prefer isXXX() instead
0667     // 0 for supported types means default for managed/unmanaged types
0668     virtual NET::WindowType windowType(bool direct = false, int supported_types = 0) const = 0;
0669     bool hasNETSupport() const;
0670     bool isDesktop() const;
0671     bool isDock() const;
0672     bool isToolbar() const;
0673     bool isMenu() const;
0674     bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
0675     bool isDialog() const;
0676     bool isSplash() const;
0677     bool isUtility() const;
0678     bool isDropdownMenu() const;
0679     bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
0680     bool isTooltip() const;
0681     bool isNotification() const;
0682     bool isCriticalNotification() const;
0683     bool isAppletPopup() const;
0684     bool isOnScreenDisplay() const;
0685     bool isComboBox() const;
0686     bool isDNDIcon() const;
0687 
0688     virtual bool isLockScreen() const;
0689     virtual bool isInputMethod() const;
0690     virtual bool isOutline() const;
0691     virtual bool isInternal() const;
0692 
0693     /**
0694      * Returns the virtual desktop within the workspace() the client window
0695      * is located in, 0 if it isn't located on any special desktop (not mapped yet),
0696      * or NET::OnAllDesktops. Do not use desktop() directly, use
0697      * isOnDesktop() instead.
0698      */
0699     virtual int desktop() const;
0700     virtual QVector<VirtualDesktop *> desktops() const;
0701     virtual QStringList activities() const;
0702     bool isOnDesktop(VirtualDesktop *desktop) const;
0703     bool isOnDesktop(int d) const;
0704     bool isOnActivity(const QString &activity) const;
0705     bool isOnCurrentDesktop() const;
0706     bool isOnCurrentActivity() const;
0707     bool isOnAllDesktops() const;
0708     bool isOnAllActivities() const;
0709     bool isLockScreenOverlay() const;
0710 
0711     void setLockScreenOverlay(bool allowed);
0712 
0713     virtual QString windowRole() const;
0714     QByteArray sessionId() const;
0715     QString resourceName() const;
0716     QString resourceClass() const;
0717     QString wmCommand();
0718     QString wmClientMachine(bool use_localhost) const;
0719     const ClientMachine *clientMachine() const;
0720     virtual bool isLocalhost() const;
0721     xcb_window_t wmClientLeader() const;
0722     virtual pid_t pid() const;
0723     static bool resourceMatch(const Window *c1, const Window *c2);
0724 
0725     bool readyForPainting() const; // true if the window has been already painted its contents
0726     xcb_visualid_t visual() const;
0727     bool shape() const;
0728     QRegion inputShape() const;
0729     void setOpacity(qreal opacity);
0730     qreal opacity() const;
0731     int depth() const;
0732     bool hasAlpha() const;
0733     virtual bool setupCompositing();
0734     virtual void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release);
0735     // these call workspace->addRepaint(), but first transform the damage if needed
0736     void addWorkspaceRepaint(const QRectF &r);
0737     void addWorkspaceRepaint(int x, int y, int w, int h);
0738     void addWorkspaceRepaint(const QRegion &region);
0739     EffectWindowImpl *effectWindow();
0740     const EffectWindowImpl *effectWindow() const;
0741     SurfaceItem *surfaceItem() const;
0742     WindowItem *windowItem() const;
0743     /**
0744      * Window will be temporarily painted as if being at the top of the stack.
0745      * Only available if Compositor is active, if not active, this method is a no-op.
0746      */
0747     void elevate(bool elevate);
0748 
0749     /**
0750      * Returns the Shadow associated with this Window or @c null if it has no shadow.
0751      */
0752     Shadow *shadow() const;
0753     /**
0754      * Updates the Shadow associated with this Window from X11 Property.
0755      * Call this method when the Property changes or Compositing is started.
0756      */
0757     void updateShadow();
0758     /**
0759      * Whether the Window currently wants the shadow to be rendered. Default
0760      * implementation always returns @c true.
0761      */
0762     virtual bool wantsShadowToBeRendered() const;
0763 
0764     /**
0765      * This method returns the area that the Window window reports to be opaque.
0766      * It is supposed to only provide valuable information if hasAlpha is @c true .
0767      * @see hasAlpha
0768      */
0769     const QRegion &opaqueRegion() const;
0770     QVector<QRectF> shapeRegion() const;
0771 
0772     bool skipsCloseAnimation() const;
0773     void setSkipCloseAnimation(bool set);
0774 
0775     quint64 surfaceSerial() const;
0776     quint32 pendingSurfaceId() const;
0777     KWaylandServer::SurfaceInterface *surface() const;
0778     void setSurface(KWaylandServer::SurfaceInterface *surface);
0779 
0780     const std::shared_ptr<QOpenGLFramebufferObject> &internalFramebufferObject() const;
0781     QImage internalImageObject() const;
0782 
0783     /**
0784      * @returns Transformation to map from global to window coordinates.
0785      *
0786      * Default implementation returns a translation on negative pos().
0787      * @see pos
0788      */
0789     virtual QMatrix4x4 inputTransformation() const;
0790 
0791     /**
0792      * Returns @c true if the window can accept input at the specified position @a point.
0793      */
0794     virtual bool hitTest(const QPointF &point) const;
0795 
0796     /**
0797      * The window has a popup grab. This means that when it got mapped the
0798      * parent window had an implicit (pointer) grab.
0799      *
0800      * Normally this is only relevant for transient windows.
0801      *
0802      * Once the popup grab ends (e.g. pointer press outside of any Window of
0803      * the client), the method popupDone should be invoked.
0804      *
0805      * The default implementation returns @c false.
0806      * @see popupDone
0807      * @since 5.10
0808      */
0809     virtual bool hasPopupGrab() const
0810     {
0811         return false;
0812     }
0813     /**
0814      * This method should be invoked for windows with a popup grab when
0815      * the grab ends.
0816      *
0817      * The default implementation does nothing.
0818      * @see hasPopupGrab
0819      * @since 5.10
0820      */
0821     virtual void popupDone(){};
0822 
0823     /**
0824      * @brief Finds the Window matching the condition expressed in @p func in @p list.
0825      *
0826      * The method is templated to operate on either a list of windows or on a list of
0827      * a subclass type of Window.
0828      * @param list The list to search in
0829      * @param func The condition function (compare std::find_if)
0830      * @return T* The found Window or @c null if there is no matching Window
0831      */
0832     template<class T, class U>
0833     static T *findInList(const QList<T *> &list, std::function<bool(const U *)> func);
0834 
0835     /**
0836      * Whether the window is a popup.
0837      *
0838      * Popups can be used to implement popup menus, tooltips, combo boxes, etc.
0839      *
0840      * @since 5.15
0841      */
0842     virtual bool isPopupWindow() const;
0843 
0844     /**
0845      * A UUID to uniquely identify this Window independent of windowing system.
0846      */
0847     QUuid internalId() const
0848     {
0849         return m_internalId;
0850     }
0851 
0852     int stackingOrder() const;
0853     void setStackingOrder(int order); ///< @internal
0854 
0855     QWeakPointer<TabBox::TabBoxClientImpl> tabBoxClient() const
0856     {
0857         return m_tabBoxClient.toWeakRef();
0858     }
0859     bool isFirstInTabBox() const
0860     {
0861         return m_firstInTabBox;
0862     }
0863     bool skipSwitcher() const
0864     {
0865         return m_skipSwitcher;
0866     }
0867     void setSkipSwitcher(bool set);
0868 
0869     bool skipTaskbar() const
0870     {
0871         return m_skipTaskbar;
0872     }
0873     void setSkipTaskbar(bool set);
0874     void setOriginalSkipTaskbar(bool set);
0875     bool originalSkipTaskbar() const
0876     {
0877         return m_originalSkipTaskbar;
0878     }
0879 
0880     bool skipPager() const
0881     {
0882         return m_skipPager;
0883     }
0884     void setSkipPager(bool set);
0885 
0886     const QIcon &icon() const
0887     {
0888         return m_icon;
0889     }
0890 
0891     bool isZombie() const;
0892     bool isActive() const
0893     {
0894         return m_active;
0895     }
0896     /**
0897      * Sets the window's active state to \a act.
0898      *
0899      * This function does only change the visual appearance of the window,
0900      * it does not change the focus setting. Use
0901      * Workspace::activateClient() or Workspace::requestFocus() instead.
0902      *
0903      * If a window receives or looses the focus, it calls setActive() on
0904      * its own.
0905      */
0906     void setActive(bool);
0907 
0908     bool keepAbove() const
0909     {
0910         return m_keepAbove;
0911     }
0912     void setKeepAbove(bool);
0913     bool keepBelow() const
0914     {
0915         return m_keepBelow;
0916     }
0917     void setKeepBelow(bool);
0918 
0919     void demandAttention(bool set = true);
0920     bool isDemandingAttention() const
0921     {
0922         return m_demandsAttention;
0923     }
0924 
0925     void cancelAutoRaise();
0926 
0927     bool wantsTabFocus() const;
0928 
0929     virtual void updateMouseGrab();
0930     /**
0931      * @returns The caption consisting of captionNormal and captionSuffix
0932      * @see captionNormal
0933      * @see captionSuffix
0934      */
0935     QString caption() const;
0936     /**
0937      * @returns The caption as set by the Window without any suffix.
0938      * @see caption
0939      * @see captionSuffix
0940      */
0941     virtual QString captionNormal() const = 0;
0942     /**
0943      * @returns The suffix added to the caption (e.g. shortcut, machine name, etc.)
0944      * @see caption
0945      * @see captionNormal
0946      */
0947     virtual QString captionSuffix() const = 0;
0948     virtual bool isPlaceable() const;
0949     virtual bool isCloseable() const = 0;
0950     virtual bool isShown() const = 0;
0951     virtual bool isHiddenInternal() const = 0;
0952     virtual void hideClient() = 0;
0953     virtual void showClient() = 0;
0954     virtual bool isFullScreenable() const;
0955     virtual bool isFullScreen() const;
0956     virtual bool isRequestedFullScreen() const;
0957     // TODO: remove boolean trap
0958     virtual Window *findModal(bool allow_itself = false) = 0;
0959     virtual bool isTransient() const;
0960     /**
0961      * @returns Whether there is a hint available to place the Window on it's parent, default @c false.
0962      * @see transientPlacementHint
0963      */
0964     virtual bool hasTransientPlacementHint() const;
0965     /**
0966      * Only valid id hasTransientPlacementHint is true
0967      * @returns The position the transient wishes to position itself
0968      */
0969     virtual QRectF transientPlacement(const QRectF &bounds) const;
0970     const Window *transientFor() const;
0971     Window *transientFor();
0972     /**
0973      * @returns @c true if transient is the transient_for window for this window,
0974      *  or recursively the transient_for window
0975      * @todo: remove boolean trap
0976      */
0977     virtual bool hasTransient(const Window *transient, bool indirect) const;
0978     const QList<Window *> &transients() const; // Is not indirect
0979     virtual void addTransient(Window *transient);
0980     virtual void removeTransient(Window *transient);
0981     virtual QList<Window *> mainWindows() const; // Call once before loop , is not indirect
0982     QList<Window *> allMainWindows() const; // Call once before loop , is indirect
0983     /**
0984      * Returns true for "special" windows and false for windows which are "normal"
0985      * (normal=window which has a border, can be moved by the user, can be closed, etc.)
0986      * true for Desktop, Dock, Splash, Override and TopMenu (and Toolbar??? - for now)
0987      * false for Normal, Dialog, Utility and Menu (and Toolbar??? - not yet) TODO
0988      */
0989     bool isSpecialWindow() const;
0990     void sendToOutput(Output *output);
0991     const QKeySequence &shortcut() const
0992     {
0993         return _shortcut;
0994     }
0995     void setShortcut(const QString &cut);
0996     bool performMouseCommand(Options::MouseCommand, const QPointF &globalPos);
0997     void setOnAllDesktops(bool set);
0998     void setDesktop(int);
0999     void enterDesktop(VirtualDesktop *desktop);
1000     void leaveDesktop(VirtualDesktop *desktop);
1001 
1002     /**
1003      * Set the window as being on the attached list of desktops
1004      * On X11 it will be set to the last entry
1005      */
1006     void setDesktops(QVector<VirtualDesktop *> desktops);
1007 
1008     QVector<uint> x11DesktopIds() const;
1009     QStringList desktopIds() const;
1010 
1011     void setMinimized(bool set);
1012     /**
1013      * Minimizes this window plus its transients
1014      */
1015     void minimize(bool avoid_animation = false);
1016     void unminimize(bool avoid_animation = false);
1017     bool isMinimized() const
1018     {
1019         return m_minimized;
1020     }
1021     virtual void setFullScreen(bool set, bool user = true);
1022 
1023     QRectF geometryRestore() const;
1024     virtual MaximizeMode maximizeMode() const;
1025     virtual MaximizeMode requestedMaximizeMode() const;
1026     virtual void maximize(MaximizeMode mode);
1027     /**
1028      * Sets the maximization according to @p vertically and @p horizontally.
1029      */
1030     Q_INVOKABLE void setMaximize(bool vertically, bool horizontally);
1031     virtual bool noBorder() const;
1032     virtual void setNoBorder(bool set);
1033     QPalette palette();
1034     const Decoration::DecorationPalette *decorationPalette();
1035     /**
1036      * Returns whether the window is resizable or has a fixed size.
1037      */
1038     virtual bool isResizable() const = 0;
1039     /**
1040      * Returns whether the window is moveable or has a fixed position.
1041      */
1042     virtual bool isMovable() const = 0;
1043     /**
1044      * Returns whether the window can be moved to another screen.
1045      */
1046     virtual bool isMovableAcrossScreens() const = 0;
1047     /**
1048      * Returns @c true if the window is shaded and shadeMode is @c ShadeNormal; otherwise returns @c false.
1049      */
1050     virtual bool isShade() const
1051     {
1052         return shadeMode() == ShadeNormal;
1053     }
1054     ShadeMode shadeMode() const; // Prefer isShade()
1055     void setShade(bool set);
1056     void setShade(ShadeMode mode);
1057     void toggleShade();
1058     void cancelShadeHoverTimer();
1059     /**
1060      * Whether the Window can be shaded. Default implementation returns @c false.
1061      */
1062     virtual bool isShadeable() const;
1063     virtual bool isMaximizable() const;
1064     virtual bool isMinimizable() const;
1065     virtual QRectF iconGeometry() const;
1066     virtual bool userCanSetFullScreen() const;
1067     virtual bool userCanSetNoBorder() const;
1068     virtual void checkNoBorder();
1069 
1070     /**
1071      * Refresh Window's cache of activites
1072      * Called when activity daemon status changes
1073      */
1074     virtual void checkActivities(){};
1075 
1076     void setOnActivity(const QString &activity, bool enable);
1077     void setOnActivities(const QStringList &newActivitiesList);
1078     void setOnAllActivities(bool all);
1079     virtual void updateActivities(bool includeTransients);
1080     void blockActivityUpdates(bool b = true);
1081 
1082     const WindowRules *rules() const
1083     {
1084         return &m_rules;
1085     }
1086     void removeRule(Rules *r);
1087     void setupWindowRules(bool ignore_temporary);
1088     void evaluateWindowRules();
1089     virtual void applyWindowRules();
1090     virtual bool takeFocus() = 0;
1091     virtual bool wantsInput() const = 0;
1092     /**
1093      * Whether a dock window wants input.
1094      *
1095      * By default KWin doesn't pass focus to a dock window unless a force activate
1096      * request is provided.
1097      *
1098      * This method allows to have dock windows take focus also through flags set on
1099      * the window.
1100      *
1101      * The default implementation returns @c false.
1102      */
1103     virtual bool dockWantsInput() const;
1104     void checkWorkspacePosition(QRectF oldGeometry = QRectF(), const VirtualDesktop *oldDesktop = nullptr);
1105     virtual xcb_timestamp_t userTime() const;
1106     virtual void updateWindowRules(Rules::Types selection);
1107 
1108     void growHorizontal();
1109     void shrinkHorizontal();
1110     void growVertical();
1111     void shrinkVertical();
1112     void updateInteractiveMoveResize(const QPointF &currentGlobalCursor);
1113     /**
1114      * Ends move resize when all pointer buttons are up again.
1115      */
1116     void endInteractiveMoveResize();
1117     void keyPressEvent(uint key_code);
1118 
1119     virtual void pointerEnterEvent(const QPointF &globalPos);
1120     virtual void pointerLeaveEvent();
1121 
1122     Qt::Edge titlebarPosition() const;
1123     bool titlebarPositionUnderMouse() const;
1124 
1125     // a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving
1126     void packTo(qreal left, qreal top);
1127 
1128     /**
1129      * Sets the quick tile mode ("snap") of this window.
1130      * This will also handle preserving and restoring of window geometry as necessary.
1131      * @param mode The tile mode (left/right) to give this window.
1132      * @param keyboard Defines whether to take keyboard cursor into account.
1133      */
1134     void setQuickTileMode(QuickTileMode mode, bool keyboard = false);
1135     QuickTileMode quickTileMode() const
1136     {
1137         return QuickTileMode(m_quickTileMode);
1138     }
1139     virtual Layer layer() const;
1140     void updateLayer();
1141 
1142     Tile *tile() const;
1143 
1144     void move(const QPointF &point);
1145     void resize(const QSizeF &size);
1146     void moveResize(const QRectF &rect);
1147 
1148     virtual QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &s) = 0;
1149     void keepInArea(QRectF area, bool partial = false);
1150     QRectF keepInArea(QRectF geometry, QRectF area, bool partial = false);
1151     virtual QSizeF minSize() const;
1152     virtual QSizeF maxSize() const;
1153 
1154     /**
1155      * How to resize the window in order to obey constraints (mainly aspect ratios).
1156      */
1157     enum SizeMode {
1158         SizeModeAny,
1159         SizeModeFixedW, ///< Try not to affect width
1160         SizeModeFixedH, ///< Try not to affect height
1161         SizeModeMax ///< Try not to make it larger in either direction
1162     };
1163 
1164     virtual QSizeF constrainClientSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
1165     QSizeF constrainFrameSize(const QSizeF &size, SizeMode mode = SizeModeAny) const;
1166 
1167     /**
1168      * Calculates the matching client position for the given frame position @p point.
1169      */
1170     virtual QPointF framePosToClientPos(const QPointF &point) const;
1171     /**
1172      * Calculates the matching frame position for the given client position @p point.
1173      */
1174     virtual QPointF clientPosToFramePos(const QPointF &point) const;
1175     /**
1176      * Calculates the matching client size for the given frame size @p size.
1177      *
1178      * Notice that size constraints won't be applied.
1179      *
1180      * Default implementation returns the frame size with frame margins being excluded.
1181      */
1182     virtual QSizeF frameSizeToClientSize(const QSizeF &size) const;
1183     /**
1184      * Calculates the matching frame size for the given client size @p size.
1185      *
1186      * Notice that size constraints won't be applied.
1187      *
1188      * Default implementation returns the client size with frame margins being included.
1189      */
1190     virtual QSizeF clientSizeToFrameSize(const QSizeF &size) const;
1191     /**
1192      * Calculates the matching client rect for the given frame rect @p rect.
1193      *
1194      * Notice that size constraints won't be applied.
1195      */
1196     QRectF frameRectToClientRect(const QRectF &rect) const;
1197     /**
1198      * Calculates the matching frame rect for the given client rect @p rect.
1199      *
1200      * Notice that size constraints won't be applied.
1201      */
1202     QRectF clientRectToFrameRect(const QRectF &rect) const;
1203 
1204     /**
1205      * Returns the last requested geometry. The returned value indicates the bounding
1206      * geometry, meaning that the client can commit smaller window geometry if the window
1207      * is resized.
1208      *
1209      * The main difference between the frame geometry and the move-resize geometry is
1210      * that the former specifies the current geometry while the latter specifies the next
1211      * geometry.
1212      */
1213     QRectF moveResizeGeometry() const;
1214 
1215     /**
1216      * Returns the output where the last move or resize operation has occurred. The
1217      * window is expected to land on this output after the move/resize operation completes.
1218      */
1219     Output *moveResizeOutput() const;
1220     void setMoveResizeOutput(Output *output);
1221 
1222     /**
1223      * Returns @c true if the Client is being interactively moved; otherwise @c false.
1224      */
1225     bool isInteractiveMove() const
1226     {
1227         return isInteractiveMoveResize() && interactiveMoveResizeGravity() == Gravity::None;
1228     }
1229     /**
1230      * Returns @c true if the Client is being interactively resized; otherwise @c false.
1231      */
1232     bool isInteractiveResize() const
1233     {
1234         return isInteractiveMoveResize() && interactiveMoveResizeGravity() != Gravity::None;
1235     }
1236     /**
1237      * Cursor shape for move/resize mode.
1238      */
1239     CursorShape cursor() const
1240     {
1241         return m_interactiveMoveResize.cursor;
1242     }
1243 
1244     virtual StrutRect strutRect(StrutArea area) const;
1245     StrutRects strutRects() const;
1246     virtual bool hasStrut() const;
1247 
1248     void setModal(bool modal);
1249     bool isModal() const;
1250 
1251     /**
1252      * Determines the mouse command for the given @p button in the current state.
1253      *
1254      * The @p handled argument specifies whether the button was handled or not.
1255      * This value should be used to determine whether the mouse button should be
1256      * passed to the Window or being filtered out.
1257      */
1258     Options::MouseCommand getMouseCommand(Qt::MouseButton button, bool *handled) const;
1259     Options::MouseCommand getWheelCommand(Qt::Orientation orientation, bool *handled) const;
1260 
1261     // decoration related
1262     KDecoration2::Decoration *decoration()
1263     {
1264         return m_decoration.decoration.get();
1265     }
1266     const KDecoration2::Decoration *decoration() const
1267     {
1268         return m_decoration.decoration.get();
1269     }
1270     bool isDecorated() const
1271     {
1272         return m_decoration.decoration != nullptr;
1273     }
1274     QPointer<Decoration::DecoratedClientImpl> decoratedClient() const;
1275     void setDecoratedClient(QPointer<Decoration::DecoratedClientImpl> client);
1276     bool decorationHasAlpha() const;
1277     void triggerDecorationRepaint();
1278     virtual void layoutDecorationRects(QRectF &left, QRectF &top, QRectF &right, QRectF &bottom) const;
1279     void processDecorationMove(const QPointF &localPos, const QPointF &globalPos);
1280     bool processDecorationButtonPress(QMouseEvent *event, bool ignoreMenu = false);
1281     void processDecorationButtonRelease(QMouseEvent *event);
1282 
1283     virtual void invalidateDecoration();
1284 
1285     /**
1286      * Returns whether the window provides context help or not. If it does,
1287      * you should show a help menu item or a help button like '?' and call
1288      * contextHelp() if this is invoked.
1289      *
1290      * Default implementation returns @c false.
1291      * @see showContextHelp;
1292      */
1293     virtual bool providesContextHelp() const;
1294 
1295     /**
1296      * Invokes context help on the window. Only works if the window
1297      * actually provides context help.
1298      *
1299      * Default implementation does nothing.
1300      *
1301      * @see providesContextHelp()
1302      */
1303     virtual void showContextHelp();
1304 
1305     /**
1306      * @returns the geometry of the virtual keyboard
1307      * This geometry is in global coordinates
1308      */
1309     QRectF virtualKeyboardGeometry() const;
1310 
1311     /**
1312      * Sets the geometry of the virtual keyboard, The window may resize itself in order to make space for the keybaord
1313      * This geometry is in global coordinates
1314      */
1315     virtual void setVirtualKeyboardGeometry(const QRectF &geo);
1316 
1317     /**
1318      * Restores the Window after it had been hidden due to show on screen edge functionality.
1319      * The Window also gets raised (e.g. Panel mode windows can cover) and the Window
1320      * gets informed in a window specific way that it is shown and raised again.
1321      */
1322     virtual void showOnScreenEdge();
1323 
1324     QString desktopFileName() const
1325     {
1326         return m_desktopFileName;
1327     }
1328 
1329     /**
1330      * Tries to terminate the process of this Window.
1331      *
1332      * Implementing subclasses can perform a windowing system solution for terminating.
1333      */
1334     virtual void killWindow() = 0;
1335     virtual void destroyWindow() = 0;
1336 
1337     enum class SameApplicationCheck {
1338         RelaxedForActive = 1 << 0,
1339         AllowCrossProcesses = 1 << 1
1340     };
1341     Q_DECLARE_FLAGS(SameApplicationChecks, SameApplicationCheck)
1342     static bool belongToSameApplication(const Window *c1, const Window *c2, SameApplicationChecks checks = SameApplicationChecks());
1343 
1344     bool hasApplicationMenu() const;
1345     bool applicationMenuActive() const
1346     {
1347         return m_applicationMenuActive;
1348     }
1349     void setApplicationMenuActive(bool applicationMenuActive);
1350 
1351     QString applicationMenuServiceName() const
1352     {
1353         return m_applicationMenuServiceName;
1354     }
1355     QString applicationMenuObjectPath() const
1356     {
1357         return m_applicationMenuObjectPath;
1358     }
1359 
1360     virtual QString preferredColorScheme() const;
1361     QString colorScheme() const;
1362     void setColorScheme(const QString &colorScheme);
1363 
1364     /**
1365      * Request showing the application menu bar
1366      * @param actionId The DBus menu ID of the action that should be highlighted, 0 for the root menu
1367      */
1368     void showApplicationMenu(int actionId);
1369 
1370     bool unresponsive() const;
1371 
1372     /**
1373      * Default implementation returns @c null.
1374      * Mostly intended for X11 clients, from EWMH:
1375      * @verbatim
1376      * If the WM_TRANSIENT_FOR property is set to None or Root window, the window should be
1377      * treated as a transient for all other windows in the same group. It has been noted that this
1378      * is a slight ICCCM violation, but as this behavior is pretty standard for many toolkits and
1379      * window managers, and is extremely unlikely to break anything, it seems reasonable to document
1380      * it as standard.
1381      * @endverbatim
1382      */
1383     virtual bool groupTransient() const;
1384     /**
1385      * Default implementation returns @c null.
1386      *
1387      * Mostly for X11 clients, holds the client group
1388      */
1389     virtual const Group *group() const;
1390     /**
1391      * Default implementation returns @c null.
1392      *
1393      * Mostly for X11 clients, holds the client group
1394      */
1395     virtual Group *group();
1396 
1397     /**
1398      * Returns whether window rules can be applied to this client.
1399      *
1400      * Default implementation returns @c false.
1401      */
1402     virtual bool supportsWindowRules() const;
1403 
1404     /**
1405      * Return window management interface
1406      */
1407     KWaylandServer::PlasmaWindowInterface *windowManagementInterface() const
1408     {
1409         return m_windowManagementInterface;
1410     }
1411 
1412     QRectF fullscreenGeometryRestore() const;
1413 
1414     /**
1415      * Helper function to compute the icon out of an application id defined by @p fileName
1416      *
1417      * @returns an icon name that can be used with QIcon::fromTheme()
1418      */
1419     static QString iconFromDesktopFile(const QString &fileName);
1420 
1421     static QString findDesktopFile(const QString &fileName);
1422 
1423     /**
1424      * Sets the last user usage serial of the surface as @p serial
1425      */
1426     void setLastUsageSerial(quint32 serial);
1427     quint32 lastUsageSerial() const;
1428 
1429     uint32_t interactiveMoveResizeCount() const;
1430 
1431     void setTile(Tile *tile);
1432 
1433     void refOffscreenRendering();
1434     void unrefOffscreenRendering();
1435 
1436 public Q_SLOTS:
1437     virtual void closeWindow() = 0;
1438 
1439 protected Q_SLOTS:
1440     void setReadyForPainting();
1441 
1442 Q_SIGNALS:
1443     void stackingOrderChanged();
1444     void shadeChanged();
1445     void opacityChanged(KWin::Window *window, qreal oldOpacity);
1446     void damaged(KWin::Window *window);
1447     void inputTransformationChanged();
1448     /**
1449      * This signal is emitted when the Window's frame geometry changes.
1450      * @deprecated since 5.19, use frameGeometryChanged instead
1451      */
1452     void geometryChanged();
1453     void geometryShapeChanged(KWin::Window *window, const QRectF &old);
1454     void windowClosed(KWin::Window *window, KWin::Deleted *deleted);
1455     void windowShown(KWin::Window *window);
1456     void windowHidden(KWin::Window *window);
1457     /**
1458      * Signal emitted when the window's shape state changed. That is if it did not have a shape
1459      * and received one or if the shape was withdrawn. Think of Chromium enabling/disabling KWin's
1460      * decoration.
1461      */
1462     void shapedChanged();
1463     /**
1464      * Emitted whenever the Window's screen changes. This can happen either in consequence to
1465      * a screen being removed/added or if the Window's geometry changes.
1466      * @since 4.11
1467      */
1468     void screenChanged();
1469     void skipCloseAnimationChanged();
1470     /**
1471      * Emitted whenever the window role of the window changes.
1472      * @since 5.0
1473      */
1474     void windowRoleChanged();
1475     /**
1476      * Emitted whenever the window class name or resource name of the window changes.
1477      * @since 5.0
1478      */
1479     void windowClassChanged();
1480     /**
1481      * @since 5.4
1482      */
1483     void hasAlphaChanged();
1484 
1485     /**
1486      * Emitted whenever the Surface for this Window changes.
1487      */
1488     void surfaceChanged();
1489 
1490     /**
1491      * Emitted whenever the window's shadow changes.
1492      * @since 5.15
1493      */
1494     void shadowChanged();
1495 
1496     /**
1497      * This signal is emitted when the Window's buffer geometry changes.
1498      */
1499     void bufferGeometryChanged(KWin::Window *window, const QRectF &oldGeometry);
1500     /**
1501      * This signal is emitted when the Window's frame geometry changes.
1502      */
1503     void frameGeometryChanged(KWin::Window *window, const QRectF &oldGeometry);
1504     /**
1505      * This signal is emitted when the Window's client geometry has changed.
1506      */
1507     void clientGeometryChanged(KWin::Window *window, const QRectF &oldGeometry);
1508 
1509     /**
1510      * This signal is emitted when the frame geometry is about to change. the new geometry is not known yet
1511      */
1512     void frameGeometryAboutToChange(KWin::Window *window);
1513 
1514     /**
1515      * This signal is emitted when the visible geometry has changed.
1516      */
1517     void visibleGeometryChanged();
1518 
1519     /**
1520      * This signal is emitted when associated tile has changed, including from and to none
1521      */
1522     void tileChanged(KWin::Tile *tile);
1523 
1524     void fullScreenChanged();
1525     void skipTaskbarChanged();
1526     void skipPagerChanged();
1527     void skipSwitcherChanged();
1528     void iconChanged();
1529     void activeChanged();
1530     void keepAboveChanged(bool);
1531     void keepBelowChanged(bool);
1532     /**
1533      * Emitted whenever the demands attention state changes.
1534      */
1535     void demandsAttentionChanged();
1536     void desktopPresenceChanged(KWin::Window *, int); // to be forwarded by Workspace
1537     void desktopChanged();
1538     void activitiesChanged(KWin::Window *window);
1539     void x11DesktopIdsChanged();
1540     void minimizedChanged();
1541     void clientMinimized(KWin::Window *window, bool animate);
1542     void clientUnminimized(KWin::Window *window, bool animate);
1543     void paletteChanged(const QPalette &p);
1544     void colorSchemeChanged();
1545     void captionChanged();
1546     void clientMaximizedStateAboutToChange(KWin::Window *, MaximizeMode);
1547     void clientMaximizedStateChanged(KWin::Window *, MaximizeMode);
1548     void clientMaximizedStateChanged(KWin::Window *c, bool h, bool v);
1549     void transientChanged();
1550     void modalChanged();
1551     void quickTileModeChanged();
1552     void moveResizedChanged();
1553     void moveResizeCursorChanged(CursorShape);
1554     void clientStartUserMovedResized(KWin::Window *);
1555     void clientStepUserMovedResized(KWin::Window *, const QRectF &);
1556     void clientFinishUserMovedResized(KWin::Window *);
1557     void closeableChanged(bool);
1558     void minimizeableChanged(bool);
1559     void shadeableChanged(bool);
1560     void maximizeableChanged(bool);
1561     void desktopFileNameChanged();
1562     void applicationMenuChanged();
1563     void hasApplicationMenuChanged(bool);
1564     void applicationMenuActiveChanged(bool);
1565     void unresponsiveChanged(bool);
1566     void decorationChanged();
1567     void hiddenChanged();
1568     void lockScreenOverlayChanged();
1569 
1570 protected:
1571     void setWindowHandles(xcb_window_t client);
1572     void detectShape(xcb_window_t id);
1573     virtual void propertyNotifyEvent(xcb_property_notify_event_t *e);
1574     virtual void clientMessageEvent(xcb_client_message_event_t *e);
1575     Xcb::Property fetchWmClientLeader() const;
1576     void readWmClientLeader(Xcb::Property &p);
1577     void getWmClientLeader();
1578     void getWmClientMachine();
1579 
1580     /**
1581      * This function fetches the opaque region from this Window.
1582      * Will only be called on corresponding property changes and for initialization.
1583      */
1584     void getWmOpaqueRegion();
1585     void discardShapeRegion();
1586 
1587     virtual std::unique_ptr<WindowItem> createItem(Scene *scene) = 0;
1588 
1589     void getResourceClass();
1590     void setResourceClass(const QString &name, const QString &className = QString());
1591     Xcb::Property fetchSkipCloseAnimation() const;
1592     void readSkipCloseAnimation(Xcb::Property &prop);
1593     void getSkipCloseAnimation();
1594     void copyToDeleted(Window *c);
1595     void disownDataPassedToDeleted();
1596     void setDepth(int depth);
1597 
1598     Output *m_output = nullptr;
1599     QRectF m_frameGeometry;
1600     QRectF m_clientGeometry;
1601     QRectF m_bufferGeometry;
1602     xcb_visualid_t m_visual;
1603     int bit_depth;
1604     NETWinInfo *info;
1605     bool ready_for_painting;
1606     /**
1607      * An FBO object KWin internal windows might render to.
1608      */
1609     std::shared_ptr<QOpenGLFramebufferObject> m_internalFBO;
1610     QImage m_internalImage;
1611 
1612 protected:
1613     Window();
1614     void setFirstInTabBox(bool enable)
1615     {
1616         m_firstInTabBox = enable;
1617     }
1618     void setIcon(const QIcon &icon);
1619     void startAutoRaise();
1620     void autoRaise();
1621     bool isMostRecentlyRaised() const;
1622     void markAsZombie();
1623     /**
1624      * Whether the window accepts focus.
1625      * The difference to wantsInput is that the implementation should not check rules and return
1626      * what the window effectively supports.
1627      */
1628     virtual bool acceptsFocus() const = 0;
1629     /**
1630      * Called from setActive once the active value got updated, but before the changed signal
1631      * is emitted.
1632      *
1633      * Default implementation does nothing.
1634      */
1635     virtual void doSetActive();
1636     /**
1637      * Called from setKeepAbove once the keepBelow value got updated, but before the changed signal
1638      * is emitted.
1639      *
1640      * Default implementation does nothing.
1641      */
1642     virtual void doSetKeepAbove();
1643     /**
1644      * Called from setKeepBelow once the keepBelow value got updated, but before the changed signal
1645      * is emitted.
1646      *
1647      * Default implementation does nothing.
1648      */
1649     virtual void doSetKeepBelow();
1650     /**
1651      * Called from setShade() once the shadeMode value got updated, but before the changed signal
1652      * is emitted.
1653      *
1654      * Default implementation does nothing.
1655      */
1656     virtual void doSetShade(ShadeMode previousShadeMode);
1657     /**
1658      * Called from setDeskop once the desktop value got updated, but before the changed signal
1659      * is emitted.
1660      *
1661      * Default implementation does nothing.
1662      */
1663     virtual void doSetDesktop();
1664     /**
1665      * Called from @ref setOnActivities just after the activity list member has been updated, but before
1666      * @ref updateActivities is called.
1667      *
1668      * @param activityList the new list of activities set on that window
1669      *
1670      * Default implementation does nothing
1671      */
1672     virtual void doSetOnActivities(const QStringList &activityList);
1673     /**
1674      * Called from @ref minimize and @ref unminimize once the minimized value got updated, but before the
1675      * changed signal is emitted.
1676      *
1677      * Default implementation does nothig.
1678      */
1679     virtual void doMinimize();
1680     virtual bool belongsToSameApplication(const Window *other, SameApplicationChecks checks) const = 0;
1681 
1682     virtual void doSetSkipTaskbar();
1683     virtual void doSetSkipPager();
1684     virtual void doSetSkipSwitcher();
1685     virtual void doSetDemandsAttention();
1686     virtual void doSetQuickTileMode();
1687 
1688     void setupWindowManagementInterface();
1689     void updateColorScheme();
1690     void ensurePalette();
1691     void setTransientFor(Window *transientFor);
1692     /**
1693      * Just removes the @p cl from the transients without any further checks.
1694      */
1695     void removeTransientFromList(Window *cl);
1696 
1697     virtual Layer belongsToLayer() const;
1698     virtual bool belongsToDesktop() const;
1699     void invalidateLayer();
1700     bool isActiveFullScreen() const;
1701     virtual Layer layerForDock() const;
1702 
1703     // electric border / quick tiling
1704     void setElectricBorderMode(QuickTileMode mode);
1705     QuickTileMode electricBorderMode() const
1706     {
1707         return m_electricMode;
1708     }
1709     void setElectricBorderMaximizing(bool maximizing);
1710     bool isElectricBorderMaximizing() const
1711     {
1712         return m_electricMaximizing;
1713     }
1714     void updateElectricGeometryRestore();
1715     QRectF quickTileGeometryRestore() const;
1716     QRectF quickTileGeometry(QuickTileMode mode, const QPointF &pos) const;
1717     void updateQuickTileMode(QuickTileMode newMode)
1718     {
1719         m_quickTileMode = newMode;
1720     }
1721 
1722     // geometry handling
1723     void checkOffscreenPosition(QRectF *geom, const QRectF &screenArea);
1724     int borderLeft() const;
1725     int borderRight() const;
1726     int borderTop() const;
1727     int borderBottom() const;
1728     void setGeometryRestore(const QRectF &rect);
1729 
1730     void blockGeometryUpdates(bool block);
1731     void blockGeometryUpdates();
1732     void unblockGeometryUpdates();
1733     bool areGeometryUpdatesBlocked() const;
1734     enum class MoveResizeMode : uint {
1735         None,
1736         Move = 0x1,
1737         Resize = 0x2,
1738         MoveResize = Move | Resize,
1739     };
1740     MoveResizeMode pendingMoveResizeMode() const;
1741     void setPendingMoveResizeMode(MoveResizeMode mode);
1742     virtual void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) = 0;
1743 
1744     /**
1745      * @returns whether the Window is currently in move resize mode
1746      */
1747     bool isInteractiveMoveResize() const
1748     {
1749         return m_interactiveMoveResize.enabled;
1750     }
1751     /**
1752      * Sets whether the Window is in move resize mode to @p enabled.
1753      */
1754     void setInteractiveMoveResize(bool enabled)
1755     {
1756         m_interactiveMoveResize.enabled = enabled;
1757     }
1758     /**
1759      * @returns whether the move resize mode is unrestricted.
1760      */
1761     bool isUnrestrictedInteractiveMoveResize() const
1762     {
1763         return m_interactiveMoveResize.unrestricted;
1764     }
1765     /**
1766      * Sets whether move resize mode is unrestricted to @p set.
1767      */
1768     void setUnrestrictedInteractiveMoveResize(bool set)
1769     {
1770         m_interactiveMoveResize.unrestricted = set;
1771     }
1772     QPointF interactiveMoveOffset() const
1773     {
1774         return m_interactiveMoveResize.offset;
1775     }
1776     void setInteractiveMoveOffset(const QPointF &offset)
1777     {
1778         m_interactiveMoveResize.offset = offset;
1779     }
1780     QPointF invertedInteractiveMoveOffset() const
1781     {
1782         return m_interactiveMoveResize.invertedOffset;
1783     }
1784     void setInvertedInteractiveMoveOffset(const QPointF &offset)
1785     {
1786         m_interactiveMoveResize.invertedOffset = offset;
1787     }
1788     QRectF initialInteractiveMoveResizeGeometry() const
1789     {
1790         return m_interactiveMoveResize.initialGeometry;
1791     }
1792     void setMoveResizeGeometry(const QRectF &geo);
1793     Gravity interactiveMoveResizeGravity() const
1794     {
1795         return m_interactiveMoveResize.gravity;
1796     }
1797     void setInteractiveMoveResizeGravity(Gravity gravity)
1798     {
1799         m_interactiveMoveResize.gravity = gravity;
1800     }
1801     bool isInteractiveMoveResizePointerButtonDown() const
1802     {
1803         return m_interactiveMoveResize.buttonDown;
1804     }
1805     void setInteractiveMoveResizePointerButtonDown(bool down)
1806     {
1807         m_interactiveMoveResize.buttonDown = down;
1808     }
1809     Output *interactiveMoveResizeStartOutput() const
1810     {
1811         return m_interactiveMoveResize.startOutput;
1812     }
1813     void checkUnrestrictedInteractiveMoveResize();
1814     /**
1815      * Sets an appropriate cursor shape for the logical mouse position.
1816      */
1817     void updateCursor();
1818     void startDelayedInteractiveMoveResize();
1819     void stopDelayedInteractiveMoveResize();
1820     bool startInteractiveMoveResize();
1821     /**
1822      * Called from startMoveResize.
1823      *
1824      * Implementing classes should return @c false if starting move resize should
1825      * get aborted. In that case startMoveResize will also return @c false.
1826      *
1827      * Base implementation returns @c true.
1828      */
1829     virtual bool doStartInteractiveMoveResize();
1830     virtual void doFinishInteractiveMoveResize();
1831     void finishInteractiveMoveResize(bool cancel);
1832     /**
1833      * Leaves the move resize mode.
1834      *
1835      * Inheriting classes must invoke the base implementation which
1836      * ensures that the internal mode is properly ended.
1837      */
1838     virtual void leaveInteractiveMoveResize();
1839     /*
1840      * Checks if the mouse cursor is near the edge of the screen and if so
1841      * activates quick tiling or maximization
1842      */
1843     void checkQuickTilingMaximizationZones(int xroot, int yroot);
1844     void resetQuickTilingMaximizationZones();
1845     /**
1846      * Whether a sync request is still pending.
1847      * Default implementation returns @c false.
1848      */
1849     virtual bool isWaitingForInteractiveMoveResizeSync() const;
1850     /**
1851      * Called during handling a resize. Implementing subclasses can use this
1852      * method to perform windowing system specific syncing.
1853      *
1854      * Default implementation does nothing.
1855      */
1856     virtual void doInteractiveResizeSync(const QRectF &rect);
1857     void handleInteractiveMoveResize(int x, int y, int x_root, int y_root);
1858     void handleInteractiveMoveResize(const QPointF &local, const QPointF &global);
1859     void dontInteractiveMoveResize();
1860 
1861     virtual QSizeF resizeIncrements() const;
1862 
1863     /**
1864      * Returns the interactive move resize gravity depending on the Decoration's section
1865      * under mouse. If no decoration it returns Gravity::None.
1866      */
1867     Gravity mouseGravity() const;
1868 
1869     void setDecoration(std::shared_ptr<KDecoration2::Decoration> decoration);
1870     void startDecorationDoubleClickTimer();
1871     void invalidateDecorationDoubleClickTimer();
1872     void updateDecorationInputShape();
1873 
1874     void setDesktopFileName(const QString &name);
1875     QString iconFromDesktopFile() const;
1876 
1877     void updateApplicationMenuServiceName(const QString &serviceName);
1878     void updateApplicationMenuObjectPath(const QString &objectPath);
1879 
1880     void setUnresponsive(bool unresponsive);
1881 
1882     virtual void setShortcutInternal();
1883     QString shortcutCaptionSuffix() const;
1884     virtual void updateCaption() = 0;
1885 
1886     /**
1887      * Looks for another Window with same captionNormal and captionSuffix.
1888      * If no such Window exists @c nullptr is returned.
1889      */
1890     Window *findWindowWithSameCaption() const;
1891 
1892     void finishWindowRules();
1893     void discardTemporaryRules();
1894 
1895     bool tabTo(Window *other, bool behind, bool activate);
1896 
1897     void startShadeHoverTimer();
1898     void startShadeUnhoverTimer();
1899 
1900     // The geometry that the window should be restored when the virtual keyboard closes
1901     QRectF keyboardGeometryRestore() const;
1902     void setKeyboardGeometryRestore(const QRectF &geom);
1903 
1904     QRectF m_virtualKeyboardGeometry;
1905 
1906     void setFullscreenGeometryRestore(const QRectF &geom);
1907 
1908     void cleanTabBox();
1909 
1910     QStringList m_activityList;
1911 
1912 private Q_SLOTS:
1913     void shadeHover();
1914     void shadeUnhover();
1915 
1916 private:
1917     void maybeSendFrameCallback();
1918 
1919     // when adding new data members, check also copyToDeleted()
1920     QUuid m_internalId;
1921     Xcb::Window m_client;
1922     bool is_shape;
1923     std::unique_ptr<EffectWindowImpl> m_effectWindow;
1924     std::unique_ptr<WindowItem> m_windowItem;
1925     std::unique_ptr<Shadow> m_shadow;
1926     QString resource_name;
1927     QString resource_class;
1928     ClientMachine *m_clientMachine;
1929     xcb_window_t m_wmClientLeader;
1930     QRegion opaque_region;
1931     mutable QVector<QRectF> m_shapeRegion;
1932     mutable bool m_shapeRegionIsValid = false;
1933     bool m_skipCloseAnimation;
1934     quint32 m_pendingSurfaceId = 0;
1935     quint64 m_surfaceSerial = 0;
1936     QPointer<KWaylandServer::SurfaceInterface> m_surface;
1937     // when adding new data members, check also copyToDeleted()
1938     qreal m_opacity = 1.0;
1939     int m_stackingOrder = 0;
1940 
1941     void handlePaletteChange();
1942     QRectF moveToArea(const QRectF &geometry, const QRectF &oldArea, const QRectF &newArea);
1943     QRectF ensureSpecialStateGeometry(const QRectF &geometry);
1944 
1945     QSharedPointer<TabBox::TabBoxClientImpl> m_tabBoxClient;
1946     bool m_firstInTabBox = false;
1947     bool m_skipTaskbar = false;
1948     /**
1949      * Unaffected by KWin
1950      */
1951     bool m_originalSkipTaskbar = false;
1952     bool m_skipPager = false;
1953     bool m_skipSwitcher = false;
1954     QIcon m_icon;
1955     bool m_active = false;
1956     bool m_zombie = false;
1957     bool m_keepAbove = false;
1958     bool m_keepBelow = false;
1959     bool m_demandsAttention = false;
1960     bool m_minimized = false;
1961     QTimer *m_autoRaiseTimer = nullptr;
1962     QTimer *m_shadeHoverTimer = nullptr;
1963     ShadeMode m_shadeMode = ShadeNone;
1964     QVector<VirtualDesktop *> m_desktops;
1965 
1966     int m_activityUpdatesBlocked = 0;
1967     bool m_blockedActivityUpdatesRequireTransients = false;
1968 
1969     QString m_colorScheme;
1970     std::shared_ptr<Decoration::DecorationPalette> m_palette;
1971     static QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> s_palettes;
1972     static std::shared_ptr<Decoration::DecorationPalette> s_defaultPalette;
1973 
1974     KWaylandServer::PlasmaWindowInterface *m_windowManagementInterface = nullptr;
1975 
1976     Window *m_transientFor = nullptr;
1977     QList<Window *> m_transients;
1978     bool m_modal = false;
1979     Layer m_layer = UnknownLayer;
1980     QPointer<Tile> m_tile;
1981 
1982     // electric border/quick tiling
1983     QuickTileMode m_electricMode = QuickTileFlag::None;
1984     QRectF m_electricGeometryRestore;
1985     bool m_electricMaximizing = false;
1986     // The quick tile mode of this window.
1987     int m_quickTileMode = int(QuickTileFlag::None);
1988     QTimer *m_electricMaximizingDelay = nullptr;
1989 
1990     // geometry
1991     int m_blockGeometryUpdates = 0; // > 0 = New geometry is remembered, but not actually set
1992     MoveResizeMode m_pendingMoveResizeMode = MoveResizeMode::None;
1993     friend class GeometryUpdatesBlocker;
1994     Output *m_moveResizeOutput;
1995     QRectF m_moveResizeGeometry;
1996     QRectF m_keyboardGeometryRestore;
1997     QRectF m_maximizeGeometryRestore;
1998     QRectF m_fullscreenGeometryRestore;
1999 
2000     struct
2001     {
2002         bool enabled = false;
2003         bool unrestricted = false;
2004         QPointF offset;
2005         QPointF invertedOffset;
2006         QRectF initialGeometry;
2007         QRectF initialGeometryRestore;
2008         Gravity gravity = Gravity::None;
2009         bool buttonDown = false;
2010         CursorShape cursor = Qt::ArrowCursor;
2011         Output *startOutput = nullptr;
2012         QTimer *delayedTimer = nullptr;
2013         uint32_t counter = 0;
2014         MaximizeMode initialMaximizeMode;
2015         QuickTileMode initialQuickTileMode;
2016     } m_interactiveMoveResize;
2017 
2018     struct
2019     {
2020         std::shared_ptr<KDecoration2::Decoration> decoration;
2021         QPointer<Decoration::DecoratedClientImpl> client;
2022         QElapsedTimer doubleClickTimer;
2023         QRegion inputRegion;
2024     } m_decoration;
2025     QString m_desktopFileName;
2026 
2027     bool m_applicationMenuActive = false;
2028     QString m_applicationMenuServiceName;
2029     QString m_applicationMenuObjectPath;
2030 
2031     bool m_unresponsive = false;
2032 
2033     QKeySequence _shortcut;
2034 
2035     WindowRules m_rules;
2036     quint32 m_lastUsageSerial = 0;
2037     bool m_lockScreenOverlay = false;
2038     uint32_t m_offscreenRenderCount = 0;
2039     QTimer m_offscreenFramecallbackTimer;
2040 };
2041 
2042 /**
2043  * Helper for Window::blockGeometryUpdates() being called in pairs (true/false)
2044  */
2045 class GeometryUpdatesBlocker
2046 {
2047 public:
2048     explicit GeometryUpdatesBlocker(Window *c)
2049         : cl(c)
2050     {
2051         cl->blockGeometryUpdates(true);
2052     }
2053     ~GeometryUpdatesBlocker()
2054     {
2055         cl->blockGeometryUpdates(false);
2056     }
2057 
2058 private:
2059     Window *cl;
2060 };
2061 
2062 inline xcb_window_t Window::window() const
2063 {
2064     return m_client;
2065 }
2066 
2067 inline void Window::setWindowHandles(xcb_window_t w)
2068 {
2069     Q_ASSERT(!m_client.isValid() && w != XCB_WINDOW_NONE);
2070     m_client.reset(w, false);
2071 }
2072 
2073 inline QRectF Window::bufferGeometry() const
2074 {
2075     return m_bufferGeometry;
2076 }
2077 
2078 inline QRectF Window::clientGeometry() const
2079 {
2080     return m_clientGeometry;
2081 }
2082 
2083 inline QSizeF Window::clientSize() const
2084 {
2085     return m_clientGeometry.size();
2086 }
2087 
2088 inline QRectF Window::frameGeometry() const
2089 {
2090     return m_frameGeometry;
2091 }
2092 
2093 inline QSizeF Window::size() const
2094 {
2095     return m_frameGeometry.size();
2096 }
2097 
2098 inline QPointF Window::pos() const
2099 {
2100     return m_frameGeometry.topLeft();
2101 }
2102 
2103 inline qreal Window::x() const
2104 {
2105     return m_frameGeometry.x();
2106 }
2107 
2108 inline qreal Window::y() const
2109 {
2110     return m_frameGeometry.y();
2111 }
2112 
2113 inline qreal Window::width() const
2114 {
2115     return m_frameGeometry.width();
2116 }
2117 
2118 inline qreal Window::height() const
2119 {
2120     return m_frameGeometry.height();
2121 }
2122 
2123 inline QRectF Window::rect() const
2124 {
2125     return QRectF(0, 0, width(), height());
2126 }
2127 
2128 inline bool Window::readyForPainting() const
2129 {
2130     return ready_for_painting;
2131 }
2132 
2133 inline xcb_visualid_t Window::visual() const
2134 {
2135     return m_visual;
2136 }
2137 
2138 inline bool Window::isDesktop() const
2139 {
2140     return windowType() == NET::Desktop;
2141 }
2142 
2143 inline bool Window::isDock() const
2144 {
2145     return windowType() == NET::Dock;
2146 }
2147 
2148 inline bool Window::isMenu() const
2149 {
2150     return windowType() == NET::Menu;
2151 }
2152 
2153 inline bool Window::isToolbar() const
2154 {
2155     return windowType() == NET::Toolbar;
2156 }
2157 
2158 inline bool Window::isSplash() const
2159 {
2160     return windowType() == NET::Splash;
2161 }
2162 
2163 inline bool Window::isUtility() const
2164 {
2165     return windowType() == NET::Utility;
2166 }
2167 
2168 inline bool Window::isDialog() const
2169 {
2170     return windowType() == NET::Dialog;
2171 }
2172 
2173 inline bool Window::isNormalWindow() const
2174 {
2175     return windowType() == NET::Normal;
2176 }
2177 
2178 inline bool Window::isDropdownMenu() const
2179 {
2180     return windowType() == NET::DropdownMenu;
2181 }
2182 
2183 inline bool Window::isPopupMenu() const
2184 {
2185     return windowType() == NET::PopupMenu;
2186 }
2187 
2188 inline bool Window::isTooltip() const
2189 {
2190     return windowType() == NET::Tooltip;
2191 }
2192 
2193 inline bool Window::isNotification() const
2194 {
2195     return windowType() == NET::Notification;
2196 }
2197 
2198 inline bool Window::isCriticalNotification() const
2199 {
2200     return windowType() == NET::CriticalNotification;
2201 }
2202 
2203 inline bool Window::isAppletPopup() const
2204 {
2205     return windowType() == NET::AppletPopup;
2206 }
2207 
2208 inline bool Window::isOnScreenDisplay() const
2209 {
2210     return windowType() == NET::OnScreenDisplay;
2211 }
2212 
2213 inline bool Window::isComboBox() const
2214 {
2215     return windowType() == NET::ComboBox;
2216 }
2217 
2218 inline bool Window::isDNDIcon() const
2219 {
2220     return windowType() == NET::DNDIcon;
2221 }
2222 
2223 inline bool Window::isLockScreen() const
2224 {
2225     return false;
2226 }
2227 
2228 inline bool Window::isInputMethod() const
2229 {
2230     return false;
2231 }
2232 
2233 inline bool Window::isOutline() const
2234 {
2235     return false;
2236 }
2237 
2238 inline bool Window::isInternal() const
2239 {
2240     return false;
2241 }
2242 
2243 inline bool Window::shape() const
2244 {
2245     return is_shape;
2246 }
2247 
2248 inline int Window::depth() const
2249 {
2250     return bit_depth;
2251 }
2252 
2253 inline bool Window::hasAlpha() const
2254 {
2255     return depth() == 32;
2256 }
2257 
2258 inline const QRegion &Window::opaqueRegion() const
2259 {
2260     return opaque_region;
2261 }
2262 
2263 inline EffectWindowImpl *Window::effectWindow()
2264 {
2265     return m_effectWindow.get();
2266 }
2267 
2268 inline const EffectWindowImpl *Window::effectWindow() const
2269 {
2270     return m_effectWindow.get();
2271 }
2272 
2273 inline WindowItem *Window::windowItem() const
2274 {
2275     return m_windowItem.get();
2276 }
2277 
2278 inline bool Window::isOnAllDesktops() const
2279 {
2280     return desktops().isEmpty();
2281 }
2282 
2283 inline bool Window::isOnAllActivities() const
2284 {
2285     return activities().isEmpty();
2286 }
2287 
2288 inline bool Window::isOnActivity(const QString &activity) const
2289 {
2290     return activities().isEmpty() || activities().contains(activity);
2291 }
2292 
2293 inline QString Window::resourceName() const
2294 {
2295     return resource_name; // it is always lowercase
2296 }
2297 
2298 inline QString Window::resourceClass() const
2299 {
2300     return resource_class; // it is always lowercase
2301 }
2302 
2303 inline const ClientMachine *Window::clientMachine() const
2304 {
2305     return m_clientMachine;
2306 }
2307 
2308 inline quint64 Window::surfaceSerial() const
2309 {
2310     return m_surfaceSerial;
2311 }
2312 
2313 inline quint32 Window::pendingSurfaceId() const
2314 {
2315     return m_pendingSurfaceId;
2316 }
2317 
2318 inline const std::shared_ptr<QOpenGLFramebufferObject> &Window::internalFramebufferObject() const
2319 {
2320     return m_internalFBO;
2321 }
2322 
2323 inline QImage Window::internalImageObject() const
2324 {
2325     return m_internalImage;
2326 }
2327 
2328 template<class T, class U>
2329 inline T *Window::findInList(const QList<T *> &list, std::function<bool(const U *)> func)
2330 {
2331     static_assert(std::is_base_of<U, T>::value,
2332                   "U must be derived from T");
2333     const auto it = std::find_if(list.begin(), list.end(), func);
2334     if (it == list.end()) {
2335         return nullptr;
2336     }
2337     return *it;
2338 }
2339 
2340 inline bool Window::isPopupWindow() const
2341 {
2342     switch (windowType()) {
2343     case NET::ComboBox:
2344     case NET::DropdownMenu:
2345     case NET::PopupMenu:
2346     case NET::Tooltip:
2347         return true;
2348 
2349     default:
2350         return false;
2351     }
2352 }
2353 
2354 inline const QList<Window *> &Window::transients() const
2355 {
2356     return m_transients;
2357 }
2358 
2359 inline bool Window::areGeometryUpdatesBlocked() const
2360 {
2361     return m_blockGeometryUpdates != 0;
2362 }
2363 
2364 inline void Window::blockGeometryUpdates()
2365 {
2366     m_blockGeometryUpdates++;
2367 }
2368 
2369 inline void Window::unblockGeometryUpdates()
2370 {
2371     m_blockGeometryUpdates--;
2372 }
2373 
2374 inline Window::MoveResizeMode Window::pendingMoveResizeMode() const
2375 {
2376     return m_pendingMoveResizeMode;
2377 }
2378 
2379 inline void Window::setPendingMoveResizeMode(MoveResizeMode mode)
2380 {
2381     m_pendingMoveResizeMode = MoveResizeMode(uint(m_pendingMoveResizeMode) | uint(mode));
2382 }
2383 
2384 KWIN_EXPORT QDebug operator<<(QDebug debug, const Window *window);
2385 
2386 class KWIN_EXPORT WindowOffscreenRenderRef
2387 {
2388 public:
2389     WindowOffscreenRenderRef(Window *window);
2390     WindowOffscreenRenderRef() = default;
2391     ~WindowOffscreenRenderRef();
2392 
2393 private:
2394     QPointer<Window> m_window;
2395 };
2396 
2397 } // namespace KWin
2398 
2399 Q_DECLARE_METATYPE(KWin::Window *)
2400 Q_DECLARE_METATYPE(QList<KWin::Window *>)
2401 Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Window::SameApplicationChecks)