(!1632) xkb: XkbWriteModifierMap(): only pass in the needed data

We don't need the whole struct here, especially do we not wanna change it.
Therefore only pass in what's really needed, so it gets easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-15 19:49:50 +02:00
parent 9a85c8dd21
commit 9070f6a543

View File

@ -1324,18 +1324,18 @@ XkbSizeModifierMap(XkbDescPtr xkb, xkbGetMapReply * rep)
} }
static char * static char *
XkbWriteModifierMap(XkbDescPtr xkb, xkbGetMapReply * rep, char *buf, XkbWriteModifierMap(XkbDescPtr xkb, KeyCode firstModMapKey, CARD8 nModMapKeys,
ClientPtr client) char *buf)
{ {
unsigned i; unsigned i;
char *start; char *start;
unsigned char *pMap; unsigned char *pMap;
start = buf; start = buf;
pMap = &xkb->map->modmap[rep->firstModMapKey]; pMap = &xkb->map->modmap[firstModMapKey];
for (i = 0; i < rep->nModMapKeys; i++, pMap++) { for (i = 0; i < nModMapKeys; i++, pMap++) {
if (*pMap != 0) { if (*pMap != 0) {
*buf++ = i + rep->firstModMapKey; *buf++ = i + firstModMapKey;
*buf++ = *pMap; *buf++ = *pMap;
} }
} }
@ -1434,7 +1434,7 @@ XkbSendMap(ClientPtr client, XkbDescPtr xkb, xkbGetMapReply * rep)
if (rep->totalKeyExplicit > 0) if (rep->totalKeyExplicit > 0)
desc = XkbWriteExplicit(xkb, rep->firstKeyExplicit, rep->nKeyExplicit, desc); desc = XkbWriteExplicit(xkb, rep->firstKeyExplicit, rep->nKeyExplicit, desc);
if (rep->totalModMapKeys > 0) if (rep->totalModMapKeys > 0)
desc = XkbWriteModifierMap(xkb, rep, desc, client); desc = XkbWriteModifierMap(xkb, rep->firstModMapKey, rep->nModMapKeys, desc);
if (rep->totalVModMapKeys > 0) if (rep->totalVModMapKeys > 0)
desc = XkbWriteVirtualModMap(xkb, rep, desc, client); desc = XkbWriteVirtualModMap(xkb, rep, desc, client);
if ((desc - start) != (len)) { if ((desc - start) != (len)) {