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 4919a089df
commit e6467895f9
26 changed files with 49 additions and 31 deletions

View File

@ -588,7 +588,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

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

View File

@ -2860,7 +2860,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

@ -323,7 +323,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

@ -142,7 +142,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)
@ -1914,7 +1914,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

@ -562,7 +562,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;
@ -601,7 +601,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;
@ -3249,7 +3249,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

@ -100,7 +100,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

@ -324,7 +324,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

@ -366,7 +366,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

@ -665,7 +665,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
if (!(pVisual = calloc(1, 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

@ -243,7 +243,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
.offsetRed = offset(vts[x].red_mask),
.offsetGreen = offset(vts[x].green_mask),
.offsetBlue = offset(vts[x].blue_mask),
.vid = FakeClientID(0),
.vid = dixAllocServerXID(),
};
xnestVisualMap[xnestNumVisualMap] = (xnest_visual_t) {
@ -310,7 +310,7 @@ breakout:
numVisuals, visuals))
return FALSE;
pScreen->defColormap = (Colormap) FakeClientID(0);
pScreen->defColormap = (Colormap) dixAllocServerXID();
pScreen->minInstalledCmaps = MINCMAPS;
pScreen->maxInstalledCmaps = MAXCMAPS;
pScreen->backingStoreSupport = XCB_BACKING_STORE_NOT_USEFUL;

View File

@ -720,7 +720,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

@ -254,7 +254,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

@ -243,4 +243,16 @@ extern _X_EXPORT int dixLookupResourceByClass(void **result,
extern _X_EXPORT RESTYPE lastResourceType;
extern _X_EXPORT RESTYPE TypeMask;
/*
* @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

@ -500,7 +500,7 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
visual->bitsPerRGBValue = visuals->bitsPerRGB;
visual->ColormapEntries = 1 << d;
visual->nplanes = d;
visual->vid = FakeClientID(0);
visual->vid = dixAllocServerXID();
if (vid)
*vid = visual->vid;
else

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

@ -368,7 +368,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

@ -80,7 +80,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

@ -91,7 +91,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

@ -87,7 +87,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

@ -402,7 +402,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

@ -288,7 +288,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;
@ -420,8 +420,8 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
if (pVisual == NULL)
return FALSE;
if (dixCreateColormap(FakeClientID(0), pScreen, pVisual,
&format->index.pColormap, AllocNone, serverClient)
if (dixCreateColormap(dixAllocServerXID(), pScreen, pVisual,
&format->index.pColormap, AllocNone, 0)
!= Success)
return FALSE;
}