summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-12-10 13:32:11 -0800
committerKeith Packard <keithp@keithp.com>2013-12-10 13:32:11 -0800
commit5de191e6b1847017ecc7e13bc195f47479d332ac (patch)
treeaa2d35f71c618c9505ac51ea2e183a515151787c
parent740fa7bc896293715afaa56b89e5eb4b5846ba13 (diff)
Update to protocol version 1.0
Add Idle and Redirect events, change PresentRegion to PresentPixmap, add capabilities Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--include/X11/extensions/Xpresent.h74
-rw-r--r--src/Xpresent.c119
2 files changed, 183 insertions, 10 deletions
diff --git a/include/X11/extensions/Xpresent.h b/include/X11/extensions/Xpresent.h
index b253870..f49b1a4 100644
--- a/include/X11/extensions/Xpresent.h
+++ b/include/X11/extensions/Xpresent.h
@@ -29,6 +29,8 @@
#include <X11/Xfuncproto.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/sync.h>
/*
* This revision number also appears in configure.ac, they have
@@ -42,6 +44,11 @@
*/
typedef struct {
+ Window window;
+ uint32_t serial;
+} XPresentNotify;
+
+typedef struct {
int type; /* event base */
unsigned long serial;
Bool send_event;
@@ -82,6 +89,58 @@ typedef struct {
uint64_t msc;
} XPresentCompleteNotifyEvent;
+typedef struct {
+ int type; /* event base */
+ unsigned long serial;
+ Bool send_event;
+ Display *display;
+ int extension;
+ int evtype;
+
+ uint32_t eid;
+ Window window;
+ uint32_t serial_number;
+ Pixmap pixmap;
+ XSyncFence idle_fence;
+} XPresentIdleNotifyEvent;
+
+typedef struct {
+ int type; /* event base */
+ unsigned long serial;
+ Bool send_event;
+ Display *display;
+ int extension;
+ int evtype;
+
+ uint32_t eid;
+ Window event_window;
+
+ Window window;
+ Pixmap pixmap;
+ uint32_t serial_number;
+
+ XserverRegion valid_region;
+ XserverRegion update_region;
+
+ XRectangle valid_rect;
+ XRectangle update_rect;
+
+ int x_off, y_off;
+
+ RRCrtc target_crtc;
+
+ XSyncFence wait_fence;
+ XSyncFence idle_fence;
+
+ uint32_t options;
+
+ uint64_t target_msc;
+ uint64_t divisor;
+ uint64_t remainder;
+ XPresentNotify *notifies;
+ int nnotifies;
+} XPresentRedirectNotifyEvent;
+
_XFUNCPROTOBEGIN
Bool XPresentQueryExtension (Display *dpy,
@@ -96,7 +155,7 @@ Status XPresentQueryVersion (Display *dpy,
int XPresentVersion (void);
void
-XPresentRegion(Display *dpy,
+XPresentPixmap(Display *dpy,
Window window,
Pixmap pixmap,
uint32_t serial,
@@ -104,10 +163,15 @@ XPresentRegion(Display *dpy,
XserverRegion update,
int x_off,
int y_off,
- XID idle_fence,
+ RRCrtc target_crtc,
+ XSyncFence wait_fence,
+ XSyncFence idle_fence,
+ uint32_t options,
uint64_t target_msc,
uint64_t divisor,
- uint64_t remainder);
+ uint64_t remainder,
+ XPresentNotify *notifies,
+ int nnotifies);
void
XPresentNotifyMSC(Display *dpy,
@@ -122,6 +186,10 @@ XPresentSelectInput(Display *dpy,
Window window,
unsigned event_mask);
+uint32_t
+XPresentQueryCapabilities(Display *dpy,
+ XID target);
+
_XFUNCPROTOEND
#endif /* _XPRESENT_H_ */
diff --git a/src/Xpresent.c b/src/Xpresent.c
index ffe82d7..b10b84d 100644
--- a/src/Xpresent.c
+++ b/src/Xpresent.c
@@ -176,8 +176,75 @@ XPresentWireToCookie(Display *dpy,
break;
}
- case PresentRedirectNotify:
+ case PresentIdleNotify: {
+ xPresentIdleNotify *proto = (xPresentIdleNotify *) ge;
+ XPresentIdleNotifyEvent *ce = malloc (sizeof (XPresentIdleNotifyEvent));
+ cookie->data = ce;
+
+ ce->type = cookie->type;
+ ce->serial = cookie->serial;
+ ce->send_event = cookie->send_event;
+ ce->display = cookie->display;
+ ce->extension = cookie->extension;
+ ce->evtype = cookie->evtype;
+
+ ce->eid = proto->eid;
+ ce->window = proto->window;
+ ce->serial_number = proto->serial;
+ ce->idle_fence = proto->idle_fence;
+
+ break;
+ }
+ case PresentRedirectNotify: {
+ xPresentRedirectNotify *proto = (xPresentRedirectNotify *) ge;
+ xPresentNotify *xNotify = (xPresentNotify *) (proto + 1);
+ int nnotifies = (((proto->length + 8) - (sizeof (xPresentRedirectNotify) >> 2))) >> 1;
+ XPresentRedirectNotifyEvent *re = malloc (sizeof (XPresentRedirectNotifyEvent) + nnotifies * sizeof (XPresentNotify));
+ XPresentNotify *XNotify = (XPresentNotify *) (re + 1);
+ int i;
+ cookie->data = re;
+
+ re->type = cookie->type;
+ re->serial = cookie->serial;
+ re->send_event = cookie->send_event;
+ re->display = cookie->display;
+ re->extension = cookie->extension;
+ re->evtype = cookie->evtype;
+
+ re->eid = proto->eid;
+ re->event_window = proto->event_window;
+
+ re->window = proto->window;
+ re->pixmap = proto->pixmap;
+ re->serial_number = proto->serial;
+
+ re->valid_region = proto->valid_region;
+ re->update_region = proto->update_region;
+
+ re->valid_rect = *(XRectangle *) &(proto->valid_rect);
+ re->update_rect = *(XRectangle *) &(proto->update_rect);
+
+ re->x_off = proto->x_off;
+ re->y_off = proto->y_off;
+ re->target_crtc = proto->target_crtc;
+
+ re->wait_fence = proto->wait_fence;
+ re->idle_fence = proto->idle_fence;
+
+ re->options = proto->options;
+
+ re->target_msc = proto->target_msc;
+ re->divisor = proto->divisor;
+ re->remainder = proto->remainder;
+
+ re->nnotifies = nnotifies;
+ re->notifies = XNotify;
+ for (i = 0; i < nnotifies; i++) {
+ XNotify[i].window = xNotify[i].window;
+ XNotify[i].serial = xNotify[i].serial;
+ }
break;
+ }
default:
printf("XPresentWireToCookie: Unknown generic event. type %d\n", ge->evtype);
@@ -395,7 +462,7 @@ XPresentVersion (void)
}
void
-XPresentRegion(Display *dpy,
+XPresentPixmap(Display *dpy,
Window window,
Pixmap pixmap,
uint32_t serial,
@@ -403,20 +470,26 @@ XPresentRegion(Display *dpy,
XserverRegion update,
int x_off,
int y_off,
- XID idle_fence,
+ RRCrtc target_crtc,
+ XSyncFence wait_fence,
+ XSyncFence idle_fence,
+ uint32_t options,
uint64_t target_msc,
uint64_t divisor,
- uint64_t remainder)
+ uint64_t remainder,
+ XPresentNotify *notifies,
+ int nnotifies)
{
XPresentExtDisplayInfo *info = XPresentFindDisplay (dpy);
- xPresentRegionReq *req;
+ xPresentPixmapReq *req;
+ long len = ((long) nnotifies) << 1;
XPresentSimpleCheckExtension (dpy, info);
LockDisplay (dpy);
- GetReq(PresentRegion, req);
+ GetReq(PresentPixmap, req);
req->reqType = info->codes->major_opcode;
- req->presentReqType = X_PresentRegion;
+ req->presentReqType = X_PresentPixmap;
req->window = window;
req->pixmap = pixmap;
req->serial = serial;
@@ -424,10 +497,15 @@ XPresentRegion(Display *dpy,
req->update = update;
req->x_off = x_off;
req->y_off = y_off;
+ req->target_crtc = target_crtc;
+ req->wait_fence = wait_fence;
req->idle_fence = idle_fence;
+ req->options = options;
req->target_msc = target_msc;
req->divisor = divisor;
req->remainder = remainder;
+ SetReqLen(req, len, len);
+ Data32(dpy, (CARD32 *) notifies, len);
UnlockDisplay (dpy);
SyncHandle();
}
@@ -479,3 +557,30 @@ XPresentSelectInput(Display *dpy,
SyncHandle();
return eid;
}
+
+uint32_t
+XPresentQueryCapabilities(Display *dpy,
+ XID target)
+{
+ XPresentExtDisplayInfo *info = XPresentFindDisplay (dpy);
+ xPresentQueryCapabilitiesReq *req;
+ xPresentQueryCapabilitiesReply rep;
+
+ XPresentCheckExtension (dpy, info, 0);
+ LockDisplay (dpy);
+ GetReq(PresentQueryCapabilities, req);
+ req->reqType = info->codes->major_opcode;
+ req->presentReqType = X_PresentQueryCapabilities;
+ req->target = target;
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ return 0;
+ }
+
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return rep.capabilities;
+}
+