forked from KDE/kscreenlocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathksldapp.h
204 lines (169 loc) · 5.12 KB
/
ksldapp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/********************************************************************
KSld - the KDE Screenlocker Daemon
This file is part of the KDE project.
Copyright 1999 Martin R. Jones <[email protected]>
Copyright 2003 Oswald Buddenhagen <[email protected]>
Copyright 2008 Chani Armitage <[email protected]>
Copyright (C) 2011 Martin Gräßlin <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef SCREENLOCKER_KSLDAPP_H
#define SCREENLOCKER_KSLDAPP_H
#include <QElapsedTimer>
#include <QProcessEnvironment>
#include <KScreenLocker/kscreenlocker_export.h>
// forward declarations
class GlobalAccel;
class LogindIntegration;
class QTimer;
class KSldTest;
class PowerManagementInhibition;
namespace KWayland
{
namespace Server {
class Display;
class ClientConnection;
}
}
namespace ScreenLocker
{
enum class EstablishLock {
Immediate, ///Require password from the start. Use if invoked explicitly by the user
Delayed, ///Allow the user to log back in without a password for a configured grace time.
DefaultToSwitchUser ///UI should default to showing the "switch user dialog"
};
class AbstractLocker;
class WaylandServer;
class KSCREENLOCKER_EXPORT KSldApp : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.ksld.App")
Q_ENUMS(LockState)
public:
enum LockState {
Unlocked,
AcquiringLock,
Locked
};
static KSldApp* self();
explicit KSldApp(QObject * parent = nullptr);
~KSldApp() override;
LockState lockState() const {
return m_lockState;
}
/**
* @returns the number of milliseconds passed since the screen has been locked.
**/
uint activeTime() const;
void configure();
bool isGraceTime() const;
void setWaylandDisplay(KWayland::Server::Display *display);
KWayland::Server::ClientConnection *greeterClientConnection() const {
return m_greeterClientConnection;
}
void setGreeterEnvironment(const QProcessEnvironment &env);
/**
* Can be used by the lock window to remove the lock during grace time.
**/
void unlock();
void inhibit();
void uninhibit();
void lock(EstablishLock establishLock, int attemptCount = 0);
void initialize();
bool event(QEvent *event) override;
/**
* For testing
* @internal
**/
int idleId() const {
return m_idleId;
}
/**
* For testing
* @internal
**/
void setIdleId(int idleId) {
m_idleId = idleId;
}
/**
* For testing
* @internal
**/
void setGraceTime(int msec) {
m_lockGrace = msec;
}
bool forceSoftwareRendering() const {
return m_forceSoftwareRendering;
}
void setForceSoftwareRendering(bool force) {
m_forceSoftwareRendering = force;
}
Q_SIGNALS:
void aboutToLock();
void locked();
void unlocked();
void greeterClientConnectionChanged();
void lockStateChanged();
private Q_SLOTS:
void cleanUp();
void endGraceTime();
void solidSuspend();
public Q_SLOTS:
void lockScreenShown();
private:
void initializeX11();
bool establishGrab();
void startLockProcess(EstablishLock establishLock);
void showLockWindow();
void hideLockWindow();
void doUnlock();
bool isFdoPowerInhibited() const;
LockState m_lockState;
QProcess *m_lockProcess;
AbstractLocker *m_lockWindow;
WaylandServer *m_waylandServer;
KWayland::Server::Display *m_waylandDisplay;
KWayland::Server::ClientConnection *m_greeterClientConnection;
/**
* Timer to measure how long the screen is locked.
* This information is required by DBus Interface.
**/
QElapsedTimer m_lockedTimer;
int m_idleId;
/**
* Number of milliseconds after locking in which user activity will result in screen being
* unlocked without requiring a password.
**/
int m_lockGrace;
/**
* Controls whether user activity may remove the lock. Only enabled after idle timeout.
**/
bool m_inGraceTime;
/**
* Grace time ends when timer expires.
**/
QTimer *m_graceTimer;
int m_inhibitCounter;
LogindIntegration *m_logind;
GlobalAccel *m_globalAccel = nullptr;
bool m_hasXInput2 = false;
bool m_forceSoftwareRendering = false;
bool m_isX11;
bool m_isWayland;
int m_greeterCrashedCounter = 0;
QProcessEnvironment m_greeterEnv;
PowerManagementInhibition *m_powerManagementInhibition;
// for auto tests
friend KSldTest;
};
} // namespace
#endif // SCREENLOCKER_KSLDAPP_H