From e9d6f2886e155804d1c8b474cb95cb9d0117b2f0 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 17 May 2024 20:29:03 +0200 Subject: [PATCH] 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 --- Xi/exevents.c | 9 ++++----- dix/dix_priv.h | 13 +++++++++++++ dix/events.c | 4 ++-- dix/grabs.c | 6 +++--- include/dixgrabs.h | 12 ------------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 2f02d7ed4..d35879902 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -105,7 +105,6 @@ SOFTWARE. #include "exglobals.h" #include "eventstr.h" #include "dixevents.h" /* DeliverFocusedEvent */ -#include "dixgrabs.h" /* CreateGrab() */ #include "scrnintstr.h" #include "listdev.h" /* for CopySwapXXXClass */ #include "xace.h" @@ -2529,7 +2528,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, else if (grabtype == XI2) 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); if (!grab) return BadAlloc; @@ -2577,7 +2576,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, if (rc != Success) 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); if (!grab) return BadAlloc; @@ -2620,7 +2619,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type, if (rc != Success) return rc; - grab = CreateGrab(client->index, dev, dev, pWin, XI2, + grab = CreateGrab(client, dev, dev, pWin, XI2, mask, param, (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, 0, NULL, cursor); @@ -2651,7 +2650,7 @@ GrabTouchOrGesture(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev, if (rc != Success) 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); if (!grab) return BadAlloc; diff --git a/dix/dix_priv.h b/dix/dix_priv.h index 8a85ed35d..54d2cf2ea 100644 --- a/dix/dix_priv.h +++ b/dix/dix_priv.h @@ -20,6 +20,7 @@ #include "include/callback.h" #include "include/cursor.h" #include "include/dix.h" +#include "include/dixgrabs.h" #include "include/events.h" #include "include/gc.h" #include "include/input.h" @@ -253,4 +254,16 @@ extern Bool explicit_display; extern Bool disableBackingStore; extern Bool enableBackingStore; +GrabPtr CreateGrab(ClientPtr client, + DeviceIntPtr device, + DeviceIntPtr modDevice, + WindowPtr window, + enum InputLevel grabtype, + GrabMask *mask, + struct _GrabParameters *param, + int type, + KeyCode keybut, + WindowPtr confineTo, + CursorPtr cursor); + #endif /* _XSERVER_DIX_PRIV_H */ diff --git a/dix/events.c b/dix/events.c index 983ce739b..d84b0491b 100644 --- a/dix/events.c +++ b/dix/events.c @@ -5636,7 +5636,7 @@ ProcGrabKey(ClientPtr client) mask.core = (KeyPressMask | KeyReleaseMask); - grab = CreateGrab(client->index, keybd, keybd, pWin, CORE, &mask, + grab = CreateGrab(client, keybd, keybd, pWin, CORE, &mask, ¶m, KeyPress, stuff->key, NullWindow, NullCursor); if (!grab) return BadAlloc; @@ -5730,7 +5730,7 @@ ProcGrabButton(ClientPtr client) mask.core = stuff->eventMask; - grab = CreateGrab(client->index, ptr, modifierDevice, pWin, + grab = CreateGrab(client, ptr, modifierDevice, pWin, CORE, &mask, ¶m, ButtonPress, stuff->button, confineTo, cursor); if (!grab) diff --git a/dix/grabs.c b/dix/grabs.c index 4e63e7203..1711449d5 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -215,7 +215,7 @@ AllocGrab(const GrabPtr src) } GrabPtr -CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, +CreateGrab(ClientPtr client, DeviceIntPtr device, DeviceIntPtr modDevice, WindowPtr window, enum InputLevel grabtype, GrabMask *mask, GrabParameters *param, int type, KeyCode keybut, /* key or button */ @@ -226,7 +226,7 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, grab = AllocGrab(NULL); if (!grab) return (GrabPtr) NULL; - grab->resource = FakeClientID(client); + grab->resource = FakeClientID(client->index); grab->device = device; grab->window = window; if (grabtype == CORE || grabtype == XI) @@ -647,7 +647,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) param.other_devices_mode = grab->pointerMode; param.modifiers = any_modifier; - pNewGrab = CreateGrab(CLIENT_ID(grab->resource), grab->device, + pNewGrab = CreateGrab(clients[CLIENT_ID(grab->resource)], grab->device, grab->modifierDevice, grab->window, grab->grabtype, (GrabMask *) &grab->eventMask, diff --git a/include/dixgrabs.h b/include/dixgrabs.h index dc1068fef..6e6e0c02e 100644 --- a/include/dixgrabs.h +++ b/include/dixgrabs.h @@ -35,18 +35,6 @@ extern GrabPtr AllocGrab(const GrabPtr src); extern void FreeGrab(GrabPtr grab); extern Bool CopyGrab(GrabPtr dst, const GrabPtr src); -extern GrabPtr CreateGrab(int /* client */ , - DeviceIntPtr /* device */ , - DeviceIntPtr /* modDevice */ , - WindowPtr /* window */ , - enum InputLevel /* grabtype */ , - GrabMask * /* mask */ , - struct _GrabParameters * /* param */ , - int /* type */ , - KeyCode /* keybut */ , - WindowPtr /* confineTo */ , - CursorPtr /* cursor */ ); - extern _X_EXPORT int DeletePassiveGrab(void *value, XID id);