From e6467895f9685ffd36c7f09f77826d794c23f56f 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 | 6 +++--- 26 files changed, 49 insertions(+), 31 deletions(-) diff --git a/Xext/dpms.c b/Xext/dpms.c index f4bf241fe..b04ef94c0 100644 --- a/Xext/dpms.c +++ b/Xext/dpms.c @@ -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, diff --git a/Xext/sync.c b/Xext/sync.c index 0e426a05e..bfcd23dea 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -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)); diff --git a/Xi/exevents.c b/Xi/exevents.c index c82f9016e..5d8b5d208 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -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; diff --git a/composite/compinit.c b/composite/compinit.c index 11e546bd6..f06e0293b 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -323,7 +323,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 e23496b77..b6afe230e 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 164ac9102..169f3f835 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 d9ea069c2..9f5e1f71f 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -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 diff --git a/dix/resource.c b/dix/resource.c index c856f3171..5a41ca334 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 7c3e157c4..f0882d21e 100644 --- a/dix/window.c +++ b/dix/window.c @@ -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; diff --git a/fb/fbscreen.c b/fb/fbscreen.c index 728c22489..316407157 100644 --- a/fb/fbscreen.c +++ b/fb/fbscreen.c @@ -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; diff --git a/glx/glxscreens.c b/glx/glxscreens.c index e5c5f974c..4c77b9fa3 100644 --- a/glx/glxscreens.c +++ b/glx/glxscreens.c @@ -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++; } diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c index 2dea819a5..45d648eda 100644 --- a/hw/kdrive/src/kxv.c +++ b/hw/kdrive/src/kxv.c @@ -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)))) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 5e34ba973..d174017c7 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -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; diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 48b8ccbb9..3eb800360 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 4a743ef2a..25a7ccae8 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -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; diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c index 04b3d1e9b..41ae6f280 100644 --- a/hw/xquartz/applewm.c +++ b/hw/xquartz/applewm.c @@ -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, diff --git a/hw/xwayland/xwayland-glamor-xv.c b/hw/xwayland/xwayland-glamor-xv.c index 85cc1dc68..6ecbe822f 100644 --- a/hw/xwayland/xwayland-glamor-xv.c +++ b/hw/xwayland/xwayland-glamor-xv.c @@ -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; diff --git a/include/resource.h b/include/resource.h index b36c03c8e..70ee2f575 100644 --- a/include/resource.h +++ b/include/resource.h @@ -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 */ diff --git a/mi/micmap.c b/mi/micmap.c index 2f3ffc38a..f9201f942 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -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 diff --git a/os/mitauth.c b/os/mitauth.c index ac519b807..6ef4c35f5 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 2047b7173..fc5cbe5c5 100644 --- a/os/xdmauth.c +++ b/os/xdmauth.c @@ -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; } diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 1eb349d67..29bd9b5fb 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -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; diff --git a/randr/rrmode.c b/randr/rrmode.c index 1cc572d73..1a0633f02 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -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; diff --git a/randr/rroutput.c b/randr/rroutput.c index 2b70258ff..a350489ce 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -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; diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 0069d8aea..cbd7d327d 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -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; diff --git a/render/picture.c b/render/picture.c index 0e5758260..3f4d01cad 100644 --- a/render/picture.c +++ b/render/picture.c @@ -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; }