aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/dispatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix/dispatch.c')
-rw-r--r--xorg-server/dix/dispatch.c316
1 files changed, 193 insertions, 123 deletions
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index fa397285c..3c6a591db 100644
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -466,8 +466,6 @@ Dispatch(void)
static int VendorRelease = VENDOR_RELEASE;
static char *VendorString = VENDOR_NAME;
-static const int padlength[4] = { 0, 3, 2, 1 };
-
void
SetVendorRelease(int release)
{
@@ -528,7 +526,7 @@ CreateConnectionBlock(void)
memmove(pBuf, VendorString, (int) setup.nbytesVendor);
sizesofar += setup.nbytesVendor;
pBuf += setup.nbytesVendor;
- i = padlength[setup.nbytesVendor & 3];
+ i = padding_for_int32(setup.nbytesVendor);
sizesofar += i;
while (--i >= 0)
*pBuf++ = 0;
@@ -926,10 +924,9 @@ GetGeometry(ClientPtr client, xGetGeometryReply * rep)
int
ProcGetGeometry(ClientPtr client)
{
- xGetGeometryReply rep;
+ xGetGeometryReply rep = { .type = X_Reply };
int status;
- memset(&rep, 0, sizeof(xGetGeometryReply));
if ((status = GetGeometry(client, &rep)) != Success)
return status;
@@ -951,14 +948,13 @@ ProcQueryTree(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
- memset(&reply, 0, sizeof(xQueryTreeReply));
- reply.type = X_Reply;
- reply.root = pWin->drawable.pScreen->root->drawable.id;
- reply.sequenceNumber = client->sequence;
- if (pWin->parent)
- reply.parent = pWin->parent->drawable.id;
- else
- reply.parent = (Window) None;
+
+ reply = (xQueryTreeReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .root = pWin->drawable.pScreen->root->drawable.id,
+ .parent = (pWin->parent) ? pWin->parent->drawable.id : (Window) None
+ };
pHead = RealChildHead(pWin);
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
numChildren++;
@@ -1003,13 +999,12 @@ ProcInternAtom(ClientPtr client)
tchar = (char *) &stuff[1];
atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists);
if (atom != BAD_RESOURCE) {
- xInternAtomReply reply;
-
- memset(&reply, 0, sizeof(xInternAtomReply));
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.atom = atom;
+ xInternAtomReply reply = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .atom = atom
+ };
WriteReplyToClient(client, sizeof(xInternAtomReply), &reply);
return Success;
}
@@ -1021,21 +1016,21 @@ int
ProcGetAtomName(ClientPtr client)
{
const char *str;
- xGetAtomNameReply reply;
- int len;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
if ((str = NameForAtom(stuff->id))) {
- len = strlen(str);
- memset(&reply, 0, sizeof(xGetAtomNameReply));
- reply.type = X_Reply;
- reply.length = bytes_to_int32(len);
- reply.sequenceNumber = client->sequence;
- reply.nameLength = len;
+ int len = strlen(str);
+ xGetAtomNameReply reply = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(len),
+ .nameLength = len
+ };
+
WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply);
- (void) WriteToClient(client, len, str);
+ WriteToClient(client, len, str);
return Success;
}
else {
@@ -1123,10 +1118,12 @@ ProcTranslateCoords(ClientPtr client)
rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
- memset(&rep, 0, sizeof(xTranslateCoordsReply));
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
+
+ rep = (xTranslateCoordsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) {
rep.sameScreen = xFalse;
rep.child = None;
@@ -1288,17 +1285,19 @@ ProcQueryTextExtents(ClientPtr client)
}
if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info))
return BadAlloc;
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.drawDirection = info.drawDirection;
- reply.fontAscent = info.fontAscent;
- reply.fontDescent = info.fontDescent;
- reply.overallAscent = info.overallAscent;
- reply.overallDescent = info.overallDescent;
- reply.overallWidth = info.overallWidth;
- reply.overallLeft = info.overallLeft;
- reply.overallRight = info.overallRight;
+ reply = (xQueryTextExtentsReply) {
+ .type = X_Reply,
+ .drawDirection = info.drawDirection,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .fontAscent = info.fontAscent,
+ .fontDescent = info.fontDescent,
+ .overallAscent = info.overallAscent,
+ .overallDescent = info.overallDescent,
+ .overallWidth = info.overallWidth,
+ .overallLeft = info.overallLeft,
+ .overallRight = info.overallRight
+ };
WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply);
return Success;
}
@@ -2143,8 +2142,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
BitsPerPixel(pDraw->depth), ClientOrder(client));
/* Don't split me, gcc pukes when you do */
- (void) WriteToClient(client,
- (int) (nlines * widthBytesLine), pBuf);
+ WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
}
linesDone += nlines;
}
@@ -2179,9 +2177,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
1, ClientOrder(client));
/* Don't split me, gcc pukes when you do */
- (void) WriteToClient(client,
- (int) (nlines * widthBytesLine),
- pBuf);
+ WriteToClient(client, (int) (nlines * widthBytesLine),
+ pBuf);
}
linesDone += nlines;
}
@@ -2468,7 +2465,6 @@ ProcAllocColor(ClientPtr client)
{
ColormapPtr pmap;
int rc;
- xAllocColorReply acr;
REQUEST(xAllocColorReq);
@@ -2476,13 +2472,15 @@ ProcAllocColor(ClientPtr client)
rc = dixLookupResourceByType((pointer *) &pmap, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
- acr.type = X_Reply;
- acr.length = 0;
- acr.sequenceNumber = client->sequence;
- acr.red = stuff->red;
- acr.green = stuff->green;
- acr.blue = stuff->blue;
- acr.pixel = 0;
+ xAllocColorReply acr = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .red = stuff->red,
+ .green = stuff->green,
+ .blue = stuff->blue,
+ .pixel = 0
+ };
if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index)))
return rc;
@@ -2511,12 +2509,11 @@ ProcAllocNamedColor(ClientPtr client)
rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
- xAllocNamedColorReply ancr;
-
- ancr.type = X_Reply;
- ancr.length = 0;
- ancr.sequenceNumber = client->sequence;
-
+ xAllocNamedColorReply ancr = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0
+ };
if (OsLookupColor
(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
&ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) {
@@ -2557,7 +2554,6 @@ ProcAllocColorCells(ClientPtr client)
rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
- xAllocColorCellsReply accr;
int npixels, nmasks;
long length;
Pixel *ppixels, *pmasks;
@@ -2587,11 +2583,13 @@ ProcAllocColorCells(ClientPtr client)
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
- accr.type = X_Reply;
- accr.length = bytes_to_int32(length);
- accr.sequenceNumber = client->sequence;
- accr.nPixels = npixels;
- accr.nMasks = nmasks;
+ xAllocColorCellsReply accr = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(length),
+ .nPixels = npixels,
+ .nMasks = nmasks
+ };
WriteReplyToClient(client, sizeof(xAllocColorCellsReply), &accr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
@@ -2631,9 +2629,11 @@ ProcAllocColorPlanes(ClientPtr client)
client->errorValue = stuff->contiguous;
return BadValue;
}
- acpr.type = X_Reply;
- acpr.sequenceNumber = client->sequence;
- acpr.nPixels = npixels;
+ acpr = (xAllocColorPlanesReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .nPixels = npixels
+ };
length = (long) npixels *sizeof(Pixel);
ppixels = malloc(length);
@@ -2771,11 +2771,12 @@ ProcQueryColors(ClientPtr client)
free(prgbs);
return rc;
}
- memset(&qcr, 0, sizeof(xQueryColorsReply));
- qcr.type = X_Reply;
- qcr.length = bytes_to_int32(count * sizeof(xrgb));
- qcr.sequenceNumber = client->sequence;
- qcr.nColors = count;
+ qcr = (xQueryColorsReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(count * sizeof(xrgb)),
+ .nColors = count
+ };
WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr);
if (count) {
client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
@@ -2803,17 +2804,22 @@ ProcLookupColor(ClientPtr client)
rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixReadAccess);
if (rc == Success) {
- xLookupColorReply lcr;
+ CARD16 exactRed, exactGreen, exactBlue;
if (OsLookupColor
(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
- &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue)) {
- lcr.type = X_Reply;
- lcr.length = 0;
- lcr.sequenceNumber = client->sequence;
- lcr.screenRed = lcr.exactRed;
- lcr.screenGreen = lcr.exactGreen;
- lcr.screenBlue = lcr.exactBlue;
+ &exactRed, &exactGreen, &exactBlue)) {
+ xLookupColorReply lcr = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .exactRed = exactRed,
+ .exactGreen = exactGreen,
+ .exactBlue = exactBlue,
+ .screenRed = exactRed,
+ .screenGreen = exactGreen,
+ .screenBlue = exactBlue
+ };
(*pcmp->pScreen->ResolveColor) (&lcr.screenRed,
&lcr.screenGreen,
&lcr.screenBlue, pcmp->pVisual);
@@ -2993,12 +2999,13 @@ ProcQueryBestSize(ClientPtr client)
return rc;
(*pScreen->QueryBestSize) (stuff->class, &stuff->width,
&stuff->height, pScreen);
- memset(&reply, 0, sizeof(xQueryBestSizeReply));
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.width = stuff->width;
- reply.height = stuff->height;
+ reply = (xQueryBestSizeReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .width = stuff->width,
+ .height = stuff->height
+ };
WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply);
return Success;
}
@@ -3078,13 +3085,15 @@ ProcGetScreenSaver(ClientPtr client)
return rc;
}
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.timeout = ScreenSaverTime / MILLI_PER_SECOND;
- rep.interval = ScreenSaverInterval / MILLI_PER_SECOND;
- rep.preferBlanking = ScreenSaverBlanking;
- rep.allowExposures = ScreenSaverAllowExposures;
+ rep = (xGetScreenSaverReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = 0,
+ .timeout = ScreenSaverTime / MILLI_PER_SECOND,
+ .interval = ScreenSaverInterval / MILLI_PER_SECOND,
+ .preferBlanking = ScreenSaverBlanking,
+ .allowExposures = ScreenSaverAllowExposures
+ };
WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep);
return Success;
}
@@ -3111,6 +3120,7 @@ ProcListHosts(ClientPtr client)
{
xListHostsReply reply;
int len, nHosts, result;
+ BOOL enabled;
pointer pdata;
/* REQUEST(xListHostsReq); */
@@ -3122,13 +3132,17 @@ ProcListHosts(ClientPtr client)
if (result != Success)
return result;
- result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
+ result = GetHosts(&pdata, &nHosts, &len, &enabled);
if (result != Success)
return result;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.nHosts = nHosts;
- reply.length = bytes_to_int32(len);
+
+ reply = (xListHostsReply) {
+ .type = X_Reply,
+ .enabled = enabled,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(len),
+ .nHosts = nHosts
+ };
WriteReplyToClient(client, sizeof(xListHostsReply), &reply);
if (nHosts) {
client->pSwapReplyFunc = (ReplySwapPtr) SLHostsExtend;
@@ -3243,15 +3257,16 @@ ProcGetFontPath(ClientPtr client)
if (rc != Success)
return rc;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = bytes_to_int32(stringLens + numpaths);
- reply.nPaths = numpaths;
+ reply = (xGetFontPathReply) {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(stringLens + numpaths),
+ .nPaths = numpaths
+ };
WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply);
if (stringLens || numpaths)
- (void) WriteToClient(client, stringLens + numpaths,
- (char *) bufferStart);
+ WriteToClient(client, stringLens + numpaths, bufferStart);
return Success;
}
@@ -3523,8 +3538,8 @@ SendConnSetup(ClientPtr client, const char *reason)
if (client->swapped)
WriteSConnSetupPrefix(client, &csp);
else
- (void) WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
- (void) WriteToClient(client, (int) csp.lengthReason, reason);
+ WriteToClient(client, sz_xConnSetupPrefix, &csp);
+ WriteToClient(client, (int) csp.lengthReason, reason);
return client->noClientException = -1;
}
@@ -3577,10 +3592,9 @@ SendConnSetup(ClientPtr client, const char *reason)
lConnectionInfo);
}
else {
- (void) WriteToClient(client, sizeof(xConnSetupPrefix),
- (char *) lconnSetupPrefix);
- (void) WriteToClient(client, (int) (lconnSetupPrefix->length << 2),
- lConnectionInfo);
+ WriteToClient(client, sizeof(xConnSetupPrefix), lconnSetupPrefix);
+ WriteToClient(client, (int) (lconnSetupPrefix->length << 2),
+ lConnectionInfo);
}
client->clientState = ClientStateRunning;
if (ClientStateCallback) {
@@ -3623,14 +3637,13 @@ void
SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode,
XID resId, int errorCode)
{
- xError rep;
-
- memset(&rep, 0, sizeof(xError));
- rep.type = X_Error;
- rep.errorCode = errorCode;
- rep.majorCode = majorCode;
- rep.minorCode = minorCode;
- rep.resourceID = resId;
+ xError rep = {
+ .type = X_Error,
+ .errorCode = errorCode,
+ .resourceID = resId,
+ .minorCode = minorCode,
+ .majorCode = majorCode
+ };
WriteEventsToClient(client, 1, (xEvent *) &rep);
}
@@ -3742,6 +3755,11 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu)
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0;
+ xorg_list_init(&pScreen->pixmap_dirty_list);
+ xorg_list_init(&pScreen->unattached_list);
+ xorg_list_init(&pScreen->output_slave_list);
+ xorg_list_init(&pScreen->offload_slave_list);
+
/*
* This loop gets run once for every Screen that gets added,
* but thats ok. If the ddx layer initializes the formats
@@ -3889,3 +3907,55 @@ RemoveGPUScreen(ScreenPtr pScreen)
free(pScreen);
}
+
+void
+AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new)
+{
+ assert(new->isGPU);
+ assert(!new->current_master);
+ xorg_list_add(&new->unattached_head, &pScreen->unattached_list);
+ new->current_master = pScreen;
+}
+
+void
+DetachUnboundGPU(ScreenPtr slave)
+{
+ assert(slave->isGPU);
+ xorg_list_del(&slave->unattached_head);
+ slave->current_master = NULL;
+}
+
+void
+AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new)
+{
+ assert(new->isGPU);
+ assert(!new->current_master);
+ xorg_list_add(&new->output_head, &pScreen->output_slave_list);
+ new->current_master = pScreen;
+}
+
+void
+DetachOutputGPU(ScreenPtr slave)
+{
+ assert(slave->isGPU);
+ xorg_list_del(&slave->output_head);
+ slave->current_master = NULL;
+}
+
+void
+AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new)
+{
+ assert(new->isGPU);
+ assert(!new->current_master);
+ xorg_list_add(&new->offload_head, &pScreen->offload_slave_list);
+ new->current_master = pScreen;
+}
+
+void
+DetachOffloadGPU(ScreenPtr slave)
+{
+ assert(slave->isGPU);
+ xorg_list_del(&slave->offload_head);
+ slave->current_master = NULL;
+}
+