dix: CreateColormap() pass in ClientPtr instead of client index
The function actually operates on ClientRec, so we can pass it in directly, so it doesn't need to fetch it from clients[] array itself. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
1c8ef6d44d
commit
38d62bcc08
|
@ -55,6 +55,7 @@ SOFTWARE.
|
|||
#include "dix/colormap_priv.h"
|
||||
#include "dix/dix_priv.h"
|
||||
#include "os/osdep.h"
|
||||
#include "os/bug_priv.h"
|
||||
|
||||
#include "misc.h"
|
||||
#include "dix.h"
|
||||
|
@ -240,8 +241,8 @@ typedef struct _colorResource {
|
|||
* \param alloc 1 iff all entries are allocated writable
|
||||
*/
|
||||
int
|
||||
CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||
ColormapPtr *ppcmap, int alloc, int client)
|
||||
dixCreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||
ColormapPtr *ppcmap, int alloc, ClientPtr pClient)
|
||||
{
|
||||
int class, size;
|
||||
unsigned long sizebytes;
|
||||
|
@ -250,9 +251,14 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
int i;
|
||||
Pixel *ppix, **pptr;
|
||||
|
||||
if (!pClient)
|
||||
return BadMatch;
|
||||
|
||||
const int clientIndex = pClient->index;
|
||||
|
||||
class = pVisual->class;
|
||||
if (!(class & DynamicClass) && (alloc != AllocNone) &&
|
||||
(client != SERVER_ID))
|
||||
(pClient != serverClient))
|
||||
return BadMatch;
|
||||
|
||||
size = pVisual->ColormapEntries;
|
||||
|
@ -309,10 +315,10 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
free(pmap);
|
||||
return BadAlloc;
|
||||
}
|
||||
pmap->clientPixelsRed[client] = ppix;
|
||||
pmap->clientPixelsRed[clientIndex] = ppix;
|
||||
for (i = 0; i < size; i++)
|
||||
ppix[i] = i;
|
||||
pmap->numPixelsRed[client] = size;
|
||||
pmap->numPixelsRed[clientIndex] = size;
|
||||
}
|
||||
|
||||
if ((class | DynamicClass) == DirectColor) {
|
||||
|
@ -347,14 +353,14 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
pmap->freeGreen = 0;
|
||||
ppix = xallocarray(size, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
free(pmap->clientPixelsRed[client]);
|
||||
free(pmap->clientPixelsRed[clientIndex]);
|
||||
free(pmap);
|
||||
return BadAlloc;
|
||||
}
|
||||
pmap->clientPixelsGreen[client] = ppix;
|
||||
pmap->clientPixelsGreen[clientIndex] = ppix;
|
||||
for (i = 0; i < size; i++)
|
||||
ppix[i] = i;
|
||||
pmap->numPixelsGreen[client] = size;
|
||||
pmap->numPixelsGreen[clientIndex] = size;
|
||||
|
||||
size = pmap->freeBlue;
|
||||
for (pent = &pmap->blue[size - 1]; pent >= pmap->blue; pent--)
|
||||
|
@ -362,15 +368,15 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
pmap->freeBlue = 0;
|
||||
ppix = xallocarray(size, sizeof(Pixel));
|
||||
if (!ppix) {
|
||||
free(pmap->clientPixelsGreen[client]);
|
||||
free(pmap->clientPixelsRed[client]);
|
||||
free(pmap->clientPixelsGreen[clientIndex]);
|
||||
free(pmap->clientPixelsRed[clientIndex]);
|
||||
free(pmap);
|
||||
return BadAlloc;
|
||||
}
|
||||
pmap->clientPixelsBlue[client] = ppix;
|
||||
pmap->clientPixelsBlue[clientIndex] = ppix;
|
||||
for (i = 0; i < size; i++)
|
||||
ppix[i] = i;
|
||||
pmap->numPixelsBlue[client] = size;
|
||||
pmap->numPixelsBlue[clientIndex] = size;
|
||||
}
|
||||
}
|
||||
pmap->flags |= CM_BeingCreated;
|
||||
|
@ -381,7 +387,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
|||
/*
|
||||
* Security creation/labeling check
|
||||
*/
|
||||
i = XaceHookResourceAccess(clients[client], mid, X11_RESTYPE_COLORMAP,
|
||||
i = XaceHookResourceAccess(pClient, mid, X11_RESTYPE_COLORMAP,
|
||||
pmap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
|
||||
if (i != Success) {
|
||||
FreeResource(mid, X11_RESTYPE_NONE);
|
||||
|
@ -547,7 +553,7 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client)
|
|||
size = pVisual->ColormapEntries;
|
||||
|
||||
/* If the create returns non-0, it failed */
|
||||
result = CreateColormap(mid, pScreen, pVisual, &pmap, alloc, client);
|
||||
result = dixCreateColormap(mid, pScreen, pVisual, &pmap, alloc, clients[client]);
|
||||
if (result != Success)
|
||||
return result;
|
||||
if (alloc == AllocAll) {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
typedef struct _CMEntry *EntryPtr;
|
||||
|
||||
int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||
ColormapPtr *ppcmap, int alloc, int client);
|
||||
int dixCreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
|
||||
ColormapPtr *ppcmap, int alloc, ClientPtr client);
|
||||
|
||||
/* should only be called via resource type's destructor */
|
||||
int FreeColormap(void *pmap, XID mid);
|
||||
|
|
|
@ -2446,8 +2446,8 @@ ProcCreateColormap(ClientPtr client)
|
|||
i < pScreen->numVisuals; i++, pVisual++) {
|
||||
if (pVisual->vid != stuff->visual)
|
||||
continue;
|
||||
return CreateColormap(mid, pScreen, pVisual, &pmap,
|
||||
(int) stuff->alloc, client->index);
|
||||
return dixCreateColormap(mid, pScreen, pVisual, &pmap,
|
||||
(int) stuff->alloc, client);
|
||||
}
|
||||
client->errorValue = stuff->visual;
|
||||
return BadMatch;
|
||||
|
|
|
@ -709,7 +709,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
|
|||
|
||||
LEGAL_NEW_RESOURCE(id, client);
|
||||
|
||||
return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index);
|
||||
return dixCreateColormap(id, pScreen, pVisual, &pmap, alloc, client);
|
||||
}
|
||||
|
||||
/* Called by the extension to install a colormap on DGA active screens */
|
||||
|
|
|
@ -469,9 +469,9 @@ xnestCreateDefaultColormap(ScreenPtr pScreen)
|
|||
for (pVisual = pScreen->visuals;
|
||||
pVisual->vid != pScreen->rootVisual; pVisual++);
|
||||
|
||||
if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap,
|
||||
if (dixCreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap,
|
||||
(pVisual->class & DynamicClass) ? AllocNone : AllocAll,
|
||||
0)
|
||||
serverClient)
|
||||
!= Success)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -520,12 +520,12 @@ winCreateDefColormap(ScreenPtr pScreen)
|
|||
#endif
|
||||
|
||||
/* Allocate an X colormap, owned by client 0 */
|
||||
if (CreateColormap(pScreen->defColormap,
|
||||
if (dixCreateColormap(pScreen->defColormap,
|
||||
pScreen,
|
||||
pVisual,
|
||||
&pcmap,
|
||||
(pVisual->class & DynamicClass) ? AllocNone : AllocAll,
|
||||
0) != Success) {
|
||||
serverClient) != Success) {
|
||||
ErrorF("winCreateDefColormap - CreateColormap failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -261,8 +261,8 @@ miCreateDefColormap(ScreenPtr pScreen)
|
|||
else
|
||||
alloctype = AllocAll;
|
||||
|
||||
if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
|
||||
alloctype, 0) != Success)
|
||||
if (dixCreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
|
||||
alloctype, serverClient) != Success)
|
||||
return FALSE;
|
||||
|
||||
if (pScreen->rootDepth > 1) {
|
||||
|
|
|
@ -421,8 +421,8 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
|
|||
if (pVisual == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (CreateColormap(FakeClientID(0), pScreen, pVisual,
|
||||
&format->index.pColormap, AllocNone, 0)
|
||||
if (dixCreateColormap(FakeClientID(0), pScreen, pVisual,
|
||||
&format->index.pColormap, AllocNone, serverClient)
|
||||
!= Success)
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue