[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/krunner
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2009-01-26 15:17:23
Message-ID: 1232983043.405217.9993.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 916963 by lunakl:

Clean up usage of internal X screensaver (its idle counter, mainly).
We always disable the internal X screensaver and only use its idle counter
(which keeps counting regardless) and we only use it to detect user
activity (not to measure the time). We also don't play with the counter,
as that affects also DPMS.
Fixes DPMS not activating.



 M  +0 -1      lock/lockprocess.cc  
 M  +8 -2      screensaver/saverengine.cpp  
 M  +15 -10    screensaver/xautolock.cpp  


--- trunk/KDE/kdebase/workspace/krunner/lock/lockprocess.cc #916962:916963
@@ -1103,7 +1103,6 @@
         return; // no resuming with dialog visible or when not visible
     if( mSuspended && mHackProc.state() == QProcess::Running )
     {
-        XForceScreenSaver(QX11Info::display(), ScreenSaverReset );
         QPainter p( this );
         p.drawPixmap( 0, 0, mSavedScreen );
         p.end();
--- trunk/KDE/kdebase/workspace/krunner/screensaver/saverengine.cpp #916962:916963
@@ -46,7 +46,11 @@
     // Save X screensaver parameters
     XGetScreenSaver(QX11Info::display(), &mXTimeout, &mXInterval,
                     &mXBlanking, &mXExposures);
-    // ... and disable it
+    // And disable it. The internal X screensaver is not used at all, but we use its
+    // internal idle timer (and it is also used by DPMS support in X). This timer \
must not +    // be altered by this code, since e.g. resetting the counter after \
activating our +    // screensaver would prevent DPMS from activating. We use the \
timer merely to detect +    // user activity.
     XSetScreenSaver(QX11Info::display(), 0, mXInterval, mXBlanking, mXExposures);
 
     mState = Waiting;
@@ -87,7 +91,6 @@
 
 void SaverEngine::Lock()
 {
-    bool ok = true;
     if (mState == Waiting)
     {
         startLockProcess( ForceLock );
@@ -125,6 +128,7 @@
 
 void SaverEngine::SimulateUserActivity()
 {
+    XForceScreenSaver( QX11Info::display(), ScreenSaverReset );
     if ( mXAutoLock && mState == Waiting )
     {
         mXAutoLock->resetTrigger();
@@ -323,6 +327,8 @@
 //
 void SaverEngine::idleTimeout()
 {
+    if( mState != Waiting )
+        return; // already saving
     startLockProcess( DefaultLock );
 }
 
--- trunk/KDE/kdebase/workspace/krunner/screensaver/xautolock.cpp #916962:916963
@@ -83,8 +83,10 @@
     mActive = false;
 
     mTimerId = startTimer( CHECK_INTERVAL );
+    // This is an internal clock timer (in seconds), used instead of querying system \
time. +    // It is incremented manually, preventing from problems with clock jumps.
+    // In other words, this is the 'now' time and the reference point for other \
times here.  mElapsed = 0;
-
 }
 
 //---------------------------------------------------------------------------
@@ -126,8 +128,6 @@
 {
     mActive = true;
     resetTrigger();
-    XSetScreenSaver(QX11Info::display(), mTimeout + 10, 100, PreferBlanking, \
                DontAllowExposures); // We'll handle blanking
-    kDebug() << "XSetScreenSaver" << mTimeout + 10;
 }
 
 //---------------------------------------------------------------------------
@@ -138,8 +138,6 @@
 {
     mActive = false;
     resetTrigger();
-    XSetScreenSaver(QX11Info::display(), 0, 100, PreferBlanking, \
                DontAllowExposures); // No blanking at all
-    kDebug() << "XSetScreenSaver 0";
 }
 
 //---------------------------------------------------------------------------
@@ -148,12 +146,15 @@
 //
 void XAutoLock::resetTrigger()
 {
+    // Time of the last user activity (used only when the internal XScreensaver
+    // idle counter is not available).
     mLastReset = mElapsed;
+    // Time when screensaver should be activated.
     mTrigger = mElapsed + mTimeout;
 #ifdef HAVE_XSCREENSAVER
     mLastIdle = 0;
 #endif
-    XForceScreenSaver( QX11Info::display(), ScreenSaverReset );
+    // Do not reset the internal X screensaver here (no XForceScreenSaver())
 }
 
 //---------------------------------------------------------------------------
@@ -205,6 +206,9 @@
     if (mMitInfo)
     {
         Display *d = QX11Info::display();
+        // Check user idle time. If it is smaller than before, it is either
+        // clock jump or user activity, so reset the trigger time. Checking whether
+        // there is user inactivity timeout is done below using mTrigger and \
mElapsed.  XScreenSaverQueryInfo(d, DefaultRootWindow(d), mMitInfo);
         if (mLastIdle < mMitInfo->idle)
             mLastIdle = mMitInfo->idle;
@@ -218,12 +222,11 @@
 
     bool activate = false;
 
-    // kDebug() << now << mTrigger;
+    // This is the test whether to activate screensaver. If we have reached the time
+    // and for the whole timeout period there was no activity (which would change \
mTrigger +    // again), activate.
     if (mElapsed >= mTrigger)
-    {
-        resetTrigger();
         activate = true;
-    }
 
 #ifdef HAVE_DPMS
     BOOL on;
@@ -237,6 +240,8 @@
     // that is always smaller than DPMS timeout (X bug I guess). So if DPMS
     // saving is active, simply always activate our saving too, otherwise
     // this could prevent locking from working.
+    // X.Org 7.4: With this version activating DPMS resets the screensaver idle \
timer, +    // so keep this. It probably makes sense to always do this anyway.
     if(state == DPMSModeStandby || state == DPMSModeSuspend || state == DPMSModeOff)
         activate = true;
     // If we are DPMS-dependent and either DPMS is turned off completely or all


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic