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