kwin/src/idledetector.h
Vlad Zahorodnii 40fb202aed Make IdleDetector not emit resumed signal when it's inhibited
At the moment, when an IdleDetector is inhibited, it can emit the
resumed signal. It makes sense on one hand, but also it doesn't.
Inhibited != resumed.

According to the idle-inhibit-v1 protocol specification, we don't
need to emit the resumed signal:

> Likewise, the inhibitor isn't honored if the system was already idled at
> the time the inhibitor was established, although if the system later
> de-idles and re-idles the inhibitor will take effect.
2022-07-05 20:36:04 +00:00

42 lines
702 B
C++

/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <kwin_export.h>
#include <QTimer>
namespace KWin
{
class KWIN_EXPORT IdleDetector : public QObject
{
Q_OBJECT
public:
explicit IdleDetector(std::chrono::milliseconds timeout, QObject *parent = nullptr);
~IdleDetector() override;
void activity();
bool isInhibited() const;
void setInhibited(bool inhibited);
Q_SIGNALS:
void idle();
void resumed();
private:
void markAsIdle();
void markAsResumed();
QTimer *m_timer;
bool m_isIdle = false;
bool m_isInhibited = false;
};
} // namespace KWin