diff options
author | Keith Packard <keithp@keithp.com> | 2008-03-04 08:17:48 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-03-10 21:42:49 -0700 |
commit | 2a5fb0e58ed6ee1ff1f0ff00b5bf5b2623991132 (patch) | |
tree | 05dce68a38bc8fc42ed8acb833963e7016875280 /src | |
parent | 23a47035818390ca197179a9a69a54badb370990 (diff) |
Add support for new Transform requests.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Xrandr.c | 28 | ||||
-rw-r--r-- | src/XrrCrtc.c | 156 |
3 files changed, 176 insertions, 10 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index b884a39..57aa59c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,7 @@ AM_CFLAGS = @X_CFLAGS@ @RANDR_CFLAGS@ @MALLOC_ZERO_CFLAGS@ INCLUDES = -I$(top_srcdir)/include/X11/extensions -libXrandr_la_LDFLAGS = -version-number 2:1:0 -no-undefined +libXrandr_la_LDFLAGS = -version-number 2:2:0 -no-undefined libXrandrincludedir = $(includedir)/X11/extensions libXrandrinclude_HEADERS = $(top_srcdir)/include/X11/extensions/Xrandr.h diff --git a/src/Xrandr.c b/src/Xrandr.c index b6068dc..bcc732b 100644 --- a/src/Xrandr.c +++ b/src/Xrandr.c @@ -88,18 +88,16 @@ static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire) return True; } case RRNotify: { - XRRNotifyEvent *aevent = (XRRNotifyEvent *) event; - xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; - aevent->type = awire->type & 0x7F; - aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); - aevent->send_event = (awire->type & 0x80) != 0; - aevent->display = dpy; - aevent->window = awire->window; - aevent->subtype = awire->subCode; - switch (aevent->subtype) { + switch (wire->u.u.detail) { case RRNotify_OutputChange: { XRROutputChangeNotifyEvent *aevent = (XRROutputChangeNotifyEvent *) event; xRROutputChangeNotifyEvent *awire = (xRROutputChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; aevent->output = awire->output; aevent->crtc = awire->crtc; aevent->mode = awire->mode; @@ -111,6 +109,12 @@ static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire) case RRNotify_CrtcChange: { XRRCrtcChangeNotifyEvent *aevent = (XRRCrtcChangeNotifyEvent *) event; xRRCrtcChangeNotifyEvent *awire = (xRRCrtcChangeNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; aevent->crtc = awire->crtc; aevent->mode = awire->mode; aevent->rotation = awire->rotation; @@ -123,6 +127,12 @@ static Bool XRRWireToEvent(Display *dpy, XEvent *event, xEvent *wire) case RRNotify_OutputProperty: { XRROutputPropertyNotifyEvent *aevent = (XRROutputPropertyNotifyEvent *) event; xRROutputPropertyNotifyEvent *awire = (xRROutputPropertyNotifyEvent *) wire; + aevent->type = awire->type & 0x7F; + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->window = awire->window; + aevent->subtype = awire->subCode; aevent->output = awire->output; aevent->property = awire->atom; aevent->timestamp = awire->timestamp; diff --git a/src/XrrCrtc.c b/src/XrrCrtc.c index 5e5c813..5b952e4 100644 --- a/src/XrrCrtc.c +++ b/src/XrrCrtc.c @@ -270,3 +270,159 @@ XRRFreeGamma (XRRCrtcGamma *crtc_gamma) { Xfree (crtc_gamma); } + +/* Version 1.3 additions */ + +void +XRRSetCrtcTransform (Display *dpy, + RRCrtc crtc, + XTransform *transform, + XTransform *inverse) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetCrtcTransformReq *req; + + RRSimpleCheckExtension (dpy, info); + + LockDisplay(dpy); + GetReq (RRSetCrtcTransform, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetCrtcTransform; + req->crtc = crtc; + + req->transform.matrix11 = transform->matrix[0][0]; + req->transform.matrix12 = transform->matrix[0][1]; + req->transform.matrix13 = transform->matrix[0][2]; + req->transform.matrix21 = transform->matrix[1][0]; + req->transform.matrix22 = transform->matrix[1][1]; + req->transform.matrix23 = transform->matrix[1][2]; + req->transform.matrix31 = transform->matrix[2][0]; + req->transform.matrix32 = transform->matrix[2][1]; + req->transform.matrix33 = transform->matrix[2][2]; + + req->inverse.matrix11 = inverse->matrix[0][0]; + req->inverse.matrix12 = inverse->matrix[0][1]; + req->inverse.matrix13 = inverse->matrix[0][2]; + req->inverse.matrix21 = inverse->matrix[1][0]; + req->inverse.matrix22 = inverse->matrix[1][1]; + req->inverse.matrix23 = inverse->matrix[1][2]; + req->inverse.matrix31 = inverse->matrix[2][0]; + req->inverse.matrix32 = inverse->matrix[2][1]; + req->inverse.matrix33 = inverse->matrix[2][2]; + + UnlockDisplay (dpy); + SyncHandle (); +} + +#define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32) + +static const xRenderTransform identity = { + 0x10000, 0, 0, + 0, 0x10000, 0, + 0, 0, 0x10000, +}; + +static Bool +_XRRHasTransform (int major, int minor) +{ + return major > 1 || (major == 1 && minor >= 3); +} + +Status +XRRGetCrtcTransform (Display *dpy, + RRCrtc crtc, + XTransform *pendingTransform, + XTransform *pendingInverse, + XTransform *currentTransform, + XTransform *currentInverse) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + XRandRInfo *xrri; + xRRGetCrtcTransformReply rep; + xRRGetCrtcTransformReq *req; + int major_version, minor_version; + + RRCheckExtension (dpy, info, False); + + if (!XRRQueryVersion (dpy, &major_version, &minor_version) || + !_XRRHasTransform (major_version, minor_version)) + { + /* For pre-1.3 servers, just report identity matrices everywhere */ + rep.pendingTransform = identity; + rep.pendingInverse = identity; + rep.currentTransform = identity; + rep.currentInverse = identity; + } + else + { + LockDisplay (dpy); + GetReq (RRGetCrtcTransform, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetCrtcTransform; + req->crtc = crtc; + + if (!_XReply (dpy, (xReply *) &rep, CrtcTransformExtra >> 2, xFalse)) + { + rep.pendingTransform = identity; + rep.pendingInverse = identity; + rep.currentTransform = identity; + rep.currentInverse = identity; + } + UnlockDisplay (dpy); + SyncHandle (); + } + + if (pendingTransform) + { + pendingTransform->matrix[0][0] = rep.pendingTransform.matrix11; + pendingTransform->matrix[0][1] = rep.pendingTransform.matrix12; + pendingTransform->matrix[0][2] = rep.pendingTransform.matrix13; + pendingTransform->matrix[1][0] = rep.pendingTransform.matrix21; + pendingTransform->matrix[1][1] = rep.pendingTransform.matrix22; + pendingTransform->matrix[1][2] = rep.pendingTransform.matrix23; + pendingTransform->matrix[2][0] = rep.pendingTransform.matrix31; + pendingTransform->matrix[2][1] = rep.pendingTransform.matrix32; + pendingTransform->matrix[2][2] = rep.pendingTransform.matrix33; + } + + if (pendingInverse) + { + pendingInverse->matrix[0][0] = rep.pendingInverse.matrix11; + pendingInverse->matrix[0][1] = rep.pendingInverse.matrix12; + pendingInverse->matrix[0][2] = rep.pendingInverse.matrix13; + pendingInverse->matrix[1][0] = rep.pendingInverse.matrix21; + pendingInverse->matrix[1][1] = rep.pendingInverse.matrix22; + pendingInverse->matrix[1][2] = rep.pendingInverse.matrix23; + pendingInverse->matrix[2][0] = rep.pendingInverse.matrix31; + pendingInverse->matrix[2][1] = rep.pendingInverse.matrix32; + pendingInverse->matrix[2][2] = rep.pendingInverse.matrix33; + } + + if (currentTransform) + { + currentTransform->matrix[0][0] = rep.currentTransform.matrix11; + currentTransform->matrix[0][1] = rep.currentTransform.matrix12; + currentTransform->matrix[0][2] = rep.currentTransform.matrix13; + currentTransform->matrix[1][0] = rep.currentTransform.matrix21; + currentTransform->matrix[1][1] = rep.currentTransform.matrix22; + currentTransform->matrix[1][2] = rep.currentTransform.matrix23; + currentTransform->matrix[2][0] = rep.currentTransform.matrix31; + currentTransform->matrix[2][1] = rep.currentTransform.matrix32; + currentTransform->matrix[2][2] = rep.currentTransform.matrix33; + } + + if (currentInverse) + { + currentInverse->matrix[0][0] = rep.currentInverse.matrix11; + currentInverse->matrix[0][1] = rep.currentInverse.matrix12; + currentInverse->matrix[0][2] = rep.currentInverse.matrix13; + currentInverse->matrix[1][0] = rep.currentInverse.matrix21; + currentInverse->matrix[1][1] = rep.currentInverse.matrix22; + currentInverse->matrix[1][2] = rep.currentInverse.matrix23; + currentInverse->matrix[2][0] = rep.currentInverse.matrix31; + currentInverse->matrix[2][1] = rep.currentInverse.matrix32; + currentInverse->matrix[2][2] = rep.currentInverse.matrix33; + } + + return True; +} |