KWayland

idle_interface.h
1 /*
2  SPDX-FileCopyrightText: 2015 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef KWAYLAND_SERVER_IDLE_INTERFACE_H
7 #define KWAYLAND_SERVER_IDLE_INTERFACE_H
8 
9 #include "global.h"
10 #include "resource.h"
11 #include <KWayland/Server/kwaylandserver_export.h>
12 
13 namespace KWayland
14 {
15 namespace Server
16 {
17 class Display;
18 class SeatInterface;
19 
20 /**
21  * @brief Global representing the org_kde_kwin_idle interface.
22  *
23  * The IdleInterface allows to register callbacks which are invoked if there has
24  * not been any user activity (no input) for a specified time span on a seat.
25  *
26  * A client can bind an idle timeout for a SeatInterface and through that register
27  * an idle timeout. The complete interaction is handled internally, thus the API
28  * user only needs to create the IdleInterface in order to provide this feature.
29  *
30  * This interface is useful for clients as it allows them to perform power management,
31  * chat applications might want to set to away after no user input for some time, etc.
32  *
33  * Of course this exposes the global input usage to all clients. Normally clients don't
34  * know whether the input devices are used, only if their surfaces have focus. With this
35  * interface it is possible to notice that there are input events. A server should consider
36  * this to decide whether it wants to provide this feature!
37  *
38  * @since 5.4
39  **/
40 class KWAYLANDSERVER_EXPORT IdleInterface : public Global
41 {
42  Q_OBJECT
43 public:
44  virtual ~IdleInterface();
45 
46  /**
47  * Inhibits the IdleInterface. While inhibited no IdleTimeoutInterface interface gets
48  * notified about an idle timeout.
49  *
50  * This can be used to inhibit power management, screen locking, etc. directly from
51  * Compositor side.
52  *
53  * To resume idle timeouts invoke @link{uninhibit}. It is possible to invoke inhibit several
54  * times, in that case uninhibit needs to called the same amount as inhibit has been called.
55  * @see uninhibit
56  * @see isInhibited
57  * @see inhibitedChanged
58  * @since 5.41
59  **/
60  void inhibit();
61 
62  /**
63  * Inhibits the IdleInterface. The idle timeouts are only restarted if uninhibit has been
64  * called the same amount as inhibit.
65  *
66  * @see inhibit
67  * @see isInhibited
68  * @see inhibitedChanged
69  * @since 5.41
70  **/
71  void uninhibit();
72 
73  /**
74  * @returns Whether idle timeouts are currently inhibited
75  * @see inhibit
76  * @see uninhibit
77  * @see inhibitedChanged
78  * @since 5.41
79  **/
80  bool isInhibited() const;
81 
82  /**
83  * Calling this method allows the Compositor to simulate user activity.
84  * This means the same action is performed as if the user interacted with
85  * an input device on the SeatInterface.
86  * Idle timeouts are resumed and the idle time gets restarted.
87  * @since 5.42
88  **/
89  void simulateUserActivity();
90 
91 Q_SIGNALS:
92  /**
93  * Emitted when the system gets inhibited or uninhibited.
94  * @see inhibit
95  * @see uninhibit
96  * @see isInhibited
97  * @since 5.41
98  **/
99  void inhibitedChanged();
100 
101 private:
102  explicit IdleInterface(Display *display, QObject *parent = nullptr);
103  friend class Display;
104  class Private;
105  Private *d_func() const;
106 };
107 
108 // TODO: KF6 make private class
109 class KWAYLANDSERVER_EXPORT IdleTimeoutInterface : public Resource
110 {
111  Q_OBJECT
112 public:
113  virtual ~IdleTimeoutInterface();
114 
115 private:
116  explicit IdleTimeoutInterface(SeatInterface *seat, IdleInterface *parent, wl_resource *parentResource);
117  friend class IdleInterface;
118  class Private;
119  Private *d_func() const;
120 };
121 
122 }
123 }
124 
125 #endif
Represents a Seat on the Wayland Display.
Class holding the Wayland server display loop.
Definition: display.h:88
Base class for all Globals.
Definition: global.h:46
Global representing the org_kde_kwin_idle interface.
Represents a bound Resource.
Definition: resource.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu May 6 2021 22:49:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.