File indexing completed on 2024-09-15 09:28:31
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 1999 Matthias Ettrich <ettrich@kde.org> 0004 SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 /* 0009 * kwindowsystem.h. Part of the KDE project. 0010 */ 0011 0012 #ifndef KWINDOWSYSTEM_H 0013 #define KWINDOWSYSTEM_H 0014 0015 #include <QObject> 0016 #include <QWidgetList> //For WId 0017 #include <kwindowinfo.h> 0018 #include <kwindowsystem_export.h> 0019 #include <netwm_def.h> 0020 0021 class KWindowSystemPrivate; 0022 class NETWinInfo; 0023 0024 /** 0025 * 0026 * Convenience access to certain properties and features of the 0027 * window manager. 0028 * 0029 * The class KWindowSystem provides information about the state of the 0030 * window manager and allows asking the window manager to change them 0031 * using a more high-level interface than the NETWinInfo/NETRootInfo 0032 * lowlevel classes. 0033 * 0034 * Because of limitations of the way Qt is implemented on Mac OSX, the WId's 0035 * returned by methods in this class are not compatible with those expected 0036 * by other Qt methods. So while it should be fine to pass WId's retrieved by 0037 * for example calling the winId method on a QWidget to methods in this class 0038 * the reverse is not true. You should never pass a WId obtained from this class 0039 * to a Qt method accepting a WId parameter. 0040 * 0041 * @short Class for interaction with the window manager. 0042 * @author Matthias Ettrich (ettrich@kde.org) 0043 */ 0044 class KWINDOWSYSTEM_EXPORT KWindowSystem : public QObject, public NET 0045 { 0046 Q_OBJECT 0047 Q_PROPERTY(bool isPlatformWayland READ isPlatformWayland CONSTANT) 0048 Q_PROPERTY(bool isPlatformX11 READ isPlatformX11 CONSTANT) 0049 0050 public: 0051 /** 0052 * Access to the singleton instance. Useful mainly for connecting to signals. 0053 */ 0054 static KWindowSystem *self(); 0055 0056 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0057 /** 0058 * Returns the list of all toplevel windows currently managed by the 0059 * window manager in the order of creation. Please do not rely on 0060 * indexes of this list: Whenever you enter Qt's event loop in your 0061 * application, it may happen that entries are removed or added. 0062 * Your module should perhaps work on a copy of this list and verify a 0063 * window with hasWId() before any operations. 0064 * 0065 * Iteration over this list can be done easily with 0066 * \code 0067 * QList<WId> windows = KWindowSystem::windows(); 0068 * for (auto it = windows.cbegin(), end = windows.cend(); it != end; ++it) { 0069 * ... do something here, (*it) is the current WId. 0070 * } 0071 * \endcode 0072 * @return the list of all toplevel windows 0073 * @deprecated since 5.101, use KX11Extras::windows() 0074 */ 0075 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::windows() instead") 0076 static QList<WId> windows(); 0077 #endif 0078 0079 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0080 /** 0081 * Test to see if @p id still managed at present. 0082 * @param id the window id to test 0083 * @return true if the window id is still managed 0084 * @deprecated since 5.101, use KX11Extras::hasWId() 0085 **/ 0086 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::hasWId() instead") 0087 static bool hasWId(WId id); 0088 #endif 0089 0090 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0091 /** 0092 * Returns information about window @p win. It is recommended to check 0093 * whether the returned info is valid by calling the valid() method. 0094 * @param win the id of the window 0095 * @param properties all properties that should be retrieved (see NET::Property 0096 * enum for details). Unlisted properties cause related information to be invalid 0097 * in the returned data, but make this function faster when not all data is needed. 0098 * @param properties2 additional properties (see NET::Property2 enum) 0099 * @return the window information 0100 * @deprecated Since 5.0, use KWindowInfo directly 0101 */ 0102 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowInfo(WId, NET::Properties, NET::Properties2") 0103 static KWindowInfo windowInfo(WId win, NET::Properties properties, NET::Properties2 properties2 = NET::Properties2()); 0104 #endif 0105 0106 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0107 /** 0108 * Returns the list of all toplevel windows currently managed by the 0109 * window manager in the current stacking order (from lower to 0110 * higher). May be useful for pagers. 0111 * @return the list of all toplevel windows in stacking order 0112 * @deprecated since 5.101, use KX11Extras::stackingOrder() 0113 */ 0114 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::stackingOrder() instead") 0115 static QList<WId> stackingOrder(); 0116 #endif 0117 0118 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0119 /** 0120 * Returns the currently active window, or 0 if no window is active. 0121 * @return the window id of the active window, or 0 if no window is 0122 * active 0123 * @deprecated since 5.101, use KX11Extras::activeWindow() 0124 **/ 0125 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::activeWindow() instead") 0126 static WId activeWindow(); 0127 #endif 0128 0129 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0130 /** 0131 * Requests that window @p win is activated. 0132 * 0133 * There are two ways how to activate a window, by calling 0134 * activateWindow() and forceActiveWindow(). Generally, 0135 * applications shouldn't make attempts to explicitly activate 0136 * their windows, and instead let the user to activate them. 0137 * In the special cases where this may be needed, applications 0138 * should use activateWindow(). Window manager may consider whether 0139 * this request wouldn't result in focus stealing, which 0140 * would be obtrusive, and may refuse the request. 0141 * 0142 * The usage of forceActiveWindow() is meant only for pagers 0143 * and similar tools, which represent direct user actions 0144 * related to window manipulation. 0145 * Except for rare cases, this request will be always honored, 0146 * and normal applications are forbidden to use it. 0147 * 0148 * In case of problems, consult the KWin README in the kdebase 0149 * package (kdebase/kwin/README), or ask on the kwin@kde.org 0150 * mailing list. 0151 * 0152 * @param win the id of the window to make active 0153 * @param time X server timestamp of the user activity that 0154 * caused this request 0155 * @deprecated since 5.101, use KX11Extras::activateWindow() or KWindowSystem::activateWindow(QWindow *) instead 0156 */ 0157 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::activateWindow() or KWindowSystem::activateWindow(QWindow *) instead") 0158 static void activateWindow(WId win, long time = 0); 0159 #endif 0160 0161 /** 0162 * Requests that window @p win is activated. 0163 * 0164 * There are two ways how to activate a window, by calling 0165 * activateWindow() and forceActiveWindow(). Generally, 0166 * applications shouldn't make attempts to explicitly activate 0167 * their windows, and instead let the user to activate them. 0168 * In the special cases where this may be needed, applications 0169 * should use activateWindow(). Window manager may consider whether 0170 * this request wouldn't result in focus stealing, which 0171 * would be obtrusive, and may refuse the request. 0172 * 0173 * The usage of forceActiveWindow() is meant only for pagers 0174 * and similar tools, which represent direct user actions 0175 * related to window manipulation. 0176 * Except for rare cases, this request will be always honored, 0177 * and normal applications are forbidden to use it. 0178 * 0179 * In case of problems, consult the KWin README in the kdebase 0180 * package (kdebase/kwin/README), or ask on the kwin@kde.org 0181 * mailing list. 0182 * 0183 * @param window the window to make active 0184 * @param time X server timestamp of the user activity that 0185 * caused this request 0186 * 0187 * @since 5.89 0188 */ 0189 Q_INVOKABLE static void activateWindow(QWindow *window, long time = 0); 0190 0191 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0192 /** 0193 * Sets window @p win to be the active window. Note that this 0194 * should be called only in special cases, applications 0195 * shouldn't force themselves or other windows to be the active 0196 * window. Generally, this call should used only by pagers 0197 * and similar tools. See the explanation in description 0198 * of activateWindow(). 0199 * 0200 * @param win the id of the window to make active 0201 * @param time X server timestamp of the user activity that 0202 * caused this request 0203 * @deprecated since 5.101, use KX11Extras::forceActiveWindow() 0204 */ 0205 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::forceActiveWindow() instead") 0206 static void forceActiveWindow(WId win, long time = 0); 0207 #endif 0208 0209 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0210 /** 0211 * When application finishes some operation and wants to notify 0212 * the user about it, it can call demandAttention(). Instead 0213 * of activating the window, which could be obtrusive, the window 0214 * will be marked specially as demanding user's attention. 0215 * See also explanation in description of activateWindow(). 0216 * 0217 * Note that it's usually better to use KNotifyClient. 0218 * @deprecated since 5.101, use QWindow::alert() instead(). 0219 */ 0220 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use QWindow::alert()") 0221 static void demandAttention(WId win, bool set = true); 0222 #endif 0223 0224 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0225 /** 0226 * Returns true if a compositing manager is running (i.e. ARGB windows 0227 * are supported, effects will be provided, etc.). 0228 * @deprecated since 5.101, use KX11Extras::compositingActive() 0229 */ 0230 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::compositingActive() instead") 0231 static bool compositingActive(); 0232 #endif 0233 0234 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0235 /** 0236 * Returns the current virtual desktop. 0237 * @return the current virtual desktop 0238 * @deprecated since 5.101, use KX11Extras::currentDesktop() 0239 **/ 0240 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::currentDesktop() instead") 0241 static int currentDesktop(); 0242 #endif 0243 0244 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0245 /** 0246 * Returns the number of virtual desktops. 0247 * @return the number of virtual desktops 0248 * @deprecated since 5.101, use KX11Extras::numberOfDesktops() 0249 **/ 0250 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::numberOfDesktops() instead") 0251 static int numberOfDesktops(); 0252 #endif 0253 0254 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0255 /** 0256 * Convenience function to set the current desktop to @p desktop. 0257 * See NETRootInfo. 0258 * @param desktop the number of the new desktop 0259 * @deprecated since 5.101, use KX11Extras::setCurrentDesktop() 0260 */ 0261 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setCurrentDesktop() instead") 0262 static void setCurrentDesktop(int desktop); 0263 #endif 0264 0265 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0266 /** 0267 * Sets window @p win to be present on all virtual desktops if @p 0268 * is true. Otherwise the window lives only on one single desktop. 0269 * 0270 * @param win the id of the window 0271 * @param b true to show the window on all desktops, false 0272 * otherwise 0273 * @deprecated since 5.101, use KX11Extras::setOnAllDesktops() 0274 */ 0275 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setOnAllDesktops() instead") 0276 static void setOnAllDesktops(WId win, bool b); 0277 #endif 0278 0279 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0280 /** 0281 * Moves window @p win to desktop @p desktop. 0282 * 0283 * @param win the id of the window 0284 * @param desktop the number of the new desktop 0285 * @deprecated since 5.101, use KX11Extras::setOnDesktop() 0286 */ 0287 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setOnDesktop() instead") 0288 static void setOnDesktop(WId win, int desktop); 0289 #endif 0290 0291 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0292 /** 0293 * Moves window @p win to activities @p activities. 0294 * 0295 * @param win the id of the window 0296 * @param activities the list of activity UUIDs 0297 * 0298 * @since 5.1 0299 * @see KWindowInfo::activities 0300 * @deprecated since 5.101, use KX11Extras::setOnActivities() 0301 */ 0302 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setOnActivities() instead") 0303 static void setOnActivities(WId win, const QStringList &activities); 0304 #endif 0305 0306 /** 0307 * Sets the parent window of @p subwindow to be @p mainwindow. 0308 * This overrides the parent set the usual way as the QWidget or QWindow parent, 0309 * but only for the window manager - e.g. stacking order and window grouping 0310 * will be affected, but features like automatic deletion of children 0311 * when the parent is deleted are unaffected and normally use 0312 * the QObject parent. 0313 * 0314 * This function should be used before a dialog is shown for a window 0315 * that belongs to another application. 0316 */ 0317 static void setMainWindow(QWindow *subwindow, WId mainwindow); 0318 0319 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 62) 0320 /** 0321 * Sets the parent window of @p subwindow to be @p mainwindow. 0322 * This overrides the parent set the usual way as the QWidget parent, 0323 * but only for the window manager - e.g. stacking order and window grouping 0324 * will be affected, but features like automatic deletion of children 0325 * when the parent is deleted are unaffected and normally use 0326 * the QWidget parent. 0327 * 0328 * This function should be used before a dialog is shown for a window 0329 * that belongs to another application. 0330 * @deprecated since 5.62, use setMainWindow(QWindow *). If all you have is a QWidget*, 0331 * you might need to call setAttribute(Qt::WA_NativeWindow, true); before calling 0332 * >window()->windowHandle(). 0333 */ 0334 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 62, "Use KWindowSystem::setMainWindow(QWindow *)") 0335 static void setMainWindow(QWidget *subwindow, WId mainwindow); 0336 #endif 0337 0338 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0339 /** 0340 * Returns the WM_TRANSIENT_FOR property for the given window, i.e. the mainwindow 0341 * for this window. 0342 * 0343 * @param window the id of the window 0344 * @deprecated Since 5.0, use KWindowInfo::transientFor 0345 */ 0346 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowInfo::transientFor()") 0347 static WId transientFor(WId window); 0348 0349 /** 0350 * Returns the leader window for the group the given window is in, if any. 0351 * @param window the id of the window 0352 * @deprecated Since 5.0, use KWindowInfo::groupLeader 0353 */ 0354 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowInfo::groupLeader()") 0355 static WId groupLeader(WId window); 0356 #endif 0357 0358 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0359 /** 0360 * Returns an icon for window @p win. 0361 * 0362 * If @p width and @p height are specified, the best icon for the requested 0363 * size is returned. 0364 * 0365 * If @p scale is true, the icon is smooth-scaled to have exactly 0366 * the requested size. 0367 * 0368 * @param win the id of the window 0369 * @param width the desired width, or -1 0370 * @param height the desired height, or -1 0371 * @param scale if true the icon will be scaled to the desired size. Otherwise the 0372 * icon will not be modified. 0373 * @return the icon of the window 0374 * @deprecated since 5.101, use KX11Extras::icon() 0375 */ 0376 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::icon() instead") 0377 static QPixmap icon(WId win, int width = -1, int height = -1, bool scale = false); 0378 #endif 0379 0380 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0381 /** 0382 * Masks specifying from which sources to read an icon. They are tried from the best 0383 * until an icon is found. 0384 * @li NETWM from property from the window manager specification 0385 * @li WMHints from WMHints property 0386 * @li ClassHint load icon after getting name from the classhint 0387 * @li XApp load the standard X icon (last fallback) 0388 */ 0389 enum IconSource { 0390 NETWM = 1, //!< read from property from the window manager specification 0391 WMHints = 2, //!< read from WMHints property 0392 ClassHint = 4, //!< load icon after getting name from the classhint 0393 XApp = 8, //!< load the standard X icon (last fallback) 0394 }; 0395 #endif 0396 0397 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0398 /** 0399 * @overload 0400 * 0401 * Overloaded variant that allows specifying from which sources the icon should be read. 0402 * You should usually prefer the simpler variant which tries all possibilities to get 0403 * an icon. 0404 * 0405 * @param win the id of the window 0406 * @param width the desired width, or -1 0407 * @param height the desired height, or -1 0408 * @param scale if true the icon will be scaled to the desired size. Otherwise the 0409 * icon will not be modified. 0410 * @param flags OR-ed flags from the IconSource enum 0411 * @deprecated since 5.101, use KX11Extras::icon() 0412 */ 0413 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::icon() instead") 0414 static QPixmap icon(WId win, int width, int height, bool scale, int flags); 0415 #endif 0416 0417 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0418 /** 0419 * @overload 0420 * 0421 * Overloaded variant that allows passing in the NETWinInfo to use for reading the 0422 * information. This variant is only useful on the X11 platform, other platforms do not 0423 * use NETWinInfo and delegate to the variant without NETWinInfo. Though if compiled with 0424 * X11 support the X11 variant is used on other platforms if info is not @c nullptr. 0425 * This can be used by applications using e.g. platform wayland but also connecting to an 0426 * XServer. 0427 * 0428 * The NETWinInfo must be constructed with property NET::WMIcon in order to use the 0429 * IconSource flag NETWM. NET::WM2IconPixmap for IconSource flag WMHints and 0430 * NET::WM2WindowClass for IconSource flag ClassHint. 0431 * 0432 * @param win the id of the window 0433 * @param width the desired width, or -1 0434 * @param height the desired height, or -1 0435 * @param scale if true the icon will be scaled to the desired size. Otherwise the 0436 * icon will not be modified. 0437 * @param flags OR-ed flags from the IconSource enum 0438 * @param into the NETWinInfo to use for reading properties. 0439 * @since 5.7 0440 * @deprecated since 5.101, use KX11Extras::icon() 0441 **/ 0442 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::icon() instead") 0443 static QPixmap icon(WId win, int width, int height, bool scale, int flags, NETWinInfo *info); 0444 #endif 0445 0446 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0447 /** 0448 * Sets an @p icon and a @p miniIcon on window @p win 0449 * @param win the id of the window 0450 * @param icon the new icon 0451 * @param miniIcon the new mini icon 0452 * @deprecated since 5.101, use QWindow::setIcon() or QGuiApplication::setWindowIcon() 0453 */ 0454 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use QWindow::setIcon() or QGuiApplication::setWindowIcon()") 0455 static void setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon); 0456 #endif 0457 0458 /** 0459 * Sets the type of window @p win to @p windowType. 0460 * 0461 * @param win the id of the window 0462 * @param windowType the type of the window (see NET::WindowType) 0463 */ 0464 static void setType(WId win, NET::WindowType windowType); 0465 /** 0466 * Sets the state of window @p win to @p state. 0467 * 0468 * Possible values are or'ed combinations of NET::Modal, 0469 * NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, 0470 * NET::SkipTaskbar, NET::SkipPager, NET::Hidden, 0471 * NET::FullScreen, NET::KeepAbove, NET::KeepBelow, 0472 * NET::SkipSwitcher 0473 * 0474 * @param win the id of the window 0475 * @param state the new flags that will be set 0476 */ 0477 static void setState(WId win, NET::States state); 0478 0479 /** 0480 * Clears the state of window @p win from @p state. 0481 * 0482 * Possible values are or'ed combinations of NET::Modal, 0483 * NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, 0484 * NET::SkipTaskbar, NET::SkipPager, NET::Hidden, 0485 * NET::FullScreen, NET::KeepAbove, NET::KeepBelow, 0486 * NET::SkipSwitcher 0487 * 0488 * @param win the id of the window 0489 * @param state the flags that will be cleared 0490 */ 0491 static void clearState(WId win, NET::States state); 0492 0493 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0494 /** 0495 * Minimizes the window with id @p win. 0496 * On X11 this follows the protocol described in ICCCM section 4.1.4. 0497 * 0498 * @param win The window to minimize 0499 * @see unminimizeWindow() 0500 * @deprecated since 5.101, use KX11Extras::minimizeWindow() or QWindow::setState() 0501 */ 0502 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::minimizeWindow() or QWindow::setState() instead") 0503 static void minimizeWindow(WId win); 0504 #endif 0505 0506 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0507 /** 0508 * Unminimizes the window with id @p win. 0509 * On X11 this follows the protocol described in ICCCM section 4.1.4. 0510 * 0511 * @param win The window to unminimize 0512 * @see minimizeWindow() 0513 * @deprecated since 5.101, use KX11Extras::unminimizeWindow() or QWindow::setState() 0514 **/ 0515 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::unminimizeWindow() or QWindow::setState() instead") 0516 static void unminimizeWindow(WId win); 0517 #endif 0518 0519 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0520 /** 0521 * @deprecated since 5.0 the @p animation is ignored. 0522 */ 0523 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::minimizeWindow(WId)") 0524 static void minimizeWindow(WId win, bool animation); 0525 #endif 0526 0527 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0528 /** 0529 * @deprecated since 5.0 the @p animation is ignored. 0530 */ 0531 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::unminimizeWindow(WId)") 0532 static void unminimizeWindow(WId win, bool animation); 0533 #endif 0534 0535 /** 0536 * Raises the given window. This call is only for pagers and similar 0537 * tools that represent direct user actions. Applications should not 0538 * use it, they should keep using QWidget::raise() or XRaiseWindow() 0539 * if necessary. 0540 */ 0541 static void raiseWindow(WId win); 0542 0543 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0544 /** 0545 * Lowers the given window. This call is only for pagers and similar 0546 * tools that represent direct user actions. Applications should not 0547 * use it, they should keep using QWidget::lower() or XLowerWindow() 0548 * if necessary. 0549 * 0550 * @deprecated since 5.101, no known users. 0551 */ 0552 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "No known users.") 0553 static void lowerWindow(WId win); 0554 #endif 0555 0556 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0557 /** 0558 * @internal 0559 * Returns true if the WM uses IconicState also for windows 0560 * on inactive virtual desktops. 0561 * 0562 * @deprecated since 5.101, internal. 0563 */ 0564 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Internal") 0565 static bool icccmCompliantMappingState(); 0566 #endif 0567 0568 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0569 /** 0570 * Returns the workarea for the specified desktop, or the current 0571 * work area if no desktop has been specified. 0572 * @param desktop the number of the desktop to check, -1 for the 0573 * current desktop 0574 * @return the size and position of the desktop 0575 * @deprecated since 5.101, use KX11Extras::workArea() 0576 **/ 0577 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::workArea() instead") 0578 static QRect workArea(int desktop = -1); 0579 #endif 0580 0581 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0582 /** 0583 * Returns the workarea for the specified desktop, or the current 0584 * work area if no desktop has been specified. Excludes struts of 0585 * clients in the exclude List. 0586 * 0587 * @param excludes the list of clients whose struts will be excluded 0588 * @param desktop the number of the desktop to check, -1 for the 0589 * current desktop 0590 * @return the size and position of the desktop 0591 * @deprecated since 5.101, use KX11Extras::workArea() 0592 **/ 0593 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::workArea() instead") 0594 static QRect workArea(const QList<WId> &excludes, int desktop = -1); 0595 #endif 0596 0597 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0598 /** 0599 * Returns the name of the specified desktop. 0600 * @param desktop the number of the desktop 0601 * @return the name of the desktop 0602 * @deprecated since 5.101, use KX11Extras::desktopName() 0603 **/ 0604 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::desktopName() instead") 0605 static QString desktopName(int desktop); 0606 #endif 0607 0608 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0609 /** 0610 * Sets the name of the specified desktop. 0611 * @param desktop the number of the desktop 0612 * @param name the new name for the desktop 0613 * @deprecated since 5.101, use KX11Extras::setDesktopName() 0614 **/ 0615 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setDesktopName() instead") 0616 static void setDesktopName(int desktop, const QString &name); 0617 #endif 0618 0619 /** 0620 * Returns the state of showing the desktop. 0621 */ 0622 static bool showingDesktop(); 0623 0624 /** 0625 * Sets the state of the "showing desktop" mode of the window manager. If on, 0626 * windows are hidden and desktop background is shown and focused. 0627 * 0628 * @param showing if true, the window manager is put in "showing desktop" mode. 0629 * If false, the window manager is put out of that mode. 0630 * 0631 * @since 5.7.0 0632 */ 0633 static void setShowingDesktop(bool showing); 0634 0635 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0636 /** 0637 * Sets user timestamp @p time on window @p win. The timestamp 0638 * is expressed as XServer time. If a window 0639 * is shown with user timestamp older than the time of the last 0640 * user action, it won't be activated after being shown. 0641 * The most common case is the special value 0 which means 0642 * not to activate the window after being shown. 0643 * 0644 * @deprecated since 5.101, use QX11Info::setAppUserTime(). 0645 */ 0646 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use QX11Info::setAppUserTime()") 0647 static void setUserTime(WId win, long time); 0648 #endif 0649 0650 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0651 /** 0652 * Sets the strut of window @p win to @p left_width 0653 * ranging from @p left_start to @p left_end on the left edge, 0654 * and simiarly for the other edges. For not reserving a strut, pass 0 as the width. 0655 * E.g. to reserve 10x10 square in the topleft corner, use e.g. 0656 * setExtendedStrut( w, 10, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 ). 0657 * 0658 * @param win the id of the window 0659 * @param left_width width of the strut at the left edge 0660 * @param left_start starting y coordinate of the strut at the left edge 0661 * @param left_end ending y coordinate of the strut at the left edge 0662 * @param right_width width of the strut at the right edge 0663 * @param right_start starting y coordinate of the strut at the right edge 0664 * @param right_end ending y coordinate of the strut at the right edge 0665 * @param top_width width of the strut at the top edge 0666 * @param top_start starting x coordinate of the strut at the top edge 0667 * @param top_end ending x coordinate of the strut at the top edge 0668 * @param bottom_width width of the strut at the bottom edge 0669 * @param bottom_start starting x coordinate of the strut at the bottom edge 0670 * @param bottom_end ending x coordinate of the strut at the bottom edge 0671 */ 0672 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setExtendedStrut() instead. In KF6 all arguments must be in the logical coordinates.") 0673 static void setExtendedStrut(WId win, 0674 int left_width, 0675 int left_start, 0676 int left_end, 0677 int right_width, 0678 int right_start, 0679 int right_end, 0680 int top_width, 0681 int top_start, 0682 int top_end, 0683 int bottom_width, 0684 int bottom_start, 0685 int bottom_end); 0686 #endif 0687 0688 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0689 /** 0690 * Convenience function for setExtendedStrut() that automatically makes struts 0691 * as wide/high as the screen width/height. 0692 * Sets the strut of window @p win to @p left, @p right, @p top, @p bottom. 0693 * 0694 * @param win the id of the window 0695 * @param left the left strut 0696 * @param right the right strut 0697 * @param top the top strut 0698 * @param bottom the bottom strut 0699 */ 0700 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::setStrut() instead. In KF6 all arguments must be in the logical coordinates.") 0701 static void setStrut(WId win, int left, int right, int top, int bottom); 0702 #endif 0703 0704 /** 0705 * Returns true if the WM announces which actions it allows for windows. 0706 */ 0707 static bool allowedActionsSupported(); 0708 0709 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0710 /** 0711 * Function that reads and returns the contents of the given text 0712 * property (WM_NAME, WM_ICON_NAME,...). 0713 */ 0714 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::readNameProperty() instead") 0715 static QString readNameProperty(WId window, unsigned long atom); 0716 #endif 0717 0718 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 104) 0719 /** 0720 * Allows a window from another process to raise and activate itself. 0721 * Depending on the window manager, the grant may only be temporary, 0722 * or for a single activation, and it may require the current process 0723 * to be the "foreground" one" (ie. the process with the input focus). 0724 * 0725 * You should call this function before executing actions that may trigger 0726 * the showing of a window or dialog in another process, e.g. a dbus signal 0727 * or function call, or any other inter-process notification mechanism. 0728 * 0729 * This is mostly used on Windows, where windows are not allowed to be raised 0730 * and activated if their process is not the foreground one, but it may also 0731 * apply to other window managers. 0732 * 0733 * @param pid if specified, the grant only applies to windows belonging to the 0734 * specific process. By default, a value of -1 means all processes. 0735 * 0736 * @deprecated since 5.104, not implemented. 0737 */ 0738 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 104, "Not implemented") 0739 static void allowExternalProcessWindowActivation(int pid = -1); 0740 #endif 0741 0742 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0743 /** 0744 * Sets whether the client wishes to block compositing (for better performance) 0745 * @since 4.7 0746 * @deprecated since 5.101, no known users. 0747 */ 0748 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "No known users") 0749 static void setBlockingCompositing(WId window, bool active); 0750 #endif 0751 0752 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0753 /** 0754 * @internal 0755 * Returns true if viewports are mapped to virtual desktops. 0756 */ 0757 static bool mapViewport(); 0758 #endif 0759 0760 /** 0761 * @internal 0762 * Returns mapped virtual desktop for the given position in the viewport. 0763 */ 0764 static int viewportToDesktop(const QPoint &pos); 0765 /** 0766 * @internal 0767 * Returns mapped virtual desktop for the given window geometry. 0768 */ 0769 static int viewportWindowToDesktop(const QRect &r); 0770 /** 0771 * @internal 0772 * Returns topleft corner of the viewport area for the given mapped virtual desktop. 0773 */ 0774 static QPoint desktopToViewport(int desktop, bool absolute); 0775 0776 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0777 /** 0778 * @internal 0779 * @since 4.0.1 0780 * Checks the relative difference used to move a window will still be inside 0781 * valid desktop area. 0782 */ 0783 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "No known users") 0784 static QPoint constrainViewportRelativePosition(const QPoint &pos); 0785 #endif 0786 0787 /** 0788 * Updates the platform-specific startup id, if any. 0789 * 0790 * This method is to be called when a running application instance 0791 * is reused for handling the request to start this application. 0792 * A typical use would be in the handler of the KDBusService activation signal. 0793 * 0794 * For X11, this updates the id for the Startup Notification protocol, 0795 * taking the id from QX11Info::nextStartupId(), if not empty. 0796 * For Wayland, this updates the token for the XDG Activation protocol, 0797 * taking the token from the "XDG_ACTIVATION_TOKEN" environment variable 0798 * and then unsetting it, if not empty. 0799 * 0800 * @param window the main window (needed by X11 platform) 0801 * 0802 * @since 5.91 0803 */ 0804 static void updateStartupId(QWindow *window); 0805 0806 /** 0807 * Enum describing the windowing system platform used by the QGuiApplication. 0808 * @see platform 0809 * @since 5.25 0810 **/ 0811 enum class Platform { 0812 /** 0813 * A platform unknown to the application is used 0814 **/ 0815 Unknown, 0816 /** 0817 * The xcb/X11 windowing system platorm. 0818 **/ 0819 X11, 0820 /** 0821 * The Wayland windowing system platform. 0822 **/ 0823 Wayland, 0824 }; 0825 Q_ENUM(Platform) 0826 /** 0827 * Returns the Platform used by the QGuiApplication. 0828 * This method allows to check for the used windowing system in a cheap and reliable way. 0829 * The Platform gets resolved the first time the method is invoked and cached for further 0830 * usages. 0831 * @returns The Platform used by the QGuiApplication. 0832 * @since 5.25 0833 **/ 0834 static Platform platform(); 0835 0836 /** 0837 * Convenience method to check whether the Platform is X11. 0838 * @see platform 0839 * @see isPlatformWayland 0840 * @since 5.25 0841 **/ 0842 static bool isPlatformX11(); 0843 0844 /** 0845 * Convenience method to check whether the Platform is Wayland. 0846 * @see platform 0847 * @see isPlatformX11 0848 * @since 5.25 0849 **/ 0850 static bool isPlatformWayland(); 0851 0852 /** 0853 * Requests an xdg_activation_v1 token for a specific window. 0854 * 0855 * @param win window in behalf this request is made 0856 * @param serial of the event that triggered the request 0857 * @param app_id identifier of the application that we are launching 0858 * 0859 * @see lastInputSerial 0860 * @since 5.83 0861 */ 0862 Q_INVOKABLE static void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id); 0863 0864 /** 0865 * Sets the @p token that will be used when activateWindow is called next 0866 * 0867 * @since 5.83 0868 */ 0869 Q_INVOKABLE static void setCurrentXdgActivationToken(const QString &token); 0870 0871 /** 0872 * Offers the seat's current serial 0873 * 0874 * This will mostly be useful on wayland sessions. 0875 * 0876 * @since 5.83 0877 */ 0878 Q_INVOKABLE static quint32 lastInputSerial(QWindow *window); 0879 0880 Q_SIGNALS: 0881 0882 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0883 /** 0884 * Switched to another virtual desktop. 0885 * @param desktop the number of the new desktop 0886 * @deprecated since 5.101, use KX11Extras::currentDesktopChanged() 0887 */ 0888 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::currentDesktopChanged()") 0889 void currentDesktopChanged(int desktop); 0890 #endif 0891 0892 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0893 /** 0894 * A window has been added. 0895 * @param id the id of the window 0896 * @deprecated since 5.101, use KX11Extras::windowAdded() 0897 */ 0898 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::windowAdded()") 0899 void windowAdded(WId id); 0900 #endif 0901 0902 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0903 /** 0904 * A window has been removed. 0905 * @param id the id of the window that has been removed 0906 * @deprecated since 5.101, use KX11Extras::windowRemoved() 0907 */ 0908 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::windowRemoved()") 0909 void windowRemoved(WId id); 0910 #endif 0911 0912 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0913 /** 0914 * Hint that \<Window> is active (= has focus) now. 0915 * @param id the id of the window that is active 0916 * @deprecated since 5.101, use KX11Extras::activeWindowChanged() 0917 */ 0918 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::activeWindowChanged()") 0919 void activeWindowChanged(WId id); 0920 #endif 0921 0922 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0923 /** 0924 * Desktops have been renamed. 0925 * @deprecated since 5.101, use KX11Extras::desktopNamesChanged() 0926 */ 0927 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::desktopNamesChanged()") 0928 void desktopNamesChanged(); 0929 #endif 0930 0931 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0932 /** 0933 * The number of desktops changed. 0934 * @param num the new number of desktops 0935 * @deprecated since 5.101, use KX11Extras::numberOfDesktopsChanged() 0936 */ 0937 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::numberOfDesktopsChanged()") 0938 void numberOfDesktopsChanged(int num); 0939 #endif 0940 0941 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0942 /** 0943 * The workarea has changed. 0944 * @deprecated since 5.101, use KX11Extras::workAreaChanged() 0945 */ 0946 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::workAreaChanged()") 0947 void workAreaChanged(); 0948 #endif 0949 0950 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0951 /** 0952 * Something changed with the struts, may or may not have changed 0953 * the work area. Usually just using the workAreaChanged() signal 0954 * is sufficient. 0955 * @deprecated since 5.101, use KX11Extras::strutChanged() 0956 */ 0957 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::strutChanged()") 0958 void strutChanged(); 0959 #endif 0960 0961 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0962 /** 0963 * Emitted when the stacking order of the window changed. The new order 0964 * can be obtained with stackingOrder(). 0965 * @deprecated since 5.101, use KX11Extras::stackingOrderChanged() 0966 */ 0967 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::stackingOrderChanged()") 0968 void stackingOrderChanged(); 0969 #endif 0970 0971 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 0972 /** 0973 * The window changed. 0974 * 0975 * Carries the NET::Properties and NET::Properties2 that were changed. 0976 * 0977 * @param id the id of the window 0978 * @param properties the properties that were modified 0979 * @param properties2 the properties2 that were modified 0980 * 0981 * @since 5.0 0982 * @deprecated since 5.101, use KX11Extras::windowChanged() 0983 */ 0984 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::windowChanged") 0985 void windowChanged(WId id, NET::Properties properties, NET::Properties2 properties2); // clazy:exclude=overloaded-signal 0986 #endif 0987 0988 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0989 /** 0990 * The window changed. 0991 * 0992 * The properties parameter contains the NET properties that 0993 * were modified (see netwm_def.h). First element are NET::Property 0994 * values, second element are NET::Property2 values (i.e. the format 0995 * is the same like for the NETWinInfo class constructor). 0996 * @param id the id of the window 0997 * @param properties the properties that were modified 0998 * 0999 * @deprecated since 5.0 use windowChanged(WId, NET::Properties, NET::Properties2) 1000 */ 1001 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::windowChanged(WId, NET::Properties, NET::Properties2)") 1002 QT_MOC_COMPAT void windowChanged(WId id, const unsigned long *properties); // clazy:exclude=overloaded-signal 1003 #endif 1004 1005 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 1006 /** 1007 * The window changed. 1008 * 1009 * The unsigned int parameter contains the NET properties that 1010 * were modified (see netwm_def.h). 1011 * @param id the id of the window 1012 * @param properties the properties that were modified 1013 * @deprecated Since 5.0 1014 */ 1015 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::windowChanged(WId, NET::Properties, NET::Properties2)") 1016 QT_MOC_COMPAT void windowChanged(WId id, unsigned int properties); // clazy:exclude=overloaded-signal 1017 #endif 1018 1019 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 80) 1020 /** 1021 * The window changed somehow. 1022 * @param id the id of the window 1023 * 1024 * @deprecated since 5.80, use windowChanged(WId, NET::Properties, NET::Properties2); 1025 **/ 1026 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 80, "Use KWindowSystem::windowChanged(WId, NET::Properties, NET::Properties2)") 1027 void windowChanged(WId id); // clazy:exclude=overloaded-signal 1028 #endif 1029 1030 /** 1031 * The state of showing the desktop has changed. 1032 */ 1033 void showingDesktopChanged(bool showing); 1034 1035 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 101) 1036 /** 1037 * Compositing was enabled or disabled. 1038 * 1039 * Note that this signal may be emitted before any compositing plugins 1040 * have been initialized in the window manager. 1041 * 1042 * If you need to check if a specific compositing plugin such as the 1043 * blur effect is enabled, you should track that separately rather 1044 * than test for it in a slot connected to this signal. 1045 * 1046 * @since 4.7.1 1047 * @deprecated since 5.101, use KX11Extras::compositingChanged() 1048 */ 1049 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 101, "Use KX11Extras::compositingChanged()") 1050 void compositingChanged(bool enabled); 1051 #endif 1052 1053 /** 1054 * Activation @p token to pass to the client. 1055 * 1056 * @see requestXdgActivationToken 1057 * @see setCurrentXdgActivationToken 1058 * @since 5.83 1059 */ 1060 void xdgActivationTokenArrived(int serial, const QString &token); 1061 1062 protected: 1063 void connectNotify(const QMetaMethod &signal) override; 1064 1065 private: 1066 friend class KWindowSystemStaticContainer; 1067 friend class KX11Extras; 1068 1069 KWindowSystem() 1070 { 1071 } 1072 static KWindowSystemPrivate *d_func(); 1073 }; 1074 1075 #endif