1 //===========================================================================
3 // This file is part of the KDE project
5 // Copyright 1999 Martin R. Jones <mjones@kde.org>
14 #include <QDBusContext>
15 #include <QDBusMessage>
17 #include "xautolock.h"
18 #include "xautolock_c.h"
20 class ScreenSaverRequest
24 // QString reasongiven;
27 enum { Inhibit
,Throttle
} type
;
30 //===========================================================================
32 * Screen saver engine. Handles screensaver window, starting screensaver
33 * hacks, and password entry.
35 class SaverEngine
: public QWidget
, protected QDBusContext
38 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
46 * Lock the screen now even if the screensaver does not lock by default.
51 * Save the screen now. If the user has locking enabled, the screen is locked also.
56 * Start the screensaver in plasma-setup mode.
57 * if plasma is not enabled, this just locks the screen.
62 * Quit the screensaver if it is running
67 * Simulate user activity
69 void SimulateUserActivity();
72 * Return true if the screensaver is enabled
77 * Enable/disable the screensaver
78 * @return true if the action succeeded
80 bool enable( bool e
, bool force
= false );
83 * Return true if the screen is currently blanked
88 * Read and apply configuration.
93 * Called by krunner_lock when locking is in effect.
95 void saverLockReady();
98 * Request a change in the state of the screensaver.
99 * Set to TRUE to request that the screensaver activate.
100 * Active means that the screensaver has blanked the
101 * screen and may run a graphical theme. This does
102 * not necessary mean that the screen is locked.
104 bool SetActive( bool state
);
106 /// Returns the value of the current state of activity (See setActive)
110 * Returns the number of seconds that the screensaver has
111 * been active. Returns zero if the screensaver is not active.
113 uint
GetActiveTime();
116 * Returns the number of seconds that the session has
117 * been idle. Returns zero if the session is not idle.
119 uint
GetSessionIdleTime();
122 * Request that saving the screen due to system idleness
123 * be blocked until UnInhibit is called or the
124 * calling process exits.
125 * The cookie is a random number used to identify the request
127 uint
Inhibit(const QString
&application_name
, const QString
&reason_for_inhibit
);
128 /// Cancel a previous call to Inhibit() identified by the cookie.
129 void UnInhibit(uint cookie
);
132 * Request that running themes while the screensaver is active
133 * be blocked until UnThrottle is called or the
134 * calling process exits.
135 * The cookie is a random number used to identify the request
137 uint
Throttle(const QString
&application_name
, const QString
&reason_for_inhibit
);
138 /// Cancel a previous call to Throttle() identified by the cookie.
139 void UnThrottle(uint cookie
);
143 void ActiveChanged(bool state
);
147 void lockProcessExited();
148 void serviceOwnerChanged(const QString
&, const QString
&, const QString
&);
151 enum LockType
{ DontLock
, DefaultLock
, ForceLock
, PlasmaSetup
};
152 bool startLockProcess( LockType lock_type
);
153 void stopLockProcess();
154 bool handleKeyPress(XKeyEvent
*xke
);
155 void processLockTransactions();
156 xautolock_corner_t
applyManualSettings(int);
159 enum State
{ Waiting
, Preparing
, Saving
};
162 XAutoLock
*mXAutoLock
;
163 KProcess mLockProcess
;
165 // the original X screensaver parameters
171 time_t m_actived_time
;
172 QList
<ScreenSaverRequest
> m_requests
;
178 QList
<QDBusMessage
> mLockTransactions
;