summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-01-26 00:05:55 +0100
committerPovilas Kanapickas <povilas@radix.lt>2022-02-03 21:44:37 +0000
commit0217cc6e0cf5013366105a90f5f91ccc4bab5425 (patch)
treee49f7352beae11b94fffd1b1e3c261ea2973f79d /xkb
parentdc7cb45482cea6ccec22d117ca0b489500b4d0a0 (diff)
downloadxserver-0217cc6e0cf5013366105a90f5f91ccc4bab5425.tar.gz
xkb: fix XkbSetMap when changing a keysym without changing a keytype
As the comment says: "symsPerKey/mapWidths must be filled regardless of client-side flags" so we always have to call CheckKeyTypes which will notably fill mapWidths and nTypes. That is needed for CheckKeySyms to work since it checks the width. Without it, any request with XkbKeySymsMask but not XkbKeyTypesMask will fail because of the missing width information, for instance this: XkbDescPtr xkb; if (!(xkb = XkbGetMap (dpy, XkbKeyTypesMask|XkbKeySymsMask, XkbUseCoreKbd))) { fprintf (stderr, "ERROR getting map\n"); exit(1); } XFlush (dpy); XSync (dpy, False); XkbMapChangesRec changes = { .changed = 0 }; int oneGroupType[XkbNumKbdGroups] = { XkbOneLevelIndex }; if (XkbChangeTypesOfKey(xkb, keycode, 1, XkbGroup1Mask, oneGroupType, &changes)) { fprintf(stderr, "ERROR changing type of key\n"); exit(1); } XkbKeySymEntry(xkb,keycode,0,0) = keysym; if (!XkbChangeMap(dpy,xkb,&changes)) { fprintf(stderr, "ERROR changing map\n"); exit(1); } XkbFreeKeyboard (xkb, 0, TRUE); XFlush (dpy); XSync (dpy, False); This had being going under the radar since about ever until commit de940e06f8733d87bbb857aef85d830053442cfe ("xkb: fix key type index check in _XkbSetMapChecks") fixed checking the values of kt_index, which was previously erroneously ignoring errors and ignoring all other checks, just because nTypes was not set, precisely because CheckKeyTypes was not called. Note: yes, CheckKeyTypes is meant to be callable without XkbKeyTypesMask, it does properly check for that and just fills nTypes and mapWidths in that case. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'xkb')
-rw-r--r--xkb/xkb.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/xkb/xkb.c b/xkb/xkb.c
index bfc21de00..820cd7166 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -2511,16 +2511,15 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req,
}
}
- if (!(req->present & XkbKeyTypesMask)) {
- nTypes = xkb->map->num_types;
- }
- else if (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values,
- &nTypes, mapWidths, doswap)) {
+ /* nTypes/mapWidths/symsPerKey must be filled for further tests below,
+ * regardless of client-side flags */
+
+ if (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values,
+ &nTypes, mapWidths, doswap)) {
client->errorValue = nTypes;
return BadValue;
}
- /* symsPerKey/mapWidths must be filled regardless of client-side flags */
map = &xkb->map->key_sym_map[xkb->min_key_code];
for (i = xkb->min_key_code; i < xkb->max_key_code; i++, map++) {
register int g, ng, w;