dix: add dixClientForInputClients()

Helper function for retrieving the owning client of an InputClients.

It's an actual function, so callers don't need access to internal
knowledge (definition of struct _InputClients, 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 12:59:09 +01:00
parent 0ca0c334d8
commit e1f8794b1d
4 changed files with 24 additions and 6 deletions

View File

@ -1047,7 +1047,7 @@ TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev,
assert(wOtherInputMasks(win));
nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) {
if (rClient(iclient) != client)
if (dixClientForInputClients(iclient) != client)
continue;
return xi2mask_isset(iclient->xi2mask, dev, XI_TouchOwnership);
@ -1401,7 +1401,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
BUG_RETURN_VAL(!iclients, FALSE);
*mask = iclients->xi2mask;
*client = rClient(iclients);
*client = dixClientForInputClients(iclients);
}
else if (listener->level == XI) {
int xi_type = GetXIType(TouchGetPointerEventType(ev));
@ -1414,7 +1414,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
break;
BUG_RETURN_VAL(!iclients, FALSE);
*client = rClient(iclients);
*client = dixClientForInputClients(iclients);
}
else {
int coretype = GetCoreType(TouchGetPointerEventType(ev));
@ -2304,7 +2304,7 @@ RetrieveGestureDeliveryData(DeviceIntPtr dev, InternalEvent *ev, GestureListener
BUG_RETURN_VAL(!iclients, FALSE);
*client = rClient(iclients);
*client = dixClientForInputClients(iclients);
}
return TRUE;

View File

@ -2271,7 +2271,7 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients * inputclients,
for (; inputclients; inputclients = inputclients->next) {
Mask mask;
ClientPtr client = rClient(inputclients);
ClientPtr client = dixClientForInputClients(inputclients);
if (IsInterferingGrab(client, dev, events))
continue;
@ -2507,7 +2507,7 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
*/
ic.next = NULL;
if (!FilterRawEvents(rClient(&ic), grab, root))
if (!FilterRawEvents(dixClientForInputClients(&ic), grab, root))
DeliverEventToInputClients(device, &ic, root, xi, 1,
filter, NULL, &c, &m);
}

View File

@ -25,3 +25,10 @@ ClientPtr dixClientForGrab(GrabPtr pGrab) {
return clients[CLIENT_ID(pGrab->resource)];
}
ClientPtr dixClientForInputClients(InputClientsPtr pInputClients) {
if (!pInputClients)
return NullClient;
return clients[CLIENT_ID(pInputClients->resource)];
}

View File

@ -29,4 +29,15 @@ ClientPtr dixClientForWindow(WindowPtr pWin);
*/
ClientPtr dixClientForGrab(GrabPtr pGrab);
/*
* @brief retrieve client that owns InputClients
*
* 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 InputClients whose owning client shall be retrieved
* @return pointer to ClientRec structure or NullClient (NULL)
*/
ClientPtr dixClientForInputClients(InputClientsPtr pInputClients);
#endif /* _XSERVER_DIX_RESOURCE_PRIV_H */