summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2008-12-09 10:51:37 -0500
committerAdam Jackson <ajax@redhat.com>2008-12-16 09:55:09 -0500
commit0bdfdaa7df8105c7ffc3248a4fdd5f64da67103c (patch)
tree7aa2618690aa2f9db10c3ef521e7fd20bb59f14a
parent09039fb89f3fd047f10b575e019bba6762448456 (diff)
randr: Add [GS]etOutputPrimary
(cherry picked from commit 9d58d2a319059989ccdfa758f586149ccdc16df6)
-rw-r--r--randr/randrstr.h8
-rw-r--r--randr/rrdispatch.c2
-rw-r--r--randr/rroutput.c109
-rw-r--r--randr/rrsdispatch.c27
4 files changed, 145 insertions, 1 deletions
diff --git a/randr/randrstr.h b/randr/randrstr.h
index f6aa5c7ec..b5cebdc7e 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -1,10 +1,11 @@
/*
* Copyright © 2000 Compaq Computer Corporation
* Copyright © 2002 Hewlett-Packard Company
* 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
* 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
@@ -269,12 +270,13 @@ typedef struct _rrScrPriv {
CARD16 maxWidth, maxHeight;
CARD16 width, height; /* last known screen size */
CARD16 mmWidth, mmHeight; /* last known screen size */
int numOutputs;
RROutputPtr *outputs;
+ RROutputPtr primaryOutput;
int numCrtcs;
RRCrtcPtr *crtcs;
/* Last known pointer position */
RRCrtcPtr pointerCrtc;
@@ -819,12 +821,18 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
void
RROutputDestroy (RROutputPtr output);
int
ProcRRGetOutputInfo (ClientPtr client);
+extern int
+ProcRRSetOutputPrimary (ClientPtr client);
+
+extern int
+ProcRRGetOutputPrimary (ClientPtr client);
+
/*
* Initialize output type
*/
Bool
RROutputInit (void);
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 0cc0bca98..5a2ea715f 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -214,8 +214,10 @@ int (*ProcRandrVector[RRNumberRequests])(ClientPtr) = {
/* V1.3 additions */
ProcRRGetScreenResourcesCurrent, /* 25 */
ProcRRSetCrtcTransform, /* 26 */
ProcRRGetCrtcTransform, /* 27 */
ProcRRGetPanning, /* 28 */
ProcRRSetPanning, /* 29 */
+ ProcRRSetOutputPrimary, /* 30 */
+ ProcRRGetOutputPrimary, /* 31 */
};
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;
+}
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 3ff9f3f85..9fbf8f0f5 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -433,12 +433,37 @@ SProcRRSetPanning (ClientPtr client)
swaps(&stuff->border_top, n);
swaps(&stuff->border_right, n);
swaps(&stuff->border_bottom, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
}
+static int
+SProcRRSetOutputPrimary (ClientPtr client)
+{
+ int n;
+ REQUEST(xRRSetOutputPrimaryReq);
+
+ REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ swapl(&stuff->output, n);
+ return ProcRandrVector[stuff->randrReqType](client);
+}
+
+static int
+SProcRRGetOutputPrimary (ClientPtr client)
+{
+ int n;
+ REQUEST(xRRSetOutputPrimaryReq);
+
+ REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->window, n);
+ return ProcRandrVector[stuff->randrReqType](client);
+}
+
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRQueryVersion, /* 0 */
/* we skip 1 to make old clients fail pretty immediately */
NULL, /* 1 SProcRandrOldGetScreenInfo */
/* V1.0 apps share the same set screen config request id */
SProcRRSetScreenConfig, /* 2 */
@@ -469,8 +494,10 @@ int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
/* V1.3 additions */
SProcRRGetScreenResources, /* 25 GetScreenResourcesCurrent */
SProcRRSetCrtcTransform, /* 26 */
SProcRRGetCrtcTransform, /* 27 */
SProcRRGetPanning, /* 28 */
SProcRRSetPanning, /* 29 */
+ SProcRRSetOutputPrimary, /* 30 */
+ SProcRRGetOutputPrimary, /* 31 */
};