XLookupString return inconsistent

Alan Coopersmith alan.coopersmith at oracle.com
Mon Sep 12 15:40:24 UTC 2016


On 09/12/16 08:25 AM, wettstae at gmail.com wrote:
>> Do you have any idea what might be going on?
>
> In libX11, file KeyBind.c, function _XTranslateKeySym, there is the
> following piece of code:
>
>     /* only apply Control key if it makes sense, else ignore it */
>     if (modifiers & ControlMask) {
>         if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
>         else if (c == '2') c = '\000';
>         else if (c >= '3' && c <= '7') c -= ('3' - '\033');
>         else if (c == '8') c = '\177';
>         else if (c == '/') c = '_' & 0x1F;
>     }
>
> I have no clue what the "sense" is the comment speaks about, but
> clearly, the weird behaviour you see was intended.

The comment from 1987 seems to have originally referred to the mapping of
ASCII characters 0x40 through 0x5F into the ASCII control character range
of 0x0 through 0x1F:

https://cgit.freedesktop.org/~alanc/xc-historical/commit/xc/lib/X11/KeyBind.c?id=0aecc4f21449050657ce34f7599d383e14fcdf40

The handling of the number keys was added the next year with a comment
about doing things vt200 style:

https://cgit.freedesktop.org/~alanc/xc-historical/commit/xc/lib/X11/KeyBind.c?id=f2485bc25a7394fbd830cd60108b220319dbcb7d

So Control-Shift-2 maps to the NULL character because someone three decades
ago thought it useful to emulate a text terminal popular in that decade.

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg mailing list