plugins/idletime: Fix processing of user activity
Currently, idle timers are not restarted on user input which triggers the lockscreen even though the user is active at computer. This change fixes that by making sure that idle timers are restarted whenever SeatInterface's timestamp changes, i.e. user moves the pointer or presses a key, etc.
This commit is contained in:
parent
7d692fd2a4
commit
7d3bce21a1
2 changed files with 13 additions and 7 deletions
|
@ -33,6 +33,7 @@ bool KWinIdleTimePoller::isAvailable()
|
|||
bool KWinIdleTimePoller::setUpPoller()
|
||||
{
|
||||
connect(waylandServer()->idle(), &KWaylandServer::IdleInterface::inhibitedChanged, this, &KWinIdleTimePoller::onInhibitedChanged);
|
||||
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::timestampChanged, this, &KWinIdleTimePoller::onTimestampChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -41,6 +42,7 @@ void KWinIdleTimePoller::unloadPoller()
|
|||
{
|
||||
if (waylandServer() && waylandServer()->idle()) {
|
||||
disconnect(waylandServer()->idle(), &KWaylandServer::IdleInterface::inhibitedChanged, this, &KWinIdleTimePoller::onInhibitedChanged);
|
||||
disconnect(waylandServer()->idle(), &KWaylandServer::IdleInterface::timestampChanged, this, &KWinIdleTimePoller::onTimestampChanged);
|
||||
}
|
||||
|
||||
qDeleteAll(m_timeouts);
|
||||
|
@ -70,7 +72,7 @@ void KWinIdleTimePoller::addTimeout(int newTimeout)
|
|||
}
|
||||
}
|
||||
|
||||
void KWinIdleTimePoller::onActivity()
|
||||
void KWinIdleTimePoller::processActivity()
|
||||
{
|
||||
if (m_idling) {
|
||||
Q_EMIT resumingFromIdle();
|
||||
|
@ -96,10 +98,15 @@ void KWinIdleTimePoller::onInhibitedChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void KWinIdleTimePoller::onTimestampChanged()
|
||||
{
|
||||
if (!waylandServer()->idle()->isInhibited()) {
|
||||
processActivity();
|
||||
}
|
||||
}
|
||||
|
||||
void KWinIdleTimePoller::catchIdleEvent()
|
||||
{
|
||||
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::timestampChanged, this, &KWinIdleTimePoller::onActivity);
|
||||
|
||||
for (QTimer *timer : qAsConst(m_timeouts)) {
|
||||
timer->start();
|
||||
}
|
||||
|
@ -107,8 +114,6 @@ void KWinIdleTimePoller::catchIdleEvent()
|
|||
|
||||
void KWinIdleTimePoller::stopCatchingIdleEvents()
|
||||
{
|
||||
disconnect(waylandServer()->seat(), &KWaylandServer::SeatInterface::timestampChanged, this, &KWinIdleTimePoller::onActivity);
|
||||
|
||||
for (QTimer *timer : qAsConst(m_timeouts)) {
|
||||
timer->stop();
|
||||
}
|
||||
|
@ -119,7 +124,7 @@ void KWinIdleTimePoller::simulateUserActivity()
|
|||
if (waylandServer()->idle()->isInhibited()) {
|
||||
return ;
|
||||
}
|
||||
onActivity();
|
||||
processActivity();
|
||||
waylandServer()->simulateUserActivity();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,11 @@ public Q_SLOTS:
|
|||
void simulateUserActivity() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onActivity();
|
||||
void onInhibitedChanged();
|
||||
void onTimestampChanged();
|
||||
|
||||
private:
|
||||
void processActivity();
|
||||
QHash<int, QTimer *> m_timeouts;
|
||||
bool m_idling = false;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue