summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2008-12-08 15:37:53 -0500
committerAdam Jackson <ajax@redhat.com>2008-12-08 15:37:53 -0500
commit59c8812099f33d56b43044f999ffe5df16adf5ff (patch)
tree2a36682ff006101dccb75024112be5d55f8ff768 /src
parent0f11922bdc0d4e3929df4dc967379ea0b48338b8 (diff)
Add [GS]etOutputPrimary
Diffstat (limited to 'src')
-rw-r--r--src/XrrOutput.c62
1 files changed, 62 insertions, 0 deletions
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;
+}