2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-07-02 09:35:16 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2021-03-10 16:08:30 +00:00
|
|
|
#pragma once
|
2015-07-02 09:35:16 +00:00
|
|
|
|
2020-07-24 17:19:19 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
#include <KWaylandServer/kwaylandserver_export.h>
|
2020-07-24 17:19:19 +00:00
|
|
|
|
|
|
|
struct wl_resource;
|
2015-07-02 09:35:16 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2015-07-02 09:35:16 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
class Display;
|
2020-07-24 17:19:19 +00:00
|
|
|
class IdleInterfacePrivate;
|
2015-07-02 09:35:16 +00:00
|
|
|
|
2015-09-10 11:36:42 +00:00
|
|
|
/**
|
|
|
|
* @brief Global representing the org_kde_kwin_idle interface.
|
|
|
|
*
|
|
|
|
* The IdleInterface allows to register callbacks which are invoked if there has
|
|
|
|
* not been any user activity (no input) for a specified time span on a seat.
|
|
|
|
*
|
|
|
|
* A client can bind an idle timeout for a SeatInterface and through that register
|
|
|
|
* an idle timeout. The complete interaction is handled internally, thus the API
|
|
|
|
* user only needs to create the IdleInterface in order to provide this feature.
|
|
|
|
*
|
|
|
|
* This interface is useful for clients as it allows them to perform power management,
|
|
|
|
* chat applications might want to set to away after no user input for some time, etc.
|
|
|
|
*
|
|
|
|
* Of course this exposes the global input usage to all clients. Normally clients don't
|
|
|
|
* know whether the input devices are used, only if their surfaces have focus. With this
|
|
|
|
* interface it is possible to notice that there are input events. A server should consider
|
|
|
|
* this to decide whether it wants to provide this feature!
|
|
|
|
**/
|
2020-07-24 17:19:19 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT IdleInterface : public QObject
|
2015-07-02 09:35:16 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-12-09 20:13:19 +00:00
|
|
|
|
2015-07-02 09:35:16 +00:00
|
|
|
public:
|
2020-12-09 20:13:19 +00:00
|
|
|
explicit IdleInterface(Display *display, QObject *parent = nullptr);
|
2020-07-24 17:19:19 +00:00
|
|
|
~IdleInterface() override;
|
2015-07-02 09:35:16 +00:00
|
|
|
|
2017-10-20 14:33:17 +00:00
|
|
|
/**
|
|
|
|
* Inhibits the IdleInterface. While inhibited no IdleTimeoutInterface interface gets
|
|
|
|
* notified about an idle timeout.
|
|
|
|
*
|
|
|
|
* This can be used to inhibit power management, screen locking, etc. directly from
|
|
|
|
* Compositor side.
|
|
|
|
*
|
|
|
|
* To resume idle timeouts invoke @link{uninhibit}. It is possible to invoke inhibit several
|
|
|
|
* times, in that case uninhibit needs to called the same amount as inhibit has been called.
|
|
|
|
* @see uninhibit
|
|
|
|
* @see isInhibited
|
|
|
|
* @see inhibitedChanged
|
|
|
|
**/
|
|
|
|
void inhibit();
|
|
|
|
|
|
|
|
/**
|
2018-09-12 17:49:38 +00:00
|
|
|
* Inhibits the IdleInterface. The idle timeouts are only restarted if uninhibit has been
|
2017-10-20 14:33:17 +00:00
|
|
|
* called the same amount as inhibit.
|
|
|
|
*
|
|
|
|
* @see inhibit
|
|
|
|
* @see isInhibited
|
|
|
|
* @see inhibitedChanged
|
|
|
|
**/
|
|
|
|
void uninhibit();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns Whether idle timeouts are currently inhibited
|
|
|
|
* @see inhibit
|
|
|
|
* @see uninhibit
|
|
|
|
* @see inhibitedChanged
|
|
|
|
**/
|
|
|
|
bool isInhibited() const;
|
|
|
|
|
2017-12-26 19:20:39 +00:00
|
|
|
/**
|
|
|
|
* Calling this method allows the Compositor to simulate user activity.
|
|
|
|
* This means the same action is performed as if the user interacted with
|
|
|
|
* an input device on the SeatInterface.
|
|
|
|
* Idle timeouts are resumed and the idle time gets restarted.
|
|
|
|
**/
|
|
|
|
void simulateUserActivity();
|
|
|
|
|
2017-10-20 14:33:17 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* Emitted when the system gets inhibited or uninhibited.
|
|
|
|
* @see inhibit
|
|
|
|
* @see uninhibit
|
|
|
|
* @see isInhibited
|
|
|
|
**/
|
|
|
|
void inhibitedChanged();
|
|
|
|
|
2015-07-02 09:35:16 +00:00
|
|
|
private:
|
2020-07-24 17:19:19 +00:00
|
|
|
QScopedPointer<IdleInterfacePrivate> d;
|
2015-07-02 09:35:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|