dix: add dixAllocServerXID()

Adding a separate function for allocating server-client's XIDs.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-03-12 15:43:10 +01:00
parent d6d510ca61
commit 824a78e8fc
26 changed files with 48 additions and 30 deletions

View File

@ -589,7 +589,7 @@ DPMSExtensionInit(void)
ClientType = CreateNewResourceType(DPMSFreeClient, "DPMSClient");
DPMSEventType = CreateNewResourceType(DPMSFreeEvents, "DPMSEvent");
eventResource = FakeClientID(0);
eventResource = dixAllocServerXID();
if (DPMSEnabled && ClientType && DPMSEventType &&
(extEntry = AddExtension(DPMSExtensionName, 0, 0,

View File

@ -1027,7 +1027,7 @@ SyncCreateSystemCounter(const char *name,
SyncSystemCounterBracketValues BracketValues
)
{
SyncCounter *pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
SyncCounter *pCounter = SyncCreateCounter(NULL, dixAllocServerXID(), initial);
if (pCounter) {
SysCounterInfo *psci;

View File

@ -2854,7 +2854,7 @@ InputClientGone(WindowPtr pWin, XID id)
FreeInputClient(&other);
}
else {
other->resource = FakeClientID(0);
other->resource = dixAllocServerXID();
if (!AddResource(other->resource, RT_INPUTCLIENT,
(void *) pWin))
return BadAlloc;

View File

@ -349,7 +349,7 @@ compScreenInit(ScreenPtr pScreen)
if (!cs)
return FALSE;
cs->overlayWid = FakeClientID(0);
cs->overlayWid = dixAllocServerXID();
cs->pOverlayWin = NULL;
cs->pOverlayClients = NULL;

View File

@ -2555,7 +2555,7 @@ ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth)
pScreen->visuals = visuals;
for (i = 0; i < new_visual_count; i++) {
vid = FakeClientID(0);
vid = dixAllocServerXID();
pScreen->visuals[first_new_visual + i].vid = vid;
vids[first_new_vid + i] = vid;
}

View File

@ -497,7 +497,7 @@ CreateRootCursor(void)
XID fontID;
const char defaultCursorFont[] = "cursor";
fontID = FakeClientID(0);
fontID = dixAllocServerXID();
err = OpenFont(serverClient, fontID, FontLoadAll | FontOpenSync,
(unsigned) strlen(defaultCursorFont), defaultCursorFont);
if (err != Success)
@ -511,7 +511,7 @@ CreateRootCursor(void)
&curs, serverClient, (XID) 0) != Success)
return NullCursor;
if (!AddResource(FakeClientID(0), X11_RESTYPE_CURSOR, (void *) curs))
if (!AddResource(dixAllocServerXID(), X11_RESTYPE_CURSOR, (void *) curs))
return NullCursor;
return curs;

View File

@ -140,7 +140,7 @@ SetDefaultFont(const char *defaultfontname)
FontPtr pf;
XID fid;
fid = FakeClientID(0);
fid = dixAllocServerXID();
err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
(unsigned) strlen(defaultfontname), defaultfontname);
if (err != Success)
@ -1900,7 +1900,7 @@ find_old_font(XID id)
static Font
get_new_font_client_id(void)
{
return FakeClientID(0);
return dixAllocServerXID();
}
static int

View File

@ -1276,3 +1276,9 @@ dixLookupResourceByClass(void **result, XID id, RESTYPE rclass,
*result = res->value;
return Success;
}
/* new API - try not to call FakeClientID() directly anymore */
XID dixAllocServerXID(void)
{
return FakeClientID(0);
}

View File

@ -574,7 +574,7 @@ CreateRootWindow(ScreenPtr pScreen)
return FALSE;
pScreen->screensaver.pWindow = NULL;
pScreen->screensaver.wid = FakeClientID(0);
pScreen->screensaver.wid = dixAllocServerXID();
pScreen->screensaver.ExternalScreenSaver = NULL;
screenIsSaved = SCREEN_SAVER_OFF;
@ -614,7 +614,7 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->nextSib = NullWindow;
pWin->drawable.id = FakeClientID(0);
pWin->drawable.id = dixAllocServerXID();
pWin->origin.x = pWin->origin.y = 0;
pWin->drawable.height = pScreen->height;
@ -3263,7 +3263,7 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
result = AllocARGBCursor(srcbits, mskbits, NULL, &cm, 0, 0, 0, 0, 0, 0,
&cursor, serverClient, (XID) 0);
if (cursor) {
cursorID = FakeClientID(0);
cursorID = dixAllocServerXID();
if (AddResource(cursorID, X11_RESTYPE_CURSOR, (void *) cursor)) {
attributes[attri] = cursorID;
mask |= CWCursor;

View File

@ -99,7 +99,7 @@ fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */
{ /* bits per pixel for screen */
if (!fbAllocatePrivates(pScreen))
return FALSE;
pScreen->defColormap = FakeClientID(0);
pScreen->defColormap = dixAllocServerXID();
if (bpp > 1) {
/* let CreateDefColormap do whatever it wants for pixels */
pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;

View File

@ -332,7 +332,7 @@ __glXScreenInit(__GLXscreen * pGlxScreen, ScreenPtr pScreen)
i = 0;
for (m = pGlxScreen->fbconfigs; m != NULL; m = m->next) {
m->fbconfigID = FakeClientID(0);
m->fbconfigID = dixAllocServerXID();
m->visualID = 0;
i++;
}

View File

@ -364,7 +364,7 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number)
}
for (pp = pPort, i = 0, numPort = 0; i < adaptorPtr->nPorts; i++) {
if (!(pp->id = FakeClientID(0)))
if (!(pp->id = dixAllocServerXID()))
continue;
if (!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))

View File

@ -667,7 +667,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
if (!(pVisual = malloc(sizeof(VisualRec))))
return BadAlloc;
pVisual->vid = FakeClientID(0);
pVisual->vid = dixAllocServerXID();
pVisual->class = pMode->visualClass;
pVisual->nplanes = pMode->depth;
pVisual->ColormapEntries = 1 << pMode->depth;

View File

@ -486,7 +486,7 @@ xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
}
for (pp = pPort, i = 0, numPort = 0; i < adaptorPtr->nPorts; i++) {
if (!(pp->id = FakeClientID(0)))
if (!(pp->id = dixAllocServerXID()))
continue;
if (!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))

View File

@ -204,7 +204,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
if (j < numVisuals)
break;
visuals[numVisuals].vid = FakeClientID(0);
visuals[numVisuals].vid = dixAllocServerXID();
depthIndex = UNDEFINED;
for (j = 0; j < numDepths; j++)
@ -247,7 +247,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
numVisuals, visuals))
return FALSE;
pScreen->defColormap = (Colormap) FakeClientID(0);
pScreen->defColormap = (Colormap) dixAllocServerXID();
pScreen->minInstalledCmaps = MINCMAPS;
pScreen->maxInstalledCmaps = MAXCMAPS;
pScreen->backingStoreSupport = NotUseful;

