File indexing completed on 2024-05-12 05:31:29
0001 /* 0002 SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org> 0003 SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com> 0004 SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org> 0005 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "kwin_export.h" 0013 0014 #include <NETWM> 0015 0016 #include <QObject> 0017 0018 class QWindow; 0019 0020 namespace KDecoration2 0021 { 0022 class Decoration; 0023 } 0024 0025 namespace KWin 0026 { 0027 0028 class EffectWindowGroup; 0029 class EffectWindowVisibleRef; 0030 class Group; 0031 class Output; 0032 class SurfaceInterface; 0033 class VirtualDesktop; 0034 class Window; 0035 class WindowItem; 0036 0037 /** 0038 * @short Representation of a window used by/for Effect classes. 0039 * 0040 * The purpose is to hide internal data and also to serve as a single 0041 * representation for the case when Client/Unmanaged becomes Deleted. 0042 */ 0043 class KWIN_EXPORT EffectWindow : public QObject 0044 { 0045 Q_OBJECT 0046 Q_PROPERTY(QRectF geometry READ frameGeometry) 0047 Q_PROPERTY(QRectF expandedGeometry READ expandedGeometry) 0048 Q_PROPERTY(qreal height READ height) 0049 Q_PROPERTY(qreal opacity READ opacity) 0050 Q_PROPERTY(QPointF pos READ pos) 0051 Q_PROPERTY(KWin::Output *screen READ screen) 0052 Q_PROPERTY(QSizeF size READ size) 0053 Q_PROPERTY(qreal width READ width) 0054 Q_PROPERTY(qreal x READ x) 0055 Q_PROPERTY(qreal y READ y) 0056 Q_PROPERTY(QList<KWin::VirtualDesktop *> desktops READ desktops) 0057 Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops) 0058 Q_PROPERTY(bool onCurrentDesktop READ isOnCurrentDesktop) 0059 Q_PROPERTY(QRectF rect READ rect) 0060 Q_PROPERTY(QString windowClass READ windowClass) 0061 Q_PROPERTY(QString windowRole READ windowRole) 0062 /** 0063 * Returns whether the window is a desktop background window (the one with wallpaper). 0064 * See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0065 */ 0066 Q_PROPERTY(bool desktopWindow READ isDesktop) 0067 /** 0068 * Returns whether the window is a dock (i.e. a panel). 0069 * See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0070 */ 0071 Q_PROPERTY(bool dock READ isDock) 0072 /** 0073 * Returns whether the window is a standalone (detached) toolbar window. 0074 * See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0075 */ 0076 Q_PROPERTY(bool toolbar READ isToolbar) 0077 /** 0078 * Returns whether the window is a torn-off menu. 0079 * See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0080 */ 0081 Q_PROPERTY(bool menu READ isMenu) 0082 /** 0083 * Returns whether the window is a "normal" window, i.e. an application or any other window 0084 * for which none of the specialized window types fit. 0085 * See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0086 */ 0087 Q_PROPERTY(bool normalWindow READ isNormalWindow) 0088 /** 0089 * Returns whether the window is a dialog window. 0090 * See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0091 */ 0092 Q_PROPERTY(bool dialog READ isDialog) 0093 /** 0094 * Returns whether the window is a splashscreen. Note that many (especially older) applications 0095 * do not support marking their splash windows with this type. 0096 * See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0097 */ 0098 Q_PROPERTY(bool splash READ isSplash) 0099 /** 0100 * Returns whether the window is a utility window, such as a tool window. 0101 * See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0102 */ 0103 Q_PROPERTY(bool utility READ isUtility) 0104 /** 0105 * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open 0106 * from the applications menubar). 0107 * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0108 */ 0109 Q_PROPERTY(bool dropdownMenu READ isDropdownMenu) 0110 /** 0111 * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu). 0112 * See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0113 */ 0114 Q_PROPERTY(bool popupMenu READ isPopupMenu) 0115 /** 0116 * Returns whether the window is a tooltip. 0117 * See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0118 */ 0119 Q_PROPERTY(bool tooltip READ isTooltip) 0120 /** 0121 * Returns whether the window is a window with a notification. 0122 * See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0123 */ 0124 Q_PROPERTY(bool notification READ isNotification) 0125 /** 0126 * Returns whether the window is a window with a critical notification. 0127 * using the non-standard _KDE_NET_WM_WINDOW_TYPE_CRITICAL_NOTIFICATION 0128 */ 0129 Q_PROPERTY(bool criticalNotification READ isCriticalNotification) 0130 /** 0131 * Returns whether the window is an on screen display window 0132 * using the non-standard _KDE_NET_WM_WINDOW_TYPE_ON_SCREEN_DISPLAY 0133 */ 0134 Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay) 0135 /** 0136 * Returns whether the window is a combobox popup. 0137 * See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0138 */ 0139 Q_PROPERTY(bool comboBox READ isComboBox) 0140 /** 0141 * Returns whether the window is a Drag&Drop icon. 0142 * See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0143 */ 0144 Q_PROPERTY(bool dndIcon READ isDNDIcon) 0145 /** 0146 * Returns the NETWM window type 0147 * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0148 */ 0149 Q_PROPERTY(int windowType READ windowType) 0150 /** 0151 * Whether this EffectWindow is managed by KWin (it has control over its placement and other 0152 * aspects, as opposed to override-redirect windows that are entirely handled by the application). 0153 */ 0154 Q_PROPERTY(bool managed READ isManaged) 0155 /** 0156 * Whether this EffectWindow represents an already deleted window and only kept for the compositor for animations. 0157 */ 0158 Q_PROPERTY(bool deleted READ isDeleted) 0159 /** 0160 * The Caption of the window. Read from WM_NAME property together with a suffix for hostname and shortcut. 0161 */ 0162 Q_PROPERTY(QString caption READ caption) 0163 /** 0164 * Whether the window is set to be kept above other windows. 0165 */ 0166 Q_PROPERTY(bool keepAbove READ keepAbove) 0167 /** 0168 * Whether the window is set to be kept below other windows. 0169 */ 0170 Q_PROPERTY(bool keepBelow READ keepBelow) 0171 /** 0172 * Whether the window is minimized. 0173 */ 0174 Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized) 0175 /** 0176 * Whether the window represents a modal window. 0177 */ 0178 Q_PROPERTY(bool modal READ isModal) 0179 /** 0180 * Whether the window is moveable. Even if it is not moveable, it might be possible to move 0181 * it to another screen. 0182 * @see moveableAcrossScreens 0183 */ 0184 Q_PROPERTY(bool moveable READ isMovable) 0185 /** 0186 * Whether the window can be moved to another screen. 0187 * @see moveable 0188 */ 0189 Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens) 0190 /** 0191 * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). 0192 * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. 0193 */ 0194 Q_PROPERTY(QSizeF basicUnit READ basicUnit) 0195 /** 0196 * Whether the window is currently being moved by the user. 0197 */ 0198 Q_PROPERTY(bool move READ isUserMove) 0199 /** 0200 * Whether the window is currently being resized by the user. 0201 */ 0202 Q_PROPERTY(bool resize READ isUserResize) 0203 /** 0204 * The optional geometry representing the minimized Client in e.g a taskbar. 0205 * See _NET_WM_ICON_GEOMETRY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0206 */ 0207 Q_PROPERTY(QRectF iconGeometry READ iconGeometry) 0208 /** 0209 * Returns whether the window is any of special windows types (desktop, dock, splash, ...), 0210 * i.e. window types that usually don't have a window frame and the user does not use window 0211 * management (moving, raising,...) on them. 0212 */ 0213 Q_PROPERTY(bool specialWindow READ isSpecialWindow) 0214 Q_PROPERTY(QIcon icon READ icon) 0215 /** 0216 * Whether the window should be excluded from window switching effects. 0217 */ 0218 Q_PROPERTY(bool skipSwitcher READ isSkipSwitcher) 0219 /** 0220 * Geometry of the actual window contents inside the whole (including decorations) window. 0221 */ 0222 Q_PROPERTY(QRectF contentsRect READ contentsRect) 0223 /** 0224 * Geometry of the transparent rect in the decoration. 0225 * May be different from contentsRect if the decoration is extended into the client area. 0226 */ 0227 Q_PROPERTY(QRectF decorationInnerRect READ decorationInnerRect) 0228 Q_PROPERTY(bool hasDecoration READ hasDecoration) 0229 Q_PROPERTY(QStringList activities READ activities) 0230 Q_PROPERTY(bool onCurrentActivity READ isOnCurrentActivity) 0231 Q_PROPERTY(bool onAllActivities READ isOnAllActivities) 0232 /** 0233 * Whether the decoration currently uses an alpha channel. 0234 * @since 4.10 0235 */ 0236 Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha) 0237 /** 0238 * Whether the window is currently visible to the user, that is: 0239 * <ul> 0240 * <li>Not minimized</li> 0241 * <li>On current desktop</li> 0242 * <li>On current activity</li> 0243 * </ul> 0244 * @since 4.11 0245 */ 0246 Q_PROPERTY(bool visible READ isVisible) 0247 /** 0248 * Whether the window does not want to be animated on window close. 0249 * In case this property is @c true it is not useful to start an animation on window close. 0250 * The window will not be visible, but the animation hooks are executed. 0251 * @since 5.0 0252 */ 0253 Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation) 0254 0255 /** 0256 * Whether the window is fullscreen. 0257 * @since 5.6 0258 */ 0259 Q_PROPERTY(bool fullScreen READ isFullScreen) 0260 0261 /** 0262 * Whether this client is unresponsive. 0263 * 0264 * When an application failed to react on a ping request in time, it is 0265 * considered unresponsive. This usually indicates that the application froze or crashed. 0266 * 0267 * @since 5.10 0268 */ 0269 Q_PROPERTY(bool unresponsive READ isUnresponsive) 0270 0271 /** 0272 * Whether this is a Wayland client. 0273 * @since 5.15 0274 */ 0275 Q_PROPERTY(bool waylandClient READ isWaylandClient CONSTANT) 0276 0277 /** 0278 * Whether this is an X11 client. 0279 * @since 5.15 0280 */ 0281 Q_PROPERTY(bool x11Client READ isX11Client CONSTANT) 0282 0283 /** 0284 * Whether the window is a popup. 0285 * 0286 * A popup is a window that can be used to implement tooltips, combo box popups, 0287 * popup menus and other similar user interface concepts. 0288 * 0289 * @since 5.15 0290 */ 0291 Q_PROPERTY(bool popupWindow READ isPopupWindow CONSTANT) 0292 0293 /** 0294 * KWin internal window. Specific to Wayland platform. 0295 * 0296 * If the EffectWindow does not reference an internal window, this property is @c null. 0297 * @since 5.16 0298 */ 0299 Q_PROPERTY(QWindow *internalWindow READ internalWindow CONSTANT) 0300 0301 /** 0302 * Whether this EffectWindow represents the outline. 0303 * 0304 * When compositing is turned on, the outline is an actual window. 0305 * 0306 * @since 5.16 0307 */ 0308 Q_PROPERTY(bool outline READ isOutline CONSTANT) 0309 0310 /** 0311 * The PID of the application this window belongs to. 0312 * 0313 * @since 5.18 0314 */ 0315 Q_PROPERTY(pid_t pid READ pid CONSTANT) 0316 0317 /** 0318 * Whether this EffectWindow represents the screenlocker greeter. 0319 * 0320 * @since 5.22 0321 */ 0322 Q_PROPERTY(bool lockScreen READ isLockScreen CONSTANT) 0323 0324 /** 0325 * Whether this EffectWindow is hidden because the show desktop mode is active. 0326 */ 0327 Q_PROPERTY(bool hiddenByShowDesktop READ isHiddenByShowDesktop) 0328 0329 public: 0330 /** Flags explaining why painting should be disabled */ 0331 enum { 0332 /** Window will not be painted */ 0333 PAINT_DISABLED = 1 << 0, 0334 /** Window will not be painted because of which desktop it's on */ 0335 PAINT_DISABLED_BY_DESKTOP = 1 << 1, 0336 /** Window will not be painted because it is minimized */ 0337 PAINT_DISABLED_BY_MINIMIZE = 1 << 2, 0338 /** Window will not be painted because it's not on the current activity */ 0339 PAINT_DISABLED_BY_ACTIVITY = 1 << 3, 0340 }; 0341 0342 explicit EffectWindow(WindowItem *windowItem); 0343 ~EffectWindow() override; 0344 0345 Q_SCRIPTABLE void addRepaint(const QRect &r); 0346 Q_SCRIPTABLE void addRepaint(int x, int y, int w, int h); 0347 Q_SCRIPTABLE void addRepaintFull(); 0348 Q_SCRIPTABLE void addLayerRepaint(const QRect &r); 0349 Q_SCRIPTABLE void addLayerRepaint(int x, int y, int w, int h); 0350 0351 void refWindow(); 0352 void unrefWindow(); 0353 0354 bool isDeleted() const; 0355 bool isHidden() const; 0356 bool isHiddenByShowDesktop() const; 0357 0358 bool isMinimized() const; 0359 double opacity() const; 0360 0361 bool isOnCurrentActivity() const; 0362 Q_SCRIPTABLE bool isOnActivity(const QString &id) const; 0363 bool isOnAllActivities() const; 0364 QStringList activities() const; 0365 0366 Q_SCRIPTABLE bool isOnDesktop(KWin::VirtualDesktop *desktop) const; 0367 bool isOnCurrentDesktop() const; 0368 bool isOnAllDesktops() const; 0369 /** 0370 * All the desktops by number that the window is in. On X11 this list will always have 0371 * a length of 1, on Wayland can be any subset. 0372 * If the list is empty it means the window is on all desktops 0373 */ 0374 QList<KWin::VirtualDesktop *> desktops() const; 0375 0376 qreal x() const; 0377 qreal y() const; 0378 qreal width() const; 0379 qreal height() const; 0380 /** 0381 * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). 0382 * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. 0383 */ 0384 QSizeF basicUnit() const; 0385 /** 0386 * Returns the geometry of the window excluding server-side and client-side 0387 * drop-shadows. 0388 * 0389 * @since 5.18 0390 */ 0391 QRectF frameGeometry() const; 0392 /** 0393 * Returns the geometry of the pixmap or buffer attached to this window. 0394 * 0395 * For X11 clients, this method returns server-side geometry of the Window. 0396 * 0397 * For Wayland clients, this method returns rectangle that the main surface 0398 * occupies on the screen, in global screen coordinates. 0399 * 0400 * @since 5.18 0401 */ 0402 QRectF bufferGeometry() const; 0403 QRectF clientGeometry() const; 0404 /** 0405 * Geometry of the window including decoration and potentially shadows. 0406 * May be different from geometry() if the window has a shadow. 0407 * @since 4.9 0408 */ 0409 QRectF expandedGeometry() const; 0410 Output *screen() const; 0411 QPointF pos() const; 0412 QSizeF size() const; 0413 QRectF rect() const; 0414 bool isMovable() const; 0415 bool isMovableAcrossScreens() const; 0416 bool isUserMove() const; 0417 bool isUserResize() const; 0418 QRectF iconGeometry() const; 0419 0420 /** 0421 * Geometry of the actual window contents inside the whole (including decorations) window. 0422 */ 0423 QRectF contentsRect() const; 0424 /** 0425 * Geometry of the transparent rect in the decoration. 0426 * May be different from contentsRect() if the decoration is extended into the client area. 0427 * @since 4.5 0428 */ 0429 QRectF decorationInnerRect() const; 0430 bool hasDecoration() const; 0431 bool decorationHasAlpha() const; 0432 /** 0433 * Returns the decoration 0434 * @since 5.25 0435 */ 0436 KDecoration2::Decoration *decoration() const; 0437 QByteArray readProperty(long atom, long type, int format) const; 0438 void deleteProperty(long atom) const; 0439 0440 QString caption() const; 0441 QIcon icon() const; 0442 QString windowClass() const; 0443 QString windowRole() const; 0444 const EffectWindowGroup *group() const; 0445 0446 /** 0447 * Returns whether the window is a desktop background window (the one with wallpaper). 0448 * See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0449 */ 0450 bool isDesktop() const; 0451 /** 0452 * Returns whether the window is a dock (i.e. a panel). 0453 * See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0454 */ 0455 bool isDock() const; 0456 /** 0457 * Returns whether the window is a standalone (detached) toolbar window. 0458 * See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0459 */ 0460 bool isToolbar() const; 0461 /** 0462 * Returns whether the window is a torn-off menu. 0463 * See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0464 */ 0465 bool isMenu() const; 0466 /** 0467 * Returns whether the window is a "normal" window, i.e. an application or any other window 0468 * for which none of the specialized window types fit. 0469 * See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0470 */ 0471 bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient' 0472 /** 0473 * Returns whether the window is any of special windows types (desktop, dock, splash, ...), 0474 * i.e. window types that usually don't have a window frame and the user does not use window 0475 * management (moving, raising,...) on them. 0476 */ 0477 bool isSpecialWindow() const; 0478 /** 0479 * Returns whether the window is a dialog window. 0480 * See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0481 */ 0482 bool isDialog() const; 0483 /** 0484 * Returns whether the window is a splashscreen. Note that many (especially older) applications 0485 * do not support marking their splash windows with this type. 0486 * See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0487 */ 0488 bool isSplash() const; 0489 /** 0490 * Returns whether the window is a utility window, such as a tool window. 0491 * See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0492 */ 0493 bool isUtility() const; 0494 /** 0495 * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open 0496 * from the applications menubar). 0497 * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0498 */ 0499 bool isDropdownMenu() const; 0500 /** 0501 * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu). 0502 * See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0503 */ 0504 bool isPopupMenu() const; // a context popup, not dropdown, not torn-off 0505 /** 0506 * Returns whether the window is a tooltip. 0507 * See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0508 */ 0509 bool isTooltip() const; 0510 /** 0511 * Returns whether the window is a window with a notification. 0512 * See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0513 */ 0514 bool isNotification() const; 0515 /** 0516 * Returns whether the window is a window with a critical notification. 0517 * using the non-standard _KDE_NET_WM_WINDOW_TYPE_CRITICAL_NOTIFICATION 0518 */ 0519 bool isCriticalNotification() const; 0520 /** 0521 * Returns whether the window is a window used for applet popups. 0522 */ 0523 bool isAppletPopup() const; 0524 /** 0525 * Returns whether the window is an on screen display window 0526 * using the non-standard _KDE_NET_WM_WINDOW_TYPE_ON_SCREEN_DISPLAY 0527 */ 0528 bool isOnScreenDisplay() const; 0529 /** 0530 * Returns whether the window is a combobox popup. 0531 * See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0532 */ 0533 bool isComboBox() const; 0534 /** 0535 * Returns whether the window is a Drag&Drop icon. 0536 * See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0537 */ 0538 bool isDNDIcon() const; 0539 /** 0540 * Returns the NETWM window type 0541 * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . 0542 */ 0543 NET::WindowType windowType() const; 0544 /** 0545 * Returns whether the window is managed by KWin (it has control over its placement and other 0546 * aspects, as opposed to override-redirect windows that are entirely handled by the application). 0547 */ 0548 bool isManaged() const; // whether it's managed or override-redirect 0549 /** 0550 * Returns whether or not the window can accept keyboard focus. 0551 */ 0552 bool acceptsFocus() const; 0553 /** 0554 * Returns whether or not the window is kept above all other windows. 0555 */ 0556 bool keepAbove() const; 0557 /** 0558 * Returns whether the window is kept below all other windows. 0559 */ 0560 bool keepBelow() const; 0561 0562 bool isModal() const; 0563 Q_SCRIPTABLE KWin::EffectWindow *findModal(); 0564 Q_SCRIPTABLE KWin::EffectWindow *transientFor(); 0565 Q_SCRIPTABLE QList<KWin::EffectWindow *> mainWindows() const; 0566 0567 /** 0568 * Returns whether the window should be excluded from window switching effects. 0569 * @since 4.5 0570 */ 0571 bool isSkipSwitcher() const; 0572 0573 void setMinimized(bool minimize); 0574 void minimize(); 0575 void unminimize(); 0576 Q_SCRIPTABLE void closeWindow(); 0577 0578 /** 0579 * @since 4.11 0580 */ 0581 bool isVisible() const; 0582 0583 /** 0584 * @since 5.0 0585 */ 0586 bool skipsCloseAnimation() const; 0587 0588 /** 0589 * @since 5.5 0590 */ 0591 SurfaceInterface *surface() const; 0592 0593 /** 0594 * @since 5.6 0595 */ 0596 bool isFullScreen() const; 0597 0598 /** 0599 * @since 5.10 0600 */ 0601 bool isUnresponsive() const; 0602 0603 /** 0604 * @since 5.15 0605 */ 0606 bool isWaylandClient() const; 0607 0608 /** 0609 * @since 5.15 0610 */ 0611 bool isX11Client() const; 0612 0613 /** 0614 * @since 5.15 0615 */ 0616 bool isPopupWindow() const; 0617 0618 /** 0619 * @since 5.16 0620 */ 0621 QWindow *internalWindow() const; 0622 0623 /** 0624 * @since 5.16 0625 */ 0626 bool isOutline() const; 0627 0628 /** 0629 * @since 5.22 0630 */ 0631 bool isLockScreen() const; 0632 0633 /** 0634 * @since 5.18 0635 */ 0636 pid_t pid() const; 0637 0638 /** 0639 * @since 5.21 0640 */ 0641 qlonglong windowId() const; 0642 /** 0643 * Returns the internal id of the window that uniquely identifies it. The main difference 0644 * between internalId() and windowId() is that the latter one works as expected only on X11, 0645 * while the former is unique regardless of the window system. 0646 * 0647 * Note that the internaId() has special meaning only to kwin. 0648 * @since 5.24 0649 */ 0650 QUuid internalId() const; 0651 0652 /** 0653 * @since 6.0 0654 */ 0655 bool isInputMethod() const; 0656 0657 /** 0658 * Can be used to by effects to store arbitrary data in the EffectWindow. 0659 * 0660 * Invoking this method will emit the signal EffectsHandler::windowDataChanged. 0661 * @see EffectsHandler::windowDataChanged 0662 */ 0663 Q_SCRIPTABLE void setData(int role, const QVariant &data); 0664 Q_SCRIPTABLE QVariant data(int role) const; 0665 0666 Window *window() const; 0667 WindowItem *windowItem() const; 0668 void elevate(bool elevate); 0669 0670 Q_SIGNALS: 0671 /** 0672 * Signal emitted when a user begins a window move or resize operation. 0673 * To figure out whether the user resizes or moves the window use 0674 * isUserMove or isUserResize. 0675 * Whenever the geometry is updated the signal @ref windowStepUserMovedResized 0676 * is emitted with the current geometry. 0677 * The move/resize operation ends with the signal @ref windowFinishUserMovedResized. 0678 * Only one window can be moved/resized by the user at the same time! 0679 * @param w The window which is being moved/resized 0680 * @see windowStepUserMovedResized 0681 * @see windowFinishUserMovedResized 0682 * @see EffectWindow::isUserMove 0683 * @see EffectWindow::isUserResize 0684 */ 0685 void windowStartUserMovedResized(KWin::EffectWindow *w); 0686 /** 0687 * Signal emitted during a move/resize operation when the user changed the geometry. 0688 * Please note: KWin supports two operation modes. In one mode all changes are applied 0689 * instantly. This means the window's geometry matches the passed in @p geometry. In the 0690 * other mode the geometry is changed after the user ended the move/resize mode. 0691 * The @p geometry differs from the window's geometry. Also the window's pixmap still has 0692 * the same size as before. Depending what the effect wants to do it would be recommended 0693 * to scale/translate the window. 0694 * @param w The window which is being moved/resized 0695 * @param geometry The geometry of the window in the current move/resize step. 0696 * @see windowStartUserMovedResized 0697 * @see windowFinishUserMovedResized 0698 * @see EffectWindow::isUserMove 0699 * @see EffectWindow::isUserResize 0700 */ 0701 void windowStepUserMovedResized(KWin::EffectWindow *w, const QRectF &geometry); 0702 /** 0703 * Signal emitted when the user finishes move/resize of window @p w. 0704 * @param w The window which has been moved/resized 0705 * @see windowStartUserMovedResized 0706 * @see windowFinishUserMovedResized 0707 */ 0708 void windowFinishUserMovedResized(KWin::EffectWindow *w); 0709 0710 /** 0711 * Signal emitted when the maximized state of the window @p w changed. 0712 * A window can be in one of four states: 0713 * @li restored: both @p horizontal and @p vertical are @c false 0714 * @li horizontally maximized: @p horizontal is @c true and @p vertical is @c false 0715 * @li vertically maximized: @p horizontal is @c false and @p vertical is @c true 0716 * @li completely maximized: both @p horizontal and @p vertical are @c true 0717 * @param w The window whose maximized state changed 0718 * @param horizontal If @c true maximized horizontally 0719 * @param vertical If @c true maximized vertically 0720 */ 0721 void windowMaximizedStateChanged(KWin::EffectWindow *w, bool horizontal, bool vertical); 0722 0723 /** 0724 * Signal emitted when the maximized state of the window @p w is about to change, 0725 * but before windowMaximizedStateChanged is emitted or any geometry change. 0726 * Useful for OffscreenEffect to grab a window image before any actual change happens 0727 * 0728 * A window can be in one of four states: 0729 * @li restored: both @p horizontal and @p vertical are @c false 0730 * @li horizontally maximized: @p horizontal is @c true and @p vertical is @c false 0731 * @li vertically maximized: @p horizontal is @c false and @p vertical is @c true 0732 * @li completely maximized: both @p horizontal and @p vertical are @c true 0733 * @param w The window whose maximized state changed 0734 * @param horizontal If @c true maximized horizontally 0735 * @param vertical If @c true maximized vertically 0736 */ 0737 void windowMaximizedStateAboutToChange(KWin::EffectWindow *w, bool horizontal, bool vertical); 0738 0739 /** 0740 * This signal is emitted when the frame geometry of a window changed. 0741 * @param window The window whose geometry changed 0742 * @param oldGeometry The previous geometry 0743 */ 0744 void windowFrameGeometryChanged(KWin::EffectWindow *window, const QRectF &oldGeometry); 0745 0746 /** 0747 * This signal is emitted when the frame geometry is about to change, the new one is not known yet. 0748 * Useful for OffscreenEffect to grab a window image before any actual change happens. 0749 * 0750 * @param window The window whose geometry is about to change 0751 */ 0752 void windowFrameGeometryAboutToChange(KWin::EffectWindow *window); 0753 0754 /** 0755 * Signal emitted when the windows opacity is changed. 0756 * @param w The window whose opacity level is changed. 0757 * @param oldOpacity The previous opacity level 0758 * @param newOpacity The new opacity level 0759 */ 0760 void windowOpacityChanged(KWin::EffectWindow *w, qreal oldOpacity, qreal newOpacity); 0761 /** 0762 * Signal emitted when a window is minimized or unminimized. 0763 * @param w The window whose minimized state has changed 0764 */ 0765 void minimizedChanged(KWin::EffectWindow *w); 0766 /** 0767 * Signal emitted when a window either becomes modal (ie. blocking for its main client) or looses that state. 0768 * @param w The window which was unminimized 0769 */ 0770 void windowModalityChanged(KWin::EffectWindow *w); 0771 /** 0772 * Signal emitted when a window either became unresponsive (eg. app froze or crashed) 0773 * or respoonsive 0774 * @param w The window that became (un)responsive 0775 * @param unresponsive Whether the window is responsive or unresponsive 0776 */ 0777 void windowUnresponsiveChanged(KWin::EffectWindow *w, bool unresponsive); 0778 /** 0779 * Signal emitted when an area of a window is scheduled for repainting. 0780 * Use this signal in an effect if another area needs to be synced as well. 0781 * @param w The window which is scheduled for repainting 0782 */ 0783 void windowDamaged(KWin::EffectWindow *w); 0784 0785 /** 0786 * This signal is emitted when the keep above state of @p w was changed. 0787 * 0788 * @param w The window whose the keep above state was changed. 0789 */ 0790 void windowKeepAboveChanged(KWin::EffectWindow *w); 0791 0792 /** 0793 * This signal is emitted when the keep below state of @p was changed. 0794 * 0795 * @param w The window whose the keep below state was changed. 0796 */ 0797 void windowKeepBelowChanged(KWin::EffectWindow *w); 0798 0799 /** 0800 * This signal is emitted when the full screen state of @p w was changed. 0801 * 0802 * @param w The window whose the full screen state was changed. 0803 */ 0804 void windowFullScreenChanged(KWin::EffectWindow *w); 0805 0806 /** 0807 * This signal is emitted when decoration of @p was changed. 0808 * 0809 * @param w The window for which decoration changed 0810 */ 0811 void windowDecorationChanged(KWin::EffectWindow *window); 0812 0813 /** 0814 * This signal is emitted when the visible geometry of a window changed. 0815 */ 0816 void windowExpandedGeometryChanged(KWin::EffectWindow *window); 0817 0818 /** 0819 * This signal is emitted when a window enters or leaves a virtual desktop. 0820 */ 0821 void windowDesktopsChanged(KWin::EffectWindow *window); 0822 0823 /** 0824 * The window @p w gets shown again. The window was previously 0825 * initially shown with windowAdded and hidden with windowHidden. 0826 * 0827 * @see windowHidden 0828 * @see windowAdded 0829 */ 0830 void windowShown(KWin::EffectWindow *w); 0831 0832 /** 0833 * The window @p w got hidden but not yet closed. 0834 * This can happen when a window is still being used and is supposed to be shown again 0835 * with windowShown. On X11 an example is autohiding panels. On Wayland every 0836 * window first goes through the window hidden state and might get shown again, or might 0837 * get closed the normal way. 0838 * 0839 * @see windowShown 0840 * @see windowClosed 0841 */ 0842 void windowHidden(KWin::EffectWindow *w); 0843 0844 protected: 0845 friend EffectWindowVisibleRef; 0846 void refVisible(const EffectWindowVisibleRef *holder); 0847 void unrefVisible(const EffectWindowVisibleRef *holder); 0848 0849 private: 0850 class Private; 0851 std::unique_ptr<Private> d; 0852 }; 0853 0854 /** 0855 * The EffectWindowDeletedRef provides a convenient way to prevent deleting a closed 0856 * window until an effect has finished animating it. 0857 */ 0858 class KWIN_EXPORT EffectWindowDeletedRef 0859 { 0860 public: 0861 EffectWindowDeletedRef() 0862 : m_window(nullptr) 0863 { 0864 } 0865 0866 explicit EffectWindowDeletedRef(EffectWindow *window) 0867 : m_window(window) 0868 { 0869 m_window->refWindow(); 0870 } 0871 0872 EffectWindowDeletedRef(const EffectWindowDeletedRef &other) 0873 : m_window(other.m_window) 0874 { 0875 if (m_window) { 0876 m_window->refWindow(); 0877 } 0878 } 0879 0880 ~EffectWindowDeletedRef() 0881 { 0882 if (m_window) { 0883 m_window->unrefWindow(); 0884 } 0885 } 0886 0887 EffectWindowDeletedRef &operator=(const EffectWindowDeletedRef &other) 0888 { 0889 if (other.m_window) { 0890 other.m_window->refWindow(); 0891 } 0892 if (m_window) { 0893 m_window->unrefWindow(); 0894 } 0895 m_window = other.m_window; 0896 return *this; 0897 } 0898 0899 bool isNull() const 0900 { 0901 return m_window == nullptr; 0902 } 0903 0904 private: 0905 EffectWindow *m_window; 0906 }; 0907 0908 /** 0909 * The EffectWindowVisibleRef provides a convenient way to force the visible status of a 0910 * window until an effect is finished animating it. 0911 */ 0912 class KWIN_EXPORT EffectWindowVisibleRef 0913 { 0914 public: 0915 EffectWindowVisibleRef() 0916 : m_window(nullptr) 0917 , m_reason(0) 0918 { 0919 } 0920 0921 explicit EffectWindowVisibleRef(EffectWindow *window, int reason) 0922 : m_window(window) 0923 , m_reason(reason) 0924 { 0925 m_window->refVisible(this); 0926 } 0927 0928 EffectWindowVisibleRef(const EffectWindowVisibleRef &other) 0929 : m_window(other.m_window) 0930 , m_reason(other.m_reason) 0931 { 0932 if (m_window) { 0933 m_window->refVisible(this); 0934 } 0935 } 0936 0937 ~EffectWindowVisibleRef() 0938 { 0939 if (m_window) { 0940 m_window->unrefVisible(this); 0941 } 0942 } 0943 0944 int reason() const 0945 { 0946 return m_reason; 0947 } 0948 0949 EffectWindowVisibleRef &operator=(const EffectWindowVisibleRef &other) 0950 { 0951 if (other.m_window) { 0952 other.m_window->refVisible(&other); 0953 } 0954 if (m_window) { 0955 m_window->unrefVisible(this); 0956 } 0957 m_window = other.m_window; 0958 m_reason = other.m_reason; 0959 return *this; 0960 } 0961 0962 bool isNull() const 0963 { 0964 return m_window == nullptr; 0965 } 0966 0967 private: 0968 EffectWindow *m_window; 0969 int m_reason; 0970 }; 0971 0972 class KWIN_EXPORT EffectWindowGroup 0973 { 0974 public: 0975 explicit EffectWindowGroup(Group *group); 0976 virtual ~EffectWindowGroup(); 0977 0978 QList<EffectWindow *> members() const; 0979 0980 private: 0981 Group *m_group; 0982 }; 0983 0984 inline void EffectWindow::addRepaint(int x, int y, int w, int h) 0985 { 0986 addRepaint(QRect(x, y, w, h)); 0987 } 0988 0989 inline void EffectWindow::addLayerRepaint(int x, int y, int w, int h) 0990 { 0991 addLayerRepaint(QRect(x, y, w, h)); 0992 } 0993 0994 } // namespace KWin