dix: let CreateGrab operate on ClientPtr instead of array index

Almost all callers have ClientPtr anyways, so we're just doing duplicate
array lookups. Just using ClientPtr directly is easier anyways.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-05-17 20:29:03 +02:00
parent a09805f675
commit 1cbfe67a5a
4 changed files with 11 additions and 11 deletions

View File

@ -2532,7 +2532,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
else if (grabtype == XI2) else if (grabtype == XI2)
type = XI_ButtonPress; type = XI_ButtonPress;
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype, grab = CreateGrab(client, dev, modifier_device, pWin, grabtype,
mask, param, type, button, confineTo, cursor); mask, param, type, button, confineTo, cursor);
if (!grab) if (!grab)
return BadAlloc; return BadAlloc;
@ -2580,7 +2580,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
if (rc != Success) if (rc != Success)
return rc; return rc;
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype, grab = CreateGrab(client, dev, modifier_device, pWin, grabtype,
mask, param, type, key, NULL, NULL); mask, param, type, key, NULL, NULL);
if (!grab) if (!grab)
return BadAlloc; return BadAlloc;
@ -2623,7 +2623,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type,
if (rc != Success) if (rc != Success)
return rc; return rc;
grab = CreateGrab(client->index, dev, dev, pWin, XI2, grab = CreateGrab(client, dev, dev, pWin, XI2,
mask, param, mask, param,
(type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, 0, (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, 0,
NULL, cursor); NULL, cursor);
@ -2654,7 +2654,7 @@ GrabTouchOrGesture(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev,
if (rc != Success) if (rc != Success)
return rc; return rc;
grab = CreateGrab(client->index, dev, mod_dev, pWin, XI2, grab = CreateGrab(client, dev, mod_dev, pWin, XI2,
mask, param, type, 0, NullWindow, NullCursor); mask, param, type, 0, NullWindow, NullCursor);
if (!grab) if (!grab)
return BadAlloc; return BadAlloc;

View File

@ -64,7 +64,7 @@ void FreeGrab(GrabPtr grab);
* Create a new grab for given client, with given parameters. * Create a new grab for given client, with given parameters.
* Returns NULL on OOM. * Returns NULL on OOM.
* *
* @param client _Index_ of the client who will hold the grab * @param pClient ClientPtr to the client who will hold the grab
* @param device Device that's being grabbed * @param device Device that's being grabbed
* @param modDevice Device whose modifiers are used (NULL = use core keyboard) * @param modDevice Device whose modifiers are used (NULL = use core keyboard)
* @param window the window getting the events * @param window the window getting the events
@ -77,7 +77,7 @@ void FreeGrab(GrabPtr grab);
* @param cursor cursor to be used while grabbed (may be NULL) * @param cursor cursor to be used while grabbed (may be NULL)
* @return newly created grab. Must be freed by ::FreeGrab() * @return newly created grab. Must be freed by ::FreeGrab()
*/ */
GrabPtr CreateGrab(int client, GrabPtr CreateGrab(ClientPtr pClient,
DeviceIntPtr device, DeviceIntPtr device,
DeviceIntPtr modDevice, DeviceIntPtr modDevice,
WindowPtr window, WindowPtr window,

View File

@ -5671,7 +5671,7 @@ ProcGrabKey(ClientPtr client)
mask.core = (KeyPressMask | KeyReleaseMask); mask.core = (KeyPressMask | KeyReleaseMask);
grab = CreateGrab(client->index, keybd, keybd, pWin, CORE, &mask, grab = CreateGrab(client, keybd, keybd, pWin, CORE, &mask,
&param, KeyPress, stuff->key, NullWindow, NullCursor); &param, KeyPress, stuff->key, NullWindow, NullCursor);
if (!grab) if (!grab)
return BadAlloc; return BadAlloc;
@ -5765,7 +5765,7 @@ ProcGrabButton(ClientPtr client)
mask.core = stuff->eventMask; mask.core = stuff->eventMask;
grab = CreateGrab(client->index, ptr, modifierDevice, pWin, grab = CreateGrab(client, ptr, modifierDevice, pWin,
CORE, &mask, &param, ButtonPress, CORE, &mask, &param, ButtonPress,
stuff->button, confineTo, cursor); stuff->button, confineTo, cursor);
if (!grab) if (!grab)

View File

@ -214,7 +214,7 @@ AllocGrab(const GrabPtr src)
} }
GrabPtr GrabPtr
CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, CreateGrab(ClientPtr client, DeviceIntPtr device, DeviceIntPtr modDevice,
WindowPtr window, enum InputLevel grabtype, GrabMask *mask, WindowPtr window, enum InputLevel grabtype, GrabMask *mask,
GrabParameters *param, int eventType, GrabParameters *param, int eventType,
KeyCode keybut, /* key or button */ KeyCode keybut, /* key or button */
@ -225,7 +225,7 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice,
grab = AllocGrab(NULL); grab = AllocGrab(NULL);
if (!grab) if (!grab)
return (GrabPtr) NULL; return (GrabPtr) NULL;
grab->resource = FakeClientID(client); grab->resource = FakeClientID(client->index);
grab->device = device; grab->device = device;
grab->window = window; grab->window = window;
if (grabtype == CORE || grabtype == XI) if (grabtype == CORE || grabtype == XI)
@ -645,7 +645,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
param.other_devices_mode = grab->pointerMode; param.other_devices_mode = grab->pointerMode;
param.modifiers = any_modifier; param.modifiers = any_modifier;
pNewGrab = CreateGrab(dixClientIdForXID(grab->resource), grab->device, pNewGrab = CreateGrab(dixClientForXID(grab->resource), grab->device,
grab->modifierDevice, grab->window, grab->modifierDevice, grab->window,
grab->grabtype, grab->grabtype,
(GrabMask *) &grab->eventMask, (GrabMask *) &grab->eventMask,