View File

@ -721,7 +721,7 @@ AppleWMExtensionInit(AppleWMProcsPtr procsPtr)
ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
EventType = CreateNewResourceType(WMFreeEvents, "WMEvent");
eventResource = FakeClientID(0);
eventResource = dixAllocServerXID();
if (ClientType && EventType &&
(extEntry = AddExtension(APPLEWMNAME,

View File

@ -255,7 +255,7 @@ xwl_glamor_xv_add_ports(XvAdaptorPtr pa)
PortResource = XvGetRTPort();
for (pp = pPorts, i = 0, nPorts = 0; i < NUM_PORTS; i++) {
if (!(pp->id = FakeClientID(0)))
if (!(pp->id = dixAllocServerXID()))
continue;
pp->pAdaptor = pa;

View File

@ -286,4 +286,16 @@ extern _X_EXPORT RESTYPE TypeMask;
*/
extern _X_EXPORT int HashResourceID(XID id, unsigned int numBits);
/*
* @brief allocate a XID (resource ID) for the server itself
*
* This is mostly for resource types that don't have their own API yet
* The XID is allocated within server's ID space and then can be used
* for registering a resource with it (@see AddResource())
*
* @obsoletes FakeClientID
* @return XID the newly allocated XID
*/
_X_EXPORT XID dixAllocServerXID(void);
#endif /* RESOURCE_H */

View File

@ -504,7 +504,7 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
visual->bitsPerRGBValue = visuals->bitsPerRGB;
visual->ColormapEntries = 1 << d;
visual->nplanes = d;
visual->vid = *vid = FakeClientID(0);
visual->vid = *vid = dixAllocServerXID();
switch (visual->class) {
case PseudoColor:
case GrayScale:

View File

@ -70,7 +70,7 @@ MitAddCookie(unsigned short data_length, const char *data)
mit_auth = new;
memcpy(new->data, data, (size_t) data_length);
new->len = data_length;
new->id = FakeClientID(0);
new->id = dixAllocServerXID();
return new->id;
}

View File

@ -369,7 +369,7 @@ XdmAddCookie(unsigned short data_length, const char *data)
xdmAuth = new;
memcpy(new->key.data, key_bits, 8);
memcpy(new->rho.data, rho_bits, 8);
new->id = FakeClientID(0);
new->id = dixAllocServerXID();
return new->id;
}

View File

@ -75,7 +75,7 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
crtc = calloc(1, sizeof(RRCrtcRec));
if (!crtc)
return NULL;
crtc->id = FakeClientID(0);
crtc->id = dixAllocServerXID();
crtc->pScreen = pScreen;
crtc->rotation = RR_Rotate_0;
crtc->rotations = RR_Rotate_0;

View File

@ -90,7 +90,7 @@ RRModeCreate(xRRModeInfo * modeInfo, const char *name, ScreenPtr userScreen)
return NULL;
}
mode->mode.id = FakeClientID(0);
mode->mode.id = dixAllocServerXID();
if (!AddResource(mode->mode.id, RRModeType, (void *) mode)) {
free(newModes);
return NULL;

View File

@ -86,7 +86,7 @@ RROutputCreate(ScreenPtr pScreen,
output = calloc(1, sizeof(RROutputRec) + nameLength + 1);
if (!output)
return NULL;
output->id = FakeClientID(0);
output->id = dixAllocServerXID();
output->pScreen = pScreen;
output->name = (char *) (output + 1);
output->nameLength = nameLength;

View File

@ -401,7 +401,7 @@ RRProviderCreate(ScreenPtr pScreen, const char *name,
if (!provider)
return NULL;
provider->id = FakeClientID(0);
provider->id = dixAllocServerXID();
provider->pScreen = pScreen;
provider->name = (char *) (provider + 1);
provider->nameLength = nameLength;

View File

@ -300,7 +300,7 @@ PictureCreateDefaultFormats(ScreenPtr pScreen, int *nformatp)
if (!pFormats)
return 0;
for (f = 0; f < nformats; f++) {
pFormats[f].id = FakeClientID(0);
pFormats[f].id = dixAllocServerXID();
pFormats[f].depth = formats[f].depth;
format = formats[f].format;
pFormats[f].format = format;
@ -432,7 +432,7 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
if (pVisual == NULL)
return FALSE;
if (CreateColormap(FakeClientID(0), pScreen, pVisual,
if (CreateColormap(dixAllocServerXID(), pScreen, pVisual,
&format->index.pColormap, AllocNone, 0)
!= Success)
return FALSE;