Skip to content

Commit

Permalink
RandR working with old clients and old API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Packard authored and Keith Packard committed Nov 16, 2006
1 parent db45767 commit 0b22ab2
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 5 deletions.
5 changes: 3 additions & 2 deletions randr/randr.c
Expand Up @@ -477,6 +477,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
if (!output)
return;
RROutputSetCrtcs (output, &crtc, 1);
RROutputSetCrtc (output, crtc);
RROutputSetConnection (output, RR_Connected);
}

Expand Down Expand Up @@ -552,8 +553,8 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)

/* notice current mode */
if (newMode)
RRCrtcSet (output->crtc, newMode, 0, 0, pScrPriv->rotation,
1, &output);
RRCrtcNotify (output->crtc, newMode, 0, 0, pScrPriv->rotation,
1, &output);
}
#endif

Expand Down
3 changes: 3 additions & 0 deletions randr/randrstr.h
Expand Up @@ -482,6 +482,9 @@ RROutputSetCrtcs (RROutputPtr output,
RRCrtcPtr *crtcs,
int numCrtcs);

void
RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc);

Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection);
Expand Down
16 changes: 16 additions & 0 deletions randr/rrcrtc.c
Expand Up @@ -59,7 +59,13 @@ RRCrtcCreate (ScreenPtr pScreen,
crtc->numOutputs = 0;
crtc->changed = TRUE;
crtc->devPrivate = devPrivate;

if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
return NULL;

pScrPriv->crtcs = crtcs;
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
pScrPriv->changed = TRUE;
return crtc;
}

Expand Down Expand Up @@ -165,6 +171,16 @@ RRCrtcSet (RRCrtcPtr crtc,
ScreenPtr pScreen = crtc->pScreen;
rrScrPriv(pScreen);

/* See if nothing changed */
if (crtc->mode == mode &&
crtc->x == x &&
crtc->y == y &&
crtc->rotation == rotation &&
crtc->numOutputs == numOutputs &&
!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)))
{
return TRUE;
}
#if RANDR_12_INTERFACE
if (pScrPriv->rrCrtcSet)
{
Expand Down
6 changes: 3 additions & 3 deletions randr/rrdispatch.c
Expand Up @@ -824,7 +824,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
if (!crtc)
{
client->errorValue = stuff->crtc;
return RRErrorBase + BadCrtc;
return RRErrorBase + BadRRCrtc;
}
if (stuff->mode == None)
{
Expand All @@ -838,7 +838,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
if (!mode)
{
client->errorValue = stuff->mode;
return RRErrorBase + BadMode;
return RRErrorBase + BadRRMode;
}
if (numOutputs == 0)
return BadMatch;
Expand All @@ -854,7 +854,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
if (!outputs[i])
{
client->errorValue = outputIds[i];
return RRErrorBase + BadOutput;
return RRErrorBase + BadRROutput;
}
/* validate crtc for this output */
for (j = 0; j < outputs[i]->numCrtcs; j++)
Expand Down
19 changes: 19 additions & 0 deletions randr/rrmode.c
Expand Up @@ -32,6 +32,7 @@ RRModeGet (ScreenPtr pScreen,
rrScrPriv (pScreen);
int i;
RRModePtr mode;
RRModePtr *modes;

for (i = 0; i < pScrPriv->numModes; i++)
{
Expand All @@ -43,16 +44,34 @@ RRModeGet (ScreenPtr pScreen,
return mode;
}
}

mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
if (!mode)
return NULL;
mode->refcnt = 1;
mode->mode = *modeInfo;
mode->name = (char *) (mode + 1);
memcpy (mode->name, name, modeInfo->nameLength);
mode->name[modeInfo->nameLength] = '\0';

if (pScrPriv->numModes)
modes = xrealloc (pScrPriv->modes,
(pScrPriv->numModes + 1) * sizeof (RRModePtr));
else
modes = xalloc (sizeof (RRModePtr));

if (!modes)
{
xfree (mode);
return NULL;
}

mode->id = FakeClientID(0);
if (!AddResource (mode->id, RRModeType, (pointer) mode))
return NULL;
++mode->refcnt;
pScrPriv->modes = modes;
pScrPriv->modes[pScrPriv->numModes++] = mode;
pScrPriv->changed = TRUE;
return mode;
}
Expand Down
18 changes: 18 additions & 0 deletions randr/rroutput.c
Expand Up @@ -56,6 +56,7 @@ RROutputCreate (ScreenPtr pScreen,
output->name = (char *) (output + 1);
output->nameLength = nameLength;
memcpy (output->name, name, nameLength);
output->name[nameLength] = '\0';
output->connection = RR_UnknownConnection;
output->subpixelOrder = SubPixelUnknown;
output->crtc = NULL;
Expand All @@ -67,7 +68,13 @@ RROutputCreate (ScreenPtr pScreen,
output->modes = NULL;
output->changed = TRUE;
output->devPrivate = devPrivate;

if (!AddResource (output->id, RROutputType, (pointer) output))
return NULL;

pScrPriv->outputs = outputs;
pScrPriv->outputs[pScrPriv->numOutputs++] = output;
pScrPriv->changed = TRUE;
return output;
}

Expand All @@ -89,6 +96,7 @@ RROutputSetClones (RROutputPtr output,
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
output->clones = newClones;
output->numClones = numClones;
output->changed = TRUE;
return TRUE;
}

Expand All @@ -107,6 +115,7 @@ RROutputSetModes (RROutputPtr output,
memcpy (newModes, modes, numModes * sizeof (RRModePtr));
output->modes = newModes;
output->numModes = numModes;
output->changed = TRUE;
return TRUE;
}

Expand All @@ -125,14 +134,23 @@ RROutputSetCrtcs (RROutputPtr output,
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
output->crtcs = newCrtcs;
output->numCrtcs = numCrtcs;
output->changed = TRUE;
return TRUE;
}

void
RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc)
{
output->crtc = crtc;
output->changed = TRUE;
}

Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection)
{
output->connection = connection;
output->changed = TRUE;
return TRUE;
}

Expand Down

0 comments on commit 0b22ab2

Please sign in to comment.