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 3cbc9eda07
commit e9d6f2886e
5 changed files with 22 additions and 22 deletions

View File

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

View File

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

View File

@@ -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,
&param, 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, &param, ButtonPress,
stuff->button, confineTo, cursor);
if (!grab)

View File

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

View File

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