KWaylandServer

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 #pragma once
7 
8 #include <QObject>
9 
10 #include <KWaylandServer/kwaylandserver_export.h>
11 
12 struct wl_resource;
13 
14 namespace KWaylandServer
15 {
16 class Display;
17 class IdleInterfacePrivate;
18 
19 /**
20  * @brief Global representing the org_kde_kwin_idle interface.
21  *
22  * The IdleInterface allows to register callbacks which are invoked if there has
23  * not been any user activity (no input) for a specified time span on a seat.
24  *
25  * A client can bind an idle timeout for a SeatInterface and through that register
26  * an idle timeout. The complete interaction is handled internally, thus the API
27  * user only needs to create the IdleInterface in order to provide this feature.
28  *
29  * This interface is useful for clients as it allows them to perform power management,
30  * chat applications might want to set to away after no user input for some time, etc.
31  *
32  * Of course this exposes the global input usage to all clients. Normally clients don't
33  * know whether the input devices are used, only if their surfaces have focus. With this
34  * interface it is possible to notice that there are input events. A server should consider
35  * this to decide whether it wants to provide this feature!
36  */
37 class KWAYLANDSERVER_EXPORT IdleInterface : public QObject
38 {
39  Q_OBJECT
40 
41 public:
42  explicit IdleInterface(Display *display, QObject *parent = nullptr);
43  ~IdleInterface() override;
44 
45  /**
46  * Inhibits the IdleInterface. While inhibited no IdleTimeoutInterface interface gets
47  * notified about an idle timeout.
48  *
49  * This can be used to inhibit power management, screen locking, etc. directly from
50  * Compositor side.
51  *
52  * To resume idle timeouts invoke @link{uninhibit}. It is possible to invoke inhibit several
53  * times, in that case uninhibit needs to called the same amount as inhibit has been called.
54  * @see uninhibit
55  * @see isInhibited
56  * @see inhibitedChanged
57  */
58  void inhibit();
59 
60  /**
61  * Inhibits the IdleInterface. The idle timeouts are only restarted if uninhibit has been
62  * called the same amount as inhibit.
63  *
64  * @see inhibit
65  * @see isInhibited
66  * @see inhibitedChanged
67  */
68  void uninhibit();
69 
70  /**
71  * @returns Whether idle timeouts are currently inhibited
72  * @see inhibit
73  * @see uninhibit
74  * @see inhibitedChanged
75  */
76  bool isInhibited() const;
77 
78  /**
79  * Calling this method allows the Compositor to simulate user activity.
80  * This means the same action is performed as if the user interacted with
81  * an input device on the SeatInterface.
82  * Idle timeouts are resumed and the idle time gets restarted.
83  */
84  void simulateUserActivity();
85 
86 Q_SIGNALS:
87  /**
88  * Emitted when the system gets inhibited or uninhibited.
89  * @see inhibit
90  * @see uninhibit
91  * @see isInhibited
92  */
93  void inhibitedChanged();
94 
95 private:
97 };
98 
99 }
Class holding the Wayland server display loop.
Definition: display.h:47
Global representing the org_kde_kwin_idle interface.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.