ch01.xml revision e9fcaa8a
1e9fcaa8aSmrg<chapter id='overview'>
2e9fcaa8aSmrg<title>Overview</title>
3e9fcaa8aSmrg
4e9fcaa8aSmrg<para>
5e9fcaa8aSmrgThe X Keyboard Extension provides capabilities that are lacking or are
6e9fcaa8aSmrgcumbersome in the core X protocol.
7e9fcaa8aSmrg</para>
8e9fcaa8aSmrg
9e9fcaa8aSmrg<sect1 id='core_x_protocol_support_for_keyboards'>
10e9fcaa8aSmrg<title>Core X Protocol Support for Keyboards</title>
11e9fcaa8aSmrg
12e9fcaa8aSmrg<para>
13e9fcaa8aSmrgThe core X protocol specifies the ways that the
14e9fcaa8aSmrg<emphasis>Shift</emphasis>,
15e9fcaa8aSmrg<emphasis>Control</emphasis>, and
16e9fcaa8aSmrg<emphasis>Lock</emphasis>
17e9fcaa8aSmrgmodifiers and the modifiers bound to the
18e9fcaa8aSmrg<emphasis>Mode_switch</emphasis> or
19e9fcaa8aSmrg<emphasis>Num_Lock</emphasis>
20e9fcaa8aSmrgkeysyms interact to generate keysyms and characters. The core protocol also
21e9fcaa8aSmrgallows users to specify that a key affects one or more modifiers. This behavior
22e9fcaa8aSmrgis simple and fairly flexible, but it has a number of limitations that make it
23e9fcaa8aSmrgdifficult or impossible to properly support many common varieties of keyboard
24e9fcaa8aSmrgbehavior. The limitations of core protocol support for keyboards include:
25e9fcaa8aSmrg</para>
26e9fcaa8aSmrg
27e9fcaa8aSmrg<itemizedlist>
28e9fcaa8aSmrg  <listitem>
29e9fcaa8aSmrg    <para>
30e9fcaa8aSmrgUse of a single, uniform, four-symbol mapping for all keyboard keys makes it
31e9fcaa8aSmrgdifficult to properly support keyboard overlays, PC-style break keys, or
32e9fcaa8aSmrgkeyboards that comply with ISO9995, or a host of other national and
33e9fcaa8aSmrginternational standards.
34e9fcaa8aSmrg    </para>
35e9fcaa8aSmrg  </listitem>
36e9fcaa8aSmrg  <listitem>
37e9fcaa8aSmrg    <para>
38e9fcaa8aSmrgA second keyboard group may be specified using a modifier, but this has side
39e9fcaa8aSmrgeffects that wreak havoc with client grabs and X toolkit translations.
40e9fcaa8aSmrgFurthermore, this approach limits the number of keyboard groups to two.
41e9fcaa8aSmrg    </para>
42e9fcaa8aSmrg  </listitem>
43e9fcaa8aSmrg  <listitem>
44e9fcaa8aSmrg    <para>
45e9fcaa8aSmrgPoorly specified locking key behavior requires X servers to look for a few
46e9fcaa8aSmrg"magic" keysyms to determine that keys should lock when pressed. This leads to
47e9fcaa8aSmrgincompatibilities between X servers with no way for clients to detect
48e9fcaa8aSmrgimplementation differences.
49e9fcaa8aSmrg    </para>
50e9fcaa8aSmrg  </listitem>
51e9fcaa8aSmrg  <listitem>
52e9fcaa8aSmrg    <para>
53e9fcaa8aSmrgPoorly specified capitalization and control behavior requires modifications to
54e9fcaa8aSmrgX library source code to support new character sets or locales and can lead to
55e9fcaa8aSmrgincompatibilities between system wide and X library capitalization behavior.
56e9fcaa8aSmrg    </para>
57e9fcaa8aSmrg  </listitem>
58e9fcaa8aSmrg  <listitem>
59e9fcaa8aSmrg    <para>
60e9fcaa8aSmrgLimited interactions between modifiers specified by the core protocol make many
61e9fcaa8aSmrgcommon keyboard behaviors difficult or impossible to implement. For example,
62e9fcaa8aSmrgthere is no reliable way to indicate whether or not the shift modifier should
63e9fcaa8aSmrg"cancel" the lock modifier.
64e9fcaa8aSmrg    </para>
65e9fcaa8aSmrg  </listitem>
66e9fcaa8aSmrg  <listitem>
67e9fcaa8aSmrg    <para>
68e9fcaa8aSmrgThe lack of any explicit descriptions for indicators, most modifiers, and other
69e9fcaa8aSmrgaspects of the keyboard appearance requires clients that wish to clearly
70e9fcaa8aSmrgdescribe the keyboard to a user to resort to a mish-mash of prior knowledge and
71e9fcaa8aSmrgheuristics.
72e9fcaa8aSmrg    </para>
73e9fcaa8aSmrg  </listitem>
74e9fcaa8aSmrg</itemizedlist>
75e9fcaa8aSmrg
76e9fcaa8aSmrg</sect1>
77e9fcaa8aSmrg<sect1 id='xkb_keyboard_extension_support_for_keyboards'>
78e9fcaa8aSmrg<title>Xkb Keyboard Extension Support for Keyboards</title>
79e9fcaa8aSmrg
80e9fcaa8aSmrg<para>
81e9fcaa8aSmrgThe X Keyboard Extension makes it possible to clearly and explicitly specify
82e9fcaa8aSmrgmost aspects of keyboard behavior on a per-key basis. It adds the notion of a
83e9fcaa8aSmrgkeyboard group to the global keyboard state and provides mechanisms to more
84e9fcaa8aSmrgclosely track the logical and physical state of the keyboard. For
85e9fcaa8aSmrgkeyboard-control clients, Xkb provides descriptions and symbolic names for many
86e9fcaa8aSmrgaspects of keyboard appearance and behavior.
87e9fcaa8aSmrg</para>
88e9fcaa8aSmrg
89e9fcaa8aSmrg<para>
90e9fcaa8aSmrgIn addition, the X Keyboard Extension includes additional keyboard controls
91e9fcaa8aSmrgdesigned to make keyboards more accessible to people with movement impairments.
92e9fcaa8aSmrg</para>
93e9fcaa8aSmrg
94e9fcaa8aSmrg</sect1>
95e9fcaa8aSmrg
96e9fcaa8aSmrg<sect1 id='xkb_extension_components'>
97e9fcaa8aSmrg<title>Xkb Extension Components</title>
98e9fcaa8aSmrg
99e9fcaa8aSmrg<para>
100e9fcaa8aSmrgThe Xkb extension is composed of two parts: a server extension, and a
101e9fcaa8aSmrgclient-side X library extension. These consist of a loadable module that may be
102e9fcaa8aSmrgactivated when an X server is started and a modified version of Xlib. Both
103e9fcaa8aSmrgserver and Xlib versions must be at least X11 R6.
104e9fcaa8aSmrg</para>
105e9fcaa8aSmrg
106e9fcaa8aSmrg
107e9fcaa8aSmrg<para>
108e9fcaa8aSmrgFigure 1.1 shows the overall structure of the Xkb extension:
109e9fcaa8aSmrg</para>
110e9fcaa8aSmrg
111e9fcaa8aSmrg<mediaobject>
112e9fcaa8aSmrg  <imageobject>
113e9fcaa8aSmrg    <imagedata format="SVG" fileref="XKBlib-1.svg"/>
114e9fcaa8aSmrg  </imageobject>
115e9fcaa8aSmrg  <caption>Overall Xkb Structure</caption>
116e9fcaa8aSmrg</mediaobject>
117e9fcaa8aSmrg
118e9fcaa8aSmrg
119e9fcaa8aSmrg<para>
120e9fcaa8aSmrgThe server portion of the Xkb extension encompasses a database of named
121e9fcaa8aSmrgkeyboard components, in unspecified format, that may be used to configure a
122e9fcaa8aSmrgkeyboard. Internally, the server maintains a <emphasis>
123e9fcaa8aSmrgkeyboard description</emphasis>
124e9fcaa8aSmrg that includes the keyboard state and configuration (mapping). By "keyboard" we
125e9fcaa8aSmrgmean the logical keyboard device, which includes not only the physical keys,
126e9fcaa8aSmrgbut also potentially a set of up to 32 indicators (usually LEDs) and bells.
127e9fcaa8aSmrg</para>
128e9fcaa8aSmrg
129e9fcaa8aSmrg
130e9fcaa8aSmrg<para>
131e9fcaa8aSmrgThe keyboard description is a composite of several different data structures,
132e9fcaa8aSmrgeach of which may be manipulated separately. When manipulating the server
133e9fcaa8aSmrgcomponents, the design allows partial components to be transmitted between the
134e9fcaa8aSmrgserver and a client. The individual components are shown in Figure 1.1.
135e9fcaa8aSmrg</para>
136e9fcaa8aSmrg
137e9fcaa8aSmrg<variablelist>
138e9fcaa8aSmrg  <varlistentry>
139e9fcaa8aSmrg    <term>Client Map</term>
140e9fcaa8aSmrg    <listitem>
141e9fcaa8aSmrg      <para>
142e9fcaa8aSmrgThe key mapping information needed to convert arbitrary keycodes to symbols.
143e9fcaa8aSmrg      </para>
144e9fcaa8aSmrg    </listitem>
145e9fcaa8aSmrg  </varlistentry>
146e9fcaa8aSmrg  <varlistentry>
147e9fcaa8aSmrg    <term>Server Map</term>
148e9fcaa8aSmrg    <listitem>
149e9fcaa8aSmrg      <para>
150e9fcaa8aSmrgThe key mapping information categorizing keys by functionality (which keys are
151e9fcaa8aSmrgmodifiers, how keys behave, and so on).
152e9fcaa8aSmrg      </para>
153e9fcaa8aSmrg    </listitem>
154e9fcaa8aSmrg  </varlistentry>
155e9fcaa8aSmrg  <varlistentry>
156e9fcaa8aSmrg    <term>Controls</term>
157e9fcaa8aSmrg    <listitem>
158e9fcaa8aSmrg      <para>
159e9fcaa8aSmrgClient configurable quantities effecting how the keyboard behaves, such as
160e9fcaa8aSmrgrepeat behavior and modifications for people with movement impairments.
161e9fcaa8aSmrg      </para>
162e9fcaa8aSmrg    </listitem>
163e9fcaa8aSmrg  </varlistentry>
164e9fcaa8aSmrg  <varlistentry>
165e9fcaa8aSmrg    <term>Indicators</term>
166e9fcaa8aSmrg    <listitem>
167e9fcaa8aSmrg      <para>
168e9fcaa8aSmrgThe mapping of behavior to indicators.
169e9fcaa8aSmrg      </para>
170e9fcaa8aSmrg    </listitem>
171e9fcaa8aSmrg  </varlistentry>
172e9fcaa8aSmrg  <varlistentry>
173e9fcaa8aSmrg    <term>Geometry</term>
174e9fcaa8aSmrg    <listitem>
175e9fcaa8aSmrg      <para>
176e9fcaa8aSmrgA complete description of the physical keyboard layout, sufficient to draw a
177e9fcaa8aSmrgrepresentation of the keyboard.
178e9fcaa8aSmrg      </para>
179e9fcaa8aSmrg    </listitem>
180e9fcaa8aSmrg  </varlistentry>
181e9fcaa8aSmrg  <varlistentry>
182e9fcaa8aSmrg    <term>Names</term>
183e9fcaa8aSmrg    <listitem>
184e9fcaa8aSmrg      <para>
185e9fcaa8aSmrgA mapping of names to various aspects of the keyboard such as individual
186e9fcaa8aSmrgvirtual modifiers, indicators, and bells.
187e9fcaa8aSmrg      </para>
188e9fcaa8aSmrg    </listitem>
189e9fcaa8aSmrg  </varlistentry>
190e9fcaa8aSmrg  <varlistentry>
191e9fcaa8aSmrg    <term>Compatibility Map</term>
192e9fcaa8aSmrg    <listitem>
193e9fcaa8aSmrg      <para>
194e9fcaa8aSmrgThe definition of how to map core protocol keyboard state to Xkb keyboard state.
195e9fcaa8aSmrg      </para>
196e9fcaa8aSmrg    </listitem>
197e9fcaa8aSmrg  </varlistentry>
198e9fcaa8aSmrg</variablelist>
199e9fcaa8aSmrg
200e9fcaa8aSmrg<para>
201e9fcaa8aSmrgA client application interrogates and manipulates the keyboard by reading and
202e9fcaa8aSmrgwriting portions of the server description for the keyboard. In a typical
203e9fcaa8aSmrgsequence a client would fetch the current information it is interested in,
204e9fcaa8aSmrgmodify it, and write it back. If a client wishes to track some portion of the
205e9fcaa8aSmrgkeyboard state, it typically maintains a local copy of the portion of the
206e9fcaa8aSmrgserver keyboard description dealing with the items of interest and updates this
207e9fcaa8aSmrglocal copy from events describing state transitions that are sent by the server.
208e9fcaa8aSmrg</para>
209e9fcaa8aSmrg
210e9fcaa8aSmrg<para>
211e9fcaa8aSmrgA client may request the server to reconfigure the keyboard either by sending
212e9fcaa8aSmrgexplicit reconfiguration instructions to it, or by telling it to load a new
213e9fcaa8aSmrgconfiguration from its database of named components. Partial reconfiguration
214e9fcaa8aSmrgand incremental reconfiguration are both supported.
215e9fcaa8aSmrg</para>
216e9fcaa8aSmrg
217e9fcaa8aSmrg<sect2 id='groups_and_shift_levels'>
218e9fcaa8aSmrg<title>Groups and Shift Levels</title>
219e9fcaa8aSmrg
220e9fcaa8aSmrg<para>
221e9fcaa8aSmrgThe graphic characters or control functions that may be accessed by one key are
222e9fcaa8aSmrglogically arranged in groups and levels. See section 14.1for a complete
223e9fcaa8aSmrgdescription of groups and levels.
224e9fcaa8aSmrg</para>
225e9fcaa8aSmrg
226e9fcaa8aSmrg
227e9fcaa8aSmrg</sect2>
228e9fcaa8aSmrg<sect2 id='radio_groups'>
229e9fcaa8aSmrg<title>Radio Groups</title>
230e9fcaa8aSmrg
231e9fcaa8aSmrg<para>
232e9fcaa8aSmrgA radio group is a set of keys whose behavior simulates a set of radio buttons.
233e9fcaa8aSmrgOnce a key in a radio group is pressed, it stays logically depressed until
234e9fcaa8aSmrganother key in the group is pressed, at which point the previously depressed
235e9fcaa8aSmrgkey is logically released. Consequently, at most one key in a radio group can
236e9fcaa8aSmrgbe logically depressed at one time. A radio group is defined by a radio group
237e9fcaa8aSmrgindex, an optional name, and by assigning each key in the radio group <emphasis>
238e9fcaa8aSmrgXkbKB_RadioGroup</emphasis>
239e9fcaa8aSmrg behavior and the radio group index.
240e9fcaa8aSmrg</para>
241e9fcaa8aSmrg
242e9fcaa8aSmrg</sect2>
243e9fcaa8aSmrg</sect1>
244e9fcaa8aSmrg
245e9fcaa8aSmrg<sect1 id='client_types'>
246e9fcaa8aSmrg<title>Client Types</title>
247e9fcaa8aSmrg
248e9fcaa8aSmrg<para>
249e9fcaa8aSmrgThis specification differentiates between three different classes of client
250e9fcaa8aSmrgapplications:
251e9fcaa8aSmrg</para>
252e9fcaa8aSmrg
253e9fcaa8aSmrg<itemizedlist>
254e9fcaa8aSmrg  <listitem>
255e9fcaa8aSmrg    <para>
256e9fcaa8aSmrgXkb-aware applications
257e9fcaa8aSmrg    </para>
258e9fcaa8aSmrg    <para>
259e9fcaa8aSmrgThese applications make specific use of Xkb functionality and APIs not present
260e9fcaa8aSmrgin the core protocol.
261e9fcaa8aSmrg    </para>
262e9fcaa8aSmrg  </listitem>
263e9fcaa8aSmrg  <listitem>
264e9fcaa8aSmrg    <para>
265e9fcaa8aSmrgXkb-capable applications
266e9fcaa8aSmrg    </para>
267e9fcaa8aSmrg    <para>
268e9fcaa8aSmrgThese applications make no use of Xkb extended functionality and Application
269e9fcaa8aSmrgProgramming Interfaces (APIs) directly. However, they are linked with a version
270e9fcaa8aSmrgof Xlib that includes Xkb and indirectly benefit from some of Xkb’s
271e9fcaa8aSmrgfeatures.
272e9fcaa8aSmrg    </para>
273e9fcaa8aSmrg  </listitem>
274e9fcaa8aSmrg  <listitem>
275e9fcaa8aSmrg    <para>
276e9fcaa8aSmrgXkb-unaware applications
277e9fcaa8aSmrg    </para>
278e9fcaa8aSmrg    <para>
279e9fcaa8aSmrgThese applications make no use of Xkb extended functionality or APIs and
280e9fcaa8aSmrgrequire Xkb’s functionality to be mapped to core Xlib functionality to
281e9fcaa8aSmrgoperate properly.
282e9fcaa8aSmrg    </para>
283e9fcaa8aSmrg  </listitem>
284e9fcaa8aSmrg</itemizedlist>
285e9fcaa8aSmrg
286e9fcaa8aSmrg</sect1>
287e9fcaa8aSmrg
288e9fcaa8aSmrg<sect1 id='compatibility_with_the_core_protocol'>
289e9fcaa8aSmrg<title>Compatibility With the Core Protocol</title>
290e9fcaa8aSmrg
291e9fcaa8aSmrg<para>
292e9fcaa8aSmrgBecause the Xkb extension allows a keyboard to be configured in ways not
293e9fcaa8aSmrgforeseen by the core protocol, and because Xkb-unaware clients are allowed to
294e9fcaa8aSmrgconnect to a server using the Xkb extension, there must be a means of
295e9fcaa8aSmrgconverting between the Xkb domain and the core protocol. The Xkb server
296e9fcaa8aSmrgextension maintains a compatibility map as part of its keyboard description;
297e9fcaa8aSmrgthis map controls the conversion of Xkb generated events to core protocol
298e9fcaa8aSmrgevents and the results of core protocol requests to appropriate Xkb state and
299e9fcaa8aSmrgconfiguration.
300e9fcaa8aSmrg</para>
301e9fcaa8aSmrg
302e9fcaa8aSmrg
303e9fcaa8aSmrg</sect1>
304e9fcaa8aSmrg<sect1 id='additional_protocol_errors'>
305e9fcaa8aSmrg<title>Additional Protocol Errors</title>
306e9fcaa8aSmrg
307e9fcaa8aSmrg<para>
308e9fcaa8aSmrgThe Xkb extension adds a single protocol error, <emphasis>
309e9fcaa8aSmrgBadKeyboard</emphasis>
310e9fcaa8aSmrg, to the core protocol error set. See section 2.6 for a discussion of the  <!-- xref -->
311e9fcaa8aSmrg<emphasis>
312e9fcaa8aSmrgBadKeyboard</emphasis>
313e9fcaa8aSmrg protocol error.
314e9fcaa8aSmrg</para>
315e9fcaa8aSmrg
316e9fcaa8aSmrg
317e9fcaa8aSmrg</sect1>
318e9fcaa8aSmrg<sect1 id='extension_library_functions'>
319e9fcaa8aSmrg<title>Extension Library Functions</title>
320e9fcaa8aSmrg
321e9fcaa8aSmrg<para>
322e9fcaa8aSmrgThe X Keyboard Extension replaces the core protocol definition of a keyboard
323e9fcaa8aSmrgwith a more comprehensive one. The X Keyboard Extension library interfaces are
324e9fcaa8aSmrgincluded in Xlib.<footnote><para>
325e9fcaa8aSmrgX11R6.1 is the first release by the X Consortium, Inc.,that includes the X
326e9fcaa8aSmrgKeyboard Extension in Xlib. X11R6 included work in progress on this extension
327e9fcaa8aSmrgas nonstandard additions to the library.
328e9fcaa8aSmrg</para>
329e9fcaa8aSmrg</footnote>
330e9fcaa8aSmrg</para>
331e9fcaa8aSmrg
332e9fcaa8aSmrg<para>
333e9fcaa8aSmrgXlib detects the presence of the X Keyboard server extension and uses Xkb
334e9fcaa8aSmrgprotocol to replace some standard X library functions related to the keyboard.
335e9fcaa8aSmrgIf an application uses only standard X library functions to examine the
336e9fcaa8aSmrgkeyboard or process key events, it should not need to be modified when linked
337e9fcaa8aSmrgwith an X library containing the X keyboard extension. All of the
338e9fcaa8aSmrgkeyboard-related X library functions have been modified to automatically use
339e9fcaa8aSmrgXkb protocol when the server extension is present.
340e9fcaa8aSmrg</para>
341e9fcaa8aSmrg
342e9fcaa8aSmrg<para>
343e9fcaa8aSmrgThe Xkb extension adds library interfaces to allow a client application to
344e9fcaa8aSmrgdirectly manipulate the new capabilities.
345e9fcaa8aSmrg</para>
346e9fcaa8aSmrg
347e9fcaa8aSmrg
348e9fcaa8aSmrg<sect2 id='error_indications'>
349e9fcaa8aSmrg<title>Error Indications</title>
350e9fcaa8aSmrg
351e9fcaa8aSmrg<para>
352e9fcaa8aSmrgXkb functions that communicate with the X server check to be sure the Xkb
353e9fcaa8aSmrgextension has been properly initialized prior to doing any other operations. If
354e9fcaa8aSmrgthe extension has not been properly initialized or the application, library,
355e9fcaa8aSmrgand server versions are incompatible, these functions return an error
356e9fcaa8aSmrgindication as shown in Table 1.1. Because of this test, <emphasis>
357e9fcaa8aSmrgBadAccess</emphasis>
358e9fcaa8aSmrg and <emphasis>
359e9fcaa8aSmrgBadMatch</emphasis>
360e9fcaa8aSmrg (due to incompatible versions) protocol errors should normally not be
361e9fcaa8aSmrggenerated.
362e9fcaa8aSmrg</para>
363e9fcaa8aSmrg
364e9fcaa8aSmrg<table frame='none'>
365e9fcaa8aSmrg<!-- <caption>Function Error Returns Due to Extension Problems</caption> -->
366e9fcaa8aSmrg<title>Function Error Returns Due to Extension Problems</title>
367e9fcaa8aSmrg<tgroup cols='2'>
368e9fcaa8aSmrg<colspec align="left" colsep="0"/>
369e9fcaa8aSmrg<colspec align="left" colsep="0"/>
370e9fcaa8aSmrg<thead>
371e9fcaa8aSmrg  <row>
372e9fcaa8aSmrg    <entry>Functions return type</entry>
373e9fcaa8aSmrg    <entry>Return value</entry>
374e9fcaa8aSmrg  </row>
375e9fcaa8aSmrg</thead>
376e9fcaa8aSmrg<tbody>
377e9fcaa8aSmrg  <row rowsep='0'>
378e9fcaa8aSmrg    <entry>pointer to a structure</entry>
379e9fcaa8aSmrg    <entry>NULL</entry>
380e9fcaa8aSmrg  </row>
381e9fcaa8aSmrg  <row rowsep='0'>
382e9fcaa8aSmrg    <entry>Bool</entry>
383e9fcaa8aSmrg    <entry>False</entry>
384e9fcaa8aSmrg  </row>
385e9fcaa8aSmrg  <row rowsep='0'>
386e9fcaa8aSmrg    <entry>Status</entry>
387e9fcaa8aSmrg    <entry>BadAccess</entry>
388e9fcaa8aSmrg  </row>
389e9fcaa8aSmrg</tbody>
390e9fcaa8aSmrg</tgroup>
391e9fcaa8aSmrg</table>
392e9fcaa8aSmrg
393e9fcaa8aSmrg<para>
394e9fcaa8aSmrgMany Xkb functions do not actually communicate with the X server; they only
395e9fcaa8aSmrgrequire processing in the client-side portion of the library. Furthermore, some
396e9fcaa8aSmrgapplications may never actually need to communicate with the server; they
397e9fcaa8aSmrgsimply use the Xkb library capabilities. The functions that do not communicate
398e9fcaa8aSmrgwith the server return either a pointer to a structure, a Bool, or a Status.
399e9fcaa8aSmrgThese functions check that the application has queried the Xkb library version
400e9fcaa8aSmrgand return the values shown in Table 1.1 if it has not.
401e9fcaa8aSmrg</para>
402e9fcaa8aSmrg</sect2>
403e9fcaa8aSmrg</sect1>
404e9fcaa8aSmrg</chapter>
405