1 /*
2     This file is part of the KDE libraries
3     SPDX-FileCopyrightText: 1999 Matthias Ettrich <ettrich@kde.org>
4     SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org>
5 
6     SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8 /*
9  * kwindowsystem.h. Part of the KDE project.
10  */
11 
12 #ifndef KWINDOWSYSTEM_H
13 #define KWINDOWSYSTEM_H
14 
15 #include <QObject>
16 #include <QWidgetList> //For WId
17 #include <kwindowinfo.h>
18 #include <kwindowsystem_export.h>
19 #include <netwm_def.h>
20 
21 class KWindowSystemPrivate;
22 class NETWinInfo;
23 
24 /**
25  *
26  * Convenience access to certain properties and features of the
27  * window manager.
28  *
29  * The class KWindowSystem provides information about the state of the
30  * window manager and allows asking the window manager to change them
31  * using a more high-level interface than the NETWinInfo/NETRootInfo
32  * lowlevel classes.
33  *
34  * Because of limitations of the way Qt is implemented on Mac OSX, the WId's
35  * returned by methods in this class are not compatible with those expected
36  * by other Qt methods. So while it should be fine to pass WId's retrieved by
37  * for example calling the winId method on a QWidget to methods in this class
38  * the reverse is not true. You should never pass a WId obtained from this class
39  * to a Qt method accepting a WId parameter.
40  *
41  * @short Class for interaction with the window manager.
42  * @author Matthias Ettrich (ettrich@kde.org)
43  */
44 class KWINDOWSYSTEM_EXPORT KWindowSystem : public QObject, public NET
45 {
46     Q_OBJECT
47     Q_PROPERTY(bool isPlatformWayland READ isPlatformWayland CONSTANT)
48     Q_PROPERTY(bool isPlatformX11 READ isPlatformX11 CONSTANT)
49 
50 public:
51     /**
52      * Access to the singleton instance. Useful mainly for connecting to signals.
53      */
54     static KWindowSystem *self();
55 
56     /**
57      * Returns the list of all toplevel windows currently managed by the
58      * window manager in the order of creation. Please do not rely on
59      * indexes of this list: Whenever you enter Qt's event loop in your
60      * application, it may happen that entries are removed or added.
61      * Your module should perhaps work on a copy of this list and verify a
62      * window with hasWId() before any operations.
63      *
64      * Iteration over this list can be done easily with
65      * \code
66      *  QList<WId> windows = KWindowSystem::windows();
67      *  for (auto it = windows.cbegin(), end = windows.cend(); it != end; ++it) {
68      *     ... do something here,  (*it) is the current WId.
69      *  }
70      * \endcode
71      * @return the list of all toplevel windows
72      */
73     static QList<WId> windows();
74 
75     /**
76      * Test to see if @p id still managed at present.
77      * @param id the window id to test
78      * @return true if the window id is still managed
79      **/
80     static bool hasWId(WId id);
81 
82 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
83     /**
84      * Returns information about window @p win. It is recommended to check
85      * whether the returned info is valid by calling the valid() method.
86      * @param win the id of the window
87      * @param properties all properties that should be retrieved (see NET::Property
88      *    enum for details). Unlisted properties cause related information to be invalid
89      *    in the returned data, but make this function faster when not all data is needed.
90      * @param properties2 additional properties (see NET::Property2 enum)
91      * @return the window information
92      * @deprecated Since 5.0, use KWindowInfo directly
93      */
94     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowInfo(WId, NET::Properties, NET::Properties2")
95     static KWindowInfo windowInfo(WId win, NET::Properties properties, NET::Properties2 properties2 = NET::Properties2());
96 #endif
97 
98     /**
99      * Returns the list of all toplevel windows currently managed by the
100      * window manager in the current stacking order (from lower to
101      * higher). May be useful for pagers.
102      * @return the list of all toplevel windows in stacking order
103      */
104     static QList<WId> stackingOrder();
105 
106     /**
107      * Returns the currently active window, or 0 if no window is active.
108      * @return the window id of the active window, or 0 if no window is
109      *  active
110      **/
111     static WId activeWindow();
112 
113     /**
114      * Requests that window @p win is activated.
115      *
116      * There are two ways how to activate a window, by calling
117      * activateWindow() and forceActiveWindow(). Generally,
118      * applications shouldn't make attempts to explicitly activate
119      * their windows, and instead let the user to activate them.
120      * In the special cases where this may be needed, applications
121      * should use activateWindow(). Window manager may consider whether
122      * this request wouldn't result in focus stealing, which
123      * would be obtrusive, and may refuse the request.
124      *
125      * The usage of forceActiveWindow() is meant only for pagers
126      * and similar tools, which represent direct user actions
127      * related to window manipulation.
128      * Except for rare cases, this request will be always honored,
129      * and normal applications are forbidden to use it.
130      *
131      * In case of problems, consult the KWin README in the kdebase
132      * package (kdebase/kwin/README), or ask on the kwin@kde.org
133      * mailing list.
134      *
135      * @param win the id of the window to make active
136      * @param time X server timestamp of the user activity that
137      *    caused this request
138      */
139     static void activateWindow(WId win, long time = 0);
140 
141     /**
142      * Requests that window @p win is activated.
143      *
144      * There are two ways how to activate a window, by calling
145      * activateWindow() and forceActiveWindow(). Generally,
146      * applications shouldn't make attempts to explicitly activate
147      * their windows, and instead let the user to activate them.
148      * In the special cases where this may be needed, applications
149      * should use activateWindow(). Window manager may consider whether
150      * this request wouldn't result in focus stealing, which
151      * would be obtrusive, and may refuse the request.
152      *
153      * The usage of forceActiveWindow() is meant only for pagers
154      * and similar tools, which represent direct user actions
155      * related to window manipulation.
156      * Except for rare cases, this request will be always honored,
157      * and normal applications are forbidden to use it.
158      *
159      * In case of problems, consult the KWin README in the kdebase
160      * package (kdebase/kwin/README), or ask on the kwin@kde.org
161      * mailing list.
162      *
163      * @param window the window to make active
164      * @param time X server timestamp of the user activity that
165      *    caused this request
166      */
167     Q_INVOKABLE static void activateWindow(QWindow *window, long time = 0);
168 
169     /**
170      * Sets window @p win to be the active window. Note that this
171      * should be called only in special cases, applications
172      * shouldn't force themselves or other windows to be the active
173      * window. Generally, this call should used only by pagers
174      * and similar tools. See the explanation in description
175      * of activateWindow().
176      *
177      * @param win the id of the window to make active
178      * @param time X server timestamp of the user activity that
179      *    caused this request
180      */
181     static void forceActiveWindow(WId win, long time = 0);
182 
183     /**
184      * When application finishes some operation and wants to notify
185      * the user about it, it can call demandAttention(). Instead
186      * of activating the window, which could be obtrusive, the window
187      * will be marked specially as demanding user's attention.
188      * See also explanation in description of activateWindow().
189      *
190      * Note that it's usually better to use KNotifyClient.
191      */
192     static void demandAttention(WId win, bool set = true);
193 
194     /**
195      * Returns true if a compositing manager is running (i.e. ARGB windows
196      * are supported, effects will be provided, etc.).
197      */
198     static bool compositingActive();
199 
200     /**
201      * Returns the current virtual desktop.
202      * @return the current virtual desktop
203      **/
204     static int currentDesktop();
205 
206     /**
207      * Returns the number of virtual desktops.
208      * @return the number of virtual desktops
209      **/
210     static int numberOfDesktops();
211 
212     /**
213      * Convenience function to set the current desktop to @p desktop.
214      * See NETRootInfo.
215      * @param desktop the number of the new desktop
216      */
217     static void setCurrentDesktop(int desktop);
218 
219     /**
220      * Sets window @p win to be present on all virtual desktops if @p
221      * is true. Otherwise the window lives only on one single desktop.
222      *
223      * @param win the id of the window
224      * @param b true to show the window on all desktops, false
225      *          otherwise
226      */
227     static void setOnAllDesktops(WId win, bool b);
228 
229     /**
230      * Moves window @p win to desktop @p desktop.
231      *
232      * @param win the id of the window
233      * @param desktop the number of the new desktop
234      */
235     static void setOnDesktop(WId win, int desktop);
236 
237     /**
238      * Moves window @p win to activities @p activities.
239      *
240      * @param win the id of the window
241      * @param activities the list of activity UUIDs
242      *
243      * @since 5.1
244      * @see KWindowInfo::activities
245      */
246     static void setOnActivities(WId win, const QStringList &activities);
247 
248     /**
249      * Sets the parent window of @p subwindow to be @p mainwindow.
250      * This overrides the parent set the usual way as the QWidget or QWindow parent,
251      * but only for the window manager - e.g. stacking order and window grouping
252      * will be affected, but features like automatic deletion of children
253      * when the parent is deleted are unaffected and normally use
254      * the QObject parent.
255      *
256      * This function should be used before a dialog is shown for a window
257      * that belongs to another application.
258      */
259     static void setMainWindow(QWindow *subwindow, WId mainwindow);
260 
261 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 62)
262     /**
263      * Sets the parent window of @p subwindow to be @p mainwindow.
264      * This overrides the parent set the usual way as the QWidget parent,
265      * but only for the window manager - e.g. stacking order and window grouping
266      * will be affected, but features like automatic deletion of children
267      * when the parent is deleted are unaffected and normally use
268      * the QWidget parent.
269      *
270      * This function should be used before a dialog is shown for a window
271      * that belongs to another application.
272      * @deprecated since 5.62, use setMainWindow(QWindow *). If all you have is a QWidget*,
273      * you might need to call setAttribute(Qt::WA_NativeWindow, true); before calling
274      * >window()->windowHandle().
275      */
276     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 62, "Use KWindowSystem::setMainWindow(QWindow *)")
277     static void setMainWindow(QWidget *subwindow, WId mainwindow);
278 #endif
279 
280 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
281     /**
282      * Returns the WM_TRANSIENT_FOR property for the given window, i.e. the mainwindow
283      * for this window.
284      *
285      * @param window the id of the window
286      * @deprecated Since 5.0, use KWindowInfo::transientFor
287      */
288     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowInfo::transientFor()")
289     static WId transientFor(WId window);
290 
291     /**
292      * Returns the leader window for the group the given window is in, if any.
293      * @param window the id of the window
294      * @deprecated Since 5.0, use KWindowInfo::groupLeader
295      */
296     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowInfo::groupLeader()")
297     static WId groupLeader(WId window);
298 #endif
299     /**
300      * Returns an icon for window @p win.
301      *
302      * If  @p width and @p height are specified, the best icon for the requested
303      * size is returned.
304      *
305      * If @p scale is true, the icon is smooth-scaled to have exactly
306      * the requested size.
307      *
308      * @param win the id of the window
309      * @param width the desired width, or -1
310      * @param height the desired height, or -1
311      * @param scale if true the icon will be scaled to the desired size. Otherwise the
312      *        icon will not be modified.
313      * @return the icon of the window
314      */
315     static QPixmap icon(WId win, int width = -1, int height = -1, bool scale = false);
316 
317     /**
318      * Masks specifying from which sources to read an icon. They are tried from the best
319      * until an icon is found.
320      * @li NETWM from property from the window manager specification
321      * @li WMHints from WMHints property
322      * @li ClassHint load icon after getting name from the classhint
323      * @li XApp load the standard X icon (last fallback)
324      */
325     enum IconSource {
326         NETWM = 1, //!< read from property from the window manager specification
327         WMHints = 2, //!< read from WMHints property
328         ClassHint = 4, //!< load icon after getting name from the classhint
329         XApp = 8, //!< load the standard X icon (last fallback)
330     };
331     /**
332      * @overload
333      *
334      * Overloaded variant that allows specifying from which sources the icon should be read.
335      * You should usually prefer the simpler variant which tries all possibilities to get
336      * an icon.
337      *
338      * @param win the id of the window
339      * @param width the desired width, or -1
340      * @param height the desired height, or -1
341      * @param scale if true the icon will be scaled to the desired size. Otherwise the
342      *        icon will not be modified.
343      * @param flags OR-ed flags from the IconSource enum
344      */
345     static QPixmap icon(WId win, int width, int height, bool scale, int flags);
346 
347     /**
348      * @overload
349      *
350      * Overloaded variant that allows passing in the NETWinInfo to use for reading the
351      * information. This variant is only useful on the X11 platform, other platforms do not
352      * use NETWinInfo and delegate to the variant without NETWinInfo. Though if compiled with
353      * X11 support the X11 variant is used on other platforms if info is not @c nullptr.
354      * This can be used by applications using e.g. platform wayland but also connecting to an
355      * XServer.
356      *
357      * The NETWinInfo must be constructed with property NET::WMIcon in order to use the
358      * IconSource flag NETWM. NET::WM2IconPixmap for IconSource flag WMHints and
359      * NET::WM2WindowClass for IconSource flag ClassHint.
360      *
361      * @param win the id of the window
362      * @param width the desired width, or -1
363      * @param height the desired height, or -1
364      * @param scale if true the icon will be scaled to the desired size. Otherwise the
365      *        icon will not be modified.
366      * @param flags OR-ed flags from the IconSource enum
367      * @param into the NETWinInfo to use for reading properties.
368      * @since 5.7
369      **/
370     static QPixmap icon(WId win, int width, int height, bool scale, int flags, NETWinInfo *info);
371 
372     /**
373      * Sets an @p icon and a  @p miniIcon on window @p win
374      * @param win the id of the window
375      * @param icon the new icon
376      * @param miniIcon the new mini icon
377      */
378     static void setIcons(WId win, const QPixmap &icon, const QPixmap &miniIcon);
379     /**
380      * Sets the type of window @p win to @p windowType.
381      *
382      * @param win the id of the window
383      * @param windowType the type of the window (see NET::WindowType)
384      */
385     static void setType(WId win, NET::WindowType windowType);
386     /**
387      * Sets the state of window @p win to @p state.
388      *
389      * Possible values are or'ed combinations of NET::Modal,
390      * NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded,
391      * NET::SkipTaskbar, NET::SkipPager, NET::Hidden,
392      * NET::FullScreen, NET::KeepAbove, NET::KeepBelow,
393      * NET::SkipSwitcher
394      *
395      * @param win the id of the window
396      * @param state the new flags that will be set
397      */
398     static void setState(WId win, NET::States state);
399 
400     /**
401      * Clears the state of window @p win from @p state.
402      *
403      * Possible values are or'ed combinations of NET::Modal,
404      * NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded,
405      * NET::SkipTaskbar, NET::SkipPager, NET::Hidden,
406      * NET::FullScreen, NET::KeepAbove, NET::KeepBelow,
407      * NET::SkipSwitcher
408      *
409      * @param win the id of the window
410      * @param state the flags that will be cleared
411      */
412     static void clearState(WId win, NET::States state);
413 
414     /**
415      * Minimizes the window with id @p win.
416      * On X11 this follows the protocol described in ICCCM section 4.1.4.
417      *
418      * @param win The window to minimize
419      * @see unminimizeWindow()
420      */
421     static void minimizeWindow(WId win);
422     /**
423      * Unminimizes the window with id @p win.
424      * On X11 this follows the protocol described in ICCCM section 4.1.4.
425      *
426      * @param win The window to unminimize
427      * @see minimizeWindow()
428      **/
429     static void unminimizeWindow(WId win);
430 
431 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
432     /**
433      * @deprecated since 5.0 the @p animation is ignored.
434      */
435     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::minimizeWindow(WId)")
436     static void minimizeWindow(WId win, bool animation);
437 #endif
438 
439 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
440     /**
441      * @deprecated since 5.0 the @p animation is ignored.
442      */
443     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::unminimizeWindow(WId)")
444     static void unminimizeWindow(WId win, bool animation);
445 #endif
446 
447     /**
448      * Raises the given window. This call is only for pagers and similar
449      * tools that represent direct user actions. Applications should not
450      * use it, they should keep using QWidget::raise() or XRaiseWindow()
451      * if necessary.
452      */
453     static void raiseWindow(WId win);
454 
455     /**
456      * Lowers the given window. This call is only for pagers and similar
457      * tools that represent direct user actions. Applications should not
458      * use it, they should keep using QWidget::lower() or XLowerWindow()
459      * if necessary.
460      */
461     static void lowerWindow(WId win);
462 
463     /**
464      * @internal
465      * Returns true if the WM uses IconicState also for windows
466      * on inactive virtual desktops.
467      */
468     static bool icccmCompliantMappingState();
469 
470     /**
471      * Returns the workarea for the specified desktop, or the current
472      * work area if no desktop has been specified.
473      * @param desktop the number of the desktop to check, -1 for the
474      *        current desktop
475      * @return the size and position of the desktop
476      **/
477     static QRect workArea(int desktop = -1);
478 
479     /**
480      * Returns the workarea for the specified desktop, or the current
481      * work area if no desktop has been specified. Excludes struts of
482      * clients in the exclude List.
483      *
484      * @param excludes the list of clients whose struts will be excluded
485      * @param desktop the number of the desktop to check, -1 for the
486      *        current desktop
487      * @return the size and position of the desktop
488      **/
489     static QRect workArea(const QList<WId> &excludes, int desktop = -1);
490 
491     /**
492      * Returns the name of the specified desktop.
493      * @param desktop the number of the desktop
494      * @return the name of the desktop
495      **/
496     static QString desktopName(int desktop);
497 
498     /**
499      * Sets the name of the specified desktop.
500      * @param desktop the number of the desktop
501      * @param name the new name for the desktop
502      **/
503     static void setDesktopName(int desktop, const QString &name);
504 
505     /**
506      * Returns the state of showing the desktop.
507      */
508     static bool showingDesktop();
509 
510     /**
511      * Sets the state of the "showing desktop" mode of the window manager. If on,
512      * windows are hidden and desktop background is shown and focused.
513      *
514      * @param showing if true, the window manager is put in "showing desktop" mode.
515      * If false, the window manager is put out of that mode.
516      *
517      * @since 5.7.0
518      */
519     static void setShowingDesktop(bool showing);
520 
521     /**
522      * Sets user timestamp @p time on window @p win. The timestamp
523      * is expressed as XServer time. If a window
524      * is shown with user timestamp older than the time of the last
525      * user action, it won't be activated after being shown.
526      * The most common case is the special value 0 which means
527      * not to activate the window after being shown.
528      */
529     static void setUserTime(WId win, long time);
530     /**
531      * Sets the strut of window @p win to @p left_width
532      * ranging from @p left_start to @p left_end on the left edge,
533      * and simiarly for the other edges. For not reserving a strut, pass 0 as the width.
534      * E.g. to reserve 10x10 square in the topleft corner, use e.g.
535      * setExtendedStrut( w, 10, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 ).
536      *
537      * @param win the id of the window
538      * @param left_width width of the strut at the left edge
539      * @param left_start starting y coordinate of the strut at the left edge
540      * @param left_end ending y coordinate of the strut at the left edge
541      * @param right_width width of the strut at the right edge
542      * @param right_start starting y coordinate of the strut at the right edge
543      * @param right_end ending y coordinate of the strut at the right edge
544      * @param top_width width of the strut at the top edge
545      * @param top_start starting x coordinate of the strut at the top edge
546      * @param top_end ending x coordinate of the strut at the top edge
547      * @param bottom_width width of the strut at the bottom edge
548      * @param bottom_start starting x coordinate of the strut at the bottom edge
549      * @param bottom_end ending x coordinate of the strut at the bottom edge
550      */
551     static void setExtendedStrut(WId win,
552                                  int left_width,
553                                  int left_start,
554                                  int left_end,
555                                  int right_width,
556                                  int right_start,
557                                  int right_end,
558                                  int top_width,
559                                  int top_start,
560                                  int top_end,
561                                  int bottom_width,
562                                  int bottom_start,
563                                  int bottom_end);
564 
565     /**
566      * Convenience function for setExtendedStrut() that automatically makes struts
567      * as wide/high as the screen width/height.
568      * Sets the strut of window @p win to @p left, @p right, @p top, @p bottom.
569      *
570      * @param win the id of the window
571      * @param left the left strut
572      * @param right the right strut
573      * @param top the top strut
574      * @param bottom the bottom strut
575      */
576     static void setStrut(WId win, int left, int right, int top, int bottom);
577     /**
578      * Returns true if the WM announces which actions it allows for windows.
579      */
580     static bool allowedActionsSupported();
581     /**
582      * Function that reads and returns the contents of the given text
583      * property (WM_NAME, WM_ICON_NAME,...).
584      */
585     static QString readNameProperty(WId window, unsigned long atom);
586 
587     /**
588      * Allows a window from another process to raise and activate itself.
589      * Depending on the window manager, the grant may only be temporary,
590      * or for a single activation, and it may require the current process
591      * to be the "foreground" one" (ie. the process with the input focus).
592      *
593      * You should call this function before executing actions that may trigger
594      * the showing of a window or dialog in another process, e.g. a dbus signal
595      * or function call, or any other inter-process notification mechanism.
596      *
597      * This is mostly used on Windows, where windows are not allowed to be raised
598      * and activated if their process is not the foreground one, but it may also
599      * apply to other window managers.
600      *
601      * @param pid if specified, the grant only applies to windows belonging to the
602      *            specific process. By default, a value of -1 means all processes.
603      */
604     static void allowExternalProcessWindowActivation(int pid = -1);
605 
606     /**
607      * Sets whether the client wishes to block compositing (for better performance)
608      * @since 4.7
609      */
610     static void setBlockingCompositing(WId window, bool active);
611 
612     /**
613      * @internal
614      * Returns true if viewports are mapped to virtual desktops.
615      */
616     static bool mapViewport();
617     /**
618      * @internal
619      * Returns mapped virtual desktop for the given position in the viewport.
620      */
621     static int viewportToDesktop(const QPoint &pos);
622     /**
623      * @internal
624      * Returns mapped virtual desktop for the given window geometry.
625      */
626     static int viewportWindowToDesktop(const QRect &r);
627     /**
628      * @internal
629      * Returns topleft corner of the viewport area for the given mapped virtual desktop.
630      */
631     static QPoint desktopToViewport(int desktop, bool absolute);
632     /**
633      * @internal
634      * @since 4.0.1
635      * Checks the relative difference used to move a window will still be inside
636      * valid desktop area.
637      */
638     static QPoint constrainViewportRelativePosition(const QPoint &pos);
639 
640     /**
641      * Enum describing the windowing system platform used by the QGuiApplication.
642      * @see platform
643      * @since 5.25
644      **/
645     enum class Platform {
646         /**
647          * A platform unknown to the application is used
648          **/
649         Unknown,
650         /**
651          * The xcb/X11 windowing system platorm.
652          **/
653         X11,
654         /**
655          * The Wayland windowing system platform.
656          **/
657         Wayland,
658     };
659     /**
660      * Returns the Platform used by the QGuiApplication.
661      * This method allows to check for the used windowing system in a cheap and reliable way.
662      * The Platform gets resolved the first time the method is invoked and cached for further
663      * usages.
664      * @returns The Platform used by the QGuiApplication.
665      * @since 5.25
666      **/
667     static Platform platform();
668 
669     /**
670      * Convenience method to check whether the Platform is X11.
671      * @see platform
672      * @see isPlatformWayland
673      * @since 5.25
674      **/
675     static bool isPlatformX11();
676 
677     /**
678      * Convenience method to check whether the Platform is Wayland.
679      * @see platform
680      * @see isPlatformX11
681      * @since 5.25
682      **/
683     static bool isPlatformWayland();
684 
685     /**
686      * Requests an xdg_activation_v1 token for a specific window.
687      *
688      * @p win window in behalf this request is made
689      * @p serial of the event that triggered the request
690      * @p app_id identifier of the application that we are launching
691      *
692      * @see currentSerial
693      * @since 5.83
694      */
695     Q_INVOKABLE static void requestXdgActivationToken(QWindow *win, uint32_t serial, const QString &app_id);
696 
697     /**
698      * Sets the @p token that will be used when activateWindow is called next
699      *
700      * @since 5.83
701      */
702     Q_INVOKABLE static void setCurrentXdgActivationToken(const QString &token);
703 
704     /**
705      * Offers the seat's current serial
706      *
707      * This will mostly be useful on wayland sessions.
708      *
709      * @since 5.83
710      */
711     Q_INVOKABLE static quint32 lastInputSerial(QWindow *window);
712 
713 Q_SIGNALS:
714 
715     /**
716      * Switched to another virtual desktop.
717      * @param desktop the number of the new desktop
718      */
719     void currentDesktopChanged(int desktop);
720 
721     /**
722      * A window has been added.
723      * @param id the id of the window
724      */
725     void windowAdded(WId id);
726 
727     /**
728      * A window has been removed.
729      * @param id the id of the window that has been removed
730      */
731     void windowRemoved(WId id);
732 
733     /**
734      * Hint that \<Window> is active (= has focus) now.
735      * @param id the id of the window that is active
736      */
737     void activeWindowChanged(WId id);
738 
739     /**
740      * Desktops have been renamed.
741      */
742     void desktopNamesChanged();
743 
744     /**
745      * The number of desktops changed.
746      * @param num the new number of desktops
747      */
748     void numberOfDesktopsChanged(int num);
749 
750     /**
751      * The workarea has changed.
752      */
753     void workAreaChanged();
754 
755     /**
756      * Something changed with the struts, may or may not have changed
757      * the work area. Usually just using the workAreaChanged() signal
758      * is sufficient.
759      */
760     void strutChanged();
761 
762     /**
763      * Emitted when the stacking order of the window changed. The new order
764      * can be obtained with stackingOrder().
765      */
766     void stackingOrderChanged();
767 
768     /**
769      * The window changed.
770      *
771      * Carries the NET::Properties and NET::Properties2 that were changed.
772      *
773      * @param id the id of the window
774      * @param properties the properties that were modified
775      * @param properties2 the properties2 that were modified
776      *
777      * @since 5.0
778      */
779     void windowChanged(WId id, NET::Properties properties, NET::Properties2 properties2); // clazy:exclude=overloaded-signal
780 
781 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
782     /**
783      * The window changed.
784      *
785      * The properties parameter contains the NET properties that
786      * were modified (see netwm_def.h). First element are NET::Property
787      * values, second element are NET::Property2 values (i.e. the format
788      * is the same like for the NETWinInfo class constructor).
789      * @param id the id of the window
790      * @param properties the properties that were modified
791      *
792      * @deprecated since 5.0 use windowChanged(WId, NET::Properties, NET::Properties2)
793      */
794     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::windowChanged(WId, NET::Properties, NET::Properties2)")
795     QT_MOC_COMPAT void windowChanged(WId id, const unsigned long *properties); // clazy:exclude=overloaded-signal
796 #endif
797 
798 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
799     /**
800      * The window changed.
801      *
802      * The unsigned int parameter contains the NET properties that
803      * were modified (see netwm_def.h).
804      * @param id the id of the window
805      * @param properties the properties that were modified
806      * @deprecated Since 5.0
807      */
808     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KWindowSystem::windowChanged(WId, NET::Properties, NET::Properties2)")
809     QT_MOC_COMPAT void windowChanged(WId id, unsigned int properties); // clazy:exclude=overloaded-signal
810 #endif
811 
812 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 80)
813     /**
814      * The window changed somehow.
815      * @param id the id of the window
816      *
817      * @deprecated since 5.80, use windowChanged(WId, NET::Properties, NET::Properties2);
818      **/
819     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 80, "Use KWindowSystem::windowChanged(WId, NET::Properties, NET::Properties2)")
820     void windowChanged(WId id); // clazy:exclude=overloaded-signal
821 #endif
822 
823     /**
824      * The state of showing the desktop has changed.
825      */
826     void showingDesktopChanged(bool showing);
827 
828     /**
829      * Compositing was enabled or disabled.
830      *
831      * Note that this signal may be emitted before any compositing plugins
832      * have been initialized in the window manager.
833      *
834      * If you need to check if a specific compositing plugin such as the
835      * blur effect is enabled, you should track that separately rather
836      * than test for it in a slot connected to this signal.
837      *
838      * @since 4.7.1
839      */
840     void compositingChanged(bool enabled);
841 
842     /**
843      * Activation @p token to pass to the client.
844      *
845      * @see requestXdgActivationToken
846      * @see setCurrentXdgActivationToken
847      * @since 5.83
848      */
849     void xdgActivationTokenArrived(int serial, const QString &token);
850 
851 protected:
852     void connectNotify(const QMetaMethod &signal) override;
853 
854 private:
855     friend class KWindowSystemStaticContainer;
856 
KWindowSystem()857     KWindowSystem()
858     {
859     }
860     static KWindowSystemPrivate *d_func();
861 };
862 
863 #endif
864