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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-03-06 13:08:25 +01:00
parent e1f8794b1d
commit d80866e764
6 changed files with 23 additions and 7 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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)];
}

View File

@ -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 */

View File

@ -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;