From d80866e764c2f8ed582656bd96aff43a4986a80b Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 6 Mar 2025 13:08:25 +0100 Subject: [PATCH] dix: add dixClientForOtherClients() Helper function for retrieving the owning client of an OtherClients. It's an actual function, so callers don't need access to internal knowledge (definition of struct _OtherClients, clients[] array, ...) Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/security.c | 2 +- Xi/exevents.c | 2 +- dix/events.c | 6 +++--- dix/lookup.c | 7 +++++++ dix/resource_priv.h | 11 +++++++++++ include/resource.h | 2 -- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Xext/security.c b/Xext/security.c index 74abfc1d9..ddf1414b9 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -208,7 +208,7 @@ SecurityDeleteAuthorization(void *value, XID id) .type = SecurityEventBase + XSecurityAuthorizationRevoked, .authId = pAuth->id }; - WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are); + WriteEventsToClient(dixClientForOtherClients(pEventClient), 1, (xEvent *) &are); FreeResource(pEventClient->resource, X11_RESTYPE_NONE); } diff --git a/Xi/exevents.c b/Xi/exevents.c index 8740e4aef..dd64fe0d4 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1428,7 +1428,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti, break; /* if owner selected, oclients is NULL */ - *client = oclients ? rClient(oclients) : dixClientForWindow(*win); + *client = oclients ? dixClientForOtherClients(oclients) : dixClientForWindow(*win); } *grab = NULL; diff --git a/dix/events.c b/dix/events.c index 268aa15fe..a7816b721 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2570,12 +2570,12 @@ Bool MaybeDeliverEventToClient(WindowPtr pWin, xEvent *pEvents, return FALSE; #ifdef XINERAMA if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum) - return XineramaTryClientEventsResult(rClient(other), NullGrab, + return XineramaTryClientEventsResult(dixClientForOtherClients(other), NullGrab, other->mask, filter); #endif /* XINERAMA */ - if (XaceHookReceiveAccess(rClient(other), pWin, pEvents, 1)) + if (XaceHookReceiveAccess(dixClientForOtherClients(other), pWin, pEvents, 1)) return TRUE; /* don't send, but pretend we did */ - return TryClientEvents(rClient(other), NULL, pEvents, 1, + return TryClientEvents(dixClientForOtherClients(other), NULL, pEvents, 1, other->mask, filter, NullGrab) == 1; } } diff --git a/dix/lookup.c b/dix/lookup.c index f9736327c..c039efd39 100644 --- a/dix/lookup.c +++ b/dix/lookup.c @@ -32,3 +32,10 @@ ClientPtr dixClientForInputClients(InputClientsPtr pInputClients) { return clients[CLIENT_ID(pInputClients->resource)]; } + +ClientPtr dixClientForOtherClients(OtherClientsPtr pOtherClients) { + if (!pOtherClients) + return NullClient; + + return clients[CLIENT_ID(pOtherClients->resource)]; +} diff --git a/dix/resource_priv.h b/dix/resource_priv.h index 16dde7bb0..ee12b0ede 100644 --- a/dix/resource_priv.h +++ b/dix/resource_priv.h @@ -40,4 +40,15 @@ ClientPtr dixClientForGrab(GrabPtr pGrab); */ ClientPtr dixClientForInputClients(InputClientsPtr pInputClients); +/* + * @brief retrieve client that owns OtherClients + * + * XIDs carry the ID of the client who created/owns the resource in upper bits. + * (every client so is assigned a range of XIDs it may use for resource creation) + * + * @param GrabPtr to the OtherClients whose owning client shall be retrieved + * @return pointer to ClientRec structure or NullClient (NULL) + */ +ClientPtr dixClientForOtherClients(OtherClientsPtr pOtherClients); + #endif /* _XSERVER_DIX_RESOURCE_PRIV_H */ diff --git a/include/resource.h b/include/resource.h index e6cbb5359..5e990bf53 100644 --- a/include/resource.h +++ b/include/resource.h @@ -128,8 +128,6 @@ extern _X_EXPORT unsigned int ResourceClientBits(void); #define BAD_RESOURCE 0xe0000000 -#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) - /* Resource state callback */ extern _X_EXPORT CallbackListPtr ResourceStateCallback;