From 270e439739e023463e7e0719a4eede69d45f7a3f Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Thu, 14 Nov 2019 14:00:31 -0500 Subject: [PATCH] xkb: only swap once in XkbSetMap The server swaps part of the request in _XkbSetMapChecks instead of SProcXkbSetMap (presumably because walking the XkbSetMap request is hard, and we don't want to maintain another copy of that code). Swap the first time _XkbSetMapChecks is called, not the second time. Signed-off-by: Peter Harris --- xkb/xkb.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index 3162574a4..9ffaf68fb 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -1587,7 +1587,7 @@ CheckKeyTypes(ClientPtr client, XkbDescPtr xkb, xkbSetMapReq * req, xkbKeyTypeWireDesc ** wireRtrn, - int *nMapsRtrn, CARD8 *mapWidthRtrn) + int *nMapsRtrn, CARD8 *mapWidthRtrn, Bool doswap) { unsigned nMaps; register unsigned i, n; @@ -1626,7 +1626,7 @@ CheckKeyTypes(ClientPtr client, for (i = 0; i < req->nTypes; i++) { unsigned width; - if (client->swapped) { + if (client->swapped && doswap) { swaps(&wire->virtualMods); } n = i + req->firstType; @@ -1653,7 +1653,7 @@ CheckKeyTypes(ClientPtr client, mapWire = (xkbKTSetMapEntryWireDesc *) &wire[1]; preWire = (xkbModsWireDesc *) &mapWire[wire->nMapEntries]; for (n = 0; n < wire->nMapEntries; n++) { - if (client->swapped) { + if (client->swapped && doswap) { swaps(&mapWire[n].virtualMods); } if (mapWire[n].realMods & (~wire->realMods)) { @@ -1671,7 +1671,7 @@ CheckKeyTypes(ClientPtr client, return 0; } if (wire->preserve) { - if (client->swapped) { + if (client->swapped && doswap) { swaps(&preWire[n].virtualMods); } if (preWire[n].realMods & (~mapWire[n].realMods)) { @@ -1710,7 +1710,7 @@ CheckKeySyms(ClientPtr client, xkbSetMapReq * req, int nTypes, CARD8 *mapWidths, - CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn) + CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn, Bool doswap) { register unsigned i; XkbSymMapPtr map; @@ -1724,7 +1724,7 @@ CheckKeySyms(ClientPtr client, KeySym *pSyms; register unsigned nG; - if (client->swapped) { + if (client->swapped && doswap) { swaps(&wire->nSyms); } nG = XkbNumGroups(wire->groupInfo); @@ -2371,11 +2371,11 @@ SetVirtualModMap(XkbSrvInfoPtr xkbi, /** * Check if the given request can be applied to the given device but don't - * actually do anything.. + * actually do anything, except swap values when client->swapped and doswap are both true. */ static int _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, - char *values) + char *values, Bool doswap) { XkbSrvInfoPtr xkbi; XkbDescPtr xkb; @@ -2415,7 +2415,7 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, if ((req->present & XkbKeyTypesMask) && (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values, - &nTypes, mapWidths))) { + &nTypes, mapWidths, doswap))) { client->errorValue = nTypes; return BadValue; } @@ -2439,7 +2439,7 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, if ((req->present & XkbKeySymsMask) && (!CheckKeySyms(client, xkb, req, nTypes, mapWidths, symsPerKey, - (xkbSymMapWireDesc **) &values, &error))) { + (xkbSymMapWireDesc **) &values, &error, doswap))) { client->errorValue = error; return BadValue; } @@ -2631,7 +2631,7 @@ ProcXkbSetMap(ClientPtr client) /* Check if we can to the SetMap on the requested device. If this succeeds, do the same thing for all extension devices (if needed). If any of them fails, fail. */ - rc = _XkbSetMapChecks(client, dev, stuff, tmp); + rc = _XkbSetMapChecks(client, dev, stuff, tmp, TRUE); if (rc != Success) return rc; @@ -2647,7 +2647,7 @@ ProcXkbSetMap(ClientPtr client) rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess); if (rc == Success) { - rc = _XkbSetMapChecks(client, other, stuff, tmp); + rc = _XkbSetMapChecks(client, other, stuff, tmp, FALSE); if (rc != Success) return rc; } @@ -2661,7 +2661,7 @@ ProcXkbSetMap(ClientPtr client) (other != master || dev != master->lastSlave)) continue; - rc = _XkbSetMapChecks(client, other, stuff, tmp); + rc = _XkbSetMapChecks(client, other, stuff, tmp, FALSE); if (rc != Success) return rc; }