summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Höglund <fredrik@kde.org>2006-03-24 20:50:13 +0000
committerFredrik Höglund <fredrik@kde.org>2006-03-24 20:50:13 +0000
commitae935832facfa81a9689882406ecca74b0346790 (patch)
tree1a0ebe7f71e7fe26be2ff383386b1d0ed01539f5
parentd1746ec0f0c8a0b750f390e7a7faf21b67683f4a (diff)
Refactored the screensaver and DPMS timer code to use the screensaver timer
for both screensaver and DPMS. Removed the SetDPMSTimers() and FreeDPMSTimers() functions.
-rw-r--r--ChangeLog14
-rw-r--r--Xext/dpms.c6
-rw-r--r--dix/main.c8
-rw-r--r--hw/xfree86/common/xf86Xinput.c5
-rw-r--r--hw/xfree86/loader/dixsym.c5
-rw-r--r--os/WaitFor.c187
6 files changed, 121 insertions, 104 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a7bacd60..1113545ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-03-24 Fredrik Höglund <fredrik@kde.org>
+
+ * Xext/dpms.c (ProcDPMSSetTimeouts):
+ * dix/main.c (main):
+ * hw/xfree86/common/xf86Xinput.c (xf86eqProcessInputEvents):
+ * hw/xfree86/loader/dixsym.c:
+ * os/WaitFor.c (NextDPMSTimeout), (ScreenSaverTimeoutExpire)
+ (SetScreenSaverTimer), (DPMSStandbyTimerExpire),
+ (DPMSSuspendTimerExpire), (DPMSOffTimerExpire), (FreeDPMSTimers),
+ (SetDPMSTimers):
+ Refactored the screensaver and DPMS timer code to use the screensaver
+ timer for both screensaver and DPMS. Removed the SetDPMSTimers()
+ and FreeDPMSTimers() functions.
+
2006-03-24 Kristian Høgsberg <krh@redhat.com>
* GL/glx/glxdri.c (__glXDRIscreenProbe): Make sure DRI module is
diff --git a/Xext/dpms.c b/Xext/dpms.c
index 3e79602d1..ea0a1ccdf 100644
--- a/Xext/dpms.c
+++ b/Xext/dpms.c
@@ -189,12 +189,12 @@ ProcDPMSSetTimeouts(client)
client->errorValue = stuff->suspend;
return BadValue;
}
-
+
DPMSStandbyTime = stuff->standby * MILLI_PER_SECOND;
DPMSSuspendTime = stuff->suspend * MILLI_PER_SECOND;
DPMSOffTime = stuff->off * MILLI_PER_SECOND;
- SetDPMSTimers();
-
+ SetScreenSaverTimer();
+
return(client->noClientException);
}
diff --git a/dix/main.c b/dix/main.c
index 39c060f31..9d66a4fa8 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xserver/xorg/dix/main.c,v 1.14 2005/07/03 08:53:38 daniels Exp $ */
+/* $XdotOrg: xserver/xorg/dix/main.c,v 1.15 2006/02/15 20:44:12 ajax Exp $ */
/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.43 2003/10/30 21:21:02 herrb Exp $ */
/***********************************************************
@@ -432,9 +432,6 @@ main(int argc, char *argv[], char *envp[])
InitRootWindow(WindowTable[i]);
DefineInitialRootWindow(WindowTable[0]);
SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
-#ifdef DPMSExtension
- SetDPMSTimers();
-#endif
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
@@ -481,9 +478,6 @@ main(int argc, char *argv[], char *envp[])
WindowTable = NULL;
FreeFonts();
-#ifdef DPMSExtension
- FreeDPMSTimers();
-#endif
FreeAuditTimer();
xfree(serverClient->devPrivates);
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index aa3f14e79..2b8fbc9d1 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -48,7 +48,7 @@
* authorization from the copyright holder(s) and author(s).
*/
/* $XConsortium: xf86Xinput.c /main/14 1996/10/27 11:05:25 kaleb $ */
-/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 1.4 2005/04/20 12:25:21 daniels Exp $ */
+/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Xinput.c,v 1.7 2005/10/21 19:06:13 ajax Exp $ */
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
@@ -773,6 +773,9 @@ xf86eqProcessInputEvents ()
if (screenIsSaved == SCREEN_SAVER_ON)
SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
#ifdef DPMSExtension
+ else if (DPMSPowerLevel != DPMSModeOn)
+ SetScreenSaverTimer();
+
if (DPMSPowerLevel != DPMSModeOn)
DPMSSet(DPMSModeOn);
#endif
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 28288f846..851db76c9 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.12 2005/05/30 18:44:55 ajax Exp $ */
+/* $XdotOrg: xserver/xorg/hw/xfree86/loader/dixsym.c,v 1.20 2006/01/08 23:43:53 ajax Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.63 2003/12/03
* 17:11:29 tsi Exp $ */
@@ -473,9 +473,6 @@ LOOKUP dixLookupTab[] = {
SYMFUNC(TimerFree)
SYMFUNC(TimerSet)
SYMFUNC(TimerCancel)
-#ifdef DPMSExtension
- SYMFUNC(SetDPMSTimers)
-#endif
/* io.c */
SYMFUNC(WriteToClient)
SYMFUNC(SetCriticalOutputPending)
diff --git a/os/WaitFor.c b/os/WaitFor.c
index a1a6846a5..a2c2126e9 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -573,26 +573,89 @@ TimerInit(void)
}
}
+#ifdef DPMSExtension
+
+#define DPMS_CHECK_MODE(mode,time)\
+ if (time > 0 && DPMSPowerLevel < mode && timeout >= time)\
+ DPMSSet(mode);
+
+#define DPMS_CHECK_TIMEOUT(time)\
+ if (time > 0 && (time - timeout) > 0)\
+ return time - timeout;
+
+static CARD32
+NextDPMSTimeout(INT32 timeout)
+{
+ /*
+ * Return the amount of time remaining until we should set
+ * the next power level. Fallthroughs are intentional.
+ */
+ switch (DPMSPowerLevel)
+ {
+ case DPMSModeOn:
+ DPMS_CHECK_TIMEOUT(DPMSStandbyTime)
+
+ case DPMSModeStandby:
+ DPMS_CHECK_TIMEOUT(DPMSSuspendTime)
+
+ case DPMSModeSuspend:
+ DPMS_CHECK_TIMEOUT(DPMSOffTime)
+
+ default: /* DPMSModeOff */
+ return 0;
+ }
+}
+#endif /* DPMSExtension */
+
static CARD32
ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
{
- INT32 timeout = now - lastDeviceEventTime.milliseconds;
+ INT32 timeout = now - lastDeviceEventTime.milliseconds;
+ CARD32 nextTimeout = 0;
+
+#ifdef DPMSExtension
+ /*
+ * Check each mode lowest to highest, since a lower mode can
+ * have the same timeout as a higher one.
+ */
+ if (DPMSEnabled)
+ {
+ DPMS_CHECK_MODE(DPMSModeOff, DPMSOffTime)
+ DPMS_CHECK_MODE(DPMSModeSuspend, DPMSSuspendTime)
+ DPMS_CHECK_MODE(DPMSModeStandby, DPMSStandbyTime)
+
+ nextTimeout = NextDPMSTimeout(timeout);
+ }
- if (timeout < ScreenSaverTime) {
- return ScreenSaverTime - timeout;
+ /*
+ * Only do the screensaver checks if we're not in a DPMS
+ * power saving mode
+ */
+ if (DPMSPowerLevel != DPMSModeOn)
+ return nextTimeout;
+#endif /* DPMSExtension */
+
+ if (!ScreenSaverTime)
+ return nextTimeout;
+
+ if (timeout < ScreenSaverTime)
+ {
+ return nextTimeout > 0 ?
+ MIN(ScreenSaverTime - timeout, nextTimeout) :
+ ScreenSaverTime - timeout;
}
ResetOsBuffers(); /* not ideal, but better than nothing */
SaveScreens(SCREEN_SAVER_ON, ScreenSaverActive);
-#ifdef DPMSExtension
- if (ScreenSaverInterval > 0 && DPMSPowerLevel == DPMSModeOn)
-#else
if (ScreenSaverInterval > 0)
-#endif /* DPMSExtension */
- return ScreenSaverInterval;
+ {
+ nextTimeout = nextTimeout > 0 ?
+ MIN(ScreenSaverInterval, nextTimeout) :
+ ScreenSaverInterval;
+ }
- return 0;
+ return nextTimeout;
}
static OsTimerPtr ScreenSaverTimer = NULL;
@@ -609,93 +672,39 @@ FreeScreenSaverTimer(void)
void
SetScreenSaverTimer(void)
{
- if (ScreenSaverTime > 0) {
- ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, ScreenSaverTime,
- ScreenSaverTimeoutExpire, NULL);
- } else if (ScreenSaverTimer) {
- FreeScreenSaverTimer();
- }
-}
+ CARD32 timeout = 0;
#ifdef DPMSExtension
-
-static OsTimerPtr DPMSStandbyTimer = NULL;
-static OsTimerPtr DPMSSuspendTimer = NULL;
-static OsTimerPtr DPMSOffTimer = NULL;
-
-static CARD32
-DPMSStandbyTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
- INT32 timeout = now - lastDeviceEventTime.milliseconds;
-
- if (timeout < DPMSStandbyTime) {
- return DPMSStandbyTime - timeout;
- }
- if (DPMSPowerLevel < DPMSModeStandby) {
- if (DPMSEnabled)
- DPMSSet(DPMSModeStandby);
- }
- return DPMSStandbyTime;
-}
-
-static CARD32
-DPMSSuspendTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
- INT32 timeout = now - lastDeviceEventTime.milliseconds;
-
- if (timeout < DPMSSuspendTime) {
- return DPMSSuspendTime - timeout;
- }
- if (DPMSPowerLevel < DPMSModeSuspend) {
- if (DPMSEnabled)
- DPMSSet(DPMSModeSuspend);
+ if (DPMSEnabled)
+ {
+ /*
+ * A higher DPMS level has a timeout that's either less
+ * than or equal to that of a lower DPMS level.
+ */
+ if (DPMSStandbyTime > 0)
+ timeout = DPMSStandbyTime;
+
+ else if (DPMSSuspendTime > 0)
+ timeout = DPMSSuspendTime;
+
+ else if (DPMSOffTime > 0)
+ timeout = DPMSOffTime;
}
- return DPMSSuspendTime;
-}
-
-static CARD32
-DPMSOffTimerExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
- INT32 timeout = now - lastDeviceEventTime.milliseconds;
+#endif
- if (timeout < DPMSOffTime) {
- return DPMSOffTime - timeout;
- }
- if (DPMSPowerLevel < DPMSModeOff) {
- if (DPMSEnabled)
- DPMSSet(DPMSModeOff);
+ if (ScreenSaverTime > 0)
+ {
+ timeout = timeout > 0 ?
+ MIN(ScreenSaverTime, timeout) :
+ ScreenSaverTime;
}
- return DPMSOffTime;
-}
-void
-FreeDPMSTimers(void)
-{
- if (DPMSStandbyTimer) {
- TimerFree(DPMSStandbyTimer);
- DPMSStandbyTimer = NULL;
+ if (timeout) {
+ ScreenSaverTimer = TimerSet(ScreenSaverTimer, 0, timeout,
+ ScreenSaverTimeoutExpire, NULL);
}
- if (DPMSSuspendTimer) {
- TimerFree(DPMSSuspendTimer);
- DPMSSuspendTimer = NULL;
- }
- if (DPMSOffTimer) {
- TimerFree(DPMSOffTimer);
- DPMSOffTimer = NULL;
+ else if (ScreenSaverTimer) {
+ FreeScreenSaverTimer();
}
}
-_X_EXPORT void
-SetDPMSTimers(void)
-{
- if (!DPMSEnabled)
- return;
-
- DPMSStandbyTimer = TimerSet(DPMSStandbyTimer, 0, DPMSStandbyTime,
- DPMSStandbyTimerExpire, NULL);
- DPMSSuspendTimer = TimerSet(DPMSSuspendTimer, 0, DPMSSuspendTime,
- DPMSSuspendTimerExpire, NULL);
- DPMSOffTimer = TimerSet(DPMSOffTimer, 0, DPMSOffTime,
- DPMSOffTimerExpire, NULL);
-}
-#endif