1 //===========================================================================
3 // This file is part of the KDE project
5 // Copyright (c) 1999 Martin R. Jones <mjones@kde.org>
8 #ifndef __SAVERENGINE_H__
9 #define __SAVERENGINE_H__
12 #include <k3process.h>
14 #include <QDBusConnection>
16 #include "xautolock.h"
17 #include "xautolock_c.h"
19 class ScreenSaverRequest
26 enum { Inhibit
,Throttle
} type
;
29 //===========================================================================
31 * Screen saver engine. Handles screensaver window, starting screensaver
32 * hacks, and password entry.
34 class SaverEngine
: public QWidget
37 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
45 * Lock the screen now even if the screensaver does not lock by default.
50 * Save the screen now. If the user has locking enabled, the screen is locked also.
55 * Quit the screensaver if it is running
60 * Simulate user activity
62 void SimulateUserActivity();
65 * Return true if the screensaver is enabled
70 * Enable/disable the screensaver
71 * @return true if the action succeeded
73 bool enable( bool e
);
76 * Return true if the screen is currently blanked
81 * Read and apply configuration.
86 * Called by krunner_lock when locking is in effect.
88 void saverLockReady();
91 * Request a change in the state of the screensaver.
92 * Set to TRUE to request that the screensaver activate.
93 * Active means that the screensaver has blanked the
94 * screen and may run a graphical theme. This does
95 * not necessary mean that the screen is locked.
97 bool SetActive( bool state
);
99 /// Returns the value of the current state of activity (See setActive)
103 * Returns the number of seconds that the screensaver has
104 * been active. Returns zero if the screensaver is not active.
106 uint
GetActiveTime();
108 /// Returns the value of the current state of session idleness.
109 bool GetSessionIdle();
112 * Returns the number of seconds that the session has
113 * been idle. Returns zero if the session is not idle.
115 uint
GetSessionIdleTime();
118 * Request that saving the screen due to system idleness
119 * be blocked until UnInhibit is called or the
120 * calling process exits.
121 * The cookie is a random number used to identify the request
123 uint
Inhibit(const QString
&application_name
, const QString
&reason_for_inhibit
);
124 /// Cancel a previous call to Inhibit() identified by the cookie.
125 void UnInhibit(uint cookie
);
128 * Request that running themes while the screensaver is active
129 * be blocked until UnThrottle is called or the
130 * calling process exits.
131 * The cookie is a random number used to identify the request
133 uint
Throttle(const QString
&application_name
, const QString
&reason_for_inhibit
);
134 /// Cancel a previous call to Throttle() identified by the cookie.
135 void UnThrottle(uint cookie
);
139 void ActiveChanged(bool state
);
143 void lockProcessExited();
144 void serviceOwnerChanged(const QString
&,const QString
&,const QString
&);
147 enum LockType
{ DontLock
, DefaultLock
, ForceLock
};
148 bool startLockProcess( LockType lock_type
);
149 void stopLockProcess();
150 bool handleKeyPress(XKeyEvent
*xke
);
151 void processLockTransactions();
152 xautolock_corner_t
applyManualSettings(int);
155 enum State
{ Waiting
, Preparing
, Saving
};
160 XAutoLock
*mXAutoLock
;
161 K3Process mLockProcess
;
164 // the original X screensaver parameters
170 time_t m_actived_time
;
171 QDBusConnection screensaverService
;
172 QList
<ScreenSaverRequest
> m_requests
;
178 // QVector< DCOPClientTransaction* > mLockTransactions;