summaryrefslogtreecommitdiff
path: root/hw/dmx
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2017-03-24 12:30:57 -0400
committerAdam Jackson <ajax@redhat.com>2017-03-27 15:59:42 -0400
commit7f1ef9289d974fc2bacc968ae0b5d7714382cb9e (patch)
tree33d7e28931d3d8d7db698ce06a736f01de7075bb /hw/dmx
parent8ed0b00fceb34cdb54a0ea113c3cdff3b4c9e7e1 (diff)
dix: Lift DPMS to a screen hook
Following on from the previous change, this adds a DPMS hook to the ScreenRec and uses that to infer DPMS support. As a result we can drop the dpms stub code from Xext. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'hw/dmx')
-rw-r--r--hw/dmx/dmxdpms.c69
-rw-r--r--hw/dmx/dmxdpms.h3
-rw-r--r--hw/dmx/dmxscrinit.c14
3 files changed, 32 insertions, 54 deletions
diff --git a/hw/dmx/dmxdpms.c b/hw/dmx/dmxdpms.c
index d53a3d998..15a2cbd8d 100644
--- a/hw/dmx/dmxdpms.c
+++ b/hw/dmx/dmxdpms.c
@@ -53,10 +53,7 @@
#include "windowstr.h" /* For screenIsSaved */
#include <X11/extensions/dpms.h>
-static unsigned long dpmsGeneration = 0;
-static Bool dpmsSupported = TRUE;
-
-static void
+static int
_dmxDPMSInit(DMXScreenInfo * dmxScreen)
{
int event_base, error_base;
@@ -65,14 +62,9 @@ _dmxDPMSInit(DMXScreenInfo * dmxScreen)
BOOL state;
const char *monitor;
- if (dpmsGeneration != serverGeneration) {
- dpmsSupported = TRUE; /* On unless a backend doesn't support it */
- dpmsGeneration = serverGeneration;
- }
-
#ifdef DPMSExtension
if (DPMSDisabledSwitch)
- dpmsSupported = FALSE; /* -dpms turns off */
+ return FALSE;
#endif
dmxScreen->dpmsCapable = 0;
@@ -80,25 +72,21 @@ _dmxDPMSInit(DMXScreenInfo * dmxScreen)
if (!dmxScreen->beDisplay) {
dmxLogOutput(dmxScreen,
"Cannot determine if DPMS supported (detached screen)\n");
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
if (!DPMSQueryExtension(dmxScreen->beDisplay, &event_base, &error_base)) {
dmxLogOutput(dmxScreen, "DPMS not supported\n");
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
if (!DPMSGetVersion(dmxScreen->beDisplay, &major, &minor)) {
dmxLogOutput(dmxScreen, "DPMS not supported\n");
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
if (!DPMSCapable(dmxScreen->beDisplay)) {
dmxLogOutput(dmxScreen, "DPMS %d.%d (not DPMS capable)\n",
major, minor);
- dpmsSupported = FALSE;
- return;
+ return FALSE;
}
DPMSInfo(dmxScreen->beDisplay, &level, &state);
@@ -134,20 +122,22 @@ _dmxDPMSInit(DMXScreenInfo * dmxScreen)
"DPMS %d.%d (%s, %s, %d %d %d)\n",
major, minor, monitor, state ? "enabled" : "disabled",
standby, suspend, off);
+ return TRUE;
}
/** Initialize DPMS support. We save the current settings and turn off
* DPMS. The settings are restored in #dmxDPMSTerm. */
-void
+int
dmxDPMSInit(DMXScreenInfo * dmxScreen)
{
int interval, preferBlanking, allowExposures;
/* Turn off DPMS */
- _dmxDPMSInit(dmxScreen);
+ if (!_dmxDPMSInit(dmxScreen))
+ return FALSE;
if (!dmxScreen->beDisplay)
- return;
+ return FALSE;
/* Turn off screen saver */
XGetScreenSaver(dmxScreen->beDisplay, &dmxScreen->savedTimeout, &interval,
@@ -156,6 +146,7 @@ dmxDPMSInit(DMXScreenInfo * dmxScreen)
preferBlanking, allowExposures);
XResetScreenSaver(dmxScreen->beDisplay);
dmxSync(dmxScreen, FALSE);
+ return TRUE;
}
/** Terminate DPMS support on \a dmxScreen. We restore the settings
@@ -199,38 +190,12 @@ dmxDPMSWakeup(void)
}
#ifdef DPMSExtension
-/** This is called on each server generation. It should determine if
- * DPMS is supported on all of the backends and, if so, return TRUE. */
-Bool
-DPMSSupported(void)
-{
- return dpmsSupported;
-}
-
-/** This is used by clients (e.g., xset) to set the DPMS level. */
-int
-DPMSSet(ClientPtr client, int level)
+void
+dmxDPMSBackend(DMXScreenInfo *dmxScreen, int level)
{
- int i;
-
- if (!dpmsSupported)
- return Success;
-
- if (level < 0)
- level = DPMSModeOn;
- if (level > 3)
- level = DPMSModeOff;
-
- DPMSPowerLevel = level;
-
- for (i = 0; i < dmxNumScreens; i++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[i];
-
- if (dmxScreen->beDisplay) {
- DPMSForceLevel(dmxScreen->beDisplay, level);
- dmxSync(dmxScreen, FALSE);
- }
+ if (dmxScreen->beDisplay) {
+ DPMSForceLevel(dmxScreen->beDisplay, level);
+ dmxSync(dmxScreen, FALSE);
}
- return Success;
}
#endif
diff --git a/hw/dmx/dmxdpms.h b/hw/dmx/dmxdpms.h
index 772fa2f11..8c4fe9d4f 100644
--- a/hw/dmx/dmxdpms.h
+++ b/hw/dmx/dmxdpms.h
@@ -36,7 +36,8 @@
#ifndef _DMXDPMS_H_
#define _DMXDPMS_H_
-extern void dmxDPMSInit(DMXScreenInfo * dmxScreen);
+extern int dmxDPMSInit(DMXScreenInfo * dmxScreen);
extern void dmxDPMSTerm(DMXScreenInfo * dmxScreen);
extern void dmxDPMSWakeup(void); /* Call when input is processed */
+extern void dmxDPMSBackend(DMXScreenInfo *dmxScreen, int level);
#endif
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index e441dceef..ae095e300 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -75,6 +75,17 @@ DevPrivateKeyRec dmxColormapPrivateKeyRec;
DevPrivateKeyRec dmxPictPrivateKeyRec;
DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
+#ifdef DPMSExtension
+static void
+dmxDPMS(ScreenPtr pScreen, int level)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxDPMSBackend(dmxScreen, level);
+}
+#else
+#define dmxDPMS NULL
+#endif
+
/** Initialize the parts of screen \a idx that require access to the
* back-end server. */
void
@@ -103,7 +114,8 @@ dmxBEScreenInit(ScreenPtr pScreen)
pScreen->blackPixel = dmxScreen->beBlackPixel;
/* Handle screen savers and DPMS on the backend */
- dmxDPMSInit(dmxScreen);
+ if (dmxDPMSInit(dmxScreen))
+ pScreen->DPMS = dmxDPMS;
/* Create root window for screen */
mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect;