[xorgproto] Add DPMSInfoNotify event

Submitted by Alexander Volkov on Oct. 2, 2018, 1:10 p.m.

Details

Message ID 20181002131038.17564-1-avolkov@astralinux.ru
State New
Series "Add DPMSInfoNotify event"
Headers show

Commit Message

Alexander Volkov Oct. 2, 2018, 1:10 p.m.
From: Alexander Volkov <a.volkov@rusbitech.ru>

This allows 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.

Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
---
 include/X11/extensions/dpmsconst.h |  5 ++++-
 include/X11/extensions/dpmsproto.h | 27 ++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

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 63fd3fc..9c26054 100644
--- a/include/X11/extensions/dpmsproto.h
+++ b/include/X11/extensions/dpmsproto.h
@@ -39,8 +39,9 @@  Equipment Corporation.
 #define X_DPMSDisable		5
 #define X_DPMSForceLevel       	6
 #define X_DPMSInfo       	7
+#define X_DPMSSelectInput	8
 
-#define DPMSNumberEvents	0
+#define DPMSNumberEvents	1
 
 #define DPMSNumberErrors	0
 
@@ -172,4 +173,28 @@  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;		/* always eventBase + DPMSInfoNotify */
+    CARD8	pad0;
+    CARD16	sequenceNumber B16;
+    Time	timestamp B32;
+    CARD16	power_level B16;
+    BOOL	state;
+    CARD8	pad1;
+    CARD32	pad2 B32;
+    CARD32	pad3 B32;
+    CARD32	pad4 B32;
+    CARD32	pad5 B32;
+    CARD32	pad6 B32;
+} xDPMSInfoNotifyEvent;
+#define sz_xDPMSInfoNotifyEvent 32
+
 #endif /* _DPMSPROTO_H_ */

Comments

Julien Cristau Oct. 2, 2018, 2:33 p.m.
On 10/02/2018 03:10 PM, Alexander Volkov wrote:
> From: Alexander Volkov <a.volkov@rusbitech.ru>
> 
> This allows 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.
> 
> Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
> ---
>  include/X11/extensions/dpmsconst.h |  5 ++++-
>  include/X11/extensions/dpmsproto.h | 27 ++++++++++++++++++++++++++-
>  2 files changed, 30 insertions(+), 2 deletions(-)
> 
We shouldn't be adding new extension events that don't come through the
Generic Event Extension, as the extension event space is basically full,
IIRC (see
https://lists.x.org/pipermail/xorg-devel/2010-March/006716.html).  This
also seems like it might belong in RANDR rather than DPMS, as DPMS
doesn't actually tie things to a monitor?

Cheers,
Julien
Alexander Volkov Oct. 2, 2018, 2:51 p.m.
02.10.2018 17:33, Julien Cristau пишет:
> We shouldn't be adding new extension events that don't come through the
> Generic Event Extension, as the extension event space is basically full,
> IIRC (see
> https://lists.x.org/pipermail/xorg-devel/2010-March/006716.html).
Ok, thanks.

> This also seems like it might belong in RANDR rather than DPMS, as DPMS
> doesn't actually tie things to a monitor?
DPMS turns off/on all monitors. It's more convenient to process a single 
event
than to detect available area from monitor's state.
Besides it seems much harder to implemet DPMS for RANDR.
Peter Harris Oct. 2, 2018, 3:46 p.m.
On 2018-10-02 Alexander Volkov wrote:
> 

> -#define DPMSNumberEvents	0

> +#define DPMSNumberEvents	1


I don't have a strong opinion, so feel free to ignore me, but in general we don't add core events any more (the limited event space is already full in some configurations).

The "modern" way to add events to extensions is called "generic events". Xcb has <event xge="true">. I'm not sure how Xlib works. See the Present extension for a recent example that uses generic events.

Peter Harris