Bug 52663 - global dpms disabled on KDE startup
Summary: global dpms disabled on KDE startup
Status: RESOLVED FIXED
Alias: None
Product: kcontrol
Classification: Miscellaneous
Component: kcmenergy (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Geert Jansen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-06 15:04 UTC by Olaf Hering
Modified: 2003-04-26 01:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
/tmp/kdebase_dpms-3.1rc6.patch (2.21 KB, patch)
2003-01-06 16:54 UTC, Olaf Hering
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olaf Hering 2003-01-06 15:04:57 UTC
Version:            (using KDE KDE 3.0.99)
Installed from:    Compiled From Sources
Compiler:          gcc 3.2.1 
OS:          Linux

fresh kde3.1rc6:

startkde does DISABLE an already configured DPMS.
Why?

olaf@ibook:~> xset +dpms
olaf@ibook:~> xset q | tail
DPMS (Energy Star):
  Standby: 300    Suspend: 1800    Off: 2400
  DPMS is Enabled
  Monitor is On

olaf@ibook:~> ssh -Xp 23 localhost
socket: Address family not supported by protocol
olaf@localhost's password: 
Last login: Mon Jan  6 14:50:08 2003 from localhost
olaf@ibook olaf $ unset KDEDIRS KDEDIR
olaf@ibook olaf $ export PATH=/opt/kde-3.1rc6/bin:/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:/usr/qt/3/bin
olaf@ibook olaf $ rm -rfv /tmp/*olaf ~/.kde* ~/.ICEauthority ~/.mcop* ~/.fonts.cache-1 ~/.qt/ ~/Desktop ~/.gtkrc-kde 
olaf@ibook olaf $ /opt/kde-3.1rc6/bin/startkde 

new user settings:
europe/germany, english/US
KDE style
default "eye-candy"
keramik default

running konsole:

DPMS (Energy Star):
  Standby: 300    Suspend: 1800    Off: 2400
  DPMS is Disabled

/kdebase-3.1rc6/kcontrol/energy/energy.cpp seems to be the culprit.
It must query the current settings and use these as defaults.
There is a call to the DPMSQueryExtension(). Maybe this  returns bogus results?
HAVE_DPMS is defined.


In any case, DPMS should be enabled per default.
Comment 1 Olaf Hering 2003-01-06 15:43:18 UTC
this patch seems to fix it:

KDE_3_1_BRANCH/kdebase # cvs diff -pu kcontrol/energy/
cvsro server: Diffing kcontrol/energy
Index: kcontrol/energy/energy.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/energy/energy.cpp,v
retrieving revision 1.18
diff -p -u -r1.18 energy.cpp
--- kcontrol/energy/energy.cpp  1 Jul 2002 11:42:14 -0000       1.18
+++ kcontrol/energy/energy.cpp  6 Jan 2003 14:41:41 -0000
@@ -86,7 +86,7 @@ extern "C" {
         KConfig *cfg = new KConfig("kcmdisplayrc", true /*readonly*/, false
/*no globals*/);
         cfg->setGroup("DisplayEnergy");

-        bool enabled = cfg->readBoolEntry("displayEnergySaving", false);
+        bool enabled = cfg->readBoolEntry("displayEnergySaving", true);
         int standby = cfg->readNumEntry("displayStandby", DFLT_STANDBY);
         int suspend = cfg->readNumEntry("displaySuspend", DFLT_SUSPEND);
         int off = cfg->readNumEntry("displayPowerOff", DFLT_OFF);
Comment 2 Olaf Hering 2003-01-06 16:54:56 UTC
Created attachment 707 [details]
/tmp/kdebase_dpms-3.1rc6.patch

one way to do it, see attached patch.

The same is required for KEnergy::readSettings(), it does blindly provide bogus
defaults instead of using the already configured DPMS (from xset in .xinitrd or
XF86config).

It would be clever if the whole dpms panel is disabled if the X server has no
dpms extension or if the display cant do dpms.

should be fixed for 3.1
Comment 3 Stephan Binner 2003-01-09 11:25:39 UTC
> startkde does DISABLE an already configured DPMS. 
> /kdebase-3.1rc6/kcontrol/energy/energy.cpp seems to be the culprit. 
 
Sure? Why should a control center module be run at KDE start? Just wondering... 
Comment 4 Daniel Molkentin 2003-04-26 01:50:13 UTC
Subject: kdebase/kcontrol/energy

CVS commit by danimo: 

Patch to query the DPMS extension and figure out system defaults this way
instead of dumbly relying on our own hardcoded defaults.

Patch by Olaf Hering, fixes #52663

CCMAIL:52663-done@bugs.kde.org


  M +29 -5     energy.cpp   1.23


--- kdebase/kcontrol/energy/energy.cpp  #1.22:1.23
@@ -60,4 +60,5 @@ extern "C" {
     Status DPMSEnable(Display *);
     Status DPMSDisable(Display *);
+    Bool DPMSGetTimeouts(Display *, CARD16 *, CARD16 *, CARD16 *);
     Bool DPMSSetTimeouts(Display *, CARD16, CARD16, CARD16);
 #if defined(XIMStringConversionRetrival) || defined (__sun) || defined(__hpux)
@@ -84,8 +85,31 @@ extern "C" {
         cfg->setGroup("DisplayEnergy");
 
-        bool enabled = cfg->readBoolEntry("displayEnergySaving", false);
-        int standby = cfg->readNumEntry("displayStandby", DFLT_STANDBY);
-        int suspend = cfg->readNumEntry("displaySuspend", DFLT_SUSPEND);
-        int off = cfg->readNumEntry("displayPowerOff", DFLT_OFF);
+        Display *dpy = qt_xdisplay();
+        CARD16 pre_configured_status;
+        BOOL pre_configured_enabled;
+        CARD16 pre_configured_standby;
+        CARD16 pre_configured_suspend;
+        CARD16 pre_configured_off;
+        bool enabled;
+        CARD16 standby;
+        CARD16 suspend;
+        CARD16 off;
+        int dummy;
+        /* query the running X server if DPMS is supported */
+        if (DPMSQueryExtension(dpy, &dummy, &dummy) && DPMSCapable(dpy)) {
+            DPMSGetTimeouts(dpy, &pre_configured_standby, &pre_configured_suspend, &pre_configured_off);
+            DPMSInfo(dpy, &pre_configured_status, &pre_configured_enabled);
+            /* let the user override the settings */
+            enabled = cfg->readBoolEntry("displayEnergySaving", pre_configured_enabled);
+            standby = cfg->readNumEntry("displayStandby", pre_configured_standby);
+            suspend = cfg->readNumEntry("displaySuspend", pre_configured_suspend);
+            off = cfg->readNumEntry("displayPowerOff", pre_configured_off);
+        } else {
+        /* provide our defauts */
+            enabled = true;
+            standby = DFLT_STANDBY;
+            suspend = DFLT_SUSPEND;
+            off = DFLT_OFF;
+        }
 
         delete cfg;