From 3f5fdfc615be065dec3f4265ca2535b94da3d0c3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 17 Sep 2025 10:53:56 +0200 Subject: [PATCH] Xi: inline SProcXGrabDeviceKey() No need to have a hole bunch of extra functions, if we can just easily inline the few relevant lines. Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/extinit.c | 2 +- Xi/grabdevk.c | 40 ++++++++++++++-------------------------- Xi/handlers.h | 1 - 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Xi/extinit.c b/Xi/extinit.c index bc159583c4..bb168a2c75 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -380,7 +380,7 @@ SProcIDispatch(ClientPtr client) case X_UngrabDevice: return ProcXUngrabDevice(client); case X_GrabDeviceKey: - return SProcXGrabDeviceKey(client); + return ProcXGrabDeviceKey(client); case X_UngrabDeviceKey: return SProcXUngrabDeviceKey(client); case X_GrabDeviceButton: diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c index d33717bde2..4ecca86eb5 100644 --- a/Xi/grabdevk.c +++ b/Xi/grabdevk.c @@ -64,25 +64,6 @@ SOFTWARE. #include "xace.h" #include "grabdev.h" -/*********************************************************************** - * - * Handle requests from clients with a different byte order. - * - */ - -int _X_COLD -SProcXGrabDeviceKey(ClientPtr client) -{ - REQUEST(xGrabDeviceKeyReq); - REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq); - swapl(&stuff->grabWindow); - swaps(&stuff->modifiers); - swaps(&stuff->event_count); - REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32)); - SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); - return (ProcXGrabDeviceKey(client)); -} - /*********************************************************************** * * Grab a key on an extension device. @@ -92,6 +73,20 @@ SProcXGrabDeviceKey(ClientPtr client) int ProcXGrabDeviceKey(ClientPtr client) { + REQUEST(xGrabDeviceKeyReq); + REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq); + + if (client->swapped) { + swapl(&stuff->grabWindow); + swaps(&stuff->modifiers); + swaps(&stuff->event_count); + } + + REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32)); + + if (client->swapped) + SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); + int ret; DeviceIntPtr dev; DeviceIntPtr mdev; @@ -99,13 +94,6 @@ ProcXGrabDeviceKey(ClientPtr client) struct tmask tmp[EMASKSIZE]; GrabMask mask; - REQUEST(xGrabDeviceKeyReq); - REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq); - - if (client->req_len != - bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count) - return BadLength; - ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess); if (ret != Success) return ret; diff --git a/Xi/handlers.h b/Xi/handlers.h index 4b6ceea7f0..558ba85538 100644 --- a/Xi/handlers.h +++ b/Xi/handlers.h @@ -74,7 +74,6 @@ int SProcXGetDeviceMotionEvents(ClientPtr client); int SProcXGetExtensionVersion(ClientPtr client); int SProcXGetSelectedExtensionEvents(ClientPtr client); int SProcXGrabDeviceButton(ClientPtr client); -int SProcXGrabDeviceKey(ClientPtr client); int SProcXIAllowEvents(ClientPtr client); int SProcXIBarrierReleasePointer(ClientPtr client); int SProcXIGetClientPointer(ClientPtr client);