libkeymap: Do not dump diacr values if lk_dump_keymap called
[platform/upstream/kbd.git] / doc / kbd.FAQ-13.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4  <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5  <TITLE>The Linux keyboard and console HOWTO: X</TITLE>
6  <LINK HREF="kbd.FAQ-14.html" REL=next>
7  <LINK HREF="kbd.FAQ-12.html" REL=previous>
8  <LINK HREF="kbd.FAQ.html#toc13" REL=contents>
9 </HEAD>
10 <BODY>
11 <A HREF="kbd.FAQ-14.html">Next</A>
12 <A HREF="kbd.FAQ-12.html">Previous</A>
13 <A HREF="kbd.FAQ.html#toc13">Contents</A>
14 <HR>
15 <H2><A NAME="s13">13. X</A></H2>
16
17 <P>
18 <P>This FAQ/HOWTO is about the Linux keyboard and console, not about X,
19 which substitutes its own handling. However, it seems useful to
20 document some of the Linux keyboard and console related properties
21 of X.
22 <P>First of all, when X is started (say using <CODE>startx</CODE> or <CODE>xinit</CODE>)
23 it opens the first unused console, unless the desired console has been
24 indicated explicitly, as in <CODE>xinit -- vt12</CODE>.
25 Note that this will fail when there is no device file <CODE>/dev/tty12</CODE>,
26 but that it will not fail when the indicated console was in use already.
27 When X finishes, it will return to the original console.
28 While it is running one can use Ctrl-Alt-Fn to switch to VTn.
29 <P>The XFree86 keymap mechanism is much poorer than the Linux mechanism.
30 For each keycode there are at most 4 symbols defined, namely for the
31 4 keymaps plain, shift, mod, mod+shift. What is the modifier mod?
32 It is the one designated by the symbol <CODE>Mode_switch</CODE>.
33 For example, the command <CODE>xmodmap keys.dk</CODE>, where the file
34 <CODE>keys.dk</CODE> contains
35 <BLOCKQUOTE><CODE>
36 <PRE>
37 keycode 64 = Mode_switch
38 keycode 113 = Mode_switch
39 keycode 38 = a A aring Aring
40 keycode 26 = e E ae AE
41 keycode 32 = o O oslash Ooblique
42 </PRE>
43 </CODE></BLOCKQUOTE>
44
45 will make both Alt keys into mod keys, so that Alt+a gives å (a-ring), etc.
46 (Note the illogical naming of oslash and Ooblique.)
47 Such an <CODE>xmodmap</CODE> command can be placed in the <CODE>.xinitrc</CODE>
48 shell script that is executed by default when X is started.
49 <P>
50 <H2><A NAME="ss13.1">13.1 What precisely does XFree86-2.1 do when it initializes its keymap?</A>
51 </H2>
52
53 <P>
54 <!--
55 keymap!initialization by XFree86
56 -->
57
58 <!--
59 XFree86!keymap initialization
60 -->
61 <P>Since version 2.1, XFree86 will initialize its keymap from the Linux keymap,
62 as far as possible. However, Linux had 16 entries per key (one for each
63 combination of the Shift, AltGr, Ctrl, Alt modifiers) and presently has
64 256 entries per key, while X has 4 entries per key (one for each combination
65 of Shift, Mod), so some information is necessarily lost.
66 <P>First <CODE>X</CODE> reads the <CODE>Xconfig</CODE> file, where definitions of the LeftAlt, RightAlt,
67 RightCtl, ScrollLock keys as Meta, ModeShift, Compose, ModeLock or ScrollLock
68 might be found - see X386keybd(1), later XFree86kbd(1).
69 <P>For Mod the LeftAlt key is taken, unless RightCtl was defined as ModeShift or
70 ModeLock, in which case RightCtl is taken, or RightAlt was so defined, in which
71 case RightAlt is taken.
72 This determines how the 4 XFree86 meanings of a key are selected from the 16
73 Linux meanings.
74 Note that Linux today does not distinguish by default between the two Ctrl keys
75 or between the two Shift keys. <CODE>X</CODE> does distinguish.
76 <P>Now the kernel keymap is read and the usually obvious corresponding X
77 bindings are made. The bindings for the "action keys" Show_Memory, Show_State,
78 Show_Registers, Last_Console, Console_n, Scroll_Backward, Scroll_Forward,
79 Caps_On and Boot are ignored, as are the dead diacriticals, and the locks
80 (except for ShiftLock), and the "ASCII-x" keys.
81 <P>Next, the definitions in the <CODE>Xconfig</CODE> file are used. (Thus, a definition
82 of Compose in <CODE>Xconfig</CODE> will override its value as found in the Linux
83 keymap.)
84 <P>What happens to the strings associated with the function keys? Nothing,
85 X does not have such a concept. (But it is possible to define strings
86 for function keys in <CODE>xterm</CODE> - note however that the window manager gets the
87 keys first.)
88 <P>I don't know how to convince <CODE>xterm</CODE> that it should use the X keymap
89 when Alt is pressed; it seems just to look at its resource <CODE>eightBitInput</CODE>,
90 and depending on whether that is true or false either set the high order bit
91 of the character, or generate an additional Escape character
92 (just like setmetamode(1) does for the console).
93 <P>
94 <HR>
95 <A HREF="kbd.FAQ-14.html">Next</A>
96 <A HREF="kbd.FAQ-12.html">Previous</A>
97 <A HREF="kbd.FAQ.html#toc13">Contents</A>
98 </BODY>
99 </HTML>