mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 03:44:06 +00:00
dix/Xinerama: untwist X_AllocColor request handling
Instead of internally faking requests, factor out the actual logic into separate function, which is getting everything it needs as parameters, so no need to fiddle with request buffer anymore. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
9b2d3ba167
commit
cf105bc990
@@ -2509,13 +2509,40 @@ PanoramiXAllocColor(ClientPtr client)
|
||||
return result;
|
||||
|
||||
XINERAMA_FOR_EACH_SCREEN_BACKWARD({
|
||||
stuff->cmap = cmap->info[walkScreenIdx].id;
|
||||
result = (*SavedProcVector[X_AllocColor]) (client);
|
||||
Colormap childCmap = cmap->info[walkScreenIdx].id;
|
||||
|
||||
CARD16 red = stuff->red;
|
||||
CARD16 green = stuff->green;
|
||||
CARD16 blue = stuff->blue;
|
||||
CARD32 pixel = 0;
|
||||
|
||||
result = dixAllocColor(client, childCmap, &red, &green, &blue, &pixel);
|
||||
if (result != Success)
|
||||
break;
|
||||
return result;
|
||||
|
||||
/* only send out reply for on first screen */
|
||||
if (!walkScreenIdx) {
|
||||
xAllocColorReply rep; /* static init would confuse preprocessor */
|
||||
rep.red = red;
|
||||
rep.green = green;
|
||||
rep.blue = blue;
|
||||
rep.pixel = pixel;
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.red);
|
||||
swaps(&rep.green);
|
||||
swaps(&rep.blue);
|
||||
swapl(&rep.pixel);
|
||||
}
|
||||
|
||||
/* iterating backwards, first screen comes last, so we can return here */
|
||||
return X_SEND_REPLY_SIMPLE(client, rep);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
/* shouldn't ever reach here, because we already returned from within the loop
|
||||
if this ever happens, PanoramiXNumScreens must be 0 */
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -2682,21 +2682,26 @@ ProcListInstalledColormaps(ClientPtr client)
|
||||
return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
|
||||
}
|
||||
|
||||
int dixAllocColor(ClientPtr client, Colormap cmap, CARD16 *red,
|
||||
CARD16 *green, CARD16 *blue, CARD32 *pixel)
|
||||
{
|
||||
ColormapPtr pmap;
|
||||
int rc = dixLookupResourceByType((void **) &pmap,
|
||||
cmap,
|
||||
X11_RESTYPE_COLORMAP,
|
||||
client,
|
||||
DixAddAccess);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
|
||||
return AllocColor(pmap, red, green, blue, pixel, client->index);
|
||||
}
|
||||
|
||||
int
|
||||
ProcAllocColor(ClientPtr client)
|
||||
{
|
||||
ColormapPtr pmap;
|
||||
int rc;
|
||||
|
||||
REQUEST(xAllocColorReq);
|
||||
|
||||
REQUEST_SIZE_MATCH(xAllocColorReq);
|
||||
rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, X11_RESTYPE_COLORMAP,
|
||||
client, DixAddAccess);
|
||||
if (rc != Success) {
|
||||
client->errorValue = stuff->cmap;
|
||||
return rc;
|
||||
}
|
||||
|
||||
xAllocColorReply rep = {
|
||||
.red = stuff->red,
|
||||
@@ -2704,9 +2709,11 @@ ProcAllocColor(ClientPtr client)
|
||||
.blue = stuff->blue,
|
||||
};
|
||||
|
||||
if ((rc = AllocColor(pmap, &rep.red, &rep.green, &rep.blue,
|
||||
&rep.pixel, client->index)))
|
||||
int rc = dixAllocColor(client, stuff->cmap, &rep.red, &rep.green, &rep.blue, &rep.pixel);
|
||||
if (rc != Success) {
|
||||
client->errorValue = stuff->cmap;
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.red);
|
||||
@@ -2715,13 +2722,7 @@ ProcAllocColor(ClientPtr client)
|
||||
swapl(&rep.pixel);
|
||||
}
|
||||
|
||||
#ifdef XINERAMA
|
||||
if (noPanoramiXExtension || !pmap->pScreen->myNum)
|
||||
return X_SEND_REPLY_SIMPLE(client, rep);
|
||||
return Success;
|
||||
#else
|
||||
return X_SEND_REPLY_SIMPLE(client, rep);
|
||||
#endif /* XINERAMA */
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -745,4 +745,20 @@ static inline int xmitClientEvent(ClientPtr pClient, xEvent ev)
|
||||
return WriteToClient(pClient, sizeof(xEvent), &ev);
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate color for given client
|
||||
* the colors channel values need to be filled into the fields pointed
|
||||
* to by the parameters, and the actually allocated ones are returned there
|
||||
*
|
||||
* @param client pointer to client
|
||||
* @param cmap XID of the cmap to use
|
||||
* @param red pointer to red channel value
|
||||
* @param green pointer to green channel value
|
||||
* @param blue pointer to blue channel value
|
||||
* @param pixel pointer to return buffer for pixel value
|
||||
* @return X11 error code
|
||||
*/
|
||||
int dixAllocColor(ClientPtr client, Colormap cmap, CARD16 *red,
|
||||
CARD16 *green, CARD16 *blue, CARD32 *pixel);
|
||||
|
||||
#endif /* _XSERVER_DIX_PRIV_H */
|
||||
|
||||
Reference in New Issue
Block a user