diff options
author | Adam Jackson <ajax@redhat.com> | 2008-12-08 15:37:53 -0500 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2008-12-08 15:37:53 -0500 |
commit | 59c8812099f33d56b43044f999ffe5df16adf5ff (patch) | |
tree | 2a36682ff006101dccb75024112be5d55f8ff768 | |
parent | 0f11922bdc0d4e3929df4dc967379ea0b48338b8 (diff) |
Add [GS]etOutputPrimary
-rw-r--r-- | include/X11/extensions/Xrandr.h | 10 | ||||
-rw-r--r-- | src/XrrOutput.c | 62 |
2 files changed, 72 insertions, 0 deletions
diff --git a/include/X11/extensions/Xrandr.h b/include/X11/extensions/Xrandr.h index 80d9d47..a411321 100644 --- a/include/X11/extensions/Xrandr.h +++ b/include/X11/extensions/Xrandr.h @@ -2,6 +2,7 @@ * Copyright © 2000 Compaq Computer Corporation, Inc. * Copyright © 2002 Hewlett-Packard Company, Inc. * Copyright © 2006 Intel Corporation + * Copyright © 2008 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -440,6 +441,15 @@ XRRSetPanning (Display *dpy, RRCrtc crtc, XRRPanning *panning); +void +XRRSetOutputPrimary(Display *dpy, + Window window, + RROutput output); + +RROutput +XRRGetOutputPrimary(Display *dpy, + Window window); + _XFUNCPROTOEND #endif /* _XRANDR_H_ */ diff --git a/src/XrrOutput.c b/src/XrrOutput.c index 1fe03ae..bc35fd1 100644 --- a/src/XrrOutput.c +++ b/src/XrrOutput.c @@ -1,5 +1,6 @@ /* * Copyright © 2006 Keith Packard + * Copyright © 2008 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -129,3 +130,64 @@ XRRFreeOutputInfo (XRROutputInfo *outputInfo) { Xfree (outputInfo); } + +static Bool +_XRRHasOutputPrimary (int major, int minor) +{ + return major > 1 || (major == 1 && minor >= 3); +} + +void +XRRSetOutputPrimary(Display *dpy, Window window, RROutput output) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRSetOutputPrimaryReq *req; + int i; + int major_version, minor_version; + + RRCheckExtension (dpy, info, 0); + + if (!XRRQueryVersion (dpy, &major_version, &minor_version) || + !_XRRHasOutputPrimary (major_version, minor_version)) + return; + + LockDisplay(dpy); + GetReq (RRSetOutputPrimary, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRSetOutputPrimary; + req->window = window; + req->output = output; + + UnlockDisplay (dpy); + SyncHandle (); +} + +RROutput +XRRGetOutputPrimary(Display *dpy, Window window) +{ + XExtDisplayInfo *info = XRRFindDisplay(dpy); + xRRGetOutputPrimaryReq *req; + xRRGetOutputPrimaryReply rep; + int i; + int major_version, minor_version; + + RRCheckExtension (dpy, info, 0); + + if (!XRRQueryVersion (dpy, &major_version, &minor_version) || + !_XRRHasOutputPrimary (major_version, minor_version)) + return None; + + LockDisplay(dpy); + GetReq (RRSetOutputPrimary, req); + req->reqType = info->codes->major_opcode; + req->randrReqType = X_RRGetOutputProperty; + req->window = window; + + if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) + rep.output = None; + + UnlockDisplay(dpy); + SyncHandle(); + + return rep.output; +} |