Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 07 Feb 2009 16:55:31 +1100
From:      Lawrence Stewart <lstewart@freebsd.org>
To:        FreeBSD-ports@freebsd.org
Subject:   Minor fix for KDE 4 monitor screen saver/power save nit
Message-ID:  <498D2253.1060508@freebsd.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050607040008060507050009
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi All,

KDE 4.1.4 (and I believe KDE 4.2.0) has an issue with krunner that stops
the monitor from dropping into power save mode if the screen saver kicks
in before the power save timeout. This bugged me sufficiently to find a 
fix, so thought I'd share this in case this issue is bugging anyone else.

The relevant KDE bug report is here:
http://bugs.kde.org/show_bug.cgi?id=165265

I've backported the fix from the 4.2 tree for KDE 4.1.4. Stick the 
attached patch in /usr/ports/x11/kdebase4-workspace/files and 
rebuild/reinstall the port.

For KDE 4.2.0, the patch obtained by running:
svn diff -c916964 svn://anonsvn.kde.org/home/kde/branches/KDE/4.2/kdebase

should work with some minor tweaks to the patch meta data. Same 
procedure applies as for 4.1.4.

I've confirmed the attached patch resolves the issue for 4.1.4.

Cheers,
Lawrence

--------------050607040008060507050009
Content-Type: text/plain;
 name="patch-krunner-r916964-fixpowersave"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch-krunner-r916964-fixpowersave"

Index: ../krunner/lock/lockprocess.cc
===================================================================
--- ../krunner/lock/lockprocess.cc.orig	(revision 916963)
+++ ../krunner/lock/lockprocess.cc	(revision 916964)
@@ -1104,7 +1104,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();
Index: ../krunner/xautolock.cpp
===================================================================
--- ../krunner/xautolock.cpp.orig	2008-08-28 18:07:00.000000000 +1000
+++ ../krunner/xautolock.cpp	2009-02-06 17:05:19.000000000 +1100
@@ -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
     xautolock_lastIdleTime = 0;
 #endif
-    XForceScreenSaver( QX11Info::display(), ScreenSaverReset );
+    // Do not reset the internal X screensaver here (no XForceScreenSaver())
 }
 
 //---------------------------------------------------------------------------
@@ -205,12 +206,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;
@@ -222,6 +222,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(!on && mDPMS) {
Index: ../krunner/saverengine.cpp
===================================================================
--- ../krunner/saverengine.cpp.orig	(revision 916963)
+++ ../krunner/saverengine.cpp	(revision 916964)
@@ -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,10 +91,9 @@
 
 void SaverEngine::Lock()
 {
-    bool ok = true;
     if (mState == Waiting)
     {
-        ok = startLockProcess( ForceLock );
+        bool ok = startLockProcess( ForceLock );
 // It takes a while for krunner_lock to start and lock the screen.
 // Therefore delay the DBus call until it tells krunner that the locking is in effect.
 // This is done only for --forcelock .
@@ -133,6 +136,7 @@
 
 void SaverEngine::SimulateUserActivity()
 {
+    XForceScreenSaver( QX11Info::display(), ScreenSaverReset );
     if ( mXAutoLock && mState == Waiting )
     {
         mXAutoLock->resetTrigger();
@@ -311,6 +315,8 @@
 //
 void SaverEngine::idleTimeout()
 {
+    if( mState != Waiting )
+        return; // already saving
     startLockProcess( DefaultLock );
 }
 


--------------050607040008060507050009--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?498D2253.1060508>