Skip to content

Fix off-by-one error in XKeycodeToKeysym

Adam Sampson requested to merge atsampson/libx11:keycodefix into master

The code in XKeycodeToKeysym that made indexes greater than 3 refer to XKB symbol groups had an off-by-one error, so it would always leave out the symbol that should have been at index 4. Rewrite the code to fix this and simplify the logic a bit.

This was originally diagnosed by firk in bugs.freedesktop.org 5349, which was migrated to GitLab as #97 (closed).

Using the XKeycodeToKeysym.c testcase from that bug, with a French keymap (setxkbmap fr), here's the original output:

0 22 
1 33 
2 0 
3 0 
4 A3 
5 0 
6 0 
7 0 
8 0 

And here's the output with this patch applied (note 23 is now included in the right place):

0 22 
1 33 
2 0 
3 0 
4 23 
5 A3 
6 0 
7 0 
8 0 

Fixes #97 (closed).

Edited by Adam Sampson

Merge request reports