diff options
author | Adam Jackson <ajax@redhat.com> | 2017-03-24 12:30:57 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2017-03-27 15:59:42 -0400 |
commit | 7f1ef9289d974fc2bacc968ae0b5d7714382cb9e (patch) | |
tree | 33d7e28931d3d8d7db698ce06a736f01de7075bb /Xext | |
parent | 8ed0b00fceb34cdb54a0ea113c3cdff3b4c9e7e1 (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 'Xext')
-rw-r--r-- | Xext/Makefile.am | 4 | ||||
-rw-r--r-- | Xext/dpms.c | 64 | ||||
-rw-r--r-- | Xext/dpmsstubs.c | 47 |
3 files changed, 65 insertions, 50 deletions
diff --git a/Xext/Makefile.am b/Xext/Makefile.am index 1ceb9803d..32a27eba8 100644 --- a/Xext/Makefile.am +++ b/Xext/Makefile.am @@ -1,4 +1,4 @@ -noinst_LTLIBRARIES = libXext.la libXextdpmsstubs.la libXvidmode.la +noinst_LTLIBRARIES = libXext.la libXvidmode.la AM_CFLAGS = $(DIX_CFLAGS) @@ -96,8 +96,6 @@ endif libXext_la_SOURCES = $(BUILTIN_SRCS) libXext_la_LIBADD = $(BUILTIN_LIBS) -libXextdpmsstubs_la_SOURCES = dpmsstubs.c - # XVidMode extension libXvidmode_la_SOURCES = vidmode.c diff --git a/Xext/dpms.c b/Xext/dpms.c index 291dad023..abc67ef1f 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -40,6 +40,70 @@ Equipment Corporation. #include <X11/extensions/dpmsproto.h> #include "dpmsproc.h" #include "extinit.h" +#include "scrnintstr.h" +#include "windowstr.h" + +Bool +DPMSSupported(void) +{ + int i; + + /* For each screen, check if DPMS is supported */ + for (i = 0; i < screenInfo.numScreens; i++) + if (screenInfo.screens[i]->DPMS != NULL) + return TRUE; + + for (i = 0; i < screenInfo.numGPUScreens; i++) + if (screenInfo.gpuscreens[i]->DPMS != NULL) + return TRUE; + + return FALSE; +} + +static Bool +isUnblank(int mode) +{ + switch (mode) { + case SCREEN_SAVER_OFF: + case SCREEN_SAVER_FORCER: + return TRUE; + case SCREEN_SAVER_ON: + case SCREEN_SAVER_CYCLE: + return FALSE; + default: + return TRUE; + } +} + +int +DPMSSet(ClientPtr client, int level) +{ + int rc, i; + + DPMSPowerLevel = level; + + if (level != DPMSModeOn) { + if (isUnblank(screenIsSaved)) { + rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive); + if (rc != Success) + return rc; + } + } else if (!isUnblank(screenIsSaved)) { + rc = dixSaveScreens(client, SCREEN_SAVER_OFF, ScreenSaverReset); + if (rc != Success) + return rc; + } + + for (i = 0; i < screenInfo.numScreens; i++) + if (screenInfo.screens[i]->DPMS != NULL) + screenInfo.screens[i]->DPMS(screenInfo.screens[i], level); + + for (i = 0; i < screenInfo.numGPUScreens; i++) + if (screenInfo.gpuscreens[i]->DPMS != NULL) + screenInfo.gpuscreens[i]->DPMS(screenInfo.gpuscreens[i], level); + + return Success; +} static int ProcDPMSGetVersion(ClientPtr client) diff --git a/Xext/dpmsstubs.c b/Xext/dpmsstubs.c deleted file mode 100644 index f05d1e9f9..000000000 --- a/Xext/dpmsstubs.c +++ /dev/null @@ -1,47 +0,0 @@ -/***************************************************************** - -Copyright (c) 1996 Digital Equipment Corporation, Maynard, Massachusetts. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. - -******************************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "dpmsproc.h" - -#define FALSE 0 - -Bool -DPMSSupported(void) -{ - return FALSE; -} - -int -DPMSSet(ClientPtr client, int level) -{ - return Success; -} |