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