summaryrefslogtreecommitdiff
path: root/randr/rroutput.c
diff options
context:
space:
mode:
Diffstat (limited to 'randr/rroutput.c')
-rw-r--r--randr/rroutput.c109
1 files changed, 108 insertions, 1 deletions
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 1ecde31a2..48b5700c8 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -1,8 +1,9 @@
/*
* 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
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
@@ -423,13 +424,13 @@ RROutputInit (void)
return FALSE;
RegisterResourceName (RROutputType, "OUTPUT");
return TRUE;
}
#define OutputInfoExtra (SIZEOF(xRRGetOutputInfoReply) - 32)
-
+
int
ProcRRGetOutputInfo (ClientPtr client)
{
REQUEST(xRRGetOutputInfoReq);
xRRGetOutputInfoReply rep;
RROutputPtr output;
@@ -530,6 +531,112 @@ ProcRRGetOutputInfo (ClientPtr client)
WriteToClient (client, extraLen, (char *) extra);
xfree (extra);
}
return client->noClientException;
}
+
+void
+RRSetPrimaryOutput(ScreenPtr pScreen, rrScrPrivPtr pScrPriv,
+ RROutputPtr output)
+{
+ if (pScrPriv->primaryOutput == output)
+ return;
+
+ /* clear the old primary */
+ if (pScrPriv->primaryOutput) {
+ RROutputChanged(pScrPriv->primaryOutput, 0);
+ pScrPriv->primaryOutput = NULL;
+ }
+
+ /* set the new primary */
+ if (output) {
+ pScrPriv->primaryOutput = output;
+ RROutputChanged(output, 0);
+ }
+
+ pScrPriv->layoutChanged = TRUE;
+
+ RRTellChanged(pScreen);
+}
+
+int
+ProcRRSetOutputPrimary(ClientPtr client)
+{
+ REQUEST(xRRSetOutputPrimaryReq);
+ RROutputPtr output = NULL;
+ WindowPtr pWin;
+ rrScrPrivPtr pScrPriv;
+
+ REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
+
+ pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW,
+ DixReadAccess);
+
+ if (!pWin) {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+
+ if (stuff->output) {
+ output = LookupOutput(client, stuff->output, DixReadAccess);
+
+ if (!output) {
+ client->errorValue = stuff->output;
+ return RRErrorBase + BadRROutput;
+ }
+
+ if (output->crtc) {
+ client->errorValue = stuff->output;
+ return BadMatch;
+ }
+
+ if (output->pScreen != pWin->drawable.pScreen) {
+ client->errorValue = stuff->window;
+ return BadMatch;
+ }
+ }
+
+ pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
+ RRSetPrimaryOutput(pWin->drawable.pScreen, pScrPriv, output);
+
+ return client->noClientException;
+}
+
+int
+ProcRRGetOutputPrimary(ClientPtr client)
+{
+ REQUEST(xRRGetOutputPrimaryReq);
+ WindowPtr pWin;
+ rrScrPrivPtr pScrPriv;
+ xRRGetOutputPrimaryReply rep;
+ RROutputPtr primary = NULL;
+
+ REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
+
+ pWin = SecurityLookupIDByType(client, stuff->window, RT_WINDOW,
+ DixReadAccess);
+
+ if (!pWin) {
+ client->errorValue = stuff->window;
+ return BadWindow;
+ }
+
+ pScrPriv = rrGetScrPriv(pWin->drawable.pScreen);
+ if (pScrPriv)
+ primary = pScrPriv->primaryOutput;
+
+ memset(&rep, 0, sizeof(rep));
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.output = primary ? primary->id : None;
+
+ if (client->swapped) {
+ int n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.output, n);
+ }
+
+ WriteToClient(client, sizeof(xRRGetOutputPrimaryReply), &rep);
+
+ return client->noClientException;
+}