From 53252ad8a977eb62fa0ed46c8d9b0fd511b123a0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 20 Apr 2026 15:37:22 +1000 Subject: [PATCH] Xi: Fix XIPassiveGrab handling of keycodes > 255 This was fixed in commit 51eb63b0ee15 but woefully badly. Instead of returning XIAlreadyGrabbed via the Reply, it simply returned the value from the request handler - causing the server to interpret it as BadRequest. Fix it and do what we intended to do instead. Fixes: 51eb63b0ee15 ("Xi: disallow passive grabs with a detail > 255") Part-of: --- Xi/xipassivegrab.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index 911691a2e..a75559e8e 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -137,12 +137,6 @@ ProcXIPassiveGrabDevice(ClientPtr client) return BadValue; } - /* XI2 allows 32-bit keycodes but thanks to XKB we can never - * implement this. Just return an error for all keycodes that - * cannot work anyway, same for buttons > 255. */ - if (stuff->detail > 255) - return XIAlreadyGrabbed; - if (XICheckInvalidMaskBits(client, (unsigned char *) &stuff[1], stuff->mask_len * 4) != Success) return BadValue; @@ -202,6 +196,14 @@ ProcXIPassiveGrabDevice(ClientPtr client) for (i = 0; i < stuff->num_modifiers; i++, modifiers++) { uint8_t status = Success; + /* XI2 allows 32-bit keycodes but thanks to XKB we can never + * implement this. Pretend that all keycodes above 255 are + * already grabbed, same for buttons > 255. */ + if (stuff->detail > 255) { + status = XIAlreadyGrabbed; + goto modifier_done; + } + param.modifiers = *modifiers; ret = CheckGrabValues(client, ¶m); if (ret != Success) @@ -234,6 +236,7 @@ ProcXIPassiveGrabDevice(ClientPtr client) break; } +modifier_done: if (status != GrabSuccess) { xXIGrabModifierInfo *info = modifiers_failed + rep.num_modifiers;