diff --git a/Xext/dpms.c b/Xext/dpms.c index b582669f76..8e3e2d9fdf 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -39,6 +39,7 @@ Equipment Corporation. #include "miext/extinit_priv.h" #include "os/screensaver.h" #include "os/osdep.h" +#include "Xext/dpms/dpms_priv.h" #include "Xext/geext_priv.h" #include "misc.h" @@ -46,7 +47,6 @@ Equipment Corporation. #include "dixstruct.h" #include "extnsionst.h" #include "opaque.h" -#include "dpmsproc.h" #include "scrnintstr.h" #include "windowstr.h" #include "protocol-versions.h" diff --git a/Xext/dpms/dpms_priv.h b/Xext/dpms/dpms_priv.h new file mode 100644 index 0000000000..3a1026c238 --- /dev/null +++ b/Xext/dpms/dpms_priv.h @@ -0,0 +1,122 @@ +/* SPDX-License-Identifier: MIT OR X11 OR AGPL-3.0-or-later + * + * DPMS (Display Power Management Signaling) — interface between the + * DPMS extension and other parts (DIX, DDX, OS). + * + * Copyright © 2026 Enrico Weigelt, metux IT consult + * + * This header is NOT part of the driver API. Drivers must NOT + * include it. It is for use by the extension, DIX, and DDX only. + * + * DDX is assumed to provide entry point via ScreenRec->DPMS() and set + * several variables (eg. DPMSStandbyTime, DPMSDisabledSwitch, etc) + * on startup. + * + * Timeout variables (DPMSStandbyTime, DPMSSuspendTime, DPMSOffTime) + * are in milliseconds. They are initialised to ~0 (UINT32_MAX) in + * Xext/dpms.c, which the extension treats as "use ScreenSaverTime". + * The DDX may override them during InitOutput (e.g. xf86Config.c + * reads them from the command line / config file and converts from + * minutes to milliseconds). + * + * Power levels are defined in : + * DPMSModeOn 0 full power + * DPMSModeStandby 1 minimal signal, fast resume + * DPMSModeSuspend 2 deeper sleep, slower resume + * DPMSModeOff 3 most power saving + */ + +#ifndef _DPMS_PRIV_H_ +#define _DPMS_PRIV_H_ + +#include + +#include "dixstruct.h" + +/** + * Set a new DPMS power level for every screen. + * + * Called by: + * - WaitFor.c (timer-driven automatic transitions) + * - mieq.c (any input event wakes the displays) + * - xf86Init.c (abort path — restore video before dying) + * - xf86Events.c(VT switch — restore before leaving VT) + * - dpms.c (Disable, ForceLevel, CloseDown) + * + * Implementation: + * Saves old DPMSPowerLevel, updates it to @level, co-ordinates + * with the screen saver (blank/unblank if needed), then calls + * walkScreen->DPMS(walkScreen, level) for every screen whose + * DPMS callback is non-NULL. + * + * @client the client requesting the change (may be serverClient) + * @level one of DPMSModeOn/Standby/Suspend/Off + * @return Success on success, or a dixSaveScreens error code. + */ +extern int DPMSSet(ClientPtr client, int level); + +/** + * Query whether DPMS is supported by any screen. + * + * Returns TRUE if at least one screen (or GPU screen) has a non-NULL + * DPMS function pointer. Called during DPMSExtensionInit to decide + * whether to register the extension at all, and by the Info request + * to report the DPMS state. + */ +extern Bool DPMSSupported(void); + +/** + * Standby timeout in milliseconds. + * + * The idle time after which the server transitions to DPMS standby + * mode. -1 (UINT32_MAX) at init; DPMSExtensionInit falls back to + * ScreenSaverTime. The DDX may set this via configuration + * (e.g. xf86Config reads the "StandbyTime" option). + */ +extern CARD32 DPMSStandbyTime; + +/** + * Suspend timeout in milliseconds. + * + * The idle time after which the server transitions to DPMS suspend + * mode. Semantics match DPMSStandbyTime. + */ +extern CARD32 DPMSSuspendTime; + +/** + * Off timeout in milliseconds. + * + * The idle time after which the server transitions to DPMS off + * mode. Semantics match DPMSStandbyTime. + */ +extern CARD32 DPMSOffTime; + +/** + * Current DPMS power level. + * + * One of DPMSModeOn (0), DPMSModeStandby (1), DPMSModeSuspend (2), + * or DPMSModeOff (3). Modified by DPMSSet() and queried by + * WaitFor.c (for timeout scheduling), mieq.c (wake on input), + * Xext/saver.c (coexistence with screen saver), xf86Init.c and + * xf86Events.c (restore before abort/VT switch). + */ +extern CARD16 DPMSPowerLevel; + +/** + * Whether the DPMS extension is currently enabled. + * + * Set to DPMSSupported() during DPMSExtensionInit. May be toggled + * by the DPMS Enable/Disable protocol requests. When FALSE, the + * timeout machinery in WaitFor.c skips DPMS transitions entirely. + */ +extern Bool DPMSEnabled; + +/** + * Set TRUE when the "-dpms" command-line flag is used. + * + * Checked by the DDX (xf86DPMSInit) to suppress DPMS initialisation + * even when the config file requests it. Set by ddxProcessArgument(). + */ +extern Bool DPMSDisabledSwitch; + +#endif diff --git a/Xext/dpmsproc.h b/Xext/dpmsproc.h deleted file mode 100644 index 9994e5103d..0000000000 --- a/Xext/dpmsproc.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Prototypes for functions that the DDX must provide */ - -#ifndef _DPMSPROC_H_ -#define _DPMSPROC_H_ - -#include - -#include "dixstruct.h" - -extern int DPMSSet(ClientPtr client, int level); -extern Bool DPMSSupported(void); - -extern CARD32 DPMSStandbyTime; -extern CARD32 DPMSSuspendTime; -extern CARD32 DPMSOffTime; -extern CARD16 DPMSPowerLevel; -extern Bool DPMSEnabled; -extern Bool DPMSDisabledSwitch; - -#endif diff --git a/Xext/saver.c b/Xext/saver.c index 8a5f028f6f..8f0571921b 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -44,6 +44,9 @@ in this Software without prior written authorization from the X Consortium. #include "miext/extinit_priv.h" #include "os/osdep.h" #include "os/screensaver.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "Xext/panoramiX.h" #include "Xext/panoramiXsrv.h" @@ -61,7 +64,6 @@ in this Software without prior written authorization from the X Consortium. #include "inputstr.h" #ifdef DPMSExtension #include -#include "dpmsproc.h" #endif #include "protocol-versions.h" diff --git a/dix/main.c b/dix/main.c index 8c55f11967..397a6fd804 100644 --- a/dix/main.c +++ b/dix/main.c @@ -104,6 +104,9 @@ Equipment Corporation. #include "os/osdep.h" #include "os/screensaver.h" #include "os/serverlock.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "Xext/panoramiXsrv.h" #include "scrnintstr.h" @@ -123,7 +126,6 @@ Equipment Corporation. #ifdef DPMSExtension #include -#include "dpmsproc.h" #endif extern void Dispatch(void); diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 297f297149..2df1a5ec49 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -32,6 +32,9 @@ #include "os/cmdline.h" #include "os/ddx_priv.h" #include "os/osdep.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "kdrive.h" #include @@ -49,10 +52,6 @@ #include "kxv.h" #endif -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif - #ifdef HAVE_EXECINFO_H #include #endif diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 79d46569a7..0de1216dcd 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -55,6 +55,9 @@ #include "os/log_priv.h" #include "os/osdep.h" #include "xkb/xkbsrv_priv.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "xf86_priv.h" #include "xf86Modes.h" @@ -72,9 +75,6 @@ #include "xf86Xinput_priv.h" #include "picture.h" -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif /* * These paths define the way the config file search is done. The escape diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c index 4f36964163..4b21fb77e3 100644 --- a/hw/xfree86/common/xf86DPMS.c +++ b/hw/xfree86/common/xf86DPMS.c @@ -36,10 +36,15 @@ #include "xf86.h" #include "xf86Priv.h" #include "xf86Opt_priv.h" + #ifdef DPMSExtension #include -#include "dpmsproc.h" #endif + +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif + #include "xf86VGAarbiter_priv.h" #ifdef DPMSExtension diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 4bf730959f..fdaf28e1b5 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -64,6 +64,9 @@ #include "hw/xfree86/common/action_priv.h" #include "mi/mi_priv.h" #include "os/log_priv.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "misc.h" #include "xf86_priv.h" @@ -85,7 +88,6 @@ #ifdef DPMSExtension #include -#include "dpmsproc.h" #endif #include "../os-support/linux/systemd-logind.h" diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index c4427df803..994a7b93d3 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -60,6 +60,9 @@ #include "os/log_priv.h" #include "os/osdep.h" #include "randr/randrstr_priv.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "servermd.h" #include "windowstr.h" @@ -89,7 +92,6 @@ #ifdef DPMSExtension #include -#include "dpmsproc.h" #endif #ifdef __linux__ diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c index bb55e3f662..0d46b3c228 100644 --- a/hw/xnest/Init.c +++ b/hw/xnest/Init.c @@ -26,6 +26,9 @@ is" without express or implied warranty. #include "os/ddx_priv.h" #include "os/log_priv.h" #include "os/osdep.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "screenint.h" #include "input.h" @@ -47,9 +50,6 @@ is" without express or implied warranty. #include "Drawable.h" #include "XNGC.h" #include "XNFont.h" -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif Bool xnestDoFullGeneration = TRUE; diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 9f81a941b7..2c21ed46b3 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -39,13 +39,13 @@ from The Open Group. #include "os/log_priv.h" #include "os/osdep.h" #include "xkb/xkbsrv_priv.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "winmsg.h" #include "winconfig.h" #include "winprefs.h" -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif #ifdef __CYGWIN__ #include #endif diff --git a/mi/mieq.c b/mi/mieq.c index 269156fb3b..d421e9c93e 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -49,9 +49,12 @@ in this Software without prior written authorization from The Open Group. #include "mi/mi_priv.h" #include "mi/mipointer_priv.h" #include "os/bug_priv.h" -#include "os/screensaver.h" +#include "os/screensaver.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif -#include "misc.h" +#include "misc.h" #include "windowstr.h" #include "pixmapstr.h" #include "inputstr.h" @@ -60,7 +63,6 @@ in this Software without prior written authorization from The Open Group. #include "eventstr.h" #ifdef DPMSExtension -#include "dpmsproc.h" #include #endif diff --git a/os/WaitFor.c b/os/WaitFor.c index 992962df4b..78d435a0b8 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -68,14 +68,14 @@ SOFTWARE. #include "os/client_priv.h" #include "os/ossock.h" #include "os/screensaver.h" +#ifdef DPMSExtension +#include "Xext/dpms/dpms_priv.h" +#endif #include "misc.h" #include "osdep.h" #include "dixstruct_priv.h" #include "globals.h" -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif #ifdef WIN32 /* Error codes from windows sockets differ from fileio error codes */ diff --git a/os/utils.c b/os/utils.c index 9525d4ae00..81834f8814 100644 --- a/os/utils.c +++ b/os/utils.c @@ -118,6 +118,7 @@ __stdcall unsigned long GetTickCount(void); #include "os/serverlock.h" #include "os/xhostname.h" #include "present/present_priv.h" +#include "Xext/dpms/dpms_priv.h" #include "Xext/xf86bigfontsrv.h" /* XF86BigfontCleanup() */ #include "xkb/xkbsrv_priv.h" @@ -125,7 +126,6 @@ __stdcall unsigned long GetTickCount(void); #include "picture.h" #include "miinitext.h" #include "dixstruct_priv.h" -#include "dpmsproc.h" #define X_INCLUDE_NETDB_H #include