|
|
@ -37,7 +37,8 @@ extern "C" {
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <tdelocale.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*! The default constructor of the class autosuspend */
|
|
|
|
/*! The default constructor of the class autosuspend */
|
|
|
|
inactivity::inactivity() {
|
|
|
|
inactivity::inactivity(screen *disp) : display(disp),
|
|
|
|
|
|
|
|
prev_screensaver_enabled(false), prev_idle_time(0), correction_value(0) {
|
|
|
|
kdDebugFuncIn(trace);
|
|
|
|
kdDebugFuncIn(trace);
|
|
|
|
|
|
|
|
|
|
|
|
proc = NULL;
|
|
|
|
proc = NULL;
|
|
|
@ -71,7 +72,7 @@ inactivity::~inactivity() {
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* This function start the monitoring of inactivity of user on the X-Server.
|
|
|
|
* This function start the monitoring of inactivity of user on the X-Server.
|
|
|
|
* Here wee set the time for the signal \ref inactivityTimeExpired() and start
|
|
|
|
* Here we set the time for the signal \ref inactivityTimeExpired() and start
|
|
|
|
* the needed TQTimer.
|
|
|
|
* the needed TQTimer.
|
|
|
|
* \param timeToExpire Integer value representing the time of inactivity which need
|
|
|
|
* \param timeToExpire Integer value representing the time of inactivity which need
|
|
|
|
* to elapse befor send signal. The time is in seconds.
|
|
|
|
* to elapse befor send signal. The time is in seconds.
|
|
|
@ -86,6 +87,9 @@ void inactivity::start( int timeToExpire, TQStringList blacked ) {
|
|
|
|
if(timeToExpire > 0 && has_XSC_Extension){
|
|
|
|
if(timeToExpire > 0 && has_XSC_Extension){
|
|
|
|
stop();
|
|
|
|
stop();
|
|
|
|
timeToInactivity = (unsigned long) (timeToExpire * 1000);
|
|
|
|
timeToInactivity = (unsigned long) (timeToExpire * 1000);
|
|
|
|
|
|
|
|
prev_screensaver_enabled = false;
|
|
|
|
|
|
|
|
prev_idle_time = 0;
|
|
|
|
|
|
|
|
correction_value = 0;
|
|
|
|
checkInactivity->start(CHECK_for_INACTIVITY, true);
|
|
|
|
checkInactivity->start(CHECK_for_INACTIVITY, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -198,7 +202,7 @@ unsigned long inactivity::getXInactivity(){
|
|
|
|
if (!mitInfo) mitInfo = XScreenSaverAllocInfo ();
|
|
|
|
if (!mitInfo) mitInfo = XScreenSaverAllocInfo ();
|
|
|
|
XScreenSaverQueryInfo (tqt_xdisplay(), DefaultRootWindow (tqt_xdisplay()), mitInfo);
|
|
|
|
XScreenSaverQueryInfo (tqt_xdisplay(), DefaultRootWindow (tqt_xdisplay()), mitInfo);
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
return workaroundCreepyXServer(mitInfo->idle);
|
|
|
|
return workaroundCreepyXServer(mitInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
@ -219,12 +223,36 @@ unsigned long inactivity::getXInactivity(){
|
|
|
|
* current timeout for this state and add this value to
|
|
|
|
* current timeout for this state and add this value to
|
|
|
|
* the current idle time and return.
|
|
|
|
* the current idle time and return.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \param _idleTime a unsigned long value with the current ideletime fromm
|
|
|
|
* \param _mitInfo a pointer to a structure containing the current XScreenSaver state
|
|
|
|
* XScreenSaverInfo->idle
|
|
|
|
|
|
|
|
* \return a unsigned long with the corrected idletime
|
|
|
|
* \return a unsigned long with the corrected idletime
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
unsigned long inactivity::workaroundCreepyXServer( unsigned long _idleTime ){
|
|
|
|
unsigned long inactivity::workaroundCreepyXServer(XScreenSaverInfo *_mitInfo){
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
|
|
|
|
unsigned long _idleTime = _mitInfo->idle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Detect whether the screensaver has become active since the last time,
|
|
|
|
|
|
|
|
// because the idle time returned by XScreenSaverQueryInfo() is resetted
|
|
|
|
|
|
|
|
// to 0 when the screensaver kicks in. Correct the idle time value if the
|
|
|
|
|
|
|
|
// screensaver is active
|
|
|
|
|
|
|
|
bool screensaver_enabled = false;
|
|
|
|
|
|
|
|
if (display->checkScreenSaverActive())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
screensaver_enabled = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!prev_screensaver_enabled && screensaver_enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
correction_value = prev_idle_time + CHECK_for_INACTIVITY - _idleTime;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_idle_time = _idleTime;
|
|
|
|
|
|
|
|
if (screensaver_enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_idleTime += correction_value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
correction_value = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_screensaver_enabled = screensaver_enabled;
|
|
|
|
|
|
|
|
|
|
|
|
int dummy;
|
|
|
|
int dummy;
|
|
|
|
CARD16 standby, suspend, off;
|
|
|
|
CARD16 standby, suspend, off;
|
|
|
@ -235,6 +263,8 @@ unsigned long inactivity::workaroundCreepyXServer( unsigned long _idleTime ){
|
|
|
|
|
|
|
|
|
|
|
|
kdDebug() << "Current idleTime: " << _idleTime << endl;
|
|
|
|
kdDebug() << "Current idleTime: " << _idleTime << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Idle time is reset when the screensaver kicks in. Need to correct with the right offset
|
|
|
|
|
|
|
|
|
|
|
|
if (DPMSQueryExtension(dpy, &dummy, &dummy)) {
|
|
|
|
if (DPMSQueryExtension(dpy, &dummy, &dummy)) {
|
|
|
|
if (DPMSCapable(dpy)) {
|
|
|
|
if (DPMSCapable(dpy)) {
|
|
|
|
DPMSGetTimeouts(dpy, &standby, &suspend, &off);
|
|
|
|
DPMSGetTimeouts(dpy, &standby, &suspend, &off);
|
|
|
|