From 824a78e8fc3485757a21572632c980d7b0229295 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 12 Mar 2025 15:43:10 +0100 Subject: [PATCH] dix: add dixAllocServerXID() Adding a separate function for allocating server-client's XIDs. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/dpms.c | 2 +- Xext/sync.c | 2 +- Xi/exevents.c | 2 +- composite/compinit.c | 2 +- dix/colormap.c | 2 +- dix/cursor.c | 4 ++-- dix/dixfonts.c | 4 ++-- dix/resource.c | 6 ++++++ dix/window.c | 6 +++--- fb/fbscreen.c | 2 +- glx/glxscreens.c | 2 +- hw/kdrive/src/kxv.c | 2 +- hw/xfree86/common/xf86DGA.c | 2 +- hw/xfree86/common/xf86xv.c | 2 +- hw/xnest/Screen.c | 4 ++-- hw/xquartz/applewm.c | 2 +- hw/xwayland/xwayland-glamor-xv.c | 2 +- include/resource.h | 12 ++++++++++++ mi/micmap.c | 2 +- os/mitauth.c | 2 +- os/xdmauth.c | 2 +- randr/rrcrtc.c | 2 +- randr/rrmode.c | 2 +- randr/rroutput.c | 2 +- randr/rrprovider.c | 2 +- render/picture.c | 4 ++-- 26 files changed, 48 insertions(+), 30 deletions(-) diff --git a/Xext/dpms.c b/Xext/dpms.c index 597f5cf4d..96e771d7d 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -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, diff --git a/Xext/sync.c b/Xext/sync.c index cab73be92..dfd757953 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -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; diff --git a/Xi/exevents.c b/Xi/exevents.c index 20b1aa716..78f8a5c32 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -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; diff --git a/composite/compinit.c b/composite/compinit.c index e0a565365..13a8be6eb 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -349,7 +349,7 @@ compScreenInit(ScreenPtr pScreen) if (!cs) return FALSE; - cs->overlayWid = FakeClientID(0); + cs->overlayWid = dixAllocServerXID(); cs->pOverlayWin = NULL; cs->pOverlayClients = NULL; diff --git a/dix/colormap.c b/dix/colormap.c index 9a8be28e2..c49e242b4 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -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; } diff --git a/dix/cursor.c b/dix/cursor.c index f12c50971..890c7eb09 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -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; diff --git a/dix/dixfonts.c b/dix/dixfonts.c index dd617d99c..457c96441 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -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 diff --git a/dix/resource.c b/dix/resource.c index 430ac1ae3..a39d23a29 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -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); +} diff --git a/dix/window.c b/dix/window.c index 9fe306c44..dcd265456 100644 --- a/dix/window.c +++ b/dix/window.c @@ -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; diff --git a/fb/fbscreen.c b/fb/fbscreen.c index 220a99511..e5e11f666 100644 --- a/fb/fbscreen.c +++ b/fb/fbscreen.c @@ -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; diff --git a/glx/glxscreens.c b/glx/glxscreens.c index ef969fcd6..4713250fe 100644 --- a/glx/glxscreens.c +++ b/glx/glxscreens.c @@ -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++; } diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c index 3077009a6..70c98563b 100644 --- a/hw/kdrive/src/kxv.c +++ b/hw/kdrive/src/kxv.c @@ -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)))) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 2482530a1..73bf256e5 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -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; diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 35eab722c..a6e300c8e 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -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)))) diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index bab6096b1..3de334698 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -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; diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 684999749..03d06734c 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -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, diff --git a/hw/xwayland/xwayland-glamor-xv.c b/hw/xwayland/xwayland-glamor-xv.c index d0aaa02c7..e3be913c6 100644 --- a/hw/xwayland/xwayland-glamor-xv.c +++ b/hw/xwayland/xwayland-glamor-xv.c @@ -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; diff --git a/include/resource.h b/include/resource.h index a48735ba0..618f12c1c 100644 --- a/include/resource.h +++ b/include/resource.h @@ -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 */ diff --git a/mi/micmap.c b/mi/micmap.c index e8b3ad568..e32f5df2b 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -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: diff --git a/os/mitauth.c b/os/mitauth.c index c61918572..a280655fb 100644 --- a/os/mitauth.c +++ b/os/mitauth.c @@ -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; } diff --git a/os/xdmauth.c b/os/xdmauth.c index 296269e41..e3f3706e1 100644 --- a/os/xdmauth.c +++ b/os/xdmauth.c @@ -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; } diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index b828b7301..e67b73ed0 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -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; diff --git a/randr/rrmode.c b/randr/rrmode.c index dbf4daed0..a360afbd5 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -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; diff --git a/randr/rroutput.c b/randr/rroutput.c index 8d0f05498..e42651620 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -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; diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 61e9001b4..23e7e2238 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -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; diff --git a/render/picture.c b/render/picture.c index feb29a7d7..64b18e26d 100644 --- a/render/picture.c +++ b/render/picture.c @@ -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;