summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-06-08 15:10:52 +0100
committerDave Airlie <airlied@redhat.com>2012-06-08 15:10:52 +0100
commitf94b6da6757500b00e29aa77c8a7d333d51be715 (patch)
tree86196352ebe712ce88b4290f9553c5b3244aa623
parente603a588b608ed2e3ff9234461709598b735f9dd (diff)
provider update to latest idea
-rw-r--r--include/X11/extensions/Xrandr.h14
-rw-r--r--src/XrrProvider.c34
2 files changed, 37 insertions, 11 deletions
diff --git a/include/X11/extensions/Xrandr.h b/include/X11/extensions/Xrandr.h
index 149ae2a..361773a 100644
--- a/include/X11/extensions/Xrandr.h
+++ b/include/X11/extensions/Xrandr.h
@@ -467,11 +467,15 @@ void
XRRFreeProviderResources(XRRProviderResources *resources);
typedef struct _XRRProviderInfo {
- unsigned int current_role;
- unsigned int allowed_roles;
- unsigned int abilities;
- int ncrtcs;
- int noutputs;
+ unsigned int current_role;
+ unsigned int allowed_roles;
+ unsigned int abilities;
+ int ncrtcs;
+ RRCrtc *crtcs;
+ int noutputs;
+ RROutput *outputs;
+ char *name;
+ int nameLen;
} XRRProviderInfo;
XRRProviderInfo *
diff --git a/src/XrrProvider.c b/src/XrrProvider.c
index 72f5d22..baf4bfe 100644
--- a/src/XrrProvider.c
+++ b/src/XrrProvider.c
@@ -90,7 +90,7 @@ XRRGetProviderResources(Display *dpy, Window window)
return (XRRProviderResources *) xrpr;
}
-
+#define ProviderInfoExtra (SIZEOF(xRRGetProviderInfoReply) - 32)
XRRProviderInfo *
XRRGetProviderInfo(Display *dpy, XID provider)
{
@@ -108,17 +108,23 @@ XRRGetProviderInfo(Display *dpy, XID provider)
req->randrReqType = X_RRGetProviderInfo;
req->provider = provider;
-
- if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
+ if (!_XReply (dpy, (xReply *) &rep, ProviderInfoExtra >> 2, xFalse))
{
UnlockDisplay (dpy);
SyncHandle ();
return NULL;
}
- nbytes = (long) rep.length << 2;
+ nbytes = ((long) rep.length << 2) - ProviderInfoExtra;
- rbytes = sizeof(XRRProviderInfo);
+ nbytesRead = (long)(rep.nCrtcs * 4 +
+ rep.nOutputs * 4 +
+ ((rep.nameLength + 3) & ~3));
+
+ rbytes = (sizeof(XRRProviderInfo) +
+ rep.nCrtcs * sizeof(RRCrtc) +
+ rep.nOutputs * sizeof(RROutput) +
+ rep.nameLength + 1);
xpi = (XRRProviderInfo *)Xmalloc(rbytes);
if (xpi == NULL) {
@@ -133,6 +139,22 @@ XRRGetProviderInfo(Display *dpy, XID provider)
xpi->current_role = rep.current_role;
xpi->ncrtcs = rep.nCrtcs;
xpi->noutputs = rep.nOutputs;
+ xpi->crtcs = (RRCrtc *)(xpi + 1);
+ xpi->outputs = (RROutput *)(xpi->crtcs + rep.nCrtcs);
+ xpi->name = (char *)(xpi->outputs + rep.nOutputs);
+
+ _XRead32(dpy, xpi->crtcs, rep.nCrtcs << 2);
+ _XRead32(dpy, xpi->outputs, rep.nOutputs << 2);
+
+ _XReadPad(dpy, xpi->name, rep.nameLength);
+ xpi->name[rep.nameLength] = '\0';
+
+ /*
+ * Skip any extra data
+ */
+ if (nbytes > nbytesRead)
+ _XEatData (dpy, (unsigned long) (nbytes - nbytesRead));
+
UnlockDisplay (dpy);
SyncHandle ();
return (XRRProviderInfo *) xpi;
@@ -153,7 +175,7 @@ XRRSetProviderRoles(Display *dpy, int nproviders,
xRRSetProviderRolesReq *req;
int len;
- RRSimpleCheckExtension (dpy, info);
+ RRCheckExtension (dpy, info, 0);
LockDisplay (dpy);
GetReq (RRSetProviderRoles, req);
req->reqType = info->codes->major_opcode;