From 564d18c8e56cd6f271a928f1dc835b40e1f5a181 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 1 Oct 2018 16:58:30 +0300 Subject: [PATCH] Add DPMSInfoNotify event This will allow applications to respond to changes of power level of a monitor, e.g. an application may stop rendering and related calculations when the monitor is off. Bump DPMS version to 1.2, install dpmsproto.pc. Signed-off-by: Alexander Volkov --- Makefile.am | 3 + configure.ac | 1 + dpmsproto.pc.in | 8 +++ include/X11/extensions/dpmsconst.h | 5 +- include/X11/extensions/dpmsproto.h | 26 ++++++++ meson.build | 1 + specs/xextproto/dpms.xml | 104 +++++++++++++++++++++++++++-- 7 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 dpmsproto.pc.in diff --git a/Makefile.am b/Makefile.am index 18f4203..59c49cf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -48,6 +48,9 @@ dmx_HEADERS = \ dmxprotopkgconfigdir = $(datadir)/pkgconfig dmxprotopkgconfig_DATA = dmxproto.pc +dpmsprotopkgconfigdir = $(datadir)/pkgconfig +dpmsprotopkgconfig_DATA = dpmsproto.pc + dri2dir = $(includedir)/X11/extensions dri2_HEADERS = \ include/X11/extensions/dri2proto.h \ diff --git a/configure.ac b/configure.ac index 0df5858..5b73036 100644 --- a/configure.ac +++ b/configure.ac @@ -110,6 +110,7 @@ AC_CONFIG_FILES([applewmproto.pc compositeproto.pc damageproto.pc dmxproto.pc + dpmsproto.pc dri2proto.pc dri3proto.pc evieproto.pc diff --git a/dpmsproto.pc.in b/dpmsproto.pc.in new file mode 100644 index 0000000..930d208 --- /dev/null +++ b/dpmsproto.pc.in @@ -0,0 +1,8 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +includedir=@includedir@ + +Name: DPMSProto +Description: DPMS extension headers +Version: 1.2 +Cflags: -I${includedir} diff --git a/include/X11/extensions/dpmsconst.h b/include/X11/extensions/dpmsconst.h index 75f0586..f46d2d9 100644 --- a/include/X11/extensions/dpmsconst.h +++ b/include/X11/extensions/dpmsconst.h @@ -30,7 +30,7 @@ Equipment Corporation. #define _DPMSCONST_H 1 #define DPMSMajorVersion 1 -#define DPMSMinorVersion 1 +#define DPMSMinorVersion 2 #define DPMSExtensionName "DPMS" @@ -39,5 +39,8 @@ Equipment Corporation. #define DPMSModeSuspend 2 #define DPMSModeOff 3 +#define DPMSInfoNotifyMask (1L << 0) +#define DPMSInfoNotify 0 + #endif /* !_DPMSCONST_H */ diff --git a/include/X11/extensions/dpmsproto.h b/include/X11/extensions/dpmsproto.h index c847016..6b7e419 100644 --- a/include/X11/extensions/dpmsproto.h +++ b/include/X11/extensions/dpmsproto.h @@ -39,6 +39,7 @@ Equipment Corporation. #define X_DPMSDisable 5 #define X_DPMSForceLevel 6 #define X_DPMSInfo 7 +#define X_DPMSSelectInput 8 #define DPMSNumberEvents 0 @@ -172,4 +173,29 @@ typedef struct { } xDPMSInfoReply; #define sz_xDPMSInfoReply 32 +typedef struct { + CARD8 reqType; /* always DPMSCode */ + CARD8 dpmsReqType; /* always X_DPMSSelectInput */ + CARD16 length B16; + CARD32 eventMask B32; +} xDPMSSelectInputReq; +#define sz_xDPMSSelectInputReq 8 + +typedef struct { + CARD8 type; + CARD8 extension; + CARD16 sequenceNumber B16; + CARD32 length; + CARD16 evtype B16; + CARD16 pad0 B16; + Time timestamp B32; + CARD16 power_level B16; + BOOL state; + CARD8 pad1; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; +} xDPMSInfoNotifyEvent; +#define sz_xDPMSInfoNotifyEvent 32 + #endif /* _DPMSPROTO_H_ */ diff --git a/meson.build b/meson.build index 68e622a..eadc2fd 100644 --- a/meson.build +++ b/meson.build @@ -29,6 +29,7 @@ pcs = [ ['compositeproto', '0.4.2'], ['damageproto', '1.2.1'], ['dmxproto', '2.3.1'], + ['dpmsproto', '1.2'], ['dri2proto', '2.8'], ['dri3proto', '1.2'], ['fixesproto', '5.0'], diff --git a/specs/xextproto/dpms.xml b/specs/xextproto/dpms.xml index f504ab7..823344d 100644 --- a/specs/xextproto/dpms.xml +++ b/specs/xextproto/dpms.xml @@ -175,7 +175,7 @@ increment for small, upward-compatible changes. Servers that support the protocol defined in this document will return a server_major_version of one (1), and a server_minor_version -of one (1). +of two (2). @@ -435,13 +435,81 @@ of DPMSModeOn, DPMSModeStandby, DPMSModeSuspend or DPMSModeOff, otherwise it is undefined. + +DPMSSelectInput + + + + + + + + + +event_mask: CARD32 + + + + => + + + + + + +This request specifies whether DPMS extension events should be generated for this client. +If DPMSInfoNotifyMask is set in event-mask, then DPMSInfoNotifyEvent +events will be generated whenever the current DPMS on/off state or power level changes. +If no bits are set, then no events will be generated. + + - -Events and Errors + + +Events + +The DPMS extension adds one event: + -No new events or errors are defined by this extension. +DPMSInfoNotifyEvent + + + + + + + + +timestamp: TIMESTAMP + + + + +power_level: CARD16 + + + + +state: BOOL + + + + + + + +This event is delivered to clients that have requested +DPMSInfoNotifyMask events using the DPMSSelectInput request +whenever the current DPMS on/off state or power level changes. +state is one of DPMSEnabled or DPMSDisabled. +If state is DPMSEnabled, +power_level is one +of DPMSModeOn, DPMSModeStandby, DPMSModeSuspend or DPMSModeOff, otherwise +it is undefined. + + @@ -563,5 +631,33 @@ The name of this extension is "DPMS". 21 unused + + +DPMSSelectInput + 1 CARD8 opcode + 1 8 DPMS opcode + 2 2 request length + 4 event mask + 0 no events + 1 DPMSInfoNotifyMask + + + +DPMSInfoNotifyEvent + 1 GenericEvent type + 1 CARD8 DPMS extension offset + 2 CARD16 sequence number + 4 0 length + 2 DPMSInfoNotify evtype + 2 unused + 4 TIMESTAMP timestamp + 2 power_level + 0 DPMSModeOn + 1 DPMSModeStandby + 2 DPMSModeSuspend + 3 DPMSModeOff + 1 BOOL state + 13 unused + -- GitLab