From b5210be9eb1b1811c1a02ed12e021a337e47506c Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 9 Sep 2025 16:55:07 +0200 Subject: [PATCH] Xi: helper for private structure retrieval Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/exglobals.h | 8 ++++++-- Xi/xiallowev.c | 2 +- Xi/xiquerydevice.c | 2 +- Xi/xiquerypointer.c | 4 ++-- Xi/xiqueryversion.c | 3 +-- dix/events.c | 4 +--- test/xi2/protocol-xiqueryversion.c | 5 ++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Xi/exglobals.h b/Xi/exglobals.h index 465e717a9d..ce66e6b503 100644 --- a/Xi/exglobals.h +++ b/Xi/exglobals.h @@ -28,11 +28,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * Globals referenced elsewhere in the server. * */ -#include "privates.h" #ifndef EXGLOBALS_H #define EXGLOBALS_H 1 +#include "dix/exevents_priv.h" +#include "include/privates.h" + extern int IEventBase; extern int BadDevice; extern int BadMode; @@ -73,6 +75,8 @@ extern RESTYPE RT_INPUTCLIENT; extern DevPrivateKeyRec XIClientPrivateKeyRec; -#define XIClientPrivateKey (&XIClientPrivateKeyRec) +static inline XIClientPtr XIClientPriv(ClientPtr client) { + return dixLookupPrivate(&client->devPrivates, &XIClientPrivateKeyRec); +} #endif /* EXGLOBALS_H */ diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c index d0ad9101bc..971e8c7cca 100644 --- a/Xi/xiallowev.c +++ b/Xi/xiallowev.c @@ -75,7 +75,7 @@ ProcXIAllowEvents(ClientPtr client) Window grabWindow = 0; uint32_t touchId = 0; - XIClientPtr xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + XIClientPtr xi_client = XIClientPriv(client); if (!xi_client) return BadImplementation; diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 47b5620b18..5a5bbf0e82 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -465,7 +465,7 @@ static Bool ShouldListGestureInfo(ClientPtr client) * and then a completely separate module within the client uses broken libxcb to call * XIQueryDevice. */ - XIClientPtr pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + XIClientPtr pXIClient = XIClientPriv(client); if (pXIClient->major_version) { return version_compare(pXIClient->major_version, pXIClient->minor_version, 2, 4) >= 0; } diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c index 8182548947..2ac260a9af 100644 --- a/Xi/xiquerypointer.c +++ b/Xi/xiquerypointer.c @@ -79,7 +79,6 @@ ProcXIQueryPointer(ClientPtr client) WindowPtr pWin, t; SpritePtr pSprite; XkbStatePtr state; - XIClientPtr xi_client; Bool have_xi22 = FALSE; REQUEST(xXIQueryPointerReq); @@ -89,7 +88,8 @@ ProcXIQueryPointer(ClientPtr client) * do not know about touches, so we must report emulated button presses. 2.2 * and later clients are aware of touches, so we don't include emulated * button presses in the reply. */ - xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + XIClientPtr xi_client = XIClientPriv(client); + if (version_compare(xi_client->major_version, xi_client->minor_version, 2, 2) >= 0) have_xi22 = TRUE; diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c index 857b5ffa43..b124afdf9b 100644 --- a/Xi/xiqueryversion.c +++ b/Xi/xiqueryversion.c @@ -55,7 +55,6 @@ extern XExtensionVersion XIVersion; /* defined in getvers.c */ int ProcXIQueryVersion(ClientPtr client) { - XIClientPtr pXIClient; int major, minor; REQUEST(xXIQueryVersionReq); @@ -67,7 +66,7 @@ ProcXIQueryVersion(ClientPtr client) return BadValue; } - pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + XIClientPtr pXIClient = XIClientPriv(client); if (version_compare(XIVersion.major_version, XIVersion.minor_version, stuff->major_version, stuff->minor_version) > 0) { diff --git a/dix/events.c b/dix/events.c index ca80e3891b..bc6474443c 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2429,15 +2429,13 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent static BOOL FilterRawEvents(const ClientPtr client, const GrabPtr grab, WindowPtr root) { - XIClientPtr client_xi_version; int cmp; /* device not grabbed -> don't filter */ if (!grab) return FALSE; - client_xi_version = - dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); + XIClientPtr client_xi_version = XIClientPriv(client); cmp = version_compare(client_xi_version->major_version, client_xi_version->minor_version, 2, 0); diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c index 4558411e27..55a7f3044a 100644 --- a/test/xi2/protocol-xiqueryversion.c +++ b/test/xi2/protocol-xiqueryversion.c @@ -204,7 +204,6 @@ test_XIQueryVersion_multiple(void) { xXIQueryVersionReq request; ClientRec client; - XIClientPtr pXIClient; int rc; init_simple(); @@ -261,7 +260,7 @@ test_XIQueryVersion_multiple(void) assert(rc == Success); /* real version is changed, too! */ - pXIClient = dixLookupPrivate(&client.devPrivates, XIClientPrivateKey); + XIClientPtr pXIClient = XIClientPriv(&client); assert(pXIClient->minor_version == 3); /* client tries to set lower version, no change */ @@ -286,7 +285,7 @@ test_XIQueryVersion_multiple(void) assert(rc == Success); /* but real client version must not be lowered */ - pXIClient = dixLookupPrivate(&client.devPrivates, XIClientPrivateKey); + pXIClient = XIClientPriv(&client); assert(pXIClient->minor_version == 3); request.major_version = 2;