summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Dew <matt@osource.org>2010-11-30 10:52:07 -0500
committerGaetan Nadon <memsize@videotron.ca>2010-11-30 10:52:55 -0500
commit8f8a3c8c42af82976d261ac2447cfbb0f90fa77d (patch)
tree04cd2bc4ede9edad76c718ba12bf7579cc6ac487
parentc8701115462b482d99ecff24d9de0f2806084ba5 (diff)
specs: convert XKBlib spec from Framemaker to DocBook.xml
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
-rw-r--r--configure.ac1
-rw-r--r--specs/Makefile.am2
-rw-r--r--specs/XKB/Makefile.am57
-rw-r--r--specs/XKB/XKBlib-1.gifbin0 -> 9516 bytes
-rw-r--r--specs/XKB/XKBlib-10.gifbin0 -> 17282 bytes
-rw-r--r--specs/XKB/XKBlib-11.gifbin0 -> 15367 bytes
-rw-r--r--specs/XKB/XKBlib-12.gifbin0 -> 9737 bytes
-rw-r--r--specs/XKB/XKBlib-13.gifbin0 -> 3213 bytes
-rw-r--r--specs/XKB/XKBlib-14.gifbin0 -> 4064 bytes
-rw-r--r--specs/XKB/XKBlib-15.gifbin0 -> 12927 bytes
-rw-r--r--specs/XKB/XKBlib-16.gifbin0 -> 8353 bytes
-rw-r--r--specs/XKB/XKBlib-17.gifbin0 -> 8538 bytes
-rw-r--r--specs/XKB/XKBlib-18.gifbin0 -> 9947 bytes
-rw-r--r--specs/XKB/XKBlib-19.gifbin0 -> 8811 bytes
-rw-r--r--specs/XKB/XKBlib-2.gifbin0 -> 12039 bytes
-rw-r--r--specs/XKB/XKBlib-20.gifbin0 -> 5503 bytes
-rw-r--r--specs/XKB/XKBlib-21.gifbin0 -> 14481 bytes
-rw-r--r--specs/XKB/XKBlib-3.gifbin0 -> 1778 bytes
-rw-r--r--specs/XKB/XKBlib-4.gifbin0 -> 1435 bytes
-rw-r--r--specs/XKB/XKBlib-5.gifbin0 -> 1274 bytes
-rw-r--r--specs/XKB/XKBlib-6.gifbin0 -> 7001 bytes
-rw-r--r--specs/XKB/XKBlib-7.gifbin0 -> 3169 bytes
-rw-r--r--specs/XKB/XKBlib-8.gifbin0 -> 4935 bytes
-rw-r--r--specs/XKB/XKBlib-9.gifbin0 -> 4600 bytes
-rw-r--r--specs/XKB/acknowledgement.xml35
-rw-r--r--specs/XKB/ch01.xml404
-rw-r--r--specs/XKB/ch02.xml818
-rw-r--r--specs/XKB/ch03.xml247
-rw-r--r--specs/XKB/ch04.xml825
-rw-r--r--specs/XKB/ch05.xml977
-rw-r--r--specs/XKB/ch06.xml413
-rw-r--r--specs/XKB/ch07.xml446
-rw-r--r--specs/XKB/ch08.xml2087
-rw-r--r--specs/XKB/ch09.xml1060
-rw-r--r--specs/XKB/ch10.xml5347
-rw-r--r--specs/XKB/ch11.xml572
-rw-r--r--specs/XKB/ch12.xml841
-rw-r--r--specs/XKB/ch13.xml4146
-rw-r--r--specs/XKB/ch14.xml1637
-rw-r--r--specs/XKB/ch15.xml2600
-rw-r--r--specs/XKB/ch16.xml4794
-rw-r--r--specs/XKB/ch17.xml1789
-rw-r--r--specs/XKB/ch18.xml1182
-rw-r--r--specs/XKB/ch19.xml328
-rw-r--r--specs/XKB/ch20.xml1188
-rw-r--r--specs/XKB/ch21.xml2043
-rw-r--r--specs/XKB/ch22.xml216
-rw-r--r--specs/XKB/glossary.xml1016
-rw-r--r--specs/XKB/xkblib.xml103
49 files changed, 35173 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 59304588..40d032dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -469,6 +469,7 @@ AC_OUTPUT([Makefile
specs/i18n/trans/Makefile
specs/libX11/Makefile
specs/XIM/Makefile
+ specs/XKB/Makefile
x11.pc
x11-xcb.pc])
diff --git a/specs/Makefile.am b/specs/Makefile.am
index 9146ebbd..6d49014a 100644
--- a/specs/Makefile.am
+++ b/specs/Makefile.am
@@ -21,4 +21,4 @@
# DEALINGS IN THE SOFTWARE.
#
-SUBDIRS=libX11 i18n XIM
+SUBDIRS=libX11 i18n XIM XKB
diff --git a/specs/XKB/Makefile.am b/specs/XKB/Makefile.am
new file mode 100644
index 00000000..97e554d7
--- /dev/null
+++ b/specs/XKB/Makefile.am
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+if ENABLE_SPECS
+
+specdir = $(docdir)/$(subdir)
+doc_sources = xkblib.xml
+dist_spec_DATA = \
+ $(doc_sources) \
+ acknowledgement.xml \
+ ch01.xml \
+ ch02.xml \
+ ch03.xml \
+ ch04.xml \
+ ch05.xml \
+ ch06.xml \
+ ch07.xml \
+ ch08.xml \
+ ch09.xml \
+ ch10.xml \
+ ch11.xml \
+ ch12.xml \
+ ch13.xml \
+ ch14.xml \
+ ch15.xml \
+ ch16.xml \
+ ch17.xml \
+ ch18.xml \
+ ch19.xml \
+ ch20.xml \
+ ch21.xml \
+ ch22.xml \
+ glossary.xml
+
+include $(top_srcdir)/specs/xmlrules.in
+
+endif ENABLE_SPECS
diff --git a/specs/XKB/XKBlib-1.gif b/specs/XKB/XKBlib-1.gif
new file mode 100644
index 00000000..2e3725df
--- /dev/null
+++ b/specs/XKB/XKBlib-1.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-10.gif b/specs/XKB/XKBlib-10.gif
new file mode 100644
index 00000000..cb9d84b0
--- /dev/null
+++ b/specs/XKB/XKBlib-10.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-11.gif b/specs/XKB/XKBlib-11.gif
new file mode 100644
index 00000000..b86772d2
--- /dev/null
+++ b/specs/XKB/XKBlib-11.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-12.gif b/specs/XKB/XKBlib-12.gif
new file mode 100644
index 00000000..74b1bff8
--- /dev/null
+++ b/specs/XKB/XKBlib-12.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-13.gif b/specs/XKB/XKBlib-13.gif
new file mode 100644
index 00000000..b385c305
--- /dev/null
+++ b/specs/XKB/XKBlib-13.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-14.gif b/specs/XKB/XKBlib-14.gif
new file mode 100644
index 00000000..439cd094
--- /dev/null
+++ b/specs/XKB/XKBlib-14.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-15.gif b/specs/XKB/XKBlib-15.gif
new file mode 100644
index 00000000..c88dcbfd
--- /dev/null
+++ b/specs/XKB/XKBlib-15.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-16.gif b/specs/XKB/XKBlib-16.gif
new file mode 100644
index 00000000..10a63555
--- /dev/null
+++ b/specs/XKB/XKBlib-16.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-17.gif b/specs/XKB/XKBlib-17.gif
new file mode 100644
index 00000000..28517578
--- /dev/null
+++ b/specs/XKB/XKBlib-17.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-18.gif b/specs/XKB/XKBlib-18.gif
new file mode 100644
index 00000000..93a761e2
--- /dev/null
+++ b/specs/XKB/XKBlib-18.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-19.gif b/specs/XKB/XKBlib-19.gif
new file mode 100644
index 00000000..4e7c7ddd
--- /dev/null
+++ b/specs/XKB/XKBlib-19.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-2.gif b/specs/XKB/XKBlib-2.gif
new file mode 100644
index 00000000..1f146b55
--- /dev/null
+++ b/specs/XKB/XKBlib-2.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-20.gif b/specs/XKB/XKBlib-20.gif
new file mode 100644
index 00000000..92764a26
--- /dev/null
+++ b/specs/XKB/XKBlib-20.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-21.gif b/specs/XKB/XKBlib-21.gif
new file mode 100644
index 00000000..6b27f53f
--- /dev/null
+++ b/specs/XKB/XKBlib-21.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-3.gif b/specs/XKB/XKBlib-3.gif
new file mode 100644
index 00000000..72d9ea59
--- /dev/null
+++ b/specs/XKB/XKBlib-3.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-4.gif b/specs/XKB/XKBlib-4.gif
new file mode 100644
index 00000000..a5b6d5e2
--- /dev/null
+++ b/specs/XKB/XKBlib-4.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-5.gif b/specs/XKB/XKBlib-5.gif
new file mode 100644
index 00000000..381076b3
--- /dev/null
+++ b/specs/XKB/XKBlib-5.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-6.gif b/specs/XKB/XKBlib-6.gif
new file mode 100644
index 00000000..8305a1be
--- /dev/null
+++ b/specs/XKB/XKBlib-6.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-7.gif b/specs/XKB/XKBlib-7.gif
new file mode 100644
index 00000000..75540ee8
--- /dev/null
+++ b/specs/XKB/XKBlib-7.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-8.gif b/specs/XKB/XKBlib-8.gif
new file mode 100644
index 00000000..15236830
--- /dev/null
+++ b/specs/XKB/XKBlib-8.gif
Binary files differ
diff --git a/specs/XKB/XKBlib-9.gif b/specs/XKB/XKBlib-9.gif
new file mode 100644
index 00000000..af9f9316
--- /dev/null
+++ b/specs/XKB/XKBlib-9.gif
Binary files differ
diff --git a/specs/XKB/acknowledgement.xml b/specs/XKB/acknowledgement.xml
new file mode 100644
index 00000000..9bf80f48
--- /dev/null
+++ b/specs/XKB/acknowledgement.xml
@@ -0,0 +1,35 @@
+<chapter id='acknowledgement'>
+<title>Acknowledgement</title>
+<para>
+This document is the result of a great deal of hard work by a great
+many people. Without Erik Fortune’s work as Architect of the X
+Keyboard Extension and the longtime support of Silicon Graphics
+Inc. there would not be a keyboard extension.
+</para>
+<para>
+We gratefully thank Will Walker and George Sachs for their help and
+expertise in providing some of the content for this document, and
+Digital Equipment Corporation and Hewlett-Packard for allowing them
+to participate in this project, and we are deeply indebted to IBM for
+providing the funding to complete this library specification.
+</para>
+<para>
+Most of all, we thank Gary Aitken and Amber J. Benson for their long
+hours and late nights as ultimate authors of this specification, and
+for serving as authors, document editors, and XKB protocol and
+implementation reviewers. Their commitment to accuracy and completeness,
+their attention to detail, their keen insight, and their good natures
+when working under tremendous pressure are in some measure responsible
+not only for the quality of this document, but for the quality of the
+Keyboard extension itself.
+</para>
+<para>
+Matt Landau
+</para>
+<para>
+Manager, X Window System
+</para>
+<para>
+X Consortium Inc.
+</para>
+</chapter>
diff --git a/specs/XKB/ch01.xml b/specs/XKB/ch01.xml
new file mode 100644
index 00000000..406f7490
--- /dev/null
+++ b/specs/XKB/ch01.xml
@@ -0,0 +1,404 @@
+<chapter id='overview'>
+<title>Overview</title>
+
+<para>
+The X Keyboard Extension provides capabilities that are lacking or are
+cumbersome in the core X protocol.
+</para>
+
+<sect1 id='core_x_protocol_support_for_keyboards'>
+<title>Core X Protocol Support for Keyboards</title>
+
+<para>
+The core X protocol specifies the ways that the
+<emphasis>Shift</emphasis>,
+<emphasis>Control</emphasis>, and
+<emphasis>Lock</emphasis>
+modifiers and the modifiers bound to the
+<emphasis>Mode_switch</emphasis> or
+<emphasis>Num_Lock</emphasis>
+keysyms interact to generate keysyms and characters. The core protocol also
+allows users to specify that a key affects one or more modifiers. This behavior
+is simple and fairly flexible, but it has a number of limitations that make it
+difficult or impossible to properly support many common varieties of keyboard
+behavior. The limitations of core protocol support for keyboards include:
+</para>
+
+<itemizedlist>
+ <listitem>
+ <para>
+Use of a single, uniform, four-symbol mapping for all keyboard keys makes it
+difficult to properly support keyboard overlays, PC-style break keys, or
+keyboards that comply with ISO9995, or a host of other national and
+international standards.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A second keyboard group may be specified using a modifier, but this has side
+effects that wreak havoc with client grabs and X toolkit translations.
+Furthermore, this approach limits the number of keyboard groups to two.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Poorly specified locking key behavior requires X servers to look for a few
+"magic" keysyms to determine that keys should lock when pressed. This leads to
+incompatibilities between X servers with no way for clients to detect
+implementation differences.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Poorly specified capitalization and control behavior requires modifications to
+X library source code to support new character sets or locales and can lead to
+incompatibilities between system wide and X library capitalization behavior.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Limited interactions between modifiers specified by the core protocol make many
+common keyboard behaviors difficult or impossible to implement. For example,
+there is no reliable way to indicate whether or not the shift modifier should
+"cancel" the lock modifier.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+The lack of any explicit descriptions for indicators, most modifiers, and other
+aspects of the keyboard appearance requires clients that wish to clearly
+describe the keyboard to a user to resort to a mish-mash of prior knowledge and
+heuristics.
+ </para>
+ </listitem>
+</itemizedlist>
+
+</sect1>
+<sect1 id='xkb_keyboard_extension_support_for_keyboards'>
+<title>Xkb Keyboard Extension Support for Keyboards</title>
+
+<para>
+The X Keyboard Extension makes it possible to clearly and explicitly specify
+most aspects of keyboard behavior on a per-key basis. It adds the notion of a
+keyboard group to the global keyboard state and provides mechanisms to more
+closely track the logical and physical state of the keyboard. For
+keyboard-control clients, Xkb provides descriptions and symbolic names for many
+aspects of keyboard appearance and behavior.
+</para>
+
+<para>
+In addition, the X Keyboard Extension includes additional keyboard controls
+designed to make keyboards more accessible to people with movement impairments.
+</para>
+
+</sect1>
+
+<sect1 id='xkb_extension_components'>
+<title>Xkb Extension Components</title>
+
+<para>
+The Xkb extension is composed of two parts: a server extension, and a
+client-side X library extension. These consist of a loadable module that may be
+activated when an X server is started and a modified version of Xlib. Both
+server and Xlib versions must be at least X11 R6.
+</para>
+
+
+<para>
+Figure 1.1 shows the overall structure of the Xkb extension:
+</para>
+
+<mediaobject>
+ <imageobject>
+ <imagedata fileref="XKBlib-1.gif"/>
+ </imageobject>
+ <caption>Overall Xkb Structure</caption>
+</mediaobject>
+
+
+<para>
+The server portion of the Xkb extension encompasses a database of named
+keyboard components, in unspecified format, that may be used to configure a
+keyboard. Internally, the server maintains a <emphasis>
+keyboard description</emphasis>
+ that includes the keyboard state and configuration (mapping). By "keyboard" we
+mean the logical keyboard device, which includes not only the physical keys,
+but also potentially a set of up to 32 indicators (usually LEDs) and bells.
+</para>
+
+
+<para>
+The keyboard description is a composite of several different data structures,
+each of which may be manipulated separately. When manipulating the server
+components, the design allows partial components to be transmitted between the
+server and a client. The individual components are shown in Figure 1.1.
+</para>
+
+<variablelist>
+ <varlistentry>
+ <term>Client Map</term>
+ <listitem>
+ <para>
+The key mapping information needed to convert arbitrary keycodes to symbols.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Server Map</term>
+ <listitem>
+ <para>
+The key mapping information categorizing keys by functionality (which keys are
+modifiers, how keys behave, and so on).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Controls</term>
+ <listitem>
+ <para>
+Client configurable quantities effecting how the keyboard behaves, such as
+repeat behavior and modifications for people with movement impairments.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Indicators</term>
+ <listitem>
+ <para>
+The mapping of behavior to indicators.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Geometry</term>
+ <listitem>
+ <para>
+A complete description of the physical keyboard layout, sufficient to draw a
+representation of the keyboard.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Names</term>
+ <listitem>
+ <para>
+A mapping of names to various aspects of the keyboard such as individual
+virtual modifiers, indicators, and bells.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Compatibility Map</term>
+ <listitem>
+ <para>
+The definition of how to map core protocol keyboard state to Xkb keyboard state.
+ </para>
+ </listitem>
+ </varlistentry>
+</variablelist>
+
+<para>
+A client application interrogates and manipulates the keyboard by reading and
+writing portions of the server description for the keyboard. In a typical
+sequence a client would fetch the current information it is interested in,
+modify it, and write it back. If a client wishes to track some portion of the
+keyboard state, it typically maintains a local copy of the portion of the
+server keyboard description dealing with the items of interest and updates this
+local copy from events describing state transitions that are sent by the server.
+</para>
+
+<para>
+A client may request the server to reconfigure the keyboard either by sending
+explicit reconfiguration instructions to it, or by telling it to load a new
+configuration from its database of named components. Partial reconfiguration
+and incremental reconfiguration are both supported.
+</para>
+
+<sect2 id='groups_and_shift_levels'>
+<title>Groups and Shift Levels</title>
+
+<para>
+The graphic characters or control functions that may be accessed by one key are
+logically arranged in groups and levels. See section 14.1for a complete
+description of groups and levels.
+</para>
+
+
+</sect2>
+<sect2 id='radio_groups'>
+<title>Radio Groups</title>
+
+<para>
+A radio group is a set of keys whose behavior simulates a set of radio buttons.
+Once a key in a radio group is pressed, it stays logically depressed until
+another key in the group is pressed, at which point the previously depressed
+key is logically released. Consequently, at most one key in a radio group can
+be logically depressed at one time. A radio group is defined by a radio group
+index, an optional name, and by assigning each key in the radio group <emphasis>
+XkbKB_RadioGroup</emphasis>
+ behavior and the radio group index.
+</para>
+
+</sect2>
+</sect1>
+
+<sect1 id='client_types'>
+<title>Client Types</title>
+
+<para>
+This specification differentiates between three different classes of client
+applications:
+</para>
+
+<itemizedlist>
+ <listitem>
+ <para>
+Xkb-aware applications
+ </para>
+ <para>
+These applications make specific use of Xkb functionality and APIs not present
+in the core protocol.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Xkb-capable applications
+ </para>
+ <para>
+These applications make no use of Xkb extended functionality and Application
+Programming Interfaces (APIs) directly. However, they are linked with a version
+of Xlib that includes Xkb and indirectly benefit from some of Xkb’s
+features.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Xkb-unaware applications
+ </para>
+ <para>
+These applications make no use of Xkb extended functionality or APIs and
+require Xkb’s functionality to be mapped to core Xlib functionality to
+operate properly.
+ </para>
+ </listitem>
+</itemizedlist>
+
+</sect1>
+
+<sect1 id='compatibility_with_the_core_protocol'>
+<title>Compatibility With the Core Protocol</title>
+
+<para>
+Because the Xkb extension allows a keyboard to be configured in ways not
+foreseen by the core protocol, and because Xkb-unaware clients are allowed to
+connect to a server using the Xkb extension, there must be a means of
+converting between the Xkb domain and the core protocol. The Xkb server
+extension maintains a compatibility map as part of its keyboard description;
+this map controls the conversion of Xkb generated events to core protocol
+events and the results of core protocol requests to appropriate Xkb state and
+configuration.
+</para>
+
+
+</sect1>
+<sect1 id='additional_protocol_errors'>
+<title>Additional Protocol Errors</title>
+
+<para>
+The Xkb extension adds a single protocol error, <emphasis>
+BadKeyboard</emphasis>
+, to the core protocol error set. See section 2.6 for a discussion of the <!-- xref -->
+<emphasis>
+BadKeyboard</emphasis>
+ protocol error.
+</para>
+
+
+</sect1>
+<sect1 id='extension_library_functions'>
+<title>Extension Library Functions</title>
+
+<para>
+The X Keyboard Extension replaces the core protocol definition of a keyboard
+with a more comprehensive one. The X Keyboard Extension library interfaces are
+included in Xlib.<footnote><para>
+X11R6.1 is the first release by the X Consortium, Inc.,that includes the X
+Keyboard Extension in Xlib. X11R6 included work in progress on this extension
+as nonstandard additions to the library.
+</para>
+</footnote>
+</para>
+
+<para>
+Xlib detects the presence of the X Keyboard server extension and uses Xkb
+protocol to replace some standard X library functions related to the keyboard.
+If an application uses only standard X library functions to examine the
+keyboard or process key events, it should not need to be modified when linked
+with an X library containing the X keyboard extension. All of the
+keyboard-related X library functions have been modified to automatically use
+Xkb protocol when the server extension is present.
+</para>
+
+<para>
+The Xkb extension adds library interfaces to allow a client application to
+directly manipulate the new capabilities.
+</para>
+
+
+<sect2 id='error_indications'>
+<title>Error Indications</title>
+
+<para>
+Xkb functions that communicate with the X server check to be sure the Xkb
+extension has been properly initialized prior to doing any other operations. If
+the extension has not been properly initialized or the application, library,
+and server versions are incompatible, these functions return an error
+indication as shown in Table 1.1. Because of this test, <emphasis>
+BadAccess</emphasis>
+ and <emphasis>
+BadMatch</emphasis>
+ (due to incompatible versions) protocol errors should normally not be
+generated.
+</para>
+
+<table frame='none'>
+<!-- <caption>Function Error Returns Due to Extension Problems</caption> -->
+<title>Function Error Returns Due to Extension Problems</title>
+<tgroup cols='2'>
+<colspec align="left" colsep="0"/>
+<colspec align="left" colsep="0"/>
+<thead>
+ <row>
+ <entry>Functions return type</entry>
+ <entry>Return value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>pointer to a structure</entry>
+ <entry>NULL</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Bool</entry>
+ <entry>False</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Status</entry>
+ <entry>BadAccess</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Many Xkb functions do not actually communicate with the X server; they only
+require processing in the client-side portion of the library. Furthermore, some
+applications may never actually need to communicate with the server; they
+simply use the Xkb library capabilities. The functions that do not communicate
+with the server return either a pointer to a structure, a Bool, or a Status.
+These functions check that the application has queried the Xkb library version
+and return the values shown in Table 1.1 if it has not.
+</para>
+</sect2>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch02.xml b/specs/XKB/ch02.xml
new file mode 100644
index 00000000..55f15a32
--- /dev/null
+++ b/specs/XKB/ch02.xml
@@ -0,0 +1,818 @@
+<chapter id='initialization_and_general_programming_information'>
+<title>Initialization and General Programming Information</title>
+<sect1 id='extension_header_files'>
+<title>Extension Header Files</title>
+<para>
+The following include files are part of the Xkb standard:
+</para>
+<itemizedlist>
+ <listitem>
+ <para>
+<emphasis>&lt;X11/XKBlib.h&gt;</emphasis>
+ </para>
+ <para><emphasis>XKBlib.h</emphasis>
+is the main header file for Xkb; it declares constants, types, and
+functions.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+<emphasis>&lt;X11/extensions/XKBstr.h&gt;</emphasis>
+ </para>
+ <para>
+<emphasis>XKBstr.h</emphasis> declares types and
+constants for Xkb. It is included automatically from
+<emphasis>&lt;X11/XKBlib.h&gt;</emphasis>
+; you should never need to reference it directly in your application code.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+<emphasis>&lt;X11/extensions/XKB.h&gt;</emphasis>
+ </para>
+ <para>
+<emphasis>XKB.h</emphasis>
+defines constants for Xkb. It is included automatically from <emphasis>
+&lt;X11/XKBstr.h&gt;</emphasis>
+; you should never need to reference it directly in your application code.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+<emphasis>&lt;X11/extensions/XKBgeom.h&gt;</emphasis>
+ </para>
+ <para><emphasis>XKBgeom.h</emphasis>
+declares types, symbolic constants, and functions for manipulating
+keyboard geometry descriptions.
+ </para>
+ </listitem>
+</itemizedlist>
+</sect1>
+<sect1 id='extension_name'>
+<title>Extension Name</title>
+<para>
+The name of the Xkb extension is given in <emphasis>
+&lt;X11/extensions/Xkb.h&gt;:</emphasis>
+</para>
+
+<para>
+<emphasis>
+#define XkbName "XKEYBOARD"</emphasis>
+</para>
+
+<para>
+Most extensions to the X protocol are initialized by calling <emphasis>
+XInitExtension</emphasis>
+ and passing the extension name. However, as explained in section 2.4, Xkb
+requires a more complex initialization sequence, and a client program should
+not call <emphasis>
+XInitExtension</emphasis>
+ directly.
+</para>
+</sect1>
+<sect1 id='determining_library_compatibility'>
+<title>Determining Library Compatibility</title>
+<para>
+If an application is dynamically linked, both the X server and the client-side
+X library must contain the Xkb extension in order for the client to use the Xkb
+extension capabilities. Therefore a dynamically linked application must check
+both the library and the server for compatibility before using Xkb function
+calls. A properly written program must check for compatibility between the
+version of the Xkb library that is dynamically loaded and the one used when the
+application was built. It must then check the server version for compatibility
+with the version of Xkb in the library.
+</para>
+<para>
+If your application is statically linked, you must still check for server
+compatibility and may check library compatibility. (It is possible to compile
+against one set of header files and link against a different, incompatible,
+version of the library, although this should not normally occur.)
+</para>
+<para>
+To determine the compatibility of a library at runtime, call <emphasis>
+XkbLibraryVersion</emphasis>.
+</para>
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbLibraryVersion</emphasis>
+(<emphasis>
+lib_major_in_out</emphasis>
+, <emphasis>
+lib_minor_in_out</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+lib_major_in_out;</emphasis>
+ /* specifies and returns the major Xkb library version. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+lib_minor_in_out;</emphasis>
+ /* specifies and returns the minor Xkb library version. */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+Pass the symbolic value <emphasis>
+XkbMajorVersion</emphasis>
+ in <emphasis>
+lib_major_in_out</emphasis>
+ and <emphasis>
+XkbMinorVersion</emphasis>
+ in <emphasis>
+lib_minor_in_out</emphasis>
+. These arguments represent the version of the library used at compile time.
+The <emphasis>
+XkbLibraryVersion </emphasis>
+function backfills the major and minor version numbers of the library used at
+run time in <emphasis>
+lib_major_in_out</emphasis>
+ and <emphasis>
+lib_minor_in_out</emphasis>
+. If the versions of the compile time and run time libraries are compatible,
+<emphasis>
+XkbLibraryVersion </emphasis>
+returns <emphasis>
+True</emphasis>
+, otherwise, it returns <emphasis>
+False.</emphasis>
+</para>
+
+<para>
+In addition, in order to use the Xkb extension, you must ensure that the
+extension is present in the server and that the server supports the version of
+the extension expected by the client. Use <emphasis>
+XkbQueryExtension</emphasis>
+ to do this, as described in the next section.
+</para>
+
+</sect1>
+<sect1 id='initializing_the_keyboard_extension'>
+<title>Initializing the Keyboard Extension</title>
+<para>
+Call <emphasis>
+XkbQueryExtension</emphasis>
+ to check for the presence and compatibility of the extension in the server and
+to initialize the extension. Because of potential version mismatches, you
+cannot use the generic extension mechanism functions (<emphasis>
+XQueryExtension </emphasis>
+and<emphasis>
+ XInitExtension</emphasis>
+) for checking for the presence of, and initializing the Xkb extension.
+</para>
+
+<para>
+You must call <emphasis>
+XkbQueryExtension</emphasis>
+ or <emphasis>
+XkbOpenDisplay</emphasis>
+ before using any other Xkb library interfaces, unless such usage is explicitly
+allowed in the interface description in this document. The exceptions are:
+<emphasis>
+XkbIgnoreExtension</emphasis>
+, <emphasis>
+XkbLibraryVersion</emphasis>
+, and a handful of audible-bell functions. You should not use any other Xkb
+functions if the extension is not present or is uninitialized. In general,
+calls to Xkb library functions made prior to initializing the Xkb extension
+cause <emphasis>
+BadAccess</emphasis>
+ protocol errors.
+</para>
+
+<para>
+<emphasis>
+XkbQueryExtension</emphasis>
+ both determines whether a compatible Xkb extension is present in the X server
+and initializes the extension when it is present.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbQueryExtension</emphasis>
+(<emphasis>
+dpy, opcode_rtrn, event_rtrn, error_rtrn, major_in_out, minor_in_out</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy; </emphasis>
+ /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+opcode_rtrn</emphasis>
+; /* backfilled with the major extension opcode */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+event_rtrn</emphasis>
+; /* backfilled with the extension base event code */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+error_rtrn</emphasis>
+; /* backfilled with the extension base error code */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+major_in_out</emphasis>
+; /* compile time lib major version in, server major version out */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+minor_in_out; </emphasis>
+ /* compile time lib min version in, server minor version out */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+XkbQueryExtension</emphasis>
+ function determines whether a compatible version of the X Keyboard Extension
+is present in the server. If a compatible extension is present, <emphasis>
+XkbQueryExtension</emphasis>
+ returns <emphasis>
+True</emphasis>
+; otherwise, it returns <emphasis>
+False</emphasis>
+.
+</para>
+
+<para>
+If a compatible version of Xkb is present, <emphasis>
+XkbQueryExtension</emphasis>
+ initializes the extension. It backfills the major opcode for the keyboard
+extension in <emphasis>
+opcode_rtrn</emphasis>
+, the base event code in <emphasis>
+event_rtrn</emphasis>
+<emphasis>
+, the base error code</emphasis>
+ in <emphasis>
+error_rtrn</emphasis>
+, and the major and minor version numbers of the extension in <emphasis>
+major_in_out</emphasis>
+ and <emphasis>
+minor_in_out</emphasis>
+. The major opcode is reported in the <emphasis>
+req_major</emphasis>
+ fields of some Xkb events. For a discussion of the base event code, see
+section 4.1. <!-- xref -->
+</para>
+
+<para>
+As a convenience, you can use the function <emphasis>
+XkbOpenDisplay</emphasis>
+ to perform these three tasks at once: open a connection to an X server, check
+for a compatible version of the Xkb extension in both the library and the
+server, and initialize the extension for use.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Display *<emphasis>
+XkbOpenDisplay</emphasis>
+(<emphasis>
+display_name, event_rtrn, error_rtrn, major_in_out, minor_in_out,
+reason_rtrn)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+display_name</emphasis>
+; /* hardware display name, which determines the display and
+communications domain to be used */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+event_rtrn</emphasis>
+; /* backfilled with the extension base event code */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+error_rtrn</emphasis>
+; /* backfilled with the extension base error code */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+major_in_out</emphasis>
+; /* compile time lib major version in, server major version out */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+minor_in_out</emphasis>
+; /* compile time lib minor version in, server minor version out */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+reason_rtrn</emphasis>
+; /* backfilled with a status code */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbOpenDisplay </emphasis>
+is a convenience function that opens an X display connection and initializes
+the X keyboard extension. In all cases, upon return <emphasis>
+reason_rtrn</emphasis>
+ contains a status value indicating success or the type of failure. If
+<emphasis>
+major_in_out</emphasis>
+ and <emphasis>
+minor_in_out</emphasis>
+ are not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbOpenDisplay</emphasis>
+ first calls <emphasis>
+XkbLibraryVersion</emphasis>
+ to determine whether the client library is compatible, passing it the values
+pointed to by <emphasis>
+major_in_out</emphasis>
+ and <emphasis>
+minor_in_out</emphasis>
+. If the library is incompatible, <emphasis>
+XkbOpenDisplay</emphasis>
+ backfills <emphasis>
+major_in_out</emphasis>
+ and <emphasis>
+minor_in_out</emphasis>
+ with the major and minor extension versions of the library being used and
+returns <emphasis>
+NULL</emphasis>
+. If the library is compatible,<emphasis>
+ XkbOpenDisplay </emphasis>
+next calls <emphasis>
+XOpenDisplay</emphasis>
+ with the <emphasis>
+display_name</emphasis>
+. If this fails, the function returns <emphasis>
+NULL</emphasis>
+. If successful, <emphasis>
+XkbOpenDisplay </emphasis>
+calls <emphasis>
+XkbQueryExtension</emphasis>
+ and<emphasis>
+ </emphasis>
+backfills the major and minor Xkb server extension version numbers in <emphasis>
+major_in_out</emphasis>
+ and <emphasis>
+minor_in_out</emphasis>
+.<emphasis>
+ </emphasis>
+If the server extension version is not compatible with the library extension
+version or if the server extension is not present, <emphasis>
+XkbOpenDisplay </emphasis>
+closes the display and returns <emphasis>
+NULL</emphasis>
+. When successful, the function returns the display connection<emphasis>
+.</emphasis>
+</para>
+
+<para>
+The possible values for <emphasis>
+reason_rtrn</emphasis> are:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+<emphasis>
+XkbOD_BadLibraryVersion</emphasis>
+ indicates <emphasis>
+XkbLibraryVersion </emphasis>
+returned <emphasis>
+False</emphasis>.
+ </para>
+</listitem>
+<listitem>
+ <para>
+<emphasis>
+XkbOD_ConnectionRefused</emphasis>
+ indicates the display could not be opened.
+ </para>
+</listitem>
+<listitem>
+ <para>
+<emphasis>
+XkbOD_BadServerVersion</emphasis>
+ indicates the library and the server have incompatible extension versions.
+ </para>
+</listitem>
+<listitem>
+ <para>
+<emphasis>
+XkbOD_NonXkbServer</emphasis>
+ indicates the extension is not present in the X server.
+ </para>
+</listitem>
+<listitem>
+ <para>
+<emphasis>
+XkbOD_Success</emphasis>
+ indicates that the function succeeded.
+ </para>
+</listitem>
+</itemizedlist>
+</sect1>
+
+<sect1 id='disabling_the_keyboard_extension'>
+<title>Disabling the Keyboard Extension</title>
+<para>
+If a server supports the Xkb extension, the X library normally implements
+preXkb keyboard functions using the Xkb keyboard description and state. The
+server Xkb keyboard state may differ from the preXkb keyboard state. This
+difference does not affect most clients, but there are exceptions. To allow
+these clients to work properly, you may instruct the extension not to use Xkb
+functionality.
+</para>
+
+<para>
+Call <emphasis>
+XkbIgnoreExtension</emphasis>
+ to prevent core X library keyboard functions from using the X Keyboard
+Extension. You must call <emphasis>
+XkbIgnoreExtension</emphasis>
+ before you open a server connection; Xkb does not provide a way to enable or
+disable use of the extension once a connection is established.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool<emphasis>
+ XkbIgnoreExtension</emphasis>
+(<emphasis>
+ignore</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ignore</emphasis>
+; /* <emphasis>
+True</emphasis>
+ means ignore the extension */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbIgnoreExtension</emphasis>
+ tells the X library whether to use the X Keyboard Extension on any
+subsequently opened X display connections. If ignore is <emphasis>
+True</emphasis>
+, the library does not initialize the Xkb extension when it opens a new
+display. This forces the X server to use compatibility mode and communicate
+with the client using only core protocol requests and events. If ignore is
+<emphasis>
+False</emphasis>
+, the library treats subsequent calls to <emphasis>
+XOpenDisplay</emphasis>
+ normally and uses Xkb extension requests, events, and state. Do not explicitly
+use Xkb on a connection for which it is disabled.<emphasis>
+ XkbIgnoreExtension</emphasis>
+ returns <emphasis>
+False</emphasis>
+ if it was unable to apply the ignore request.
+</para>
+
+</sect1>
+<sect1 id='protocol_errors'>
+<title>Protocol Errors</title>
+<para>
+Many of the Xkb extension library functions described in this document can
+cause the X server to report an error, referred to in this document as a
+<emphasis>
+BadXxx</emphasis>
+ protocol error, where <emphasis>
+Xxx</emphasis>
+ is some name. These errors are fielded in the normal manner, by the default
+Xlib error handler or one replacing it. Note that X protocol errors are not
+necessarily reported immediately because of the buffering of X protocol
+requests in Xlib and the server.
+</para>
+
+<para>
+Table 2.1 lists the protocol errors that can be generated, and their causes. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>Xkb Protocol Errors</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+ <row rowsep='1'>
+ <entry>Error</entry>
+ <entry>Cause</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>BadAccess</entry>
+ <entry>
+<para>
+The Xkb extension has not been properly initialized
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadKeyboard</entry>
+ <entry>
+<para>
+The device specified was not a valid core or input extension device
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadImplementation</entry>
+ <entry>
+<para>
+Invalid reply from server
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadAlloc</entry>
+ <entry>
+<para>
+Unable to allocate storage
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadMatch</entry>
+ <entry>
+<para>
+A compatible version of Xkb was not available in the server or an argument has
+correct type and range, but is otherwise invalid
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadValue</entry>
+ <entry>
+<para>
+An argument is out of range
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadAtom</entry>
+ <entry>
+<para>
+A name is neither a valid Atom or <emphasis>
+None</emphasis>
+</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BadDevice</entry>
+ <entry>
+<para>
+Device, Feedback Class, or Feedback ID invalid
+</para>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The Xkb extension adds a single protocol error, <emphasis>
+BadKeyboard</emphasis>
+, to the core protocol error set. This error code will be reported as the
+<emphasis>
+error_rtrn</emphasis>
+ when <emphasis>
+XkbQueryExtension</emphasis>
+ is called. When a <emphasis>
+BadKeyboard</emphasis>
+ error is reported in an <emphasis>
+XErrorEvent</emphasis>
+, additional information is reported in the <emphasis>
+resource_id</emphasis>
+ field. The most significant byte of the <emphasis>
+resource_id</emphasis>
+ is a further refinement of the error cause, as defined in Table 2.2. The least
+significant byte will contain the device, class, or feedback ID as indicated in
+the table.
+</para>
+
+<table frame='none'>
+<title>BadKeyboard Protocol Error resource_id Values</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+ <row rowsep='0'>
+ <entry>high-order byte</entry>
+ <entry>value</entry>
+ <entry>meaning</entry>
+ <entry>low-order byte</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbErr_BadDevice</entry>
+ <entry>0xff</entry>
+ <entry>
+<para>
+device not found
+</para>
+ </entry>
+ <entry>device ID</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbErr_BadClass</entry>
+ <entry>0xfe</entry>
+ <entry>
+<para>
+device found, but it is of the wrong class
+</para>
+ </entry>
+ <entry>class ID</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbErr_BadId</entry>
+ <entry>0xfd</entry>
+ <entry>
+<para>
+device found, class ok, but device does not contain a feedback with the
+indicated ID
+</para>
+ </entry>
+ <entry>feedback ID</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+</sect1>
+
+<sect1 id='display_and_device_specifications_in_function_calls'>
+<title>Display and Device Specifications in Function Calls</title>
+<para>
+Where a connection to the server is passed as an argument (Display*) and an
+<emphasis>
+XkbDescPtr</emphasis>
+ is also passed as an argument, the Display* argument must match the <emphasis>
+dpy</emphasis>
+ field of the <emphasis>
+XkbDescRec</emphasis>
+ pointed to by the <emphasis>
+XkbDescPtr</emphasis>
+ argument, or else the <emphasis>
+dpy</emphasis>
+ field of the <emphasis>
+XkbDescRec</emphasis>
+ must be <emphasis>
+NULL</emphasis>
+. If they don’t match or the <emphasis>
+dpy</emphasis>
+ field is not <emphasis>
+NULL</emphasis>
+, a <emphasis>
+BadMatch</emphasis>
+ error is returned (either in the return value or a backfilled <emphasis>
+Status</emphasis>
+ variable). Upon successful return, the <emphasis>
+dpy</emphasis>
+ field of the <emphasis>
+XkbDescRec</emphasis>
+ always contains the Display* value passed in.
+</para>
+
+<para>
+The Xkb extension can communicate with the X input extension if it is present.
+Consequently, there can potentially be more than one input device connected to
+the server. Most Xkb library calls that require communicating with the server
+involve both a server connection (Display * <emphasis>
+dpy</emphasis>
+) and a device identifier (unsigned int <emphasis>
+device_spec</emphasis>
+). In some cases, the device identifier is implicit and is taken as the
+<emphasis>
+device_spec</emphasis>
+ field of an <emphasis>
+XkbDescRec</emphasis>
+ structure passed as an argument.
+</para>
+
+<para>
+The device identifier can specify any X input extension device with a <emphasis>
+KeyClass</emphasis>
+ component, or it can specify the constant, <emphasis>
+XkbUseCoreKbd</emphasis>
+. The use of <emphasis>
+XkbUseCoreKbd</emphasis>
+ allows applications to indicate the core keyboard without having to determine
+its device identifier.
+</para>
+
+<para>
+Where an Xkb device identifier is passed as an argument and an <emphasis>
+XkbDescPtr</emphasis>
+ is also passed as an argument, if either the argument or the <emphasis>
+XkbDescRec</emphasis>
+ <emphasis>
+device_spec</emphasis>
+ field is <emphasis>
+XkbUseCoreKbd</emphasis>
+, and if the function returns successfully, the <emphasis>
+XkbDescPtr</emphasis>
+ <emphasis>
+device_spec</emphasis>
+ field will have been converted from <emphasis>
+XkbUseCoreKbd</emphasis>
+ to a real Xkb device ID. If the function does not complete successfully, the
+<emphasis>
+device_spec</emphasis>
+ field remains unchanged. Subsequently, the device id argument must match the
+<emphasis>
+device_spec</emphasis>
+ field of the <emphasis>
+XkbDescPtr</emphasis>
+ argument. If they don’t match, a <emphasis>
+BadMatch</emphasis>
+ error is returned (either in the return value or a backfilled <emphasis>
+Status</emphasis>
+ variable).
+</para>
+
+<para>
+When the Xkb extension in the server hands an application a device identifier
+to use for the keyboard, that ID is the input extension identifier for the
+device if the server supports the X Input Extension. If the server does not
+support the input extension, the meaning of the identifier is undefined — the
+only guarantee is that when you use <emphasis>
+XkbUseCoreKbd</emphasis>
+, <emphasis>
+XkbUseCoreKbd</emphasis>
+ will work and the identifier returned by the server will refer to the core
+keyboard device.
+</para>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch03.xml b/specs/XKB/ch03.xml
new file mode 100644
index 00000000..5ea411c4
--- /dev/null
+++ b/specs/XKB/ch03.xml
@@ -0,0 +1,247 @@
+<chapter id='data_structures'>
+<title>Data Structures</title>
+
+<para>
+An Xkb keyboard description consists of a variety of data structures, each of
+which describes some aspect of the keyboard. Although each data structure has
+its own peculiarities, there are a number of features common to nearly all Xkb
+structures. This chapter describes these common features and techniques for
+manipulating them.
+</para>
+
+
+<para>
+Many Xkb data structures are interdependent; changing a field in one might
+require changes to others. As an additional complication, some Xkb library
+functions allocate related components as a group to reduce fragmentation and
+allocator overhead. In these cases, simply allocating and freeing fields of Xkb
+structures might corrupt program memory. Creating and destroying such
+structures or keeping them properly synchronized during editing is complicated
+and error prone.
+</para>
+
+
+<para>
+Xkb provides functions and macros to allocate and free all major data
+structures. You should use them instead of allocating and freeing the
+structures yourself.
+</para>
+
+<sect1 id='allocating_xkb_data_structures'>
+<title>Allocating Xkb Data Structures</title>
+
+<para>
+Xkb provides functions, known as allocators, to create and initialize Xkb data
+structures. In most situations, the Xkb functions that read a keyboard
+description from the server call these allocators automatically. As a result,
+you will seldom have to directly allocate or initialize Xkb data structures.
+</para>
+
+
+<para>
+However, if you need to enlarge an existing structure or construct a keyboard
+definition from scratch, you may need to allocate and initialize Xkb data
+structures directly. Each major Xkb data structure has its own unique
+allocator. The allocator functions share common features: allocator functions
+for structures with optional components take as an input argument a mask of
+subcomponents to be allocated. Allocators for data structures containing
+variable-length data take an argument specifying the initial length of the data.
+</para>
+
+
+<para>
+You may call an allocator to change the size of the space allocated for
+variable-length data. When you call an allocator with an existing data
+structure as a parameter, the allocator does not change the data in any of the
+fields, with one exception: variable-length data might be moved. The allocator
+resizes the allocated memory if the current size is too small. This normally
+involves allocating new memory, copying existing data to the newly allocated
+memory, and freeing the original memory. This possible reallocation is
+important to note because local variables pointing into Xkb data structures
+might be invalidated by calls to allocator functions.
+</para>
+
+</sect1>
+<sect1 id='adding_data_and_editing_data_structures'>
+<title>Adding Data and Editing Data Structures</title>
+
+<para>
+You should edit most data structures via the Xkb-supplied helper functions and
+macros, although a few data structures can be edited directly. The helper
+functions and macros make sure everything is initialized and interdependent
+values are properly updated for those Xkb structures that have
+interdependencies. As a general rule, if there is a helper function or macro to
+edit the data structure, use it. For example, increasing the width of a type
+requires you to resize every key that uses that type. This is complicated and
+ugly, which is why there’s an <emphasis>
+XkbResizeKeyType</emphasis>
+ function.
+</para>
+
+
+<para>
+Many Xkb data structures have arrays whose size is reported by two fields. The
+first field, whose name is usually prefixed by <emphasis>
+sz_</emphasis>
+, represents the total number of elements that can be stored in the array. The
+second field, whose name is usually prefixed by <emphasis>
+num_</emphasis>
+, specifies the number of elements currently stored there. These arrays
+typically represent data whose total size cannot always be determined when the
+array is created. In these instances, the usual way to allocate space and add
+data is as follows:
+</para>
+
+<itemizedlist>
+ <listitem>
+ <para>
+Call the allocator function with some arbitrary size, as a hint.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+For those arrays that have an <emphasis>
+Xkb...Add...</emphasis>
+ function, call it each time you want to add new data to the array. The
+function expands the array if necessary.
+ </para>
+ </listitem>
+</itemizedlist>
+
+<para>
+For example, call:
+</para>
+
+<para>
+XkbAllocGeomShapes(geom,4)
+</para>
+
+<para>
+to say "I’ll need space for four new shapes in this geometry." This makes
+sure that <emphasis>
+sz_shapes</emphasis>
+ - <emphasis>
+num_shapes</emphasis>
+ &gt;= 4, and resizes the shapes array if it isn’t. If this function
+succeeds, you are guaranteed to have space for the number of shapes you need.
+</para>
+
+
+<para>
+When you call an editing function for a structure, you do not need to check for
+space, because the function automatically checks the <emphasis>
+sz_</emphasis>
+ and <emphasis>
+num_</emphasis>
+ fields of the array, resizes the array if necessary, adds the entry to the
+array, and then updates the <emphasis>
+num_</emphasis>
+ field.
+</para>
+
+
+</sect1>
+<sect1 id='making_changes_to_the_servers_keyboard_description'>
+<title>Making Changes to the Server’s Keyboard Description</title>
+
+<para>
+In Xkb, as in the core protocol, the client and server have independent copies
+of the data structures that describe the keyboard. The recommended way to
+change some aspect of the keyboard mapping in the X server is to edit a local
+copy of the Xkb keyboard description and then send only the changes to the X
+server. This method helps eliminate the need to transfer the entire keyboard
+description or even an entire data structure for only minor changes.
+</para>
+
+
+<para>
+To help you keep track of the changes you make to a local copy of the keyboard
+description, Xkb provides separate special <emphasis>
+changes</emphasis>
+ data structures for each major Xkb data structure. These data structures do
+not contain the actual changed values: they only indicate the changes that have
+been made to the structures that actually describe the keyboard.
+</para>
+
+
+<para>
+When you wish to change the keyboard description in the server, you first
+modify a local copy of the keyboard description and then flag the modifications
+in an appropriate changes data structure. When you finish editing the local
+copy of the keyboard description, you pass your modified version of the
+keyboard description and the modified changes data structure to an Xkb
+function. This function uses the modified keyboard description and changes
+structure to pass only the changed information to the server. Note that
+modifying the keyboard description but not setting the appropriate flags in the
+changes data structure causes indeterminate behavior.
+</para>
+
+
+</sect1>
+<sect1 id='tracking_keyboard_changes_in_the_server'>
+<title>Tracking Keyboard Changes in the Server</title>
+
+<para>
+The server reports all changes in its keyboard description to any interested
+clients via special Xkb events. Just as clients use special changes data
+structures to change the keyboard description in the server, the server uses
+special changes data structures to tell a client what changed in the server’s
+keyboard description.
+</para>
+
+
+<para>
+Unlike clients, however, the server does not always pass the new values when it
+reports changes to its copy of the keyboard description. Instead, the server
+only passes a changes data structure when it reports changes to its keyboard
+description. This is done for efficiency reasons — some clients do not always
+need to update their copy of the keyboard description with every report from
+the server.
+</para>
+
+
+<para>
+When your client application receives a report from the server indicating the
+keyboard description has changed, you can determine the set of changes by
+passing the event to an Xkb function that "notes" event information in the
+corresponding changes data structure. These "note changes" functions are
+defined for all major Xkb components, and their names have the form <emphasis>
+XkbNote{Component}Changes</emphasis>
+, where <emphasis>
+Component</emphasis>
+ is the name of a major Xkb component such as <emphasis>
+Map</emphasis>
+ or <emphasis>
+Names</emphasis>
+. When you want to copy these changes from the server into a local copy of the
+keyboard description, use the corresponding <emphasis>
+XkbGet{Component}Changes</emphasis>
+ function<emphasis>
+, </emphasis>
+passing it the changes structure. The function then retrieves only the changed
+structures from the server and copies the modified pieces into the local
+keyboard description.
+</para>
+
+</sect1>
+<sect1 id='freeing_data_structures'>
+<title>Freeing Data Structures</title>
+
+<para>
+For the same reasons you should not directly use <emphasis>
+malloc</emphasis>
+ to allocate Xkb data structures, you should not free Xkb data structures or
+components directly using <emphasis>
+free</emphasis>
+ or <emphasis>
+Xfree</emphasis>
+. Xkb provides functions to free the various data structures and their
+components. Always use the free functions supplied by Xkb. There is no
+guarantee that any particular field can be safely freed by <emphasis>
+free</emphasis>
+ or <emphasis>
+Xfree</emphasis>
+.
+</para>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch04.xml b/specs/XKB/ch04.xml
new file mode 100644
index 00000000..dc9065d7
--- /dev/null
+++ b/specs/XKB/ch04.xml
@@ -0,0 +1,825 @@
+<chapter id='xkb_events'>
+<title>Xkb Events</title>
+
+<para>
+The primary way the X server communicates with clients is by sending X events
+to them. Some events are sent to all clients, while others are sent only to
+clients that have requested them. Some of the events that can be requested are
+associated with a particular window and are only sent to those clients who have
+both requested the event and specified the window in which the event occurred.
+</para>
+
+
+<para>
+The Xkb extension uses events to communicate the keyboard status to interested
+clients. These events are not associated with a particular window. Instead, all
+Xkb keyboard status events are reported to all interested clients, regardless
+of which window currently has the keyboard focus and regardless of the grab
+state of the keyboard.<footnote><para>The one exception to this rule is the
+XkbExtensionDeviceNotify event report that is sent when a client attempts to
+use an unsupported feature of an X Input Extension device (see section 21.4).
+</para></footnote> <!-- xref -->
+</para>
+
+
+<para>
+The X server reports the events defined by the Xkb extension to your client
+application only if you have requested them. You may request Xkb events by
+calling either <emphasis>
+XkbSelectEvents</emphasis>
+ or <emphasis>
+XkbSelectEventDetails</emphasis>
+. <emphasis>
+XkbSelectEvents</emphasis>
+ requests Xkb events by their event type and causes them to be reported to your
+client application under all circumstances. You can specify a finer granularity
+for event reporting by using <emphasis>
+XkbSelectEventDetails</emphasis>
+; in this case events are reported only when the specific detail conditions you
+specify have been met.
+</para>
+
+<sect1 id='xkb_event_types'>
+<title>Xkb Event Types</title>
+
+<para>
+The Xkb Extension adds new event types to the X protocol definition. An Xkb
+event type is defined by two fields in the X event data structure. One is the
+<emphasis>
+type</emphasis>
+ field, containing the <emphasis>
+base event code.</emphasis>
+ This base event code is a value the X server assigns to each X extension at
+runtime and thatidentifies the extension that generated the event; thus, the
+event code in the <emphasis>
+type</emphasis>
+ field identifies the event as an Xkb extension event, rather than an event
+from another extension or a core X protocol event. You can obtain the base
+event code via a call to <emphasis>
+XkbQueryExtension</emphasis>
+ or <emphasis>
+XkbOpenDisplay</emphasis>
+. The second field is the Xkb event type, which contains a value uniquely
+identifying each different Xkb event type. Possible values are defined by
+constants declared in the header file &lt;X11/extensions/Xkb.h&gt;.
+</para>
+
+
+<para>
+Table 4.1 lists the categories of events defined by Xkb and their associated
+event types, as defined in <emphasis>
+Xkb.h</emphasis>
+. Each event is described in more detail in the section referenced for that
+event.
+</para>
+
+<table frame='none'>
+<title>Xkb Event Types</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Event Type</entry>
+ <entry>Conditions Generating Event</entry>
+ <entry>Section</entry>
+ <entry>Page</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbNewKeyboardNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard geometry; keycode range change</para>
+ </entry>
+ <entry>
+ <para>19</para>
+ </entry>
+ <entry>
+ <para>187</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para>
+ <emphasis>XkbMapNotify</emphasis>
+ </para>
+ </entry>
+ <entry>
+ <para>Keyboard mapping change</para>
+ </entry>
+ <entry>
+ <para>14.4</para>
+ </entry>
+ <entry>
+ <para>122</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbStateNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard state change</para>
+ </entry>
+ <entry>
+ <para>5.4</para>
+ </entry>
+ <entry>
+ <para>25</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbControlsNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard controls state change</para>
+ </entry>
+ <entry>
+ <para>10.11</para>
+ </entry>
+ <entry>
+ <para>79</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbIndicatorStateNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard indicators state change</para>
+ </entry>
+ <entry>
+ <para>8.5</para>
+ </entry>
+ <entry>
+ <para>45</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbIndicatorMapNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard indicators map change</para>
+ </entry>
+ <entry>
+ <para>8.5</para>
+ </entry>
+ <entry>
+ <para>45</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbNamesNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard name change</para>
+ </entry>
+ <entry>
+ <para>18.5</para>
+ </entry>
+ <entry>
+ <para>185</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbCompatMapNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard compatibility map change</para>
+ </entry>
+ <entry>
+ <para>17.5</para>
+ </entry>
+ <entry>
+ <para>178</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbBellNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard bell generated</para>
+ </entry>
+ <entry>
+ <para>9.4</para>
+ </entry>
+ <entry>
+ <para>52</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbActionMessage</emphasis></para>
+ </entry>
+ <entry>
+ <para>Keyboard action message</para>
+ </entry>
+ <entry>
+ <para>16.1.11</para>
+ </entry>
+ <entry>
+ <para>155</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbAccessXNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>AccessX state change</para>
+ </entry>
+ <entry>
+ <para>10.6.4</para>
+ </entry>
+ <entry>
+ <para>65</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>
+ <para><emphasis>XkbExtensionDeviceNotify</emphasis></para>
+ </entry>
+ <entry>
+ <para>Extension device change</para>
+ </entry>
+ <entry>
+ <para>21.6</para>
+ </entry>
+ <entry>
+ <para>207</para>
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+<sect1 id='xkb_event_data_structures'>
+<title>Xkb Event Data Structures</title>
+
+<para>
+Xkb reports each event it generates in a unique structure holding the data
+values needed to describe the conditions the event is reporting. However, all
+Xkb events have certain things in common. These common features are contained
+in the same fields at the beginning of all Xkb event structures and are
+described in the <emphasis>
+XkbAnyEvent</emphasis>
+ structure:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis> True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event
+generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* Xkb minor event code */
+ unsigned int device; /* Xkb device ID, will not be
+ <emphasis>XkbUseCoreKbd</emphasis> */
+} <emphasis>XkbAnyEvent</emphasis>
+;
+</programlisting></para>
+
+<para>
+For any Xkb event, the <emphasis>
+type</emphasis>
+ field is set to the base event code for the Xkb extension, assigned by the
+server to all Xkb extension events. The <emphasis>
+serial</emphasis>
+, <emphasis>
+send_event</emphasis>
+, and <emphasis>
+display</emphasis>
+ fields are as described for all X11 events. The <emphasis>
+time</emphasis>
+ field is set to the time when the event was generated and is expressed in
+milliseconds. The <emphasis>
+xkb_type</emphasis>
+ field contains the minor extension event code, which is the extension event
+type, and is one of the values listed in Table 4.1. The <emphasis>
+device</emphasis>
+ field contains the keyboard device identifier associated with the event. This
+is never <emphasis>
+XkbUseCoreKbd</emphasis>
+, even if the request that generated the event specified a device of <emphasis>
+XkbUseCoreKbd</emphasis>
+. If the request that generated the event specified <emphasis>
+XkbUseCoreKbd</emphasis>
+, <emphasis>
+device</emphasis>
+ contains a value assigned by the server to specify the core keyboard. If the
+request that generated the event specified an X input extension device,
+<emphasis>
+device</emphasis>
+ contains that same identifier.
+</para>
+
+
+<para>
+Other data fields specific to individual Xkb events are described in subsequent
+chapters where the events are described.
+</para>
+
+
+</sect1>
+<sect1 id='selecting_xkb_events'>
+<title>Selecting Xkb Events</title>
+
+<para>
+Xkb events are selected using an event mask, much the same as normal core X
+events are selected. However, unlike selecting core X events, where you must
+specify the selection status (on or off) for all possible event types whenever
+you wish to change the selection criteria for any one event, Xkb allows you to
+restrict the specification to only the event types you wish to change. This
+means that you do not need to remember the event selection values for all
+possible types each time you want to change one of them.
+</para>
+
+
+<para>
+Many Xkb event types are generated under several different circumstances. When
+selecting to receive an Xkb event, you may specify either that you want it
+delivered under all circumstances, or that you want it delivered only for a
+subset of the possible circumstances.
+</para>
+
+<para>
+You can also deselect an event type that was previously selected for, using the
+same granularity.
+</para>
+
+<para>
+Xkb provides two functions to select and deselect delivery of Xkb events.
+<emphasis>
+XkbSelectEvents</emphasis>
+ allows you to select or deselect delivery of more than one Xkb event type at
+once. Events selected using <emphasis>
+XkbSelectEvents</emphasis>
+ are delivered to your program under all circumstances that generate the
+events. To restrict delivery of an event to a subset of the conditions under
+which it occurs, use <emphasis>
+XkbSelectEventDetails</emphasis>
+. <emphasis>
+XkbSelectEventDetails</emphasis>
+ only allows you to change the selection conditions for a single event at a
+time, but it provides a means of fine-tuning the conditions under which the
+event is delivered.
+</para>
+
+
+<para>
+To select and / or deselect for delivery of one or more Xkb events and have
+them delivered under all conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSelectEvents</emphasis>
+(<emphasis>
+display, device_spec, bits_to_change, values_for_bits</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long int <emphasis>
+bits_to_change; </emphasis>
+/* determines events to be selected / deselected */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long int <emphasis>
+values_for_bits</emphasis>
+; /* 1=&gt;select, 0-&gt;deselect; for events in <emphasis>
+bits_to_change</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+This request changes the Xkb event selection mask for the keyboard specified by
+<emphasis>
+device_spec</emphasis>
+.
+</para>
+
+
+<para>
+Each Xkb event that can be selected is represented by a bit in the <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ masks. Only the event selection bits specified by the <emphasis>
+bits_to_change</emphasis>
+ parameter are affected; any unspecified bits are left unchanged. To turn on
+event selection for an event, set the bit for the event in the <emphasis>
+bits_to_change</emphasis>
+ parameter and set the corresponding bit in the <emphasis>
+values_for_bits</emphasis>
+ parameter. To turn off event selection for an event, set the bit for the event
+in the <emphasis>
+bits_to_change</emphasis>
+ parameter and do not set the corresponding bit in the <emphasis>
+values_for_bits</emphasis>
+ parameter. The valid values for both of these parameters are an inclusive
+bitwise OR of the masks shown in Table 4.2. There is no interface to return
+your client’s current event selection mask. Clients cannot set other
+clients’ event selection masks.
+</para>
+
+
+<para>
+If a bit is not set in the <emphasis>
+bits_to_change</emphasis>
+ parameter, but the corresponding bit is set in the <emphasis>
+values_for_bits</emphasis>
+ parameter, a <emphasis>
+BadMatch</emphasis>
+ protocol error results. If an undefined bit is set in either the <emphasis>
+bits_to_change</emphasis>
+ or the <emphasis>
+values_for_bits</emphasis>
+ parameter, a <emphasis>
+BadValue</emphasis>
+ protocol error results.
+</para>
+
+
+<para>
+All event selection bits are initially zero for clients using the Xkb
+extension. Once you set some bits, they remain set for your client until you
+clear them via another call to <emphasis>
+XkbSelectEvents</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbSelectEvents</emphasis>
+ returns <emphasis>
+False</emphasis>
+ if the Xkb extension has not been initilialized and <emphasis>
+True</emphasis>
+ otherwise.
+</para>
+
+
+<para>
+To select or deselect for a specific Xkb event and optionally place conditions
+on when events of that type are reported to your client, use <emphasis>
+XkbSelectEventDetails</emphasis>
+. This allows you to exercise a finer granularity of control over delivery of
+Xkb events with <emphasis>
+XkbSelectEvents</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSelectEventDetails</emphasis>
+(<emphasis>
+display, device_spec, event_type, bits_to_change</emphasis>
+, <emphasis>
+values_for_bits</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+event_type</emphasis>
+; /* Xkb event type of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long int <emphasis>
+bits_to_change</emphasis>
+; /* event selection details */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long int <emphasis>
+values_for_bits</emphasis>
+; /* values for bits selected by <emphasis>
+bits_to_change</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+While <emphasis>
+XkbSelectEvents</emphasis>
+ allows multiple events to be selected, <emphasis>
+XkbSelectEventDetails</emphasis>
+ changes the selection criteria for a single type of Xkb event. The
+interpretation of the <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ masks depends on the event type in question.
+</para>
+
+
+<para>
+<emphasis>
+XkbSelectEventDetails</emphasis>
+ changes the Xkb event selection mask for the keyboard specified by <emphasis>
+device_spec</emphasis>
+ and the Xkb event specified by <emphasis>
+event_type</emphasis>
+. To turn on event selection for an event detail, set the bit for the detail in
+the <emphasis>
+bits_to_change</emphasis>
+ parameter and set the corresponding bit in the <emphasis>
+values_for_bits</emphasis>
+ parameter. To turn off event detail selection for a detail, set the bit for
+the detail in the <emphasis>
+bits_to_change</emphasis>
+ parameter and do not set the corresponding bit in the <emphasis>
+values_for_bits</emphasis>
+ parameter.
+</para>
+
+
+<para>
+If an invalid event type is specified, a <emphasis>
+BadValue</emphasis>
+ protocol error results. If a bit is not set in the <emphasis>
+bits_to_change</emphasis>
+ parameter, but the corresponding bit is set in the <emphasis>
+values_for_bits</emphasis>
+ parameter, a <emphasis>
+BadMatch</emphasis>
+ protocol error results. If an undefined bit is set in either the <emphasis>
+bits_to_change</emphasis>
+ or the <emphasis>
+values_for_bits</emphasis>
+ parameter, a <emphasis>
+BadValue</emphasis>
+ protocol error results.
+</para>
+
+
+<para>
+For each type of Xkb event, the legal event details that you can specify in the
+<emphasis>
+XkbSelectEventDetails</emphasis>
+ request are listed in the chapters that describe each event in detail.
+</para>
+
+
+<sect2 id='event_masks'>
+<title>Event Masks</title>
+
+<para>
+The X server reports the events defined by Xkb to your client application only
+if you have requested them via a call to <emphasis>
+XkbSelectEvents</emphasis>
+ or <emphasis>
+XkbSelectEventDetails</emphasis>
+. Specify the event types in which you are interested in a mask, as described
+in section 4.3.
+</para>
+
+
+<para>
+Table 4.2 lists the event mask constants that can be specified with the <!-- xref -->
+<emphasis>
+XkbSelectEvents</emphasis>
+ request and the circumstances in which the mask should be specified.
+</para>
+
+<table frame='none'>
+<title>XkbSelectEvents Mask Constants</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Event Mask</entry>
+ <entry>Value</entry>
+ <entry>Notification Wanted</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbNewKeyboardNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;0)</entry>
+ <entry>Keyboard geometry change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+ <emphasis>XkbMapNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;1)</entry>
+ <entry>Keyboard mapping change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XkbStateNotifyMask</emphasis></para>
+ </entry>
+ <entry>(1L&lt;&lt;2)</entry>
+ <entry><para>Keyboard state change</para></entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XkbControlsNotifyMask</emphasis></para>
+ </entry>
+ <entry>(1L&lt;&lt;3)</entry>
+ <entry>Keyboard control change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbIndicatorStateNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;4)</entry>
+ <entry>Keyboard indicator state change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbIndicatorMapNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;5)</entry>
+ <entry>Keyboard indicator map change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbNamesNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;6)</entry>
+ <entry>Keyboard name change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbCompatMapNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;7)</entry>
+ <entry>Keyboard compat map change</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbBellNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;8)</entry>
+ <entry>Bell</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbActionMessageMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;9)</entry>
+ <entry>Action message</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbAccessXNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;10)</entry>
+ <entry>AccessX features</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbExtensionDeviceNotifyMask</emphasis>
+ </entry>
+ <entry>(1L&lt;&lt;11)</entry>
+ <entry>Extension device</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<emphasis>XkbAllEventsMask</emphasis>
+ </entry>
+ <entry>(0xFFF)</entry>
+ <entry>All Xkb events</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect2>
+</sect1>
+<sect1 id='unified_xkb_event_type'>
+<title>Unified Xkb Event Type</title>
+
+<para>
+The <emphasis>
+XkbEvent</emphasis>
+ structure is a union of the individual structures declared for each Xkb event
+type and for the core protocol <emphasis>
+XEvent</emphasis>
+ type. Given an <emphasis>
+XkbEvent</emphasis>
+ structure, you may use the <emphasis>
+type</emphasis>
+ field to determine if the event is an Xkb event (<emphasis>
+type</emphasis>
+ equals the Xkb base event code; see section 2.4). If the event is an Xkb
+event, you may then use the <emphasis>
+any.xkb_type</emphasis>
+ field to determine the type of Xkb event and thereafter access the
+event-dependent components using the union member corresponding to the
+particular Xkb event type.
+</para>
+
+<para><programlisting>
+typedef union _XkbEvent {
+ int type;
+ XkbAnyEvent any;
+ XkbStateNotifyEvent state;
+ XkbMapNotifyEvent map;
+ XkbControlsNotifyEvent ctrls;
+ XkbIndicatorNotifyEvent indicators;
+ XkbBellNotifyEvent bell;
+ XkbAccessXNotifyEvent accessx;
+ XkbNamesNotifyEvent names;
+ XkbCompatMapNotifyEvent compat;
+ XkbActionMessageEvent message;
+ XkbExtensionDeviceNotifyEvent device;
+ XkbNewKeyboardNotifyEvent new_kbd;
+ XEvent core;
+} <emphasis>XkbEvent</emphasis>;
+</programlisting></para>
+
+<para>
+This unified Xkb event type includes a normal <emphasis>
+XEvent</emphasis>
+ as used by the core protocol, so it is straightforward for applications that
+use Xkb events to call the X library event functions without having to cast
+every reference. For example, to get the next event, you can simply declare a
+variable of type <emphasis>
+XkbEvent</emphasis>
+ and call:
+</para>
+
+<para>XNextEvent(dpy,&amp;xkbev.core);</para>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch05.xml b/specs/XKB/ch05.xml
new file mode 100644
index 00000000..791f2be4
--- /dev/null
+++ b/specs/XKB/ch05.xml
@@ -0,0 +1,977 @@
+<chapter id='keyboard_state'>
+<title>Keyboard State</title>
+
+<para>
+Keyboard state encompasses all of the transitory information necessary to map a physical key press or release to an appropriate event. The Xkb keyboard state consists of primitive components and additional derived components that are maintained for efficiency reasons. Figure 5.1 shows the components of Xkb keyboard state and their relationships.
+</para>
+
+<mediaobject>
+<!-- <title>Keyboard State Description</title> -->
+ <imageobject> <imagedata fileref="XKBlib-2.gif"/>
+ </imageobject>
+<caption>Xkb State</caption>
+</mediaobject>
+
+
+<sect1 id='keyboard_state_description'>
+<title>Keyboard State Description</title>
+<para>
+The Xkb keyboard state is comprised of the state of all keyboard modifiers, the keyboard group, and the state of the pointer buttons. These are grouped into the following components:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The locked group and locked modifiers
+ </para>
+</listitem>
+<listitem>
+ <para>
+The latched group and latched modifiers
+ </para>
+</listitem>
+<listitem>
+ <para>
+The base group and base modifiers
+ </para>
+</listitem>
+<listitem>
+ <para>
+The effective group and effective modifiers
+ </para>
+</listitem>
+<listitem>
+ <para>
+The state of the core pointer buttons
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The <emphasis>
+modifiers</emphasis>
+ are <emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+, <emphasis>
+Control</emphasis>
+, and <emphasis>
+Mod1</emphasis>
+-<emphasis>
+Mod5</emphasis>
+, as defined by the core protocol. A modifier can be thought of as a toggle that is either set or unset. All modifiers are initially unset. When a modifier is locked, it is set and remains set for all future key events, until it is explicitly unset. A latched modifier is set, but automatically unsets after the next key event that does not change the keyboard state. Locked and latched modifier state can be changed by keyboard activity or via Xkb extension library functions.
+</para>
+
+
+<para>
+The Xkb extension provides support for <emphasis>
+keysym</emphasis>
+ <emphasis>
+groups</emphasis>
+, as defined by ISO9995:
+</para>
+
+
+<variablelist>
+ <varlistentry>
+ <term>Group</term>
+ <listitem>
+ <para>
+A logical state of a keyboard providing access to a collection of characters.
+A group usually contains a set of characters that logically belong together
+and that may be arranged on several shift levels within that group.
+ </para>
+ </listitem>
+ </varlistentry>
+</variablelist>
+
+
+
+<para>
+The Xkb extension supports up to four keysym groups. Groups are named beginning with one and indexed beginning with zero. All group states are indicated using the group index. At any point in time, there is zero or one locked group, zero or one latched group, and one base group. When a group is locked, it supersedes any previous locked group and remains the locked group for all future key events, until a new group is locked. A latched group applies only to the next key event that does not change the keyboard state. The locked and latched group can be changed by keyboard activity or via Xkb extension library functions.
+</para>
+
+
+<para>
+Changing to a different group changes the keyboard state to produce characters from a different group. Groups are typically used to switch between keysyms of different languages and locales.
+</para>
+
+
+<para>
+The <emphasis>
+pointer buttons</emphasis>
+ are <emphasis>
+Button1</emphasis>
+ - <emphasis>
+Button5</emphasis>
+, as defined by the core protocol.
+</para>
+
+
+<para>
+The <emphasis>
+base group</emphasis>
+ and <emphasis>
+base modifiers</emphasis>
+ represent keys that are physically or logically down. These
+and the pointer buttons can be changed by keyboard activity and
+not by Xkb requests. It is possible for a key to be logically
+down, but not physically down, and neither latched nor locked.
+<footnote><para>
+Keys may be logically down when they are physically up because
+of their electrical properties or because of the keyboard extension
+in the X server having filtered the key release, for esoteric reasons.
+</para></footnote>
+
+</para>
+
+
+<para>
+The <emphasis>
+effective modifiers</emphasis>
+ are the bitwise union of the locked, latched, and the base modifiers.
+</para>
+
+
+<para>
+The <emphasis>
+effective group</emphasis>
+ is the arithmetic sum of the group indices of the latched group, locked group, and base group, which is then normalized by some function. The result is a meaningful group index.
+</para>
+
+<simplelist type='vert' columns='1'>
+<member>
+n = number of keyboard groups, 1&lt;= n &lt;= 4
+</member>
+
+<member>
+0 &lt;= any of locked, latched, or base group &lt; n
+</member>
+
+<member>
+effective group = f(locked group + latched group + base group)
+</member>
+</simplelist>
+
+<para>
+The function f ensures that the effective group is within range. The precise function is specified for the keyboard and can be retrieved through the keyboard description. It may wrap around, clamp down, or default. Few applications will actually examine the effective group, and far fewer still will examine the locked, latched, and base groups.
+</para>
+
+
+<para>
+There are two circumstances under which groups are normalized:
+</para>
+
+<orderedlist>
+ <listitem><para>
+The global locked or effective group changes. In this case, the changed group is normalized into range according to the settings of the <emphasis>
+groups_wrap</emphasis>
+ field of the <emphasis>
+XkbControlsRec</emphasis>
+ structure for the keyboard (see section 10.7.1). <!-- xref -->
+ </para></listitem>
+ <listitem><para>
+
+The Xkb library is interpreting an event with an effective group that is legal for the keyboard as a whole, but not for the key in question. In this case, the group to use for this event only is determined using the <emphasis>
+group_info</emphasis>
+ field of the key symbol mapping (<emphasis>
+XkbSymMapRec</emphasis>
+) for the event key.
+ </para></listitem>
+</orderedlist>
+
+<para>
+Each nonmodifier key on a keyboard has zero or more symbols, or keysyms, associated with it. These are the logical symbols that the key can generate when it is pressed. The set of all possible keysyms for a keyboard is divided into groups. Each key is associated with zero or more groups; each group contains one or more symbols. When a key is pressed, the determination of which symbol for the key is selected is based on the effective group and the shift level, which is determined by which modifiers are set.
+</para>
+
+
+<para>
+A client that does not explicitly call Xkb functions, but that otherwise makes use of an X library containing the Xkb extension, will have keyboard state represented in bits 0 - 14 of the state field of events that report modifier and button state. Such a client is said to be <emphasis>
+Xkb-capable</emphasis>
+. A client that does explicitly call Xkb functions is an <emphasis>
+Xkb-aware</emphasis>
+ client. The Xkb keyboard state includes information derived from the effective state and from two server parameters that can be set through the keyboard extension. The following components of keyboard state pertain to Xkb-capable and Xkb-aware clients:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+lookup state: lookup group and lookup modifiers
+ </para>
+</listitem>
+<listitem>
+ <para>
+grab state: grab group and grab modifiers
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The <emphasis>
+lookup modifiers</emphasis>
+ and <emphasis>
+lookup group</emphasis>
+ are represented in the state field of core X events. The modifier state and keycode of a key event are used to determine the symbols associated with the event. For <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events, the lookup modifiers are computed as:
+</para>
+
+<literallayout>
+ ((base | latched | locked) &amp; ~<emphasis> server_internal_modifiers</emphasis>)
+</literallayout>
+
+<para>
+Otherwise the lookup modifiers are computed as:
+</para>
+
+<literallayout>
+(((base | latched | (locked &amp; ~<emphasis> ignore_locks</emphasis>)) &amp; ~<emphasis> server_internal_modifiers</emphasis>)
+</literallayout>
+
+<para>
+The lookup group is the same as the effective group.
+</para>
+
+
+<para>
+When an Xkb-capable or Xkb-aware client wishes to map a keycode to a keysym, it should use the <emphasis>
+lookup state</emphasis>
+ — the lookup group and the lookup modifiers.
+</para>
+
+
+<para>
+The <emphasis>
+grab state</emphasis>
+ is the state used when matching events to passive grabs. If the event activates a grab, the <emphasis>
+grab modifiers</emphasis>
+ and <emphasis>
+grab group</emphasis>
+ are represented in the state field of core X events; otherwise, the lookup state is used. The grab modifiers are computed as:
+</para>
+
+<literallayout>
+(((base | latched | (locked &amp; ~ignore_locks)) &amp; ~server_internal_modifiers)
+</literallayout>
+
+<para>
+If the server’s <emphasis>
+IgnoreGroupLock</emphasis>
+ control (see section 10.7.3) is not set, the grab group is the same as the effective group. Otherwise, the grab group is computed from the base group and latched group, ignoring the locked group.
+</para>
+
+
+<para>
+The final three components of Xkb state are applicable to clients that are not linked with an Xlib containing the X keyboard extension library and therefore are not aware of the keyboard extension (<emphasis>
+Xkb-unaware </emphasis>
+clients):
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The compatibility modifier state
+ </para>
+</listitem>
+<listitem>
+ <para>
+The compatibility lookup modifier state
+ </para>
+</listitem>
+<listitem>
+ <para>
+The compatibility grab modifier state
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The X11 protocol interpretation of modifiers does not include direct support for multiple groups. When an Xkb-extended X server connects to an Xkb-unaware client, the compatibility states remap the keyboard group into a core modifier whenever possible. The compatibility state corresponds to the effective modifier and effective group state, with the group remapped to a modifier. The compatibility lookup and grab states correspond to the lookup and grab states, respectively, with the group remapped to a modifier. The compatibility lookup state is reported in events that do not trigger passive grabs; otherwise, the compatibility grab state is reported.
+</para>
+
+
+</sect1>
+<sect1 id='changing_the_keyboard_state'>
+<title>Changing the Keyboard State</title>
+
+<sect2 id='changing_modifiers'>
+<title>Changing Modifiers</title>
+
+<para>
+The functions in this section that change the use of modifiers use a mask in the parameter <emphasis>
+affect</emphasis>
+. It is a bitwise inclusive OR of the legal modifier masks:
+</para>
+
+<table frame='none'>
+<title>Real Modifier Masks</title>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='1'>
+ <entry>Mask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>ShiftMask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>LockMask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>ControlMask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Mod1Mask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Mod2Mask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Mod3Mask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Mod4Mask</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Mod5Mask</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+To lock and unlock any of the eight real keyboard modifiers, use <emphasis>
+XkbLockModifiers:</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis> XkbLockModifiers</emphasis>
+(<emphasis>
+display, device_spec, affect, values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ affect</emphasis>
+; /* mask of real modifiers whose lock state is to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+values</emphasis>
+; /* 1 =&gt; lock, 0 =&gt; unlock; only for modifiers selected by <emphasis>
+affect</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbLockModifiers</emphasis>
+ sends a request to the server to lock the real modifiers selected by both <emphasis>
+affect</emphasis>
+ and <emphasis>
+values</emphasis>
+ and to unlock the real modifiers selected by <emphasis>
+affect</emphasis>
+ but not selected by <emphasis>
+values</emphasis>
+. <emphasis>
+XkbLockModifiers</emphasis>
+ does not wait for a reply from the server. It returns <emphasis>
+True</emphasis>
+ if the request was sent, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+<para>
+To latch and unlatch any of the eight real keyboard modifiers, use <emphasis>
+XkbLatchModifiers:</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbLatchModifiers</emphasis>
+(d<emphasis>
+isplay, device_spec, affect, values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ affect</emphasis>
+; /* mask of modifiers whose latch state is to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>values</emphasis>;
+/* 1 =&gt; latch, 0 =&gt; unlatch; only for mods selected by <emphasis>
+affect</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbLatchModifiers</emphasis>
+ sends a request to the server to latch the real modifiers selected by both <emphasis>
+affect</emphasis>
+ and <emphasis>
+values</emphasis>
+ and to unlatch the real modifiers selected by <emphasis>
+affect</emphasis>
+ but not selected by <emphasis>
+values</emphasis>
+. <emphasis>
+XkbLatchModifiers</emphasis>
+ does not wait for a reply from the server. It returns <emphasis>
+True</emphasis>
+ if the request was sent, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+</sect2>
+<sect2 id='changing_groups'>
+<title>Changing Groups</title>
+
+<para>
+Reference the keysym group indices with these symbolic constants:
+</para>
+
+<table frame='none'>
+<title>Symbolic Group Names</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry>Symbolic Name</entry>
+ <entry>Value</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup1Index</entry>
+ <entry>0</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup2Index</entry>
+ <entry>1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup3Index</entry>
+ <entry>2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup4Index</entry>
+ <entry>3</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+To lock the keysym group, use <emphasis>
+XkbLockGroup. </emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbLockGroup</emphasis>
+(<emphasis>
+display, device_spec, group</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+group</emphasis>
+; /* index of the keysym group to lock */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbLockGroup</emphasis>
+ sends a request to the server to lock the specified <emphasis>
+group </emphasis>
+and does not wait for a reply. It returns <emphasis>
+True</emphasis>
+ if the request was sent and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+<para>
+To latch the keysym group, use <emphasis>
+XkbLatchGroup.</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbLatchGroup</emphasis>
+(<emphasis>
+display, device_spec, group</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ group</emphasis>
+; /* index of the keysym group to latch */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbLatchGroup</emphasis>
+ sends a request to the server to latch the specified group and does not wait for a reply. It returns <emphasis>
+True</emphasis>
+ if the request was sent and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='determining_keyboard_state'>
+<title>Determining Keyboard State</title>
+
+<para>
+Xkb keyboard state may be represented in an <emphasis>
+XkbStateRec</emphasis>
+ structure:
+</para>
+
+<para><programlisting>
+typedef struct {
+ unsigned char group; /* effective group index */
+ unsigned char base_group; /* base group index */
+ unsigned char latched_group; /* latched group index */
+ unsigned char locked_group; /* locked group index */
+ unsigned char mods; /* effective modifiers */
+ unsigned char base_mods; /* base modifiers */
+ unsigned char latched_mods; /* latched modifiers */
+ unsigned char locked_mods; /* locked modifiers */
+ unsigned char compat_state; /* effective group =&gt; modifiers */
+ unsigned char grab_mods; /* modifiers used for grabs */
+ unsigned char compat_grab_mods; /* mods used for compatibility mode grabs */
+ unsigned char lookup_mods; /* modifiers used to lookup symbols */
+ unsigned char compat_lookup_mods; /* mods used for compatibility lookup */
+ unsigned short ptr_buttons; /* 1 bit =&gt; corresponding pointer btn is down */
+} <emphasis>
+XkbStateRec</emphasis>
+,*XkbStatePtr;
+</programlisting></para>
+
+<para>
+To obtain the keyboard state, use <emphasis>
+XkbGetState.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetState</emphasis>
+(<emphasis>
+display</emphasis>
+, <emphasis>
+device_spec</emphasis>
+, <emphasis>
+state_return</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbStatePtr <emphasis>
+state_return</emphasis>
+; /* backfilled with Xkb state */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+XkbGetState </emphasis>
+function queries the server for the current keyboard state, waits for a reply, and then backfills <emphasis>
+state_return</emphasis>
+ with the results.
+</para>
+
+
+<para>
+All group values are expressed as group indices in the range [0..3]. Modifiers and the compatibility modifier state values are expressed as the bitwise union of the core X11 modifier masks. The pointer button state is reported as in the core X11 protocol.
+</para>
+
+
+</sect1>
+<sect1 id='tracking_keyboard_state'>
+<title>Tracking Keyboard State</title>
+
+<para>
+The Xkb extension reports <emphasis>
+XkbStateNotify </emphasis>
+events to clients wanting notification whenever the Xkb state changes. The changes reported include changes to any aspect of the keyboard state: when a modifier is set or unset, when the current group changes, or when a pointer button is pressed or released. As with all Xkb events, <emphasis>
+XkbStateNotify</emphasis>
+ events are reported to all interested clients without regard to the current keyboard input focus or grab state.
+</para>
+
+
+<para>
+There are many different types of Xkb state changes. Xkb defines an event detail mask corresponding to each type of change. The event detail masks are listed in Table 5.3.
+</para>
+
+<table frame='none'>
+<title>XkbStateNotify Event Detail Masks</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<thead>
+ <row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbModifierStateMask</entry>
+ <entry>(1L &lt;&lt; 0)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbModifierBaseMask</entry>
+ <entry>(1L &lt;&lt; 1)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbModifierLatchMask</entry>
+ <entry>(1L &lt;&lt; 2)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbModifierLockMask</entry>
+ <entry>(1L &lt;&lt; 3)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroupStateMask</entry>
+ <entry>(1L &lt;&lt; 4)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroupBaseMask</entry>
+ <entry>(1L &lt;&lt; 5)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroupLatchMask</entry>
+ <entry>(1L &lt;&lt; 6)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroupLockMask</entry>
+ <entry>(1L &lt;&lt; 7)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbCompatStateMask</entry>
+ <entry>(1L &lt;&lt; 8)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGrabModsMask</entry>
+ <entry>(1L &lt;&lt; 9)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbCompatGrabModsMask</entry>
+ <entry>(1L &lt;&lt; 10)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLookupModsMask</entry>
+ <entry>(1L &lt;&lt; 11)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbCompatLookupModsMask</entry>
+ <entry>(1L &lt;&lt; 12)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbPointerButtonMask</entry>
+ <entry>(1L &lt;&lt; 13)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAllStateComponentsMask</entry>
+ <entry>(0x3fff)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+To track changes in the keyboard state for a particular device, select to receive <emphasis>
+XkbStateNotify</emphasis>
+ events by calling either <emphasis>
+XkbSelectEvents</emphasis>
+ or <emphasis>
+XkbSelectEventDetails</emphasis>
+ (see section 4.3). <!-- xref -->
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbStateNotify</emphasis>
+ events under all possible conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+ and pass <emphasis>
+XkbStateNotifyMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbStateNotify</emphasis>
+ events only under certain conditions, use <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbStateNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying the desired state changes in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ using mask bits from Table 5.3. <!-- xref -->
+</para>
+
+
+<para>
+The structure for <emphasis>
+XkbStateNotify</emphasis>
+ events is:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis> True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis> XkbStateNotify</emphasis> */
+ int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
+ unsigned int changed; /* bits indicating what has changed */
+ int group; /* group index of effective group */
+ int base_group; /* group index of base group */
+ int latched_group; /* group index of latched group */
+ int locked_group; /* group index of locked group */
+ unsigned int mods; /* effective modifiers */
+ unsigned int base_mods; /* base modifiers */
+ unsigned int latched_mods; /* latched modifiers */
+ unsigned int locked_mods; /* locked modifiers */
+ int compat_state; /* computed compatibility state */
+ unsigned char grab_mods; /* modifiers used for grabs */
+ unsigned char compat_grab_mods; /* modifiers used for compatibility grabs */
+ unsigned char lookup_mods; /* modifiers used to lookup symbols */
+ unsigned char compat_lookup_mods; /* mods used for compatibility look up */
+ int ptr_buttons; /* core pointer buttons */
+ KeyCode keycode; /* keycode causing event, 0 if programmatic */
+ char event_type; /* core event if <emphasis> req_major</emphasis> or
+ <emphasis> req_minor</emphasis> non zero */
+ char req_major; /* major request code if program trigger, else 0 */
+ char req_minor; /* minor request code if program trigger, else 0 */
+} <emphasis>XkbStateNotifyEvent</emphasis>
+;
+</programlisting></para>
+
+<para>
+When you receive an <emphasis>
+XkbStateNotify</emphasis>
+ event, the <emphasis>
+changed</emphasis>
+ field indicates which elements of keyboard state have changed.
+This will be the bitwise inclusive OR of one or more of the <emphasis>
+XkbStateNotify</emphasis>
+ event detail masks shown in Table 5.3. All fields reported in <!-- xref -->
+the event are valid, but only those indicated in <emphasis>
+changed</emphasis>
+ have changed values.
+</para>
+
+
+<para>
+The <emphasis>
+group</emphasis>
+ field is the group index of the effective keysym group. The <emphasis>
+base_group</emphasis>
+, <emphasis>
+latched_group</emphasis>
+, and <emphasis>
+locked_group</emphasis>
+ fields are set to a group index value representing the base group,
+the latched group, and the locked group, respectively. The X
+server can set the modifier and compatibility state fields to
+a union of the core modifier mask bits; this union represents the
+corresponding modifier states. The <emphasis>ptr_button</emphasis>
+ field gives the state of the core pointer buttons as a
+mask composed of an inclusive OR of zero or more of the
+core pointer button masks.
+</para>
+
+
+<para>
+Xkb state changes can occur either in response to keyboard
+activity or under application control. If a key event
+caused the state change, the <emphasis>
+keycode</emphasis>
+ field gives the keycode of the key event, and the <emphasis>
+event_type</emphasis>
+ field is set to either <emphasis>KeyPress</emphasis>
+ or <emphasis>
+KeyRelease</emphasis>
+. If a pointer button event caused the state change, the <emphasis>
+keycode</emphasis>
+ field is zero, and the <emphasis>event_type</emphasis>
+ field is set to either <emphasis>ButtonPress</emphasis>
+ or <emphasis>ButtonRelease</emphasis>
+. Otherwise, the major and minor codes of the request that caused the
+state change are given in the <emphasis>
+req_major</emphasis>
+ and <emphasis>
+req_minor</emphasis>
+ fields, and the <emphasis>
+keycode</emphasis>
+ field is zero. The <emphasis>
+req_major</emphasis>
+ value is the same as the major extension opcode.
+</para>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch06.xml b/specs/XKB/ch06.xml
new file mode 100644
index 00000000..3bd77fab
--- /dev/null
+++ b/specs/XKB/ch06.xml
@@ -0,0 +1,413 @@
+<chapter id='complete_keyboard_description'>
+<title>Complete Keyboard Description</title>
+
+<para>
+The complete Xkb description for a keyboard device is accessed using a single
+structure containing pointers to major Xkb components. This chapter describes
+this single structure and provides references to other sections of this
+document that discuss the major Xkb components in detail.
+</para>
+
+<sect1 id='the_xkbdescrec_structure'>
+<title>The XkbDescRec Structure</title>
+
+<para>
+The complete description of an Xkb keyboard is given by an <emphasis>
+XkbDescRec</emphasis>
+. The component structures in the <emphasis>
+XkbDescRec</emphasis>
+ represent the major Xkb components outlined in Figure 1.1. <!-- xref -->
+</para>
+
+<para><programlisting>
+typedef struct {
+ struct _XDisplay * display; /* connection to
+X server */
+ unsigned short flags; /* private to Xkb, do
+not modify */
+ unsigned short device_spec; /* device of
+interest */
+ KeyCode min_key_code; /* minimum keycode for
+device */
+ KeyCode max_key_code; /* maximum keycode for
+device */
+ XkbControlsPtr ctrls; /* controls */
+ XkbServerMapPtr server; /* server keymap */
+ XkbClientMapPtr map; /* client keymap */
+ XkbIndicatorPtr indicators; /* indicator map
+*/
+ XkbNamesPtr names; /* names for all
+components */
+ XkbCompatMapPtr compat; /* compatibility map
+*/
+ XkbGeometryPtr geom; /* physical geometry of
+keyboard */
+} <emphasis>
+XkbDescRec</emphasis>
+, *XkbDescPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+display</emphasis>
+ field points to an X display structure. The <emphasis>
+flags</emphasis>
+ field is private to the library: modifying <emphasis>
+flags</emphasis>
+ may yield unpredictable results. The <emphasis>
+device_spec</emphasis>
+ field specifies the device identifier of the keyboard input device, or
+<emphasis>
+XkbUseCoreKeyboard</emphasis>
+, which specifies the core keyboard device. The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields specify the least and greatest keycode that can be returned by the
+keyboard.
+</para>
+
+
+<para>
+The other fields specify structure components of the keyboard description and
+are described in detail in other sections of this document. Table 6.1
+identifies the subsequent sections of this document that discuss the individual
+components of the <emphasis>
+XkbDescRec</emphasis>
+.
+</para>
+
+<table frame='none'>
+<title>XkbDescRec Component References</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>XkbDescRec Field</entry>
+ <entry>For more info</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>ctrls</entry>
+ <entry>Chapter 10</entry>
+</row>
+<row rowsep='0'>
+ <entry>server</entry>
+ <entry>Chapter 16</entry>
+</row>
+<row rowsep='0'>
+ <entry>map</entry>
+ <entry>Chapter 15</entry>
+</row>
+<row rowsep='0'>
+ <entry>indicators</entry>
+ <entry>Chapter 8</entry>
+</row>
+<row rowsep='0'>
+ <entry>names</entry>
+ <entry>Chapter 18</entry>
+</row>
+<row rowsep='0'>
+ <entry>compat</entry>
+ <entry>Chapter 17</entry>
+</row>
+<row rowsep='0'>
+ <entry>geom</entry>
+ <entry>Chapter 13</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Each structure component has a corresponding mask bit that is used in function
+calls to indicate that the structure should be manipulated in some manner, such
+as allocating it or freeing it. These masks and their relationships to the
+fields in the <emphasis>
+XkbDescRec</emphasis>
+ are shown in Table 6.2. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>Mask Bits for XkbDescRec</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask Bit</entry>
+ <entry>XkbDescRec Field</entry>
+ <entry>Value</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbControlsMask</entry>
+ <entry>ctrls</entry>
+ <entry>(1L&lt;&lt;0)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbServerMapMask</entry>
+ <entry>server</entry>
+ <entry>(1L&lt;&lt;1)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbIClientMapMask</entry>
+ <entry>map</entry>
+ <entry>(1L&lt;&lt;2)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbIndicatorMapMask</entry>
+ <entry>indicators</entry>
+ <entry>(1L&lt;&lt;3)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbNamesMask</entry>
+ <entry>names</entry>
+ <entry>(1L&lt;&lt;4)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbCompatMapMask</entry>
+ <entry>compat</entry>
+ <entry>(1L&lt;&lt;5)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbGeometryMask</entry>
+ <entry>geom</entry>
+ <entry>(1L&lt;&lt;6)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAllComponentsMask</entry>
+ <entry>All Fields</entry>
+ <entry>(0x7f)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+<sect1 id='obtaining_a_keyboard_description_from_the_server'>
+<title>Obtaining a Keyboard Description from the Server</title>
+
+<para>
+To retrieve one or more components of a keyboard device description, use
+<emphasis>
+XkbGetKeyboard</emphasis>
+ (see also <emphasis>
+XkbGetKeyboardbyName</emphasis>
+).
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDescPtr <emphasis>
+XkbGetKeyboard</emphasis>
+(<emphasis>
+display, which, device_spec</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask indicating components to return */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ device_spec</emphasis>
+; /* device for which to fetch description, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyboard </emphasis>
+allocates and returns a pointer to a keyboard description. It queries the
+server for those components specified in the <emphasis>
+which</emphasis>
+ parameter for device <emphasis>
+device_spec</emphasis>
+ and copies the results to the <emphasis>
+XkbDescRec</emphasis>
+ it allocated. The remaining fields in the keyboard description are set to
+<emphasis>
+NULL</emphasis>
+. The valid masks for <emphasis>
+which</emphasis>
+ are those listed in Table 6.2. <!-- xref -->
+</para>
+
+
+<para>
+<emphasis>
+XkbGetKeyboard</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+ protocol errors.
+</para>
+
+
+<para>
+To free the returned keyboard description, use <emphasis>
+XkbFreeKeyboard</emphasis>
+ (see section 6.4). <!-- xref -->
+</para>
+
+
+</sect1>
+<sect1 id='tracking_changes_to_the_keyboard_description_in_the_server'>
+<title>Tracking Changes to the Keyboard Description in the Server</title>
+
+<para>
+The server can generate events whenever its copy of the keyboard description
+for a device changes. Refer to section 14.4 for detailed information on <!-- xref -->
+tracking changes to the keyboard description.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_a_keyboard_description'>
+<title>Allocating and Freeing a Keyboard Description</title>
+
+<para>
+Applications seldom need to directly allocate a keyboard description; calling
+<emphasis>
+XkbGetKeyboard</emphasis>
+ usually suffices. In the event you need to create a keyboard description from
+scratch, however, use <emphasis>
+XkbAllocKeyboard</emphasis>
+ rather than directly calling <emphasis>
+malloc </emphasis>
+or <emphasis>
+Xmalloc</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDescRec * <emphasis>
+XkbAllocKeyboard</emphasis>
+(void)
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If <emphasis>
+XkbAllocKeyboard</emphasis>
+ fails to allocate the keyboard description, it returns <emphasis>
+NULL</emphasis>
+. Otherwise, it returns a pointer to an empty keyboard description structure.
+The <emphasis>
+device_spec</emphasis>
+ field will have been initialized to <emphasis>
+XkbUseCoreKbd</emphasis>
+. You may then either fill in the structure components or use Xkb functions to
+obtain values for the structure components from a keyboard device.
+</para>
+
+
+<para>
+To destroy either an entire an <emphasis>
+XkbDescRec</emphasis>
+ or just some of its members, use <emphasis>
+XkbFreeKeyboard.</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeKeyboard</emphasis>
+<emphasis>
+(xkb, which, free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description with components to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ which</emphasis>
+; /* mask selecting components to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; free all components and <emphasis>
+xkb</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbFreeKeyboard</emphasis>
+ frees the components of <emphasis>
+xkb</emphasis>
+ specified by <emphasis>
+which</emphasis>
+ and sets the corresponding values to <emphasis>
+NULL</emphasis>
+. If <emphasis>
+free_all</emphasis>
+ is <emphasis>
+True</emphasis>
+, <emphasis>
+XkbFreeKeyboard</emphasis>
+ frees every non-<emphasis>
+NULL</emphasis>
+ component of <emphasis>
+xkb</emphasis>
+ and then frees the <emphasis>
+xkb</emphasis>
+ structure itself.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch07.xml b/specs/XKB/ch07.xml
new file mode 100644
index 00000000..cd1b7dbd
--- /dev/null
+++ b/specs/XKB/ch07.xml
@@ -0,0 +1,446 @@
+<chapter id='virtual_modifiers'>
+<title>Virtual Modifiers</title>
+
+<para>
+The core protocol specifies that certain keysyms, when bound to modifiers,
+affect the rules of keycode to keysym interpretation for all keys; for example,
+when the <emphasis>
+Num_Lock</emphasis>
+ keysym is bound to some modifier, that modifier is used to select between
+shifted and unshifted state for the numeric keypad keys. The core protocol does
+not provide a convenient way to determine the mapping of modifier bits (in
+particular <emphasis>
+Mod1</emphasis>
+ through <emphasis>
+Mod5</emphasis>
+) to keysyms such as <emphasis>
+Num_Lock</emphasis>
+ and <emphasis>
+Mode_switch</emphasis>
+. Using the core protocol only, a client application must retrieve and search
+the modifier map to determine the keycodes bound to each modifier, and then
+retrieve and search the keyboard mapping to determine the keysyms bound to the
+keycodes. It must repeat this process for all modifiers whenever any part of
+the modifier mapping is changed.
+</para>
+
+
+<para>
+Xkb alleviates these problems by defining virtual modifiers. In addition to the
+eight core modifiers, referred to as the <emphasis>
+real modifiers</emphasis>
+, Xkb provides a set of sixteen named <emphasis>
+virtual modifiers</emphasis>
+. Each virtual modifier can be bound to any set of the real modifiers
+(<emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+, <emphasis>
+Control,</emphasis>
+ and <emphasis>
+Mod1</emphasis>
+-<emphasis>
+Mod5</emphasis>
+).
+</para>
+
+
+<para>
+The separation of function from physical modifier bindings makes it easier to
+specify more clearly the intent of a binding. X servers do not all assign
+modifiers the same way — for example, <emphasis>
+Num_Lock</emphasis>
+ might be bound to <emphasis>
+Mod2</emphasis>
+ for one vendor and to <emphasis>
+Mod4</emphasis>
+ for another. This makes it cumbersome to automatically remap the keyboard to a
+desired configuration without some kind of prior knowledge about the keyboard
+layout and bindings. With XKB, applications can use virtual modifiers to
+specify the desired behavior, without regard for the actual physical bindings
+in effect.
+</para>
+
+<sect1 id='virtual_modifier_names_and_masks'>
+<title>Virtual Modifier Names and Masks</title>
+
+<para>
+Virtual modifiers are named by converting their string name to an X <emphasis>
+Atom</emphasis>
+ and storing the Atom in the <emphasis>
+names.vmods</emphasis>
+ array in an <emphasis>
+XkbDescRec</emphasis>
+ structure (see section 6.1). The position of a name Atom in the <emphasis>
+names.vmods</emphasis>
+ array defines the bit position used to represent the virtual modifier and also
+the index used when accessing virtual modifier information in arrays: the name
+in the i-th (0 relative) entry of <emphasis>
+names.vmods</emphasis>
+ is the i-th virtual modifier, represented by the mask (1&lt;&lt;i). Throughout
+Xkb, various functions have a parameter that is a mask representing virtual
+modifier choices. In each case, the i-th bit (0 relative) of the mask
+represents the i-th virtual modifier.
+</para>
+
+
+<para>
+To set the name of a virtual modifier, use <emphasis>
+XkbSetNames</emphasis>
+, using <emphasis>
+XkbVirtualModNamesMask</emphasis>
+ in <emphasis>
+which</emphasis>
+ and the name in the <emphasis>
+xkb</emphasis>
+ argument; to retrieve indicator names, use <emphasis>
+XkbGetNames</emphasis>
+. These functions are discussed in Chapter 18.
+</para>
+
+
+</sect1>
+<sect1 id='modifier_definitions'>
+<title>Modifier Definitions</title>
+
+<para>
+An Xkb<emphasis>
+ modifier definition</emphasis>
+ enumerates a collection of real and virtual modifiers but does not in itself
+bind those modifiers to any particular key or to each other. Modifier
+definitions are included in a number of structures in the keyboard description
+to define the collection of modifiers that affect or are affected by some other
+entity. A modifier definition is relevant only in the context of some other
+entity such as an indicator map, a control, or a key type. (See sections 8.2.2,
+10.8, and 15.2.) <!-- xref -->
+</para>
+
+<para><programlisting>
+typedef struct _XkbMods {
+ unsigned char mask; /* real_mods | vmods mapped to
+real modifiers */
+ unsigned char real_mods; /* real modifier bits */
+ unsigned short vmods; /* virtual modifier bits */
+} <emphasis>
+XkbModsRec</emphasis>
+,*XkbModsPtr;
+</programlisting></para>
+
+<para>
+An Xkb modifier definition consists of a set of bit masks corresponding to the
+eight real modifiers (<emphasis>
+real_mods</emphasis>
+); a similar set of bitmasks corresponding to the 16 named virtual modifiers
+(<emphasis>
+vmods</emphasis>
+); and an effective mask (<emphasis>
+mask</emphasis>
+). The effective mask represents the set of all real modifiers that can
+logically be set either by setting any of the real modifiers or by setting any
+of the virtual modifiers in the definition. <emphasis>
+mask</emphasis>
+ is derived from the real and virtual modifiers and should never be explicitly
+changed — it contains all of the real modifiers specified in the definition
+(<emphasis>
+real_mods</emphasis>
+)<emphasis>
+ plus</emphasis>
+ any real modifiers that are bound to the virtual modifiers specified in the
+definition (<emphasis>
+vmods</emphasis>
+). The binding of the virtual modifiers to real modifiers is exterior to the
+modifier definition. Xkb automatically recomputes the mask field of modifier
+definitions as necessary. Whenever you access a modifier definition that has
+been retrieved using an Xkb library function, the mask field will be correct
+for the keyboard mapping of interest.
+</para>
+
+
+</sect1>
+<sect1 id='binding_virtual_modifiers_to_real_modifiers'>
+<title>Binding Virtual Modifiers to Real Modifiers</title>
+
+<para>
+The binding of virtual modifiers to real modifiers is defined by the <emphasis>
+server.vmods</emphasis>
+ array in an <emphasis>
+XkbDescRec</emphasis>
+ structure. Each entry contains the real modifier bits that are bound to the
+virtual modifier corresponding to the entry. The overall relationship of fields
+dealing with virtual modifiers in the server keyboard description are shown in
+Figure 16.2. <!-- xref -->
+</para>
+
+
+</sect1>
+<sect1 id='virtual_modifier_key_mapping'>
+<title>Virtual Modifier Key Mapping</title>
+
+<para>
+Xkb maintains a <emphasis>
+virtual modifier mapping</emphasis>
+, which lists the virtual modifiers associated with, or bound to, each key. The
+real modifiers bound to a virtual modifier always include all of the modifiers
+bound to any of the keys that specify that virtual modifier in their virtual
+modifier mapping. The <emphasis>
+server.vmodmap</emphasis>
+ array indicates which virtual modifiers are bound to each key; each entry is a
+bitmask for the virtual modifier bits. The <emphasis>
+server.vmodmap</emphasis>
+ array is indexed by keycode.
+</para>
+
+
+<para>
+The <emphasis>
+vmodmap</emphasis>
+ and <emphasis>
+vmods</emphasis>
+ members of the server map are the "master" virtual modifier definitions. Xkb
+automatically propagates any changes to these fields to all other fields that
+use virtual modifier mappings (see section 16.4).
+</para>
+
+
+<para>
+For example, if <emphasis>
+Mod3</emphasis>
+ is bound to the <emphasis>
+Num_Lock</emphasis>
+ key by the core protocol modifier mapping, and the <emphasis>
+NumLock</emphasis>
+ virtual modifier is bound to they <emphasis>
+Num_Lock</emphasis>
+ key by the virtual modifier mapping, <emphasis>
+Mod3</emphasis>
+ is added to the set of modifiers associated with <emphasis>
+NumLock</emphasis>
+.
+</para>
+
+
+<para>
+The virtual modifier mapping is normally updated whenever actions are
+automatically applied to symbols (see section 16.4 for details), and few
+applications should need to change the virtual modifier mapping explicitly.
+</para>
+
+
+<para>
+Use <emphasis>
+XkbGetMap </emphasis>
+(see section 14.2) to get the virtual modifiers from the server or use <!-- xref -->
+<emphasis>
+XkbGetVirtualMods</emphasis>
+ (see section 16.4.1) to update a local copy of the virtual modifiers bindings <!-- xref -->
+from the server. To set the binding of a virtual modifier to a real modifier,
+use <emphasis>
+XkbSetMap</emphasis>
+ (see<emphasis>
+ </emphasis>
+section 14.3<emphasis> <!-- xref -->
+).</emphasis>
+</para>
+
+
+<para>
+To determine the mapping of virtual modifiers to core X protocol modifiers, use
+<emphasis>
+XkbVirtualModsToReal</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbVirtualModsToReal</emphasis>
+(<emphasis>
+xkb, virtual_mask, mask_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description for input device */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ virtual_mask</emphasis>
+; /* virtual modifier mask to translate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+mask_rtrn</emphasis>
+; /* backfilled with real modifiers */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If the keyboard description defined by <emphasis>
+xkb</emphasis>
+ includes bindings for virtual modifiers, <emphasis>
+XkbVirtualModsToReal</emphasis>
+ uses those bindings to determine the set of real modifiers that correspond to
+the set of virtual modifiers specified in <emphasis>
+virtual_mask</emphasis>
+. The <emphasis>
+virtual_mask</emphasis>
+ parameter is a mask specifying the virtual modifiers to translate; the i-th
+bit (0 relative) of the mask represents the i-th virtual modifier. If <emphasis>
+mask_rtrn</emphasis>
+ is non-<emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbVirtualModsToReal</emphasis>
+ backfills it with the resulting real modifier mask. If the keyboard
+description in <emphasis>
+xkb</emphasis>
+ does not include virtual modifier bindings, <emphasis>
+XkbVirtualModsToReal</emphasis>
+ returns <emphasis>
+False</emphasis>
+; otherwise, it returns <emphasis>
+True</emphasis>
+.
+</para>
+
+<note><para>It is possible for a local (client-side) keyboard description (the
+<emphasis>
+xkb</emphasis>
+ parameter) to not contain any virtual modifier information (simply because the
+client has not requested it) while the server’s corresponding definition may
+contain virtual modifier information. </para></note>
+
+
+<sect2 id='inactive_modifier_sets'>
+<title>Inactive Modifier Sets</title>
+
+<para>
+An unbound virtual modifier is one that is not bound to any real modifier
+(<emphasis>
+server</emphasis>
+-&gt;<emphasis>
+vmods</emphasis>
+[virtual_modifier_index] is zero).
+</para>
+
+
+<para>
+Some Xkb operations ignore modifier definitions in which the virtual modifiers
+are unbound. Consider this example:
+</para>
+
+<literallayout>
+if (state matches {Shift}) Do OneThing;
+if (state matches {Shift+NumLock}) Do Another;
+</literallayout>
+
+<para>
+If the <emphasis>
+NumLock</emphasis>
+ virtual modifier is not bound to any real modifiers, the effective masks for
+these two cases are identical (that is, contain only <emphasis>
+Shift</emphasis>
+). When it is essential to distinguish between <emphasis>
+OneThing</emphasis>
+ and Another, Xkb considers only those modifier definitions for which all
+virtual modifiers are bound.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='conventions'>
+<title>Conventions</title>
+
+<para>
+The Xkb extension does not require any specific virtual modifier names.
+However, everyone benefits if the same names are used for common modifiers. The
+following names are suggested:
+</para>
+
+<literallayout class='monospaced'>
+ <emphasis>
+ NumLock
+ ScrollLock
+ Alt
+ Meta
+ AltGr
+ LevelThree</emphasis>
+</literallayout>
+
+</sect1>
+<sect1 id='example'>
+<title>Example</title>
+
+<para>
+If the second (0-relative) entry in <emphasis>
+names.vmods</emphasis>
+ contains the Atom for "NumLock", then 0x4 (1&lt;&lt;2) is the virtual modifier
+bit for the <emphasis>
+NumLock</emphasis>
+ virtual modifier. If <emphasis>
+server.vmods</emphasis>
+[2] contains <emphasis>
+Mod3Mask</emphasis>
+, then the <emphasis>
+NumLock</emphasis>
+ virtual modifier is bound to the <emphasis>
+Mod3</emphasis>
+ real modifier.
+</para>
+
+
+<para>
+A virtual modifier definition for this example would have:
+</para>
+
+<literallayout class='monospaced'>
+ real_mods = 0
+ vmods = 0x4 (NumLock named virtual modifier)
+ mask = 0x20 (Mod3Mask)
+</literallayout>
+
+<para>
+Continuing the example, if the keyboard has a <emphasis>
+Num_Lock</emphasis>
+ keysym bound to the key with keycode 14, and the <emphasis>
+NumLock</emphasis>
+ virtual modifier is bound to this key, <emphasis>
+server.vmodmap</emphasis>
+[14] contains 0x4.
+</para>
+
+
+<para>
+Finally, if the keyboard also used the real <emphasis>
+Mod1</emphasis>
+ modifier for numeric lock operations, the modifier definition below would
+represent the situation where either the key bound to <emphasis>
+Mod1</emphasis>
+ or the <emphasis>
+NumLock</emphasis>
+ virtual modifier could be used for this purpose:
+</para>
+
+<literallayout class='monospaced'>
+ real_mods = 0x8 (Mod1Mask)
+ vmods = 0x4 (NumLock named virtual modifier)
+ mask = 0x28 (Mod1Mask | Mod3Mask)
+</literallayout>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch08.xml b/specs/XKB/ch08.xml
new file mode 100644
index 00000000..0d19a3d7
--- /dev/null
+++ b/specs/XKB/ch08.xml
@@ -0,0 +1,2087 @@
+<chapter id='indicators'>
+<title>Indicators</title>
+
+<para>
+Although the core X implementation supports up to 32 LEDs on an input device,
+it does not provide any linkage between the state of the LEDs and the logical
+state of the input device. For example, most keyboards have a <emphasis>
+CapsLock</emphasis>
+ LED, but X does not provide a mechanism to make the LED automatically follow
+the logical state of the <emphasis>
+CapsLock</emphasis>
+ key.
+</para>
+
+
+<para>
+Furthermore, the core X implementation does not provide clients with the
+ability to determine what bits in the <emphasis>
+led_mask</emphasis>
+ field of the <emphasis>
+XKeyboardState</emphasis>
+ map to the particular LEDs on the keyboard. For example, X does not provide a
+method for a client to determine what bit to set in the <emphasis>
+led_mask</emphasis>
+ field to turn on the <emphasis>
+Scroll Lock </emphasis>
+LED or whether the keyboard even has a <emphasis>
+Scroll Lock</emphasis>
+ LED.
+</para>
+
+
+<para>
+Xkb provides indicator names and programmable indicators to help solve these
+problems. Using Xkb, clients can determine the names of the various indicators,
+determine and control the way that the individual indicators should be updated
+to reflect keyboard changes, and determine which of the 32 keyboard indicators
+reported by the protocol are actually present on the keyboard. Clients may also
+request immediate notification of changes to the state of any subset of the
+keyboard indicators, which makes it straightforward to provide an on-screen
+"virtual" LED panel. This chapter describes Xkb indicators and the functions
+used for manipulating them.
+</para>
+
+<sect1 id='indicator_names'>
+<title>Indicator Names</title>
+
+<para>
+Xkb provides the capability of symbolically naming indicators. Xkb itself
+doesn’t use these symbolic names for anything; they are there only to help
+make the keyboard description comprehensible to humans. To set the names of
+specific indicators, use <emphasis>
+XkbSetNames</emphasis>
+ as discussed in Chapter 18. Then set the map using <emphasis> <!-- xref -->
+XkbSetMap</emphasis>
+ (see section 14.3) or <emphasis> <!-- xref -->
+XkbSetNamedIndicator</emphasis>
+ (below). To retrieve indicator names, use <emphasis>
+XkbGetNames</emphasis>
+ (Chapter 18). <!-- xref -->
+</para>
+
+
+</sect1>
+<sect1 id='indicator_data_structures'>
+<title>Indicator Data Structures</title>
+
+<para>
+Use the indicator description record, <emphasis>
+XkbIndicatorRec</emphasis>
+, and its indicator map, <emphasis>
+XkbIndicatorMapRec</emphasis>
+, to inquire about and control most indicator properties and behaviors.
+</para>
+
+
+<sect2 id='xkbindicatorrec'>
+<title>XkbIndicatorRec</title>
+
+<para>
+The description for all the Xkb indicators is held in the <emphasis>
+indicators</emphasis>
+ field of the complete keyboard description (see Chapter 6), which is defined <!-- xref -->
+as follows:
+</para>
+
+<para><programlisting>
+#define XkbNumIndicators 32
+</programlisting></para>
+<para><programlisting>
+typedef struct {
+ unsigned long phys_indicators; /* LEDs existence */
+ XkbIndicatorMapRec maps[XkbNumIndicators]; /* indicator maps */
+} <emphasis>XkbIndicatorRec</emphasis>,*XkbIndicatorPtr;
+</programlisting></para>
+
+<para>
+This structure contains the <emphasis>
+phys_indicators</emphasis>
+ field, which relates some information about the correspondence between
+indicators and physical LEDs on the keyboard, and an array of indicator
+<emphasis>
+maps</emphasis>
+, one map per indicator.
+</para>
+
+<para>
+The <emphasis>
+phys_indicators</emphasis>
+ field indicates which indicators are bound to physical LEDs on the keyboard;
+if a bit is set in <emphasis>
+phys_indicators</emphasis>
+, then the associated indicator has a physical LED associated with it. This
+field is necessary because some indicators may not have corresponding physical
+LEDs on the keyboard. For example, most keyboards have an LED for indicating
+the state of <emphasis>
+CapsLock</emphasis>
+, but most keyboards do not have an LED that indicates the current group.
+Because <emphasis>
+phys_indicators</emphasis>
+ describes a physical characteristic of the keyboard, you cannot directly
+change it under program control. However, if a client program loads a
+completely new keyboard description via <emphasis>
+XkbGetKeyboardByName</emphasis>
+, or if a new keyboard is attached and the X implementation notices, <emphasis>
+phys_indicators</emphasis>
+ changes if the indicators for the new keyboard are different.
+</para>
+
+
+</sect2>
+<sect2 id='xkbindicatormaprec'>
+<title>XkbIndicatorMapRec</title>
+
+<para>
+Each indicator has its own set of attributes that specify whether clients can
+explicitly set its state and whether it tracks the keyboard state. The
+attributes of each indicator are held in the <emphasis>
+maps</emphasis>
+ array, which is an array of <emphasis>
+XkbIndicatorRec</emphasis>
+ structures:
+</para>
+
+<para><programlisting>
+typedef struct {
+ unsigned char flags; /* how the indicator can be changed */
+ unsigned char which_groups; /* match criteria for groups */
+ unsigned char groups; /* which keyboard groups the indicator watches */
+ unsigned char which_mods; /* match criteria for modifiers */
+ XkbModsRec mods; /* which modifiers the indicator watches */
+ unsigned int ctrls; /* which controls the indicator watches */
+} <emphasis>XkbIndicatorMapRec</emphasis>, *XkbIndicatorMapPtr;
+</programlisting></para>
+
+<para>
+This indicator map specifies for each indicator:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The conditions under which the keyboard modifier state affects the indicator
+ </para>
+</listitem>
+<listitem>
+ <para>
+The conditions under which the keyboard group state affects the indicator
+ </para>
+</listitem>
+<listitem>
+ <para>
+The conditions under which the state of the boolean controls affects the
+indicator
+ </para>
+</listitem>
+<listitem>
+ <para>
+The effect (if any) of attempts to explicitly change the state of the indicator
+using the functions <emphasis>
+XkbSetControls</emphasis>
+ or <emphasis>
+XChangeKeyboardControl</emphasis>
+
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+For more information on the effects of explicit changes to indicators and the
+relationship to the indicator map, see section 8.4.1. <!-- xref -->
+</para>
+
+<sect3 id='xkbindicatormaprec_flags_field'>
+<title>XkbIndicatorMapRec flags field</title>
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field specifies the conditions under which the indicator can be changed and
+the effects of changing the indicator. The valid values for <emphasis>
+flags</emphasis>
+ and their effects are shown in Table 8.1. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>XkbIndicatorMapRec flags Field</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Value</entry>
+ <entry></entry>
+ <entry>Effect</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbIM_NoExplicit</entry>
+ <entry>(1L&lt;&lt;7)</entry>
+ <entry>Client applications cannot change the state of the indicator.</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_NoAutomatic</entry>
+ <entry>(1L&lt;&lt;6)</entry>
+ <entry>Xkb does not automatically change the value of the indicator based
+upon a change in the keyboard state, regardless of the values for the other
+fields of the indicator map.</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_LEDDrivesKB</entry>
+ <entry>(1L&lt;&lt;5)</entry>
+ <entry>A client application changing the state of the indicator causes the
+state of the keyboard to change.</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Note that if <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ is not set, by default the indicator follows the keyboard state.
+</para>
+
+
+<para>
+If <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is set and <emphasis>
+XkbIM_NoExplicit</emphasis>
+ is not, and if you call a function which updates the server’s image of the
+indicator map (such as <emphasis>
+XkbSetIndicatorMap</emphasis>
+ or <emphasis>
+XkbSetNamedIndicator</emphasis>
+), Xkb changes the keyboard state and controls to reflect the other fields of
+the indicator map, as described in the remainder of this section. If you
+attempt to explicitly change the value of an indicator for which <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is absent or for which <emphasis>
+XkbIM_NoExplicit</emphasis>
+ is present, keyboard state or controls are unaffected.
+</para>
+
+
+<para>
+For example, a keyboard designer may want to make the <emphasis>
+CapsLock</emphasis>
+ LED controllable only by the server, but allow the <emphasis>
+Scroll Lock</emphasis>
+ LED to be controlled by client applications. To do so, the keyboard designer
+could set the <emphasis>
+XkbIM_NoExplicit</emphasis>
+ flag for the <emphasis>
+CapsLock</emphasis>
+<emphasis>
+ </emphasis>
+LED, but not set it for the <emphasis>
+Scroll Lock</emphasis>
+ LED. Or the keyboard designer may wish to allow the <emphasis>
+CapsLock</emphasis>
+ LED to be controlled by both the server and client applications and also have
+the server to automatically change the <emphasis>
+CapsLock</emphasis>
+<emphasis>
+ </emphasis>
+modifier state whenever a client application changes the <emphasis>
+CapsLock</emphasis>
+ LED. To do so, the keyboard designer would not set the <emphasis>
+XkbIM_NoExplicit</emphasis>
+ flag, but would instead set the <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ flag.
+</para>
+
+<para>
+The remaining fields in the indicator map specify the conditions under which
+Xkb automatically turns an indicator on or off (only if <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ is not set). If these conditions match the keyboard state, Xkb turns the
+indicator on. If the conditions do not match, Xkb turns the indicator off.
+</para>
+
+</sect3>
+
+<sect3 id='xkbindicatormaprec_which_groups_and_groups_fields'>
+<title>XkbIndicatorMapRec which_groups and groups fields</title>
+
+<para>
+The <emphasis>
+which_groups</emphasis>
+ and the <emphasis>
+groups</emphasis>
+ fields of an indicator map determine how the keyboard group state affects the
+corresponding indicator. The <emphasis>
+which_groups</emphasis>
+ field controls the interpretation of <emphasis>
+groups</emphasis>
+ and may contain any one of the following values:
+</para>
+
+<para><programlisting>
+#define XkbIM_UseNone 0
+#define XkbIM_UseBase (1L &lt;&lt; 0)
+#define XkbIM_UseLatched (1L &lt;&lt; 1)
+#define XkbIM_UseLocked (1L &lt;&lt; 2)
+#define XkbIM_UseEffective (1L &lt;&lt; 3)
+#define XkbIM_UseAnyGroup XkbIM_UseLatched | XkbIM_UseLocked |
+ XkbIM_UseEffective
+</programlisting></para>
+
+<para>
+The <emphasis>
+groups </emphasis>
+field specifies what keyboard groups an indicator watches and is the bitwise
+inclusive OR of the following valid values:
+</para>
+
+<para><programlisting>
+#define XkbGroup1Mask (1&lt;&lt;0)
+#define XkbGroup2Mask (1&lt;&lt;1)
+#define XkbGroup3Mask (1&lt;&lt;2)
+#define XkbGroup4Mask (1&lt;&lt;3)
+#define XkbAnyGroupMask (1&lt;&lt;7)
+#define XkbAllGroupsMask (0xf)
+</programlisting></para>
+
+<para>
+If <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ is not set (the keyboard drives the indicator), the effect of <emphasis>
+which_groups</emphasis>
+ and <emphasis>
+groups</emphasis>
+ is shown in Table 8.2. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>XkbIndicatorMapRec which_groups and groups, Keyboard Drives
+Indicator</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>which_groups</entry>
+ <entry>Effect</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbIM_UseNone</entry>
+ <entry>
+The <emphasis>
+groups</emphasis>
+ field and the current keyboard group state are ignored.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseBase</entry>
+ <entry>
+If <emphasis>
+groups</emphasis>
+ is nonzero, the indicator is lit whenever the base keyboard group is nonzero.
+If <emphasis>
+groups</emphasis>
+ is zero, the indicator is lit whenever the base keyboard group is zero.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLatched</entry>
+ <entry>
+If <emphasis>
+groups</emphasis>
+ is nonzero, the indicator is lit whenever the latched keyboard group is
+nonzero. If <emphasis>
+groups</emphasis>
+ is zero, the indicator is lit whenever the latched keyboard group is zero.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLocked</entry>
+ <entry>
+The <emphasis>
+groups</emphasis>
+ field is interpreted as a mask. The indicator is lit when the current locked
+keyboard group matches one of the bits that are set in <emphasis>
+groups</emphasis>.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseEffective</entry>
+ <entry>
+The <emphasis>
+groups</emphasis>
+ field is interpreted as a mask. The indicator is lit when the current
+effective keyboard group matches one of the bits that are set in <emphasis>
+groups</emphasis>
+.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The effect of <emphasis>
+which_groups</emphasis>
+ and <emphasis>
+groups</emphasis>
+ when you change an indicator for which <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is set (the indicator drives the keyboard) is shown in Table 8.3. The "New
+State" column refers to the new state to which you set the indicator.
+</para>
+
+<table frame='none'>
+<title>XkbIndicatorMapRec which_groups and groups, Indicator Drives
+Keyboard</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>which_groups</entry>
+ <entry>New State</entry>
+ <entry>Effect on Keyboard Group State</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbIM_UseNone </entry>
+ <entry>On or Off</entry>
+ <entry>No effect</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseBase</entry>
+ <entry>On or Off</entry>
+ <entry>No effect</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLatched</entry>
+ <entry>On</entry>
+ <entry>
+The <emphasis>
+groups</emphasis>
+ field is treated as a group mask. The keyboard group latch is changed to the
+lowest numbered group specified in <emphasis>
+groups</emphasis>
+; if <emphasis>
+groups</emphasis>
+ is empty, the keyboard group latch is changed to zero.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLatched</entry>
+ <entry>Off</entry>
+ <entry>
+The <emphasis>
+groups</emphasis>
+ field is treated as a group mask. If the indicator is explicitly extinguished,
+keyboard group latch is changed to the lowest numbered group not specified in
+<emphasis>
+groups</emphasis>
+; if <emphasis>
+groups</emphasis>
+ is zero, the keyboard group latch is set to the index of the highest legal
+keyboard group.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLocked or XkbIM_UseEffective</entry>
+ <entry>On</entry>
+ <entry>
+If the <emphasis>
+groups</emphasis>
+ mask is empty, group is not changed; otherwise, the locked keyboard group is
+changed to the lowest numbered group specified in <emphasis>
+groups</emphasis>.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLocked or XkbIM_UseEffective</entry>
+ <entry>Off</entry>
+ <entry>
+Locked keyboard group is changed to the lowest numbered group that is not
+specified in the <emphasis>
+groups</emphasis>
+ mask, or to <emphasis>
+Group1</emphasis>
+ if the <emphasis>
+groups</emphasis>
+ mask contains all keyboard groups.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect3>
+<sect3 id='xkbindicatormaprec_which_mods_and_mods_fields'>
+<title>XkbIndicatorMapRec which_mods and mods fields</title>
+
+<para>
+The <emphasis>
+mods </emphasis>
+field specifies what modifiers an indicator watches. The <emphasis>
+mods</emphasis>
+ field is an Xkb modifier definition, <emphasis>
+XkbModsRec</emphasis>
+, as described in section 7.2, which can specify both real and virtual <!-- xref -->
+modifiers. The <emphasis>
+mods</emphasis>
+ field takes effect even if some or all of the virtual indicators specified in
+<emphasis>
+mods</emphasis>
+ are unbound. To specify the mods field, in general, assign the modifiers of
+interest to <emphasis>
+mods.real_mods</emphasis>
+ and the virtual modifiers of interest to <emphasis>
+mods.vmods</emphasis>
+. You can disregard the <emphasis>
+mods.mask</emphasis>
+ field unless your application needs to interpret the indicator map directly
+(that is, to simulate automatic indicator behavior on its own). Relatively few
+applications need to do so, but if you find it necessary, you can either read
+the indicator map back from the server after you update it (the server
+automatically updates the mask field whenever any of the real or virtual
+modifiers are changed in the modifier definition) or you can use <emphasis>
+XkbVirtualModsToReal</emphasis>
+ to determine the proper contents for the mask field, assuming that the
+<emphasis>
+XkbDescRec</emphasis>
+ contains the virtual modifier definitions.
+</para>
+
+<para>
+<emphasis>
+which_mods</emphasis>
+ specifies what criteria Xkb uses to determine a match with the corresponding
+<emphasis>
+mods</emphasis>
+ field by specifying one or more components of the Xkb keyboard state. If
+<emphasis>
+XkbIM_NoAutomatic</emphasis>
+ is not set (the keyboard drives the indicator), the indicator is lit whenever
+any of the modifiers specified in the <emphasis>
+mask</emphasis>
+ field of the<emphasis>
+ mods</emphasis>
+ modifier definition are also set in any of the current keyboard state
+components specified by <emphasis>
+which_mods</emphasis>
+. Remember that the <emphasis>
+mask</emphasis>
+ field is comprised of all of the real modifiers specified in the definition
+plus any real modifiers that are bound to the virtual modifiers specified in
+the definition. (See Chapter 5 for more information on the keyboard state and <!-- xref -->
+Chapter 7 for more information on virtual modifiers.) Use a bitwise inclusive
+OR of the following values to compose a value for <emphasis>
+which_mods</emphasis>:
+</para>
+
+<para><programlisting>
+#define XkbIM_UseNone 0
+#define XkbIM_UseBase (1L &lt;&lt; 0)
+#define XkbIM_UseLatched (1L &lt;&lt; 1)
+#define XkbIM_UseLocked (1L &lt;&lt; 2)
+#define XkbIM_UseEffective (1L &lt;&lt; 3)
+#define XkbIM_UseCompat (1L &lt;&lt; 4)
+#define XkbIM_UseAnyMods XkbIM_UseBase | XkbIM_UseLatched |
+ XkbIM_UseLocked | XkbIM_UseEffective |
+ XkbIM_UseCompat
+</programlisting></para>
+
+<para>
+If <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ is not set (the keyboard drives the indicator), the effect of <emphasis>
+which_mods</emphasis>
+ and <emphasis>
+mods</emphasis>
+ is shown in Table 8.4 <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>XkbIndicatorMapRec which_mods and mods, Keyboard Drives Indicator</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>which_mods</entry>
+ <entry>Effect on Keyboard Modifiers</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbIM_UseNone</entry>
+ <entry>The mods field and the current keyboard modifier state are
+ignored.</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseBase</entry>
+ <entry>
+The indicator is lit when any of the modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are on in the keyboard base state. If both <emphasis>
+mods.real_mods</emphasis>
+ and <emphasis>
+mods.vmods</emphasis>
+ are zero, the indicator is lit when the base keyboard state contains no
+modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLatched</entry>
+ <entry>
+The indicator is lit when any of the modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are latched. If both <emphasis>
+mods.real_mods</emphasis>
+ and <emphasis>
+mods.vmods</emphasis>
+ are zero, the indicator is lit when none of the modifier keys are latched.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLocked</entry>
+ <entry>
+The indicator is lit when any of the modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are locked. If both <emphasis>
+mods.real_mods</emphasis>
+ and <emphasis>
+mods.vmods</emphasis>
+ are zero, the indicator is lit when none of the modifier keys are locked.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseEffective</entry>
+ <entry>
+The indicator is lit when any of the modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are in the effective keyboard state. If both <emphasis>
+mods.real_mods</emphasis>
+ and <emphasis>
+mods.vmods</emphasis>
+ are zero, the indicator is lit when the effective keyboard state contains no
+modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseCompat</entry>
+ <entry>
+The indicator is lit when any of the modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are in the keyboard compatibility state. If both <emphasis>
+mods.real_mods</emphasis>
+ and <emphasis>
+mods.vmods</emphasis>
+ are zero, the indicator is lit when the keyboard compatibility state contains
+no modifiers.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The effect on the keyboard modifiers of <emphasis>
+which_mods</emphasis>
+ and <emphasis>
+mods</emphasis>
+ when you change an indicator for which <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is set (the indicator drives the keyboard) is shown in Table 8.5. The "New
+State" column refers to the new state to which you set the indicator.
+</para> <!-- xref -->
+
+<table frame='none'>
+<title>XkbIndicatorMapRec which_mods and mods, Indicator Drives Keyboard</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>which_mods</entry>
+ <entry>New State</entry>
+ <entry>Effect on Keyboard Modifiers</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbIM_UseNone or XkbIM_UseBase</entry>
+ <entry>On or Off</entry>
+ <entry>No Effect</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLatched</entry>
+ <entry>On</entry>
+ <entry>
+Any modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are added to the latched modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLatched</entry>
+ <entry>Off</entry>
+ <entry>
+Any modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are removed from the latched modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLocked, XkbIM_UseCompat, or XkbIM_UseEffective</entry>
+ <entry>On</entry>
+ <entry>
+Any modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are added to the locked modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseLocked</entry>
+ <entry>Off</entry>
+ <entry>
+Any modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are removed from the locked modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIM_UseCompat or XkbIM_UseEffective</entry>
+ <entry>Off</entry>
+ <entry>
+Any modifiers specified in the <emphasis>
+mask</emphasis>
+ field of <emphasis>
+mods</emphasis>
+ are removed from both the locked and latched modifiers.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect3>
+<sect3 id='xkbindicatormaprec_ctrls_field'>
+<title>XkbIndicatorMapRec ctrls field</title>
+
+<para>
+The <emphasis>
+ctrls</emphasis>
+ field specifies what controls (see Chapter 10) the indicator watches and is
+composed using the bitwise inclusive OR of the following values:
+</para> <!-- xref -->
+
+<para><programlisting>
+#define XkbRepeatKeysMask (1L &lt;&lt; 0)
+#define XkbSlowKeysMask (1L &lt;&lt; 1)
+#define XkbBounceKeysMask (1L &lt;&lt; 2)
+#define XkbStickyKeysMask (1L &lt;&lt; 3)
+#define XkbMouseKeysMask (1L &lt;&lt; 4)
+#define XkbMouseKeysAccelMask (1L &lt;&lt; 5)
+#define XkbAccessXKeysMask (1L &lt;&lt; 6)
+#define XkbAccessXTimeoutMask (1L &lt;&lt; 7)
+#define XkbAccessXFeedbackMask (1L &lt;&lt; 8)
+#define XkbAudibleBellMask (1L &lt;&lt; 9)
+#define XkbOverlay1Mask (1L &lt;&lt; 10)
+#define XkbOverlay2Mask (1L &lt;&lt; 11)
+#define XkbAllBooleanCtrlsMask (0x00001FFF)
+</programlisting></para>
+
+<para>
+Xkb lights the indicator whenever any of the boolean controls specified in
+<emphasis>
+ctrls</emphasis>
+ is enabled.
+</para>
+
+
+</sect3>
+</sect2>
+</sect1>
+<sect1 id='getting_information_about_indicators'>
+<title>Getting Information About Indicators</title>
+
+<para>
+Xkb allows applications to obtain information about indicators using two
+different methods. The first method, which is similar to the core X
+implementation, uses a mask to specify the indicators. The second method, which
+is more suitable for applications concerned with interoperability, uses
+indicator names. The correspondence between the indicator name and the bit
+position in masks is as follows: one of the parameters returned from <emphasis>
+XkbGetNamedIndicators</emphasis>
+ is an index that is the bit position to use in any function call that requires
+a mask of indicator bits, as well as the indicator’s index into the <emphasis>
+XkbIndicatorRec</emphasis>
+ array of indicator maps.
+</para>
+
+
+<sect2 id='getting_indicator_state'>
+<title>Getting Indicator State</title>
+
+<para>
+Because the state of the indicators is relatively volatile, the keyboard
+description does not hold the current state of the indicators. To obtain the
+current state of the keyboard indicators, use <emphasis>
+XkbGetIndicatorState</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetIndicatorState</emphasis>
+(<emphasis>
+display</emphasis>
+, <emphasis>
+device_spec</emphasis>
+, <emphasis>
+state_return</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+state_return</emphasis>
+; /* backfilled with a mask of the indicator state */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetIndicatorState</emphasis>
+ queries the <emphasis>
+display</emphasis>
+ for the state of the indicators on the device specified by the <emphasis>
+device_spec</emphasis>
+. For each indicator that is "turned on" on the device, the associated bit is
+set in <emphasis>
+state_return</emphasis>
+. If a compatible version of the Xkb extension is not available in the server,
+<emphasis>
+XkbGetIndicatorState</emphasis>
+ returns a <emphasis>
+BadMatch</emphasis>
+ error. Otherwise, it sends the request to the X server, places the state of
+the indicators into <emphasis>
+state_return,</emphasis>
+ and returns <emphasis>
+Success</emphasis>
+. Thus the value reported by <emphasis>
+XkbGetIndicatorState</emphasis>
+ is identical to the value reported by the core protocol.
+</para>
+
+
+</sect2>
+<sect2 id='getting_indicator_information_by_index'>
+<title>Getting Indicator Information by Index</title>
+
+<para>
+To get the map for one or more indicators, using a mask to specify the
+indicators, use <emphasis>
+XkbGetIndicatorMap</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetIndicatorMap</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ which</emphasis>
+,<emphasis>
+ desc</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of indicators for which maps should be returned */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+desc</emphasis>
+; /* keyboard description to be updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetIndicatorMap</emphasis>
+ obtains the maps from the server for only those indicators specified by the
+<emphasis>
+which</emphasis>
+ mask and copies the values into the keyboard description specified by
+<emphasis>
+desc</emphasis>
+. If the <emphasis>
+indicators</emphasis>
+ field of the <emphasis>
+desc</emphasis>
+ parameter is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetIndicatorMap</emphasis>
+ allocates and initializes it.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetIndicatorMap</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadLength</emphasis>
+, <emphasis>
+BadMatch</emphasis>
+, and <emphasis>
+BadImplementation</emphasis>
+ errors.
+</para>
+
+
+<para>
+To free the indicator maps, use <emphasis>
+XkbFreeIndicatorMaps</emphasis>
+ (see section 8.6).
+</para>
+
+
+</sect2>
+<sect2 id='getting_indicator_information_by_name'>
+<title>Getting Indicator Information by Name</title>
+
+<para>
+Xkb also allows applications to refer to indicators by name. Use <emphasis>
+XkbGetNames</emphasis>
+ to get the indicator names (see Chapter 18). Using names eliminates the need
+for hard-coding bitmask values for particular keyboards. For example, instead
+of using vendor-specific constants such as <emphasis>
+WSKBLed_ScrollLock</emphasis>
+ mask on Digital workstations or <emphasis>
+XLED_SCROLL_LOCK</emphasis>
+ on Sun workstations, you can instead use <emphasis>
+XkbGetNamedIndicator</emphasis>
+ to look up information on the indicator named "Scroll Lock."
+</para>
+
+<para>
+Use <emphasis>
+XkbGetNamedIndicator</emphasis>
+ to look up the indicator map and other information for an indicator by name.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetNamedIndicator</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ dev_spec</emphasis>
+,<emphasis>
+ name</emphasis>
+,<emphasis>
+ ndx_rtrn</emphasis>
+,<emphasis>
+ state_rtrn</emphasis>
+,<emphasis>
+ map_rtrn</emphasis>
+, <emphasis>
+real_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ device_spec</emphasis>
+; /* keyboard device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+ name</emphasis>
+; /* name of the indicator to be retrieved */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+ndx_rtrn</emphasis>
+; /* backfilled with the index of the retrieved indicator */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool * <emphasis>
+state_rtrn</emphasis>
+; /* backfilled with the current state of the retrieved indicator */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbIndicatorMapPtr <emphasis>
+ map_rtrn</emphasis>
+; /* backfilled with the mapping for the retrieved indicator */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool * <emphasis>
+real_rtrn</emphasis>
+; /* backfilled with <emphasis>
+True</emphasis>
+ if the named indicator is real (physical) */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If the device specified by <emphasis>
+device_spec</emphasis>
+ has an indicator named <emphasis>
+name</emphasis>
+,<emphasis>
+ XkbGetNamedIndicator</emphasis>
+ returns <emphasis>
+True</emphasis>
+ and populates the rest of the parameters with information about the indicator.
+Otherwise, <emphasis>
+XkbGetNamedIndicator</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+ndx_rtrn</emphasis>
+ field returns the zero-based index of the named indicator. This index is the
+bit position to use in any function call that requires a mask of indicator
+bits, as well as the indicator’s index into the <emphasis>
+XkbIndicatorRec</emphasis>
+ array of indicator maps. <emphasis>
+state_rtrn</emphasis>
+ returns the current state of the named indicator (<emphasis>
+True</emphasis>
+ = on, <emphasis>
+False</emphasis>
+ = off). <emphasis>
+map_rtrn</emphasis>
+ returns the indicator map for the named indicator. In addition, if the
+indicator is mapped to a physical LED, the <emphasis>
+real_rtrn</emphasis>
+ parameter is set to <emphasis>
+True</emphasis>
+.
+</para>
+
+
+<para>
+Each of the "<emphasis>
+_rtrn</emphasis>
+" arguments is optional; you can pass <emphasis>
+NULL</emphasis>
+ for any unneeded "<emphasis>
+_rtrn</emphasis>
+" arguments.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetNamedIndicator</emphasis>
+ can generate <emphasis>
+BadAtom</emphasis>
+ and <emphasis>
+BadImplementation</emphasis>
+ errors.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='changing_indicator_maps_and_state'>
+<title>Changing Indicator Maps and State</title>
+
+<para>
+Just as you can get the indicator map using a mask or using an indicator name,
+so you can change it using a mask or a name.
+</para>
+
+<note><para>You cannot change the <emphasis>
+phys_indicators</emphasis>
+ field of the indicators structure. The only way to change the <emphasis>
+phys_indicators</emphasis>
+ field is to change the keyboard map.</para></note>
+
+<para>
+There are two ways to make changes to indicator maps and state: either change a
+local copy of the indicator maps and use <emphasis>
+XkbSetIndicatorMap</emphasis>
+ or <emphasis>
+XkbSetNamedIndicator</emphasis>
+, or, to reduce network traffic, use an<emphasis>
+ XkbIndicatorChangesRec</emphasis>
+ structure and use <emphasis>
+XkbChangeIndicators</emphasis>.
+</para>
+
+
+<sect2 id='effects_of_explicit_changes_on_indicators'>
+<title>Effects of Explicit Changes on Indicators</title>
+
+<para>
+This section discusses the effects of explicitly changing indicators depending
+upon different settings in the indicator map. See Tables 8.3 and Table 8.5 for
+information on the effects of the indicator map fields when explicit changes
+are made.
+</para>
+
+
+<para>
+If <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is set and <emphasis>
+XkbIM_NoExplicit</emphasis>
+ is not, and if you call a function that updates the server’s image of the
+indicator map (such as <emphasis>
+XkbSetIndicatorMap</emphasis>
+ or <emphasis>
+XkbSetNamedIndicator</emphasis>
+), Xkb changes the keyboard state and controls to reflect the other fields of
+the indicator map. If you attempt to explicitly change the value of an
+indicator for which <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is absent or for which <emphasis>
+XkbIM_NoExplicit</emphasis>
+ is present, keyboard state or controls are unaffected.
+</para>
+
+
+<para>
+If neither <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ nor <emphasis>
+XkbIM_NoExplicit</emphasis>
+ is set in an indicator map, Xkb honors any request to change the state of the
+indicator, but the new state might be immediately superseded by automatic
+changes to the indicator state if the keyboard state or controls change.
+</para>
+
+
+<para>
+The effects of changing an indicator that drives the keyboard are cumulative;
+it is possible for a single change to affect keyboard group, modifiers, and
+controls simultaneously.
+</para>
+
+
+<para>
+If you change an indicator for which both the <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ and <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ flags are specified, Xkb applies the keyboard changes specified in the other
+indicator map fields and changes the indicator to reflect the state that was
+explicitly requested. The indicator remains in the new state until it is
+explicitly changed again.
+</para>
+
+
+<para>
+If the <emphasis>
+XkbIM_NoAutomatic</emphasis>
+ flag is not set and <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is set, Xkb applies the changes specified in the other indicator map fields
+and sets the state of the indicator to the values specified by the indicator
+map. Note that it is possible in this case for the indicator to end up in a
+different state than the one that was explicitly requested. For example, Xkb
+does not extinguish an indicator with <emphasis>
+which_mods</emphasis>
+ of <emphasis>
+XkbIM_UseBase</emphasis>
+ and <emphasis>
+mods</emphasis>
+ of <emphasis>
+Shift</emphasis>
+ if, at the time Xkb processes the request to extinguish the indicator, one of
+the <emphasis>
+Shift</emphasis>
+ keys is physically depressed.
+</para>
+
+
+<para>
+If you explicitly light an indicator for which <emphasis>
+XkbIM_LEDDrivesKB</emphasis>
+ is set, Xkb enables all of the boolean controls specified in the <emphasis>
+ctrls</emphasis>
+ field of its indicator map. Explicitly extinguishing such an indicator causes
+Xkb to disable all of the boolean controls specified in <emphasis>
+ctrls</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='changing_indicator_maps_by_index'>
+<title>Changing Indicator Maps by Index</title>
+
+<para>
+To update the maps for one or more indicators, first modify a local copy of the
+keyboard description, then use <emphasis>
+XkbSetIndicatorMap</emphasis>
+ to download the changes to the server:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool<emphasis>
+ XkbSetIndicatorMap</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ which</emphasis>
+,<emphasis>
+ desc</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of indicators to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+desc</emphasis>
+; /* keyboard description from which the maps are taken */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+For each<emphasis>
+ </emphasis>
+bit set in the <emphasis>
+which </emphasis>
+parameter,<emphasis>
+ XkbSetIndicatorMap</emphasis>
+ sends the corresponding indicator map from the <emphasis>
+desc</emphasis>
+ parameter to the server.
+</para>
+
+
+</sect2>
+<sect2 id='changing_indicator_maps_by_name'>
+<title>Changing Indicator Maps by Name</title>
+
+<para>
+<emphasis>
+XkbSetNamedIndicator</emphasis>
+ can do several related things:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Name an indicator if it is not already named
+ </para>
+</listitem>
+<listitem>
+ <para>
+Toggle the state of the indicator
+ </para>
+</listitem>
+<listitem>
+ <para>
+Set the indicator to a specified state
+ </para>
+</listitem>
+<listitem>
+ <para>
+Set the indicator map for the indicator
+ </para>
+</listitem>
+</itemizedlist>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool<emphasis>
+ XkbSetNamedIndicator</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ name</emphasis>
+,<emphasis>
+ change_state, state</emphasis>
+,<emphasis>
+ create_new</emphasis>
+,<emphasis>
+ map</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+ name</emphasis>
+; /* name of the indicator to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ change_state</emphasis>
+; /* whether to change the indicator state or not */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ state</emphasis>
+; /* desired new state for the indicator */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+create_new</emphasis>
+; /* whether a new indicator with the specified name should be
+created when necessary */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbIndicatorMapPtr <emphasis>
+map</emphasis>
+; /* new map for the indicator */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If a compatible version of the Xkb extension is not available in the server,
+<emphasis>
+XkbSetNamedIndicator</emphasis>
+ returns <emphasis>
+False</emphasis>
+. Otherwise, it sends a request to the X server to change the indicator
+specified by <emphasis>
+name</emphasis>
+ and returns <emphasis>
+True</emphasis>.
+</para>
+
+
+<para>
+If <emphasis>
+change_state</emphasis>
+ is <emphasis>
+True</emphasis>
+, and the optional parameter, <emphasis>
+state</emphasis>
+, is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbSetNamedIndicator</emphasis>
+ tells the server to change the state of the named indicator to the value
+specified by <emphasis>
+state</emphasis>.
+</para>
+
+
+<para>
+If an indicator with the name specified by <emphasis>
+name</emphasis>
+ does not already exist, the <emphasis>
+create_new</emphasis>
+ parameter tells the server whether it should create a new named indicator. If
+<emphasis>
+create_new</emphasis>
+ is <emphasis>
+True</emphasis>
+, the server finds the first indicator that doesn’t have a name and gives it
+the name specified by <emphasis>
+name</emphasis>.
+</para>
+
+
+<para>
+If the optional parameter, <emphasis>
+map</emphasis>
+, is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbSetNamedIndicator</emphasis>
+ tells the server to change the indicator’s map to the values specified
+in <emphasis>map</emphasis>.
+</para>
+
+<para>
+<emphasis>
+XkbSetNamedIndicator</emphasis>
+ can generate <emphasis>
+BadAtom</emphasis>
+ and <emphasis>
+BadImplementation</emphasis>
+ errors. In addition, it can also generate <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ (see section 8.5), <emphasis> <!-- xref -->
+XkbIndicatorMapNotify</emphasis>
+, and <emphasis>
+XkbNamesNotify</emphasis>
+ events (see section 18.5). <!-- xref -->
+</para>
+
+
+</sect2>
+<sect2 id='the_xkbindicatorchangesrec_structure'>
+<title>The XkbIndicatorChangesRec Structure</title>
+
+<para>
+The <emphasis>
+XkbIndicatorChangesRec</emphasis>
+ identifies small modifications to the indicator map. Use it with the function
+<emphasis>
+XkbChangeIndicators</emphasis>
+ to reduce the amount of traffic sent to the server.
+</para>
+
+<para><programlisting>
+typedef struct _XkbIndicatorChanges {
+ unsigned int state_changes;
+ unsigned int map_changes;
+}<emphasis>
+XkbIndicatorChangesRec</emphasis>,*XkbIndicatorChangesPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+state_changes</emphasis>
+ field is a mask that specifies the indicators that have changed state, and
+<emphasis>
+map_changes</emphasis>
+ is a mask that specifies the indicators whose maps have changed.
+</para>
+
+
+<para>
+To change indicator maps or state without passing the entire keyboard
+description, use <emphasis>
+XkbChangeIndicators</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbChangeIndicators</emphasis>
+(<emphasis>
+dpy, xkb, changes, state</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description from which names are to be
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+ taken. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbIndicatorChangesPtr <emphasis>
+changes</emphasis>
+; /* indicators to be updated on the server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+state</emphasis>
+; /* new state of indicators listed in
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+<emphasis>
+ changes</emphasis>
+-&gt;<emphasis>
+state_changes</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbChangeIndicators</emphasis>
+ copies any maps specified by <emphasis>
+changes</emphasis>
+ from the keyboard description, <emphasis>
+xkb</emphasis>
+, to the server specified by <emphasis>
+dpy</emphasis>
+. If any bits are set in the <emphasis>
+state_changes</emphasis>
+ field of <emphasis>
+changes</emphasis>
+, <emphasis>
+XkbChangeIndicators</emphasis>
+ also sets the state of those indicators to the values specified in the
+<emphasis>
+state</emphasis>
+ mask. A 1 bit in <emphasis>
+state</emphasis>
+ turns the corresponding indicator on, a 0 bit turns it off.
+</para>
+
+
+<para>
+<emphasis>
+XkbChangeIndicator</emphasis>
+s can generate <emphasis>
+BadAtom</emphasis>
+ and <emphasis>
+BadImplementation</emphasis>
+ errors. In addition, it can also generate <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ and <emphasis>
+XkbIndicatorMapNotify</emphasis>
+ events (see section 8.5). <!-- xref -->
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='tracking_changes_to_indicator_state_or_map'>
+<title>Tracking Changes to Indicator State or Map</title>
+
+<para>
+Whenever an indicator changes state, the server sends <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ events to all interested clients. Similarly, whenever an indicator’s map
+changes, the server sends <emphasis>
+XkbIndicatorMapNotify</emphasis>
+ events to all interested clients.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ events, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) with both the <emphasis> <!-- xref -->
+bits_to_change </emphasis>
+and<emphasis>
+ values_for_bits</emphasis>
+ parameters containing <emphasis>
+XkbIndicatorStateNotifyMask</emphasis>
+. To receive <emphasis>
+XkbIndicatorMapNotify</emphasis>
+ events, use <emphasis>
+XkbSelectEvents</emphasis>
+ with <emphasis>
+XkbIndicatorMapNotifyMask</emphasis>
+.
+</para>
+
+
+<para>
+To receive events for only specific indicators, use <emphasis>
+XkbSelectEventDetails</emphasis>
+. Set the <emphasis>
+event_type</emphasis>
+ parameter<emphasis>
+ to XkbIndicatorStateNotify</emphasis>
+ or <emphasis>
+XkbIndicatorMapNotify</emphasis>
+, and set both the <emphasis>
+bits_to_change </emphasis>
+and<emphasis>
+ values_for_bits</emphasis>
+ detail parameters to a mask where each bit specifies one indicator, turning on
+those bits that specify the indicators for which you want to receive events.
+</para>
+
+
+<para>
+Both types of indicator events use the same structure:
+</para>
+
+<para><programlisting>
+typedef struct _XkbIndicatorNotify {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis> True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* specifies state or map notify */
+ int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
+ unsigned int changed; /* mask of indicators with new state or map */
+ unsigned int state; /* current state of all indicators */
+} <emphasis>XkbIndicatorNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+<emphasis>
+xkb_type</emphasis>
+ is either <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ or <emphasis>
+XkbIndicatorMapNotify</emphasis>
+, depending on whether the event is a <emphasis>
+kbIndicatorStateNotify</emphasis>
+ event or <emphasis>
+kbIndicatorMapNotify</emphasis>
+ event.
+</para>
+
+<para>
+The <emphasis>
+changed</emphasis>
+ parameter is a mask that is the bitwise inclusive OR of the indicators that
+have changed. If the event is of type <emphasis>
+XkbIndicatorMapNotify</emphasis>
+, <emphasis>
+changed</emphasis>
+ reports the maps that changed. If the event is of type <emphasis>
+XkbIndicatorStateNotify</emphasis>
+, <emphasis>
+changed</emphasis>
+ reports the indicators that have changed state. <emphasis>
+state</emphasis>
+ is a mask that specifies the current state of all indicators, whether they
+have changed or not, for both <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ and <emphasis>IndicatorMapNotify</emphasis> events.
+</para>
+
+<para>
+When your client application receives either a <emphasis>
+XkbIndicatorStateNotify</emphasis>
+ event or <emphasis>
+XkbIndicatorMapNotify</emphasis>
+ event, you can note the changes in a changes structure by calling <emphasis>
+XkbNoteIndicatorChanges</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbNoteIndicatorChanges</emphasis>
+(<emphasis>
+old</emphasis>
+,<emphasis>
+ new</emphasis>
+,<emphasis>
+ wanted</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbIndicatorChangesPtr <emphasis>
+ old</emphasis>
+; /* XkbIndicatorChanges structure to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbIndicatorNotifyEvent * <emphasis>
+new</emphasis>
+; /* event from which changes are to be copied */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ wanted</emphasis>
+; /* which changes are to be noted */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+wanted</emphasis>
+ parameter is the bitwise inclusive OR of <emphasis>
+XkbIndicatorMapMask</emphasis>
+ and <emphasis>
+XkbIndicatorStateMask</emphasis>
+. <emphasis>
+XkbNoteIndicatorChanges</emphasis>
+ copies any changes reported in <emphasis>
+new</emphasis>
+ and specified in <emphasis>
+wanted</emphasis>
+ into the changes record specified by <emphasis>
+old</emphasis>.
+</para>
+
+
+<para>
+To update a local copy of the keyboard description with the actual values, pass
+the results of one or more calls to <emphasis>
+XkbNoteIndicatorChanges</emphasis>
+ to <emphasis>
+XkbGetIndicatorChanges</emphasis>:
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetIndicatorChanges</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ xkb</emphasis>
+,<emphasis>
+ changes</emphasis>
+,<emphasis>
+ state</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description to hold the new values */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbIndicatorChangesPtr <emphasis>
+changes</emphasis>
+; /* indicator maps/state to be obtained from the server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+state</emphasis>
+; /* backfilled with the state of the indicators */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetIndicatorChanges</emphasis>
+ examines the <emphasis>
+changes</emphasis>
+ parameter, pulls over the necessary information from the server, and copies
+the results into the <emphasis>
+xkb</emphasis>
+ keyboard description. If any bits are set in the <emphasis>
+state_changes</emphasis>
+ field of <emphasis>
+changes</emphasis>
+, <emphasis>
+XkbGetIndicatorChanges</emphasis>
+ also places the state of those indicators in <emphasis>
+state</emphasis>
+. If the <emphasis>
+indicators</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetIndicatorChanges</emphasis>
+ allocates and initializes it. To free the <emphasis>
+indicators</emphasis>
+ field, use <emphasis>
+XkbFreeIndicators</emphasis>
+ (see section 8.6). <!-- xref -->
+</para>
+
+
+<para>
+<emphasis>
+XkbGetIndicatorChanges</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadImplementation,</emphasis>
+ and <emphasis>
+BadMatch</emphasis>
+ errors.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_indicator_maps'>
+<title>Allocating and Freeing Indicator Maps</title>
+
+<para>
+Most applications do not need to directly allocate the <emphasis>
+indicators</emphasis>
+ member of the keyboard description record (the keyboard description record is
+described in Chapter 6). If the need arises, however, use <emphasis>
+XkbAllocIndicatorMaps.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocIndicatorMaps</emphasis>
+(<emphasis>
+xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description structure */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+xkb</emphasis>
+ parameter must point to a valid keyboard description. If it doesn’t,
+<emphasis>
+XkbAllocIndicatorMaps</emphasis>
+ returns a <emphasis>
+BadMatch</emphasis>
+ error. Otherwise, <emphasis>
+XkbAllocIndicatorMaps</emphasis>
+ allocates and initializes the <emphasis>
+indicators</emphasis>
+ member of the keyboard description record and returns <emphasis>
+Success</emphasis>
+. If <emphasis>
+XkbAllocIndicatorMaps</emphasis>
+ was unable to allocate the indicators record, it reports a Bad<emphasis>
+Alloc</emphasis>
+ error.
+</para>
+
+<para>
+To free memory used by the <emphasis>
+indicators</emphasis>
+ member of an <emphasis>
+XkbDescRec</emphasis>
+ structure, use <emphasis>
+XkbFreeIndicatorMaps.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeIndicatorMaps</emphasis>
+(<emphasis>
+xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description structure */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If the <emphasis>indicators</emphasis>
+ member of the keyboard description record
+pointed to by <emphasis>xkb</emphasis>
+is not <emphasis>NULL</emphasis>
+, <emphasis>XkbFreeIndicatorMaps</emphasis>
+frees the memory associated with
+the <emphasis>indicators</emphasis>
+member of <emphasis>xkb</emphasis>.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch09.xml b/specs/XKB/ch09.xml
new file mode 100644
index 00000000..d04669a1
--- /dev/null
+++ b/specs/XKB/ch09.xml
@@ -0,0 +1,1060 @@
+<chapter id='bells'>
+<title>Bells</title>
+
+<para>
+The core X protocol allows only applications to explicitly sound the system
+bell with a given duration, pitch, and volume. Xkb extends this capability by
+allowing clients to attach symbolic names to bells, disable audible bells, and
+receive an event whenever the keyboard bell is rung. For the purposes of this
+document, the <emphasis>
+audible</emphasis>
+ bell is defined to be the system bell, or the default keyboard bell, as
+opposed to any other audible sound generated elsewhere in the system.
+</para>
+
+
+<para>
+You can ask to receive <emphasis>
+XkbBellNotify</emphasis>
+ events (see section 9.4) when any client rings any one of the following: <!-- xref -->
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The default bell
+ </para>
+</listitem>
+<listitem>
+ <para>
+Any bell on an input device that can be specified by a <emphasis>
+bell_class</emphasis>
+ and <emphasis>
+bell_id</emphasis>
+ pair
+ </para>
+</listitem>
+<listitem>
+ <para>
+Any bell specified only by an arbitrary name. (This is, from the server’s
+point of view, merely a name, and not connected with any physical
+sound-generating device. Some client application must generate the sound, or
+visual feedback, if any, that is associated with the name.)
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+You can also ask to receive <emphasis>
+XkbBellNotify</emphasis>
+ events when the server rings the default bell or if any client has requested
+events only (without the bell sounding) for any of the bell types previously
+listed.
+</para>
+
+<para>
+You can disable audible bells on a global basis (to set the <emphasis>
+AudibleBell</emphasis>
+ control, see Chapter 10). For example, a client that replaces the keyboard
+bell with some other audible cue might want to turn off the <emphasis>
+AudibleBell</emphasis>
+ control to prevent the server from also generating a sound and avoid
+cacophony. If you disable audible bells and request to receive <emphasis>
+XkbBellNotify</emphasis>
+ events, you can generate feedback different from the default bell.
+</para>
+
+
+<para>
+You can, however, override the <emphasis>
+AudibleBell</emphasis>
+ control by calling one of the functions that force the ringing of a bell in
+spite of the setting of the <emphasis>
+AudibleBell</emphasis>
+ control — <emphasis>
+XkbForceDeviceBell</emphasis>
+ or <emphasis>
+XkbForceBell</emphasis>
+ (see section 9.3.3). In this case the server does not generate a bell event. <!-- xref -->
+</para>
+
+
+<para>
+Just as some keyboards can produce keyclicks to indicate when a key is pressed
+or repeating, Xkb can provide feedback for the controls by using special beep
+codes. The <emphasis>
+AccessXFeedback</emphasis>
+ control is used to configure the specific types of operations that generate
+feedback. See section 10.6.3 for a discussion on <emphasis> <!-- xref -->
+AccessXFeedback</emphasis>
+ control.
+</para>
+
+<para>
+This chapter describes bell names, the functions used to generate named bells,
+and the events the server generates for bells.
+</para>
+
+<sect1 id='bell_names'>
+<title>Bell Names</title>
+
+<para>
+You can associate a name to an act of ringing a bell by converting the name to
+an Atom and then using this name when you call the functions listed in this
+chapter. If an event is generated as a result, the name is then passed to all
+other clients interested in receiving <emphasis>
+XkbBellNotify</emphasis>
+ events. Note that these are arbitrary names and that there is no binding to
+any sounds. Any sounds or other effects (such as visual bells on the screen)
+must be generated by a client application upon receipt of the bell event
+containing the name. There is no default name for the default keyboard bell.
+The server does generate some predefined bells for the AccessX controls (see
+section 10.6.3). These named bells are shown in Table 9.1; the name is included
+in any bell event sent to clients that have requested to receive <emphasis>
+XkbBellNotify</emphasis>
+ events.
+</para>
+
+<table frame='none'>
+<title>Predefined Bells</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Action</entry>
+ <entry>Named Bell</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>Indicator turned on</entry>
+ <entry>AX_IndicatorOn</entry>
+</row>
+<row rowsep='0'>
+ <entry>Indicator turned off</entry>
+ <entry>AX_IndicatorOff</entry>
+</row>
+<row rowsep='0'>
+ <entry>More than one indicator changed state</entry>
+ <entry>AX_IndicatorChange</entry>
+</row>
+<row rowsep='0'>
+ <entry>Control turned on</entry>
+ <entry>AX_FeatureOn</entry>
+</row>
+<row rowsep='0'>
+ <entry>Control turned off</entry>
+ <entry>AX_FeatureOff</entry>
+</row>
+<row rowsep='0'>
+ <entry>More than one control changed state</entry>
+ <entry>AX_FeatureChange</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys and BounceKeys about to be turned on or off</entry>
+ <entry>AX_SlowKeysWarning</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys key pressed</entry>
+ <entry>AX_SlowKeyPress</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys key accepted</entry>
+ <entry>AX_SlowKeyAccept</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys key rejected</entry>
+ <entry>AX_SlowKeyReject</entry>
+</row>
+<row rowsep='0'>
+ <entry>Accepted SlowKeys key released</entry>
+ <entry>AX_SlowKeyRelease</entry>
+</row>
+<row rowsep='0'>
+ <entry>BounceKeys key rejected</entry>
+ <entry>AX_BounceKeyReject</entry>
+</row>
+<row rowsep='0'>
+ <entry>StickyKeys key latched</entry>
+ <entry>AX_StickyLatch</entry>
+</row>
+<row rowsep='0'>
+ <entry>StickyKeys key locked</entry>
+ <entry>AX_StickyLock</entry>
+</row>
+<row rowsep='0'>
+ <entry>StickyKeys key unlocked</entry>
+ <entry>AX_StickyUnlock</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+<sect1 id='audible_bells'>
+<title>Audible Bells</title>
+
+<para>
+Using Xkb you can generate bell events that do not necessarily ring the system
+bell. This is useful if you need to use an audio server instead of the system
+beep. For example, when an audio client starts, it could disable the audible
+bell (the system bell) and then listen for <emphasis>
+XkbBellNotify</emphasis>
+ events (see section 9.4). When it receives a <emphasis> <!-- xref -->
+XkbBellNotify</emphasis>
+ event, the audio client could then send a request to an audio server to play a
+sound.
+</para>
+
+
+<para>
+You can control the audible bells feature by passing the <emphasis>
+XkbAudibleBellMask</emphasis>
+ to <emphasis>
+XkbChangeEnabledControls</emphasis>
+ (see section 10.1.1). If you set <emphasis> <!-- xref -->
+XkbAudibleBellMask</emphasis>
+ on, the server rings the system bell when a bell event occurs. This is the
+default. If you set <emphasis>
+XkbAudibleBellMask</emphasis>
+ off and a bell event occurs, the server does not ring the system bell unless
+you call <emphasis>
+XkbForceDeviceBell</emphasis>
+ or <emphasis>
+XkbForceBell</emphasis>
+ (see section 9.3.3). <!-- xref -->
+</para>
+
+<para>
+Audible bells are also part of the per-client auto-reset controls. For more
+information on auto-reset controls, see section 10.1.2. <!-- xref -->
+</para>
+
+</sect1>
+<sect1 id='bell_functions'>
+<title>Bell Functions</title>
+
+<para>
+Use the functions described in this section to ring bells and to generate bell
+events.
+</para>
+
+<para>
+The input extension has two types of feedbacks that can generate bells — bell
+feedback and keyboard feedback. Some of the functions in this section have
+<emphasis>
+bell_class</emphasis>
+ and <emphasis>
+bell_id</emphasis>
+ parameters; set them as follows: Set <emphasis>
+bell_class</emphasis>
+ to <emphasis>
+BellFeedbackClass</emphasis>
+ or <emphasis>
+KbdFeedbackClass</emphasis>
+. A device can have more than one feedback of each type; set <emphasis>
+bell_id</emphasis>
+ to the particular bell feedback of <emphasis>
+bell_class</emphasis>
+ type.
+</para>
+
+<para>
+Table 9.2 shows the conditions that cause a bell to sound or an <emphasis> <!-- xref -->
+XkbBellNotifyEvent</emphasis>
+ to be generated when a bell function is called.
+</para>
+
+<table frame='none'>
+<title>Bell Sounding and Bell Event Generating</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+ <row rowsep='0'>
+ <entry>Function called</entry>
+ <entry>AudibleBell</entry>
+ <entry>Server sounds a bell</entry>
+ <entry>Server sends an XkbBellNotifyEvent</entry>
+ </row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbDeviceBell</entry>
+ <entry>On</entry>
+ <entry>Yes</entry>
+ <entry>Yes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbDeviceBell</entry>
+ <entry>Off</entry>
+ <entry>No</entry>
+ <entry>Yes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbBell</entry>
+ <entry>On</entry>
+ <entry>Yes</entry>
+ <entry>Yes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbBell</entry>
+ <entry>Off</entry>
+ <entry>No</entry>
+ <entry>Yes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbDeviceBellEvent</entry>
+ <entry>On or Off</entry>
+ <entry>No</entry>
+ <entry>Yes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbBellEvent</entry>
+ <entry>On or Off</entry>
+ <entry>No</entry>
+ <entry>Yes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbDeviceForceBell</entry>
+ <entry>On or Off</entry>
+ <entry>Yes</entry>
+ <entry>No</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbForceBell</entry>
+ <entry>On or Off</entry>
+ <entry>Yes</entry>
+ <entry>No</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<sect2 id='generating_named_bells'>
+<title>Generating Named Bells</title>
+
+<para>
+To ring the bell on an X input extension device or the default keyboard, use
+<emphasis>
+XkbDeviceBell.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbDeviceBell</emphasis>
+(<emphasis>
+display, window, device_id, bell_class, bell_id, percent, name</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Window<emphasis>
+ window</emphasis>
+; /* window for which the bell is generated, or None */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+bell_class</emphasis>
+; /* X input extension bell class of the bell to be rung */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+bell_id</emphasis>
+; /* X input extension bell ID of the bell to be rung */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+percent</emphasis>
+; /* bell volume, from -100 to 100 inclusive */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+name</emphasis>
+; /* a name for the bell, or <emphasis>
+NULL</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+Set <emphasis>
+percent</emphasis>
+ to be the volume relative to the base volume for the keyboard as described for
+<emphasis>
+XBell</emphasis>.
+</para>
+
+<para>
+Note that <emphasis>
+bell_class</emphasis>
+ and <emphasis>
+bell_id</emphasis>
+ indicate the bell to physically ring. <emphasis>
+name</emphasis>
+ is simply an arbitrary moniker for the client application’s use.
+</para>
+
+<para>
+To determine the current feedback settings of an extension input device, use
+<emphasis>
+XGetFeedbackControl</emphasis>
+. See the X input extension documentation for more information on <emphasis>
+XGetFeedbackControl</emphasis>
+ and related data structures.
+</para>
+
+<para>
+If a compatible keyboard extension is not present in the X server, <emphasis>
+XkbDeviceBell</emphasis>
+ immediately returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbDeviceBell </emphasis>
+rings the bell as specified for the display and keyboard device and returns
+<emphasis>
+True</emphasis>
+. If you have disabled the audible bell, the server does not ring the system
+bell, although it does generate a <emphasis>
+XkbBellNotify</emphasis>
+ event.
+</para>
+
+<para>
+You can call <emphasis>
+XkbDeviceBell</emphasis>
+ without first initializing the keyboard extension.
+</para>
+
+<para>
+As a convenience function, Xkb provides a function to ring the bell on the
+default keyboard: <emphasis>
+XkbBell.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbBell</emphasis>
+(<emphasis>
+display, window, percent, name</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Window<emphasis>
+ window</emphasis>
+; /* event window, or None*/
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int<emphasis>
+ percent</emphasis>
+; /* relative volume, which can range from -100 to 100 inclusive */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom<emphasis>
+ name</emphasis>
+; /* a bell name, or <emphasis>
+NULL</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If a compatible keyboard extension isn’t present in the X server, <emphasis>
+XkbBell</emphasis>
+ calls <emphasis>
+XBell </emphasis>
+with the specified <emphasis>
+display</emphasis>
+ and <emphasis>
+percent</emphasis>
+, and returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbBell </emphasis>
+calls <emphasis>
+XkbDeviceBell</emphasis>
+ with the specified <emphasis>
+display, window, percent, </emphasis>
+and <emphasis>
+name</emphasis>
+, a <emphasis>
+device_spec</emphasis>
+ of <emphasis>
+XkbUseCoreKbd</emphasis>
+, a <emphasis>
+bell_class </emphasis>
+of <emphasis>
+XkbDfltXIClass</emphasis>
+, and a <emphasis>
+bell_id </emphasis>
+of <emphasis>
+XkbDfltXIId,</emphasis>
+ and returns <emphasis>
+True</emphasis>.
+</para>
+
+<para>
+If you have disabled the audible bell, the server does not ring the system
+bell, although it does generate a <emphasis>
+XkbBellNotify</emphasis>
+ event.
+</para>
+
+<para>
+You can call <emphasis>
+XkbBell</emphasis>
+ without first initializing the keyboard extension.
+</para>
+
+</sect2>
+<sect2 id='generating_named_bell_events'>
+<title>Generating Named Bell Events</title>
+
+<para>
+Using Xkb, you can also generate a named bell event that does not ring any
+bell. This allows you to do things such as generate events when your
+application starts.
+</para>
+
+<para>
+For example, if an audio client listens for these types of bells, it can
+produce a "whoosh" sound when it receives a named bell event to indicate a
+client just started. In this manner, applications can generate start-up
+feedback and not worry about producing annoying beeps if an audio server is not
+running.
+</para>
+
+
+<para>
+To cause a bell event for an X input extension device or for the keyboard,
+without ringing the corresponding bell, use <emphasis>
+XkbDeviceBellEvent.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbDeviceBellEvent</emphasis>
+(<emphasis>
+display, window, device_spec, bell_class, bell_id, percent, name</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Window <emphasis>
+window</emphasis>
+; /* event window, or None*/
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+bell_class;</emphasis>
+ /* input extension bell class for the event */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+bell_id</emphasis>
+; /* input extension bell ID for the event */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+percent</emphasis>
+; /* volume for the bell, which can range from -100 to 100 inclusive */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+name</emphasis>
+; /* a bell name, or <emphasis>
+NULL</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If a compatible keyboard extension isn’t present in the X server, <emphasis>
+XkbDeviceBellEvent</emphasis>
+ immediately returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbDeviceBellEvent</emphasis>
+ causes an <emphasis>
+XkbBellNotify</emphasis>
+ event to be sent to all interested clients and returns <emphasis>
+True</emphasis>
+. Set <emphasis>
+percent</emphasis>
+ to be the volume relative to the base volume for the keyboard as described for
+<emphasis>XBell</emphasis>.
+</para>
+
+
+<para>
+In addition, <emphasis>
+XkbDeviceBellEvent</emphasis>
+ may generate <emphasis>
+Atom</emphasis>
+ protocol errors as well as <emphasis>
+XkbBellNotify</emphasis>
+ events. You can call <emphasis>
+XkbBell</emphasis>
+ without first initializing the keyboard extension.
+</para>
+
+
+<para>
+As a convenience function, Xkb provides a function to cause a bell event for
+the keyboard without ringing the bell: <emphasis>
+XkbBellEvent.</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbBellEvent</emphasis>
+(<emphasis>
+display, window, percent, name</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Window <emphasis>
+window</emphasis>
+; /* the event window, or None */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+percent</emphasis>
+; /* relative volume, which can range from -100 to 100 inclusive */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+name</emphasis>
+; /* a bell name, or <emphasis>
+NULL</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If a compatible keyboard extension isn’t present in the X server, <emphasis>
+XkbBellEvent</emphasis>
+ immediately returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbBellEvent </emphasis>
+calls<emphasis>
+ XkbDeviceBellEvent</emphasis>
+ with the specified <emphasis>
+display, window, percent, </emphasis>
+and <emphasis>
+name</emphasis>
+, a <emphasis>
+device_spec</emphasis>
+ of <emphasis>
+XkbUseCoreKbd</emphasis>
+, a <emphasis>
+bell_class </emphasis>
+of <emphasis>
+XkbDfltXIClass</emphasis>
+, and a <emphasis>
+bell_id </emphasis>
+of <emphasis>
+XkbDfltXIId,</emphasis>
+ and returns what <emphasis>
+XkbDeviceBellEvent</emphasis>
+ returns.
+</para>
+
+<para>
+<emphasis>XkbBellEvent</emphasis>
+generates a <emphasis>XkbBellNotify</emphasis>
+event.
+</para>
+
+
+<para>
+You can call <emphasis>
+XkbBellEvent</emphasis>
+without first initializing the keyboard extension.
+</para>
+
+</sect2>
+<sect2 id='forcing_a_server_generated_bell'>
+<title>Forcing a Server-Generated Bell</title>
+
+<para>
+To ring the bell on any keyboard, overriding user preference settings for
+audible bells, use <emphasis>XkbForceDeviceBell</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbForceDeviceBell</emphasis>
+(<emphasis>
+display, window, device_spec, bell_class, bell_id, percent</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Window <emphasis>
+window</emphasis>
+; /* event window, or None */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+bell_class</emphasis>
+; /* input extension class of the bell to be rung */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+bell_id</emphasis>
+; /* input extension ID of the bell to be rung */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+percent</emphasis>
+; /* relative volume, which can range from -100 to 100 inclusive */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If a compatible keyboard extension isn’t present in the X server, <emphasis>
+XkbForceDeviceBell</emphasis>
+ immediately returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbForceDeviceBell </emphasis>
+rings the bell as specified for the display and keyboard device and returns
+<emphasis>
+True</emphasis>
+. Set <emphasis>
+percent</emphasis>
+ to be the volume relative to the base volume for the keyboard as described for
+<emphasis>
+XBell</emphasis>
+. There is no <emphasis>
+name</emphasis>
+ parameter because <emphasis>
+XkbForceDeviceBell </emphasis>
+does not cause an <emphasis>
+XkbBellNotify</emphasis>
+ event.
+</para>
+
+<para>
+You can call <emphasis>
+XkbBell</emphasis>
+ without first initializing the keyboard extension.
+</para>
+
+<para>
+To ring the bell on the default keyboard, overriding user preference settings
+for audible bells, use <emphasis>
+XkbForceBell</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbForceBell</emphasis>
+(<emphasis>
+display, percent)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+percent</emphasis>
+; /* volume for the bell, which can range from -100 to 100 inclusive */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If a compatible keyboard extension isn’t present in the X server, <emphasis>
+XkbForceBell</emphasis>
+ calls <emphasis>
+XBell </emphasis>
+with the specified <emphasis>
+display</emphasis>
+ and <emphasis>
+percent</emphasis>
+ and returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbForceBell </emphasis>
+calls <emphasis>
+XkbForceDeviceBell</emphasis>
+ with the specified <emphasis>
+display </emphasis>
+and<emphasis>
+ percent</emphasis>
+, <emphasis>
+device_spec</emphasis>
+ =<emphasis>
+XkbUseCoreKbd</emphasis>
+, <emphasis>
+bell_class </emphasis>
+= <emphasis>
+XkbDfltXIClass</emphasis>
+, <emphasis>
+bell_id </emphasis>
+= <emphasis>
+XkbDfltXIId,</emphasis>
+ <emphasis>
+window</emphasis>
+ = None, and <emphasis>
+name</emphasis>
+ = <emphasis>
+NULL</emphasis>
+, and returns what<emphasis>
+ XkbForceDeviceBell</emphasis>
+ returns.
+</para>
+
+<para>
+<emphasis>
+XkbForceBell </emphasis>
+does not cause an <emphasis>
+XkbBellNotify</emphasis>
+ event.
+</para>
+
+<para>
+You can call <emphasis>
+XkbBell</emphasis>
+ without first initializing the keyboard extension.
+</para>
+
+</sect2>
+</sect1>
+<sect1 id='detecting_bells'>
+<title>Detecting Bells</title>
+
+<para>
+Xkb generates <emphasis>
+XkbBellNotify</emphasis>
+ events for all bells except for those resulting from calls to <emphasis>
+XkbForceDeviceBell</emphasis>
+ and <emphasis>
+XkbForceBell</emphasis>
+. To receive <emphasis>
+XkbBellNotify</emphasis>
+ events under all possible conditions, pass <emphasis>
+XkbBellNotifyMask</emphasis>
+ in both the <emphasis>
+bits_to_change </emphasis>
+and<emphasis>
+ values_for_bits</emphasis>
+ parameters to <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3). <!-- xref -->
+</para>
+
+<para>
+The <emphasis>
+XkbBellNotify</emphasis>
+ event has no event details. It is either selected or it is not. However, you
+can call <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbBellNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying <emphasis>
+XkbAllBellNotifyMask</emphasis>
+ in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits.</emphasis>
+ This has the same effect as a call to <emphasis>
+XkbSelectEvents</emphasis>.
+</para>
+
+<para>
+The structure for the <emphasis>
+XkbBellNotify</emphasis>
+ event type contains:
+</para>
+
+<para><programlisting>
+typedef struct _XkbBellNotify {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis> True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis> XkbBellNotify</emphasis> */
+ unsigned int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
+ int percent; /* requested volume as % of max */
+ int pitch; /* requested pitch in Hz */
+ int duration; /* requested duration in microseconds */
+ unsigned int bell_class; /* X input extension feedback class */
+ unsigned int bell_id; /* X input extension feedback ID */
+ Atom name; /* "name" of requested bell */
+ Window window; /* window associated with event */
+ Bool event_only; /* <emphasis> False</emphasis> -&gt; the server did not produce a beep */
+} <emphasis>XkbBellNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+If your application needs to generate visual bell feedback on the screen when
+it receives a bell event, use the window ID in the <emphasis>
+XkbBellNotifyEvent</emphasis>
+, if present.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch10.xml b/specs/XKB/ch10.xml
new file mode 100644
index 00000000..c1972750
--- /dev/null
+++ b/specs/XKB/ch10.xml
@@ -0,0 +1,5347 @@
+<chapter id='keyboard_controls'>
+<title>Keyboard Controls</title>
+
+<para>
+The Xkb extension is composed of two parts: a server extension, and a
+client-side X library extension. This chapter discusses functions used to
+modify controls effecting the behavior of the server portion of the Xkb
+extension. Chapter 11 discusses functions used to modify controls that affect
+only the behavior of the client portion of the extension; those controls are
+known as Library Controls.
+</para>
+
+
+<para>
+Xkb contains control features that affect the entire keyboard, known as global
+keyboard controls. Some of the controls may be selectively enabled and
+disabled; these controls are known as the <emphasis>
+Boolean Controls</emphasis>
+. Boolean Controls can be turned on or off under program control and can also
+be automatically set to an on or off condition when a client program exits. The
+remaining controls, known as the <emphasis>
+Non-Boolean Controls</emphasis>
+, are always active. The<emphasis>
+ XkbControlsRec</emphasis>
+ structure describes the current state of most of the global controls and the
+attributes effecting the behavior of each of these Xkb features. This chapter
+describes the Xkb controls and how to manipulate them.
+</para>
+
+
+<para>
+There are two possible components for each of the Boolean Controls: attributes
+describing how the control should work, and a state describing whether the
+behavior as a whole is enabled or disabled. The attributes and state for most
+of these controls are held in the <emphasis>
+XkbControlsRec</emphasis>
+ structure (see section 10.8).
+</para>
+
+
+<para>
+You can manipulate the Xkb controls individually, via convenience functions, or
+as a whole. To treat them as a group, modify an <emphasis>
+XkbControlsRec</emphasis>
+ structure to describe all of the changes to be made, and then pass that
+structure and appropriate flags to an Xkb library function, or use a <emphasis>
+XkbControlsChangesRec</emphasis>
+ (see section 10.10.1) to reduce network traffic. When using a convenience
+function to manipulate one control individually, you do not use an <emphasis>
+XkbControlsRec</emphasis>
+ structure directly.
+</para>
+
+
+<para>
+The Xkb controls are grouped as shown in Table 10.1. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>Xkb Keyboard Controls</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type of Control</entry>
+ <entry>Control Name</entry>
+ <entry>Boolean Control?</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>Controls for enabling and disabling other controls</entry>
+ <entry>EnabledControls</entry>
+ <entry>No</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>AutoReset</entry>
+ <entry>No</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Control for bell behavior</entry>
+ <entry>AudibleBell</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Controls for repeat key behavior</entry>
+ <entry>PerKeyRepeat</entry>
+ <entry>No</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>RepeatKeys</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>DetectableAutorepeat</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Controls for keyboard overlays</entry>
+ <entry>Overlay1</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>Overlay2</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Controls for using the mouse from the keyboard</entry>
+ <entry>MouseKeys</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>MouseKeysAccel</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Controls for better keyboard access by </entry>
+ <entry>AccessXFeedback</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>physically impaired persons</entry>
+ <entry>AccessXKeys</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>AccessXTimeout</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>BounceKeys</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>SlowKeys</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>StickyKeys</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Controls for general keyboard mapping</entry>
+ <entry>GroupsWrap</entry>
+ <entry>No</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>IgnoreGroupLock</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>IgnoreLockMods</entry>
+ <entry>No</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>InternalMods</entry>
+ <entry>No</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Miscellaneous per-client controls</entry>
+ <entry>GrabsUseXKBState</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>LookupStateWhenGrabbed</entry>
+ <entry>Boolean</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>SendEventUsesXKBState</entry>
+ <entry>Boolean</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The individual categories and controls are described first, together with
+functions for manipulating them. A description of the <emphasis>
+XkbControlsRec</emphasis>
+ structure and the general functions for dealing with all of the controls at
+once follow at the end of the chapter.
+</para>
+
+<sect1 id='controls_that_enable_and_disable_other_controls'>
+<title>Controls that Enable and Disable Other Controls</title>
+
+<para>
+Enable and disable the boolean controls under program control by using the
+<emphasis>
+EnabledControls</emphasis>
+ control; enable and disable them upon program exit by configuring the
+<emphasis>
+AutoReset</emphasis>
+ control.
+</para>
+
+
+<sect2 id='the_enabledcontrols_control'>
+<title>The EnabledControls Control</title>
+
+<para>
+The <emphasis>
+EnabledControls</emphasis>
+ control is a bit mask where each bit that is turned on means the corresponding
+control is enabled, and when turned off, disabled. It corresponds to the
+<emphasis>
+enabled_ctrls</emphasis>
+ field of an <emphasis>
+XkbControlsRec</emphasis>
+ structure (see section 10.8). The bits describing which controls are turned on
+or off are defined in Table 10.7. <!-- xref -->
+</para>
+
+
+<para>
+Use <emphasis>
+XkbChangeEnabledControls</emphasis>
+ to manipulate the <emphasis>
+EnabledControls</emphasis>
+ control.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbChangeEnabledControls</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+device_spec</emphasis>
+, <emphasis>
+mask</emphasis>
+,<emphasis>
+ values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* keyboard device to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+mask</emphasis>
+; /* 1 bit -&gt; controls to enable / disable */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+values</emphasis>
+; /* 1 bit =&gt; enable, 0 bit =&gt; disable */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+mask</emphasis>
+ parameter specifies the boolean controls to be enabled or disabled, and the
+<emphasis>
+values</emphasis>
+ mask specifies the new state for those controls. Valid values for both of
+these masks are composed of a bitwise inclusive OR of bits taken from the set
+of mask bits in Table 10.7, using only those masks with "ok" in the <emphasis>
+enabled_ctrls</emphasis>
+ column.
+</para>
+
+
+<para>
+If the X server does not support a compatible version of Xkb or the Xkb
+extension has not been properly initialized, <emphasis>
+XkbChangeEnabledControls</emphasis>
+ returns <emphasis>
+False</emphasis>
+; otherwise, it sends the request to the X server and returns <emphasis>
+True</emphasis>
+.
+</para>
+
+
+<para>
+Note that the <emphasis>
+EnabledControls</emphasis>
+ control only enables and disables controls; it does not configure them. Some
+controls, such as the <emphasis>
+AudibleBell</emphasis>
+ control, have no configuration attributes and are therefore manipulated solely
+by enabling and disabling them. Others, however, have additional attributes to
+configure their behavior. For example, the <emphasis>
+RepeatControl</emphasis>
+ control uses <emphasis>
+repeat_delay</emphasis>
+ and <emphasis>
+repeat_interval</emphasis>
+ fields to describe the timing behavior of keys that repeat. The <emphasis>
+RepeatControl</emphasis>
+ behavior is turned on or off depending on the value of the <emphasis>
+XkbRepeatKeysMask</emphasis>
+ bit, but you must use other means, as described in this chapter, to configure
+its behavior in detail.
+</para>
+
+
+</sect2>
+<sect2 id='the_autoreset_control'>
+<title>The AutoReset Control</title>
+
+<para>
+You can configure the boolean controls to automatically be enabled or disabled
+when a program exits. This capability is controlled via two masks maintained in
+the X server on a per-client basis. There is no client-side Xkb data structure
+corresponding to these masks. Whenever the client exits for any reason, any
+boolean controls specified in the <emphasis>
+auto-reset mask</emphasis>
+ are set to the corresponding value from the <emphasis>
+auto-reset values</emphasis>
+ mask. This makes it possible for clients to "clean up after themselves"
+automatically, even if abnormally terminated. The bits used in the masks
+correspond to the <emphasis>
+EnabledControls</emphasis>
+ control bits.
+</para>
+
+
+<para>
+For example, a client that replaces the keyboard bell with some other audible
+cue might want to turn off the <emphasis>
+AudibleBell</emphasis>
+ control to prevent the server from also generating a sound and avoid
+cacophony. If the client were to exit without resetting the <emphasis>
+AudibleBell </emphasis>
+control, the user would be left without any feedback at all. Setting <emphasis>
+AudibleBell</emphasis>
+ in both the auto-reset mask and auto-reset values guarantees that the audible
+bell will be turned back on when the client exits.
+</para>
+
+
+<para>
+To get the current values of the auto-reset controls, use <emphasis>
+XkbGetAutoResetControls</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetAutoResetControls</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+auto_ctrls</emphasis>
+, <emphasis>
+auto_values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+auto_ctrls</emphasis>
+; /* specifies which bits in <emphasis>
+auto_values</emphasis>
+ are relevant */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+auto_values</emphasis>
+; /* 1 bit =&gt; corresponding control has auto-reset on */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetAutoResetControls</emphasis>
+ backfills <emphasis>
+auto_ctrls</emphasis>
+ and <emphasis>
+auto_values</emphasis>
+ with the <emphasis>
+AutoReset</emphasis>
+ control attributes for this particular client. It returns <emphasis>
+True</emphasis>
+ if successful, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+<para>
+To change the current values of the <emphasis>
+AutoReset</emphasis>
+ control attributes, use <emphasis>
+XkbSetAutoResetControls.</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetAutoResetControls</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+changes</emphasis>
+,<emphasis>
+ auto_ctrls</emphasis>
+, <emphasis>
+auto_values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+changes</emphasis>
+; /* controls for which to change auto-reset values */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+auto_ctrls</emphasis>
+; /* controls from changes that should auto reset */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+auto_values</emphasis>
+; /* 1 bit =&gt; auto-reset on */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetAutoResetControls changes the auto-reset status and associated auto-reset
+values for the controls selected by </emphasis>
+<emphasis>
+changes</emphasis>
+<emphasis>
+. For any control selected by </emphasis>
+<emphasis>
+changes</emphasis>
+<emphasis>
+, if the corresponding bit is set in </emphasis>
+<emphasis>
+auto_ctrls</emphasis>
+<emphasis>
+, the control is configured to auto-reset when the client exits. If the
+corresponding bit in </emphasis>
+<emphasis>
+auto_values</emphasis>
+<emphasis>
+ is on, the control is turned on when the client exits; if zero, the control is
+turned off when the client exits.</emphasis>
+ For any control selected by <emphasis>
+changes</emphasis>
+, if the corresponding bit is not set in <emphasis>
+auto_ctrls</emphasis>
+, the control is configured to not reset when the client exits. For example:
+</para>
+
+
+<para>
+<emphasis>
+To leave the auto-reset controls for </emphasis>
+<emphasis>
+StickyKeys</emphasis>
+<emphasis>
+ the way they are:</emphasis>
+</para>
+
+<para><programlisting>
+ok = XkbSetAutoResetControls(dpy, 0, 0, 0);
+</programlisting></para>
+
+<para>
+<emphasis>
+To change the auto-reset controls so that </emphasis>
+<emphasis>
+StickyKeys</emphasis>
+<emphasis>
+ are unaffected when the client exits:</emphasis>
+</para>
+
+<para><programlisting>
+ok = XkbSetAutoResetControls(dpy, XkbStickyKeysMask, 0, 0);
+</programlisting></para>
+
+<para>
+<emphasis>
+To change the auto-reset controls so that </emphasis>
+<emphasis>
+StickyKeys</emphasis>
+<emphasis>
+ are turned off when the client exits:</emphasis>
+</para>
+
+<para><programlisting>
+ok = XkbSetAutoResetControls(dpy, XkbStickyKeysMask, XkbStickyKeysMask, 0);
+</programlisting></para>
+
+<para>
+<emphasis>
+To change the auto-reset controls so that </emphasis>
+<emphasis>
+StickyKeys</emphasis>
+<emphasis>
+ are turned on when the client exits:</emphasis>
+</para>
+
+<para><programlisting>
+ok = XkbSetAutoResetControls(dpy, XkbStickyKeysMask, XkbStickyKeysMask,
+XkbStickyKeysMask);
+</programlisting></para>
+
+<para>
+<emphasis>
+XkbSetAutoResetControls</emphasis>
+ backfills <emphasis>
+auto_ctrls</emphasis>
+ and <emphasis>
+auto_values</emphasis>
+ with the auto-reset controls for this particular client. Note that all of the
+bits are valid in the returned values, not just the ones selected in the
+<emphasis>
+changes</emphasis>
+ mask.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='control_for_bell_behavior'>
+<title>Control for Bell Behavior</title>
+
+<para>
+The X server’s generation of sounds is controlled by the <emphasis>
+AudibleBell</emphasis>
+ control. Configuration of different bell sounds is discussed in Chapter 9.
+</para>
+
+
+<sect2 id='the_audiblebell_control'>
+<title>The AudibleBell Control</title>
+
+<para>
+The <emphasis>
+AudibleBell</emphasis>
+ control is a boolean control that has no attributes. As such, you may enable
+and disable it using either the <emphasis>
+EnabledControls</emphasis>
+ control or the <emphasis>
+AutoReset</emphasis>
+ control discussed in section 10.1.1. When enabled, protocol requests to <!-- xref -->
+generate a sound result in the X server actually producing a real sound; when
+disabled, requests to the server to generate a sound are ignored unless the
+sound is forced. See section 9.2. <!-- xref -->
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='controls_for_repeat_key_behavior'>
+<title>Controls for Repeat Key Behavior</title>
+
+<para>
+The repeating behavior of keyboard keys is governed by three controls, the
+<emphasis>
+PerKeyRepeat</emphasis>
+ control, which is always active, and the <emphasis>
+RepeatKeys</emphasis>
+ and <emphasis>
+DetectableAutorepeat</emphasis>
+ controls, which are boolean controls that may be enabled and disabled.
+<emphasis>
+PerKeyRepeat</emphasis>
+ determines which keys are allowed to repeat. <emphasis>
+RepeatKeys</emphasis>
+ governs the behavior of an individual key when it is repeating. <emphasis>
+DetectableAutorepeat</emphasis>
+ allows a client to detect when a key is repeating as a result of being held
+down.
+</para>
+
+
+<sect2 id='the_perkeyrepeat_control'>
+<title>The PerKeyRepeat Control</title>
+
+<para>
+The <emphasis>
+PerKeyRepeat</emphasis>
+ control is a bitmask long enough to contain a bit for each key on the device;
+it determines which individual keys are allowed to repeat. The Xkb <emphasis>
+PerKeyRepeat</emphasis>
+ control provides no functionality different from that available via the core X
+protocol. There are no convenience functions in Xkb for manipulating this
+control. The <emphasis>
+PerKeyRepeat</emphasis>
+ control settings are carried in the <emphasis>
+per_key_repeat</emphasis>
+ field of an <emphasis>
+XkbControlsRec</emphasis>
+ structure, discussed in section 10.8. <!-- xref -->
+</para>
+
+
+</sect2>
+<sect2 id='the_repeatkeys_control'>
+<title>The RepeatKeys Control</title>
+
+<para>
+The core protocol allows only control over whether or not the entire keyboard
+or individual keys should auto-repeat when held down. <emphasis>
+RepeatKeys</emphasis>
+ is a boolean control that extends this capability by adding control over the
+delay until a key begins to repeat and the rate at which it repeats. <emphasis>
+RepeatKeys</emphasis>
+ is coupled with the core auto-repeat control: when <emphasis>
+RepeatKeys</emphasis>
+ is enabled or disabled, the core auto-repeat is enabled or disabled and vice
+versa.
+</para>
+
+
+<para>
+Auto-repeating keys are controlled by two attributes. The first, <emphasis>
+timeout</emphasis>
+, is the delay after the initial press of an auto-repeating key and the first
+generated repeat event. The second, <emphasis>
+interval</emphasis>
+, is the delay between all subsequent generated repeat events. As with all
+boolean controls, configuring the attributes that determine how the control
+operates does not automatically enable the control as a whole; see section 10.1.
+</para>
+
+
+<para>
+To get the current attributes of the <emphasis>
+RepeatKeys</emphasis>
+ control for a keyboard device, use <emphasis>
+XkbGetAutoRepeatRate</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetAutoRepeatRate</emphasis>
+(<emphasis>
+display, device_spec, timeout_rtrn, interval_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ device_spec</emphasis>
+; /* desired device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+* timeout_rtrn</emphasis>
+; /* backfilled with initial repeat delay, ms */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+* interval_rtrn</emphasis>
+; /* backfilled with subsequent repeat delay, ms */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetAutoRepeatRate</emphasis>
+ queries the server for the current values of the <emphasis>
+RepeatControls</emphasis>
+ control attributes, backfills <emphasis>
+timeout_rtrn</emphasis>
+ and <emphasis>
+interval_rtrn</emphasis>
+ with them, and returns <emphasis>
+True</emphasis>
+. If a compatible version of the Xkb extension is not available in the server
+<emphasis>
+XkbGetAutoRepeatRate</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+To set the attributes of the RepeatKeys control for a keyboard device, use
+<emphasis>
+XkbSetAutoRepeatRate</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetAutoRepeatRate</emphasis>
+(<emphasis>
+display, device_spec, timeout, interval</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device to configure, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ timeout</emphasis>
+; /* initial delay, ms */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ interval</emphasis>
+; /* delay between repeats, ms */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetAutoRepeatRate</emphasis>
+ sends a request to the X server to configure the <emphasis>
+AutoRepeat</emphasis>
+ control attributes to the values specified in <emphasis>
+timeout</emphasis>
+ and <emphasis>
+interval</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbSetAutoRepeatRate</emphasis>
+ does not wait for a reply; it normally returns <emphasis>
+True</emphasis>
+. Specifying a zero value for either <emphasis>
+timeout</emphasis>
+ or <emphasis>
+interval</emphasis>
+ causes the server to generate a <emphasis>
+BadValue</emphasis>
+ protocol error. If a compatible version of the Xkb extension is not available
+in the server, <emphasis>
+XkbSetAutoRepeatRate</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='the_detectableautorepeat_control'>
+<title>The DetectableAutorepeat Control</title>
+
+<para>
+Auto-repeat is the generation of multiple key events by a keyboard when the
+user presses a key and holds it down. Keyboard hardware and device-dependent X
+server software often implement auto-repeat by generating multiple <emphasis>
+KeyPress</emphasis>
+ events with no intervening <emphasis>
+KeyRelease</emphasis>
+ event. The standard behavior of the X server is to generate a <emphasis>
+KeyRelease</emphasis>
+ event for every <emphasis>
+KeyPress</emphasis>
+ event. If the keyboard hardware and device-dependent software of the X server
+implement auto-repeat by generating multiple <emphasis>
+KeyPress</emphasis>
+ events, the device-independent part of the X server by default synthetically
+generates a <emphasis>
+KeyRelease</emphasis>
+ event after each <emphasis>
+KeyPress</emphasis>
+ event. This provides predictable behavior for X clients, but does not allow
+those clients to detect the fact that a key is auto-repeating.
+</para>
+
+
+<para>
+Xkb allows clients to request <emphasis>
+detectable auto-repeat</emphasis>
+. If a client requests and the server supports <emphasis>
+DetectableAutorepeat</emphasis>
+, Xkb generates <emphasis>
+KeyRelease</emphasis>
+ events only when the key is physically released. If <emphasis>
+DetectableAutorepeat</emphasis>
+ is not supported or has not been requested, the server synthesizes a <emphasis>
+KeyRelease</emphasis>
+ event for each repeating <emphasis>
+KeyPress</emphasis>
+ event it generates.
+</para>
+
+
+<para>
+<emphasis>
+DetectableAutorepeat</emphasis>
+, unlike the other controls in this chapter, is not contained in the <emphasis>
+XkbControlsRec</emphasis>
+ structure, nor can it be enabled or disabled via the <emphasis>
+EnabledControls</emphasis>
+ control. Instead, query and set <emphasis>
+DetectableAutorepeat</emphasis>
+ using <emphasis>
+XkbGetDetectableAutorepeat</emphasis>
+ and <emphasis>
+XkbSetDetectableAutorepeat</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+DetectableAutorepeat</emphasis>
+ is a condition that applies to all keyboard devices for a client’s
+connection to a given X server; it cannot be selectively set for some devices
+and not for others. For this reason, none of the Xkb library functions
+involving <emphasis>
+DetectableAutorepeat</emphasis>
+ involve a device specifier.
+</para>
+
+
+<para>
+To determine whether or not the server supports <emphasis>
+DetectableAutorepeat</emphasis>
+, use <emphasis>
+XkbGetDetectableAutorepeat</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetDetectableAutorepeat</emphasis>
+(<emphasis>
+display, supported_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool *<emphasis>
+ supported_rtrn</emphasis>
+; /* backfilled <emphasis>
+True</emphasis>
+ if <emphasis>
+DetectableAutorepeat</emphasis>
+ supported */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetDetectableAutorepeat</emphasis>
+ queries the server for the current state of <emphasis>
+DetectableAutorepeat</emphasis>
+ and waits for a reply. If <emphasis>
+supported_rtrn</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+, it backfills supported_rtrn with <emphasis>
+True</emphasis>
+ if the server supports <emphasis>
+DetectableAutorepeat</emphasis>
+, and <emphasis>
+False</emphasis>
+ otherwise. <emphasis>
+XkbGetDetectableAutorepeat</emphasis>
+ returns the current state of <emphasis>
+DetectableAutorepeat</emphasis>
+ for the requesting client: <emphasis>
+True</emphasis>
+ if <emphasis>
+DetectableAutorepeat</emphasis>
+ is set, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+<para>
+To set <emphasis>
+DetectableAutorepeat</emphasis>
+, use <emphasis>
+XkbSetDetectableAutorepeat</emphasis>
+. This request affects all keyboard activity for the requesting client only;
+other clients still see the expected nondetectable auto-repeat behavior, unless
+they have requested otherwise.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetDetectableAutorepeat</emphasis>
+(<emphasis>
+display, detectable, supported_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool<emphasis>
+ detectable</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; set <emphasis>
+DetectableAutorepeat</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool *<emphasis>
+ supported_rtrn</emphasis>
+; /* backfilled <emphasis>
+True</emphasis>
+ if <emphasis>
+DetectableAutorepeat</emphasis>
+ supported */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetDetectableAutorepeat</emphasis>
+ sends a request to the server to set <emphasis>
+DetectableAutorepeat</emphasis>
+ on for the current client if <emphasis>
+detectable</emphasis>
+ is <emphasis>
+True</emphasis>
+, and off it <emphasis>
+detectable</emphasis>
+ is <emphasis>
+False</emphasis>
+; it then waits for a reply. If <emphasis>
+supported_rtrn</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbSetDetectableAutorepeat</emphasis>
+ backfills <emphasis>
+supported_rtrn</emphasis>
+ with <emphasis>
+True</emphasis>
+ if the server supports <emphasis>
+DetectableAutorepeat</emphasis>
+, and <emphasis>
+False</emphasis>
+ if it does not. <emphasis>
+XkbSetDetectableAutorepeat</emphasis>
+ returns the current state of <emphasis>
+DetectableAutorepeat</emphasis>
+ for the requesting client: <emphasis>
+True</emphasis>
+ if <emphasis>
+DetectableAutorepeat</emphasis>
+ is set, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='controls_for_keyboard_overlays_overlay1_and_overlay2_controls'>
+<title>Controls for Keyboard Overlays (Overlay1 and Overlay2 Controls)</title>
+
+<para>
+A keyboard overlay allows some subset of the keyboard to report alternate
+keycodes when the overlay is enabled. For example, a keyboard overlay can be
+used to simulate a numeric or editing keypad on a keyboard that does not
+actually have one by reusing some portion of the keyboard as an overlay. This
+technique is very common on portable computers and embedded systems with small
+keyboards.
+</para>
+
+
+<para>
+Xkb includes direct support for two keyboard overlays, using the <emphasis>
+Overlay1</emphasis>
+ and <emphasis>
+Overlay2</emphasis>
+ controls. When <emphasis>
+Overlay1</emphasis>
+ is enabled, all of the keys that are members of the first keyboard overlay
+generate an alternate keycode. When <emphasis>
+Overlay2</emphasis>
+ is enabled, all of the keys that are members of the second keyboard overlay
+generate an alternate keycode. The two overlays are mutually exclusive; any
+particular key may be in at most one overlay. <emphasis>
+Overlay1</emphasis>
+ and <emphasis>
+Overlay2</emphasis>
+ are boolean controls. As such, you may enable and disable them using either
+the <emphasis>
+EnabledControls</emphasis>
+ control or the <emphasis>
+AutoReset</emphasis>
+ control discussed in section 10.1.1. <!-- xref -->
+</para>
+
+
+<para>
+To specify the overlay to which a key belongs and the alternate keycode it
+should generate when that overlay is enabled, assign it either the <emphasis>
+XkbKB_Overlay1</emphasis>
+ or <emphasis>
+XkbKB_Overlay2</emphasis>
+ key behaviors, as described in section 16.2. <!-- xref -->
+</para>
+
+
+</sect1>
+<sect1 id='controls_for_using_the_mouse_from_the_keyboard'>
+<title>Controls for Using the Mouse from the Keyboard</title>
+
+<para>
+Using Xkb, it is possible to configure the keyboard to allow simulation of the
+X pointer device. This simulation includes both movement of the pointer itself
+and press and release events associated with the buttons on the pointer. Two
+controls affect this behavior: the <emphasis>
+MouseKeys</emphasis>
+ control determines whether or not simulation of the pointer device is active,
+as well as configuring the default button; the <emphasis>
+MouseKeysAccel</emphasis>
+ control determines the movement characteristics of the pointer when simulated
+via the keyboard. Both of them are boolean controls; as such, you may enable
+and disable them using either the <emphasis>
+EnabledControls</emphasis>
+ control or the <emphasis>
+AutoReset</emphasis>
+ control discussed in section 10.1.1. The individual keys that simulate <!-- xref -->
+different aspects of the pointer device are determined by the keyboard mapping,
+discussed in Chapter 16. <!-- xref -->
+</para>
+
+
+<sect2 id='the_mousekeys_control'>
+<title>The MouseKeys Control</title>
+
+<para>
+The <emphasis>
+MouseKeys</emphasis>
+ control allows a user to control all the mouse functions from the keyboard.
+When <emphasis>
+MouseKeys</emphasis>
+ are enabled, all keys with <emphasis>
+MouseKeys</emphasis>
+ actions bound to them generate core pointer events instead of normal <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events.
+</para>
+
+
+<para>
+The <emphasis>
+MouseKeys</emphasis>
+ control has a single attribute, <emphasis>
+mk_dflt_btn</emphasis>
+ that specifies the core button number to be used by mouse keys actions that do
+not explicitly specify a button. There is no convenience function for getting
+or setting the attribute; instead use <emphasis>
+XkbGetControls</emphasis>
+ and <emphasis>
+XkbSetControls</emphasis>
+ (see sections 10.9 and 10.10). <!-- xref -->
+</para>
+
+<note><para><emphasis>
+MouseKeys</emphasis>
+ can also be turned on and off by pressing the key combination necessary to
+produce an <emphasis>
+XK_Pointer_EnableKeys</emphasis>
+ keysym. The de facto default standard for this is <emphasis>
+Shift+Alt+NumLock</emphasis>
+, but this may vary depending on the keymap.</para></note>
+
+</sect2>
+<sect2 id='the_mousekeysaccel_control'>
+<title>The MouseKeysAccel Control</title>
+
+<para>
+When the <emphasis>
+MouseKeysAccel</emphasis>
+ control is enabled, the effect of a key-activated pointer motion action
+changes as a key is held down. If the control is disabled, pressing a
+mouse-pointer key yields one mouse event. When <emphasis>
+MouseKeysAccel</emphasis>
+ is enabled, mouse movement is defined by an initial distance specified in the
+<emphasis>
+XkbSA_MovePtr</emphasis>
+ action and the following fields in the <emphasis>
+XkbControlsRec</emphasis>
+ structure (see section 10.8). <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>MouseKeysAccel Fields</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Field</entry>
+ <entry>Function</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>mk_delay</entry>
+ <entry>Time (ms) between the initial key press and the first repeated
+motion event</entry>
+</row>
+<row rowsep='0'>
+ <entry>mk_interval</entry>
+ <entry>Time (ms) between repeated motion events</entry>
+</row>
+<row rowsep='0'>
+ <entry>mk_time_to_max</entry>
+ <entry>Number of events (count) before the pointer reaches maximum
+speed</entry>
+</row>
+<row rowsep='0'>
+ <entry>mk_max_speed</entry>
+ <entry>The maximum speed (in pixels per event) the pointer reaches</entry>
+</row>
+<row rowsep='0'>
+ <entry>mk_curve</entry>
+ <entry>The ramp used to reach maximum pointer speed</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+There are no convenience functions to query or change the attributes of the
+<emphasis>
+MouseKeysAccel</emphasis>
+ control; instead use <emphasis>
+XkbGetControls</emphasis>
+ and <emphasis>
+XkbSetControls</emphasis>
+ (see sections 10.9 and 10.10). <!-- xref -->
+</para>
+
+
+<para>
+The effects of the attributes of the <emphasis>
+MouseKeysAccel</emphasis>
+ control depend on whether the <emphasis>
+XkbSA_MovePtr</emphasis>
+ action (see section 16.1) specifies relative or absolute pointer motion. <!-- xref -->
+</para>
+
+<sect3 id='absolute_pointer_motion'>
+<title>Absolute Pointer Motion</title>
+
+<para>
+If an <emphasis>
+XkbSA_MovePtr</emphasis>
+ action specifies an absolute position for one of the coordinates but still
+allows acceleration, all repeated events contain any absolute coordinates
+specified in the action. For example, if the <emphasis>
+XkbSA_MovePtr</emphasis>
+ action specifies an absolute position for the X direction, but a relative
+motion for the Y direction, the pointer accelerates in the Y direction, but
+stays at the same X position.
+</para>
+
+
+</sect3>
+<sect3 id='relative_pointer_motion'>
+<title>Relative Pointer Motion</title>
+
+<para>
+If the <emphasis>
+XkbSA_MovePtr</emphasis>
+ action specifies relative motion, the initial event always moves the cursor
+the distance specified in the action. After <emphasis>
+mk_delay</emphasis>
+ milliseconds, a second motion event is generated, and another occurs every
+<emphasis>
+mk_interval</emphasis>
+ milliseconds until the user releases the key.
+</para>
+
+
+<para>
+Between the time of the second motion event and <emphasis>
+mk_time_to_max</emphasis>
+ intervals, the change in pointer distance per interval increases with each
+interval. After <emphasis>
+mk_time_to_max</emphasis>
+ intervals have elapsed, the change in pointer distance per interval remains
+the same and is calculated by multiplying the original distance specified in
+the action by <emphasis>
+mk_max_speed</emphasis>
+.
+</para>
+
+
+<para>
+For example, if the <emphasis>
+XkbSA_MovePtr</emphasis>
+ action specifies a relative motion in the X direction of 5, <emphasis>
+mk_delay</emphasis>
+=160, <emphasis>
+mk_interval</emphasis>
+=40, <emphasis>
+mk_time_to_max</emphasis>
+=30, and <emphasis>
+mk_max_speed</emphasis>
+=30, the following happens when the user presses the key:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The pointer immediately moves 5 pixels in the X direction when the key is
+pressed.
+ </para>
+</listitem>
+<listitem>
+ <para>
+After 160 milliseconds (<emphasis>
+mk_delay</emphasis>
+), and every 40 milliseconds thereafter (<emphasis>
+mk_interval</emphasis>
+), the pointer moves in the X direction.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The distance in the X direction increases with each interval until 30 intervals
+(<emphasis>
+mk_time_to_max</emphasis>
+) have elapsed.
+ </para>
+</listitem>
+<listitem>
+ <para>
+After 30 intervals, the pointer stops accelerating, and moves 150 pixels
+(<emphasis>
+mk_max_speed</emphasis>
+ * the original distance) every interval thereafter, until the key is released.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The increase in pointer difference for each interval is a function of<emphasis>
+ mk_curve.</emphasis>
+ Events after the first but before maximum acceleration has been achieved are
+accelerated according to the formula:
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-3.gif"/>
+ </imageobject>
+ </mediaobject>
+
+
+<para>
+Where <emphasis>
+action_delta</emphasis>
+ is the relative motion specified by the <emphasis>
+XkbSA_MovePtr</emphasis>
+ action, <emphasis>
+mk_max_speed </emphasis>
+and <emphasis>
+mk_time_to_max</emphasis>
+ are parameters to the <emphasis>
+MouseKeysAccel</emphasis>
+ control, and the curveFactor is computed using the <emphasis>
+MouseKeysAccel</emphasis>
+ <emphasis>
+mk_curve</emphasis>
+ parameter as follows:
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-4.gif"/>
+ </imageobject>
+ </mediaobject>
+
+
+<para>
+With the result that a <emphasis>
+mk_curve</emphasis>
+ of zero causes the distance moved to increase linearly from <emphasis>
+action_delta</emphasis>
+ to <mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-5.gif"/>
+ </imageobject>
+ </mediaobject>
+
+. A negative <emphasis>
+mk_curve</emphasis>
+ causes an initial sharp increase in acceleration that tapers off, and a
+positive curve yields a slower initial increase in acceleration followed by a
+sharp increase as the number of pointer events generated by the action
+approaches <emphasis>
+mk_time_to_max</emphasis>
+. The legal values for <emphasis>
+mk_curve</emphasis>
+ are between -1000 and 1000.
+</para>
+
+
+<para>
+A distance vs. time graph of the pointer motion is shown in Figure 10.1. <!-- xref -->
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-6.gif"/>
+ </imageobject>
+<caption>MouseKeys Acceleration</caption>
+ </mediaobject>
+
+<!--
+<H5 CLASS="Figure">
+MouseKeys Acceleration</H5>
+-->
+</sect3>
+</sect2>
+</sect1>
+<sect1 id='controls_for_better_keyboard_access_by_physically_impaired_persons'>
+<title>Controls for Better Keyboard Access by Physically Impaired
+Persons</title>
+
+<para>
+The Xkb extension includes several controls specifically aimed at making
+keyboard use more effective for physically impaired people. All of these
+controls are boolean controls and may be individually enabled and disabled, as
+well as configured to tune their specific behavior. The behavior of these
+controls is based on the AccessDOS package
+<footnote><para>
+AccessDOS provides access to the DOS operating system for people with physical
+impairments and was developed by the Trace R&amp;D Center at the University of
+Wisconsin. For more information on AccessDOS, contact the Trace R&amp;D Center,
+Waisman Center and Department of Industrial Engineering, University of
+Wisconsin-Madison WI 53705-2280. Phone: 608-262-6966. e-mail: info@trace.wisc.edu.
+</para></footnote>.
+</para>
+
+<sect2 id='the_accessxkeys_control'>
+<title>The AccessXKeys Control</title>
+
+<para>
+Enabling or disabling the keyboard controls through a graphical user interface
+may be impossible for people who need to use the controls. For example, a user
+who needs <emphasis>
+SlowKeys</emphasis>
+ (see section 10.6.6) may not even be able to start the graphical application, <!-- xref -->
+let alone use it, if <emphasis>
+SlowKeys</emphasis>
+ is not enabled. To allow easier access to some of the controls, the <emphasis>
+AccessXKeys</emphasis>
+ control provides a set of special key sequences similar to those available in
+AccessDOS.
+</para>
+
+
+<para>
+When the <emphasis>
+AccessXKeys</emphasis>
+ control is enabled, the user can turn controls on or off from the keyboard by
+entering the following standard key sequences:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Holding down a shift key by itself for eight seconds toggles the <emphasis>
+SlowKeys</emphasis>
+ control.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Pressing and releasing the left or right <emphasis>
+Shift</emphasis>
+ key five times in a row, without any intervening key events and with less than
+30 seconds delay between consecutive presses, toggles the state of the
+<emphasis>
+StickyKeys</emphasis>
+ control.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Simultaneously operating two or more modifier keys deactivates the <emphasis>
+StickyKeys</emphasis>
+ control.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+When the <emphasis>
+AccessXKeys</emphasis>
+ control is disabled, Xkb does not look for the above special key sequences.
+</para>
+
+
+<para>
+Some of these key sequences optionally generate audible feedback of the change
+in state, as described in section 10.6.3, or <!-- xref -->
+<emphasis>XkbControlsNotify</emphasis>
+ events, described in section 10.11. <!-- xref -->
+</para>
+
+</sect2>
+<sect2 id='the_accessxtimeout_control'>
+<title>The AccessXTimeout Control</title>
+
+<para>
+In environments where computers are shared, features such as <emphasis>
+SlowKeys</emphasis>
+ present a problem: if <emphasis>
+SlowKeys</emphasis>
+ is on, the keyboard can appear to be unresponsive because keys are not
+accepted until they are held for a certain period of time. To help solve this
+problem, Xkb provides an <emphasis>
+AccessXTimeout</emphasis>
+ control to automatically change the enabled/disabled state of any boolean
+controls and to change the value of the <emphasis>
+AccessXKeys</emphasis>
+ and <emphasis>
+AccessXFeedback</emphasis>
+ control attributes if the keyboard is idle for a specified period of time.
+</para>
+
+
+<para>
+When a timeout as specified by <emphasis>
+AccessXTimeout</emphasis>
+ occurs and a control is consequently modified, Xkb generates an <emphasis>
+XkbControlsNotify</emphasis>
+ event. For more information on <emphasis>
+XkbControlsNotify</emphasis>
+ events, refer to section 10.11. <!-- xref -->
+</para>
+
+
+<para>
+Use <emphasis>
+XkbGetAccessXTimeout</emphasis>
+ to query the current <emphasis>
+AccessXTimeout</emphasis>
+ options for a keyboard device.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetAccessXTimeout</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ timeout_rtrn</emphasis>
+,<emphasis>
+ ctrls_mask_rtrn</emphasis>
+,<emphasis>
+ ctrls_values_rtrn</emphasis>
+,<emphasis>
+ options_mask_rtrn, options_values_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device to query, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short * <emphasis>
+timeout_rtrn</emphasis>
+; /* delay until AccessXTimeout, seconds */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int *<emphasis>
+ ctrls_mask_rtrn</emphasis>
+; /* backfilled with controls to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+ctrls_values_rtrn</emphasis>
+; /* backfilled with on/off status for controls */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short * <emphasis>
+opts_mask_rtrn</emphasis>
+; /* backfilled with <emphasis>
+ax_options</emphasis>
+ to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short * <emphasis>
+opts_values_rtrn</emphasis>
+; /* backfilled with values for <emphasis>
+ax_options</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetAccessXTimeout</emphasis>
+ sends a request to the X server to obtain the current values for the <emphasis>
+AccessXTimeout</emphasis>
+ attributes, waits for a reply, and backfills the values into the appropriate
+arguments.<emphasis>
+ </emphasis>
+The parameters <emphasis>
+opts_mask_rtrn</emphasis>
+ and <emphasis>
+opts_values_rtrn</emphasis>
+ are backfilled with the options to modify and the values for <emphasis>
+ax_options</emphasis>
+, which is a field in the
+<emphasis>XkbControlsRec</emphasis>
+ structure (see section 10.8). <!-- xref -->
+<emphasis>
+XkbGetAccessXTimeout </emphasis>
+returns<emphasis>
+ </emphasis>
+<emphasis>
+True</emphasis>
+ if successful; if a compatible version of the Xkb extension is not available
+in the server, <emphasis>
+XkbGetAccessXTimeout</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+To configure the <emphasis>
+AccessXTimeout</emphasis>
+ options for a keyboard device, use <emphasis>
+XkbSetAccessXTimeout</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetAccessXTimeout</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec, timeout, ctrls_mask, ctrls_values, opts_mask,
+opts_values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ device_spec</emphasis>
+; /* device to configure, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short <emphasis>
+timeout</emphasis>
+; /* seconds idle until AccessXTimeout occurs */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ ctrls_mask</emphasis>
+; /* boolean controls to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ ctrls_values</emphasis>
+; /* new bits for controls selected by <emphasis>
+ctrls_mask</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short <emphasis>
+opts_mask</emphasis>
+; /* <emphasis>
+ax_options</emphasis>
+ to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short <emphasis>
+opts_values</emphasis>
+; /* new bits for <emphasis>
+ax_options</emphasis>
+ selected by <emphasis>
+opts_mask</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+timeout</emphasis>
+ specifies the number of seconds the keyboard must be idle before the controls
+are modified. <emphasis>
+ctrls_mask</emphasis>
+ specifies what controls are to be enabled or disabled, and <emphasis>
+ctrls_values</emphasis>
+ specifies whether those controls are to be enabled or disabled. The bit values
+correspond to those for enabling and disabling boolean controls (see section
+10.1.1). The <emphasis>
+opts_mask</emphasis>
+ field specifies which attributes of the <emphasis>
+AccessXKeys</emphasis>
+ and <emphasis>
+AccessXFeedback</emphasis>
+ controls are to be changed, and <emphasis>
+opts_values</emphasis>
+ specifies the new values for those options. The bit values correspond to those
+for the <emphasis>
+ax_options</emphasis>
+ field of an <emphasis>
+XkbDescRec</emphasis>
+ (see section 10.8). <!-- xref -->
+</para>
+
+
+<para>
+<emphasis>
+XkbSetAccessXTimeout</emphasis>
+ sends a request to configure the <emphasis>
+AccessXTimeout</emphasis>
+ control to the server.<emphasis>
+ </emphasis>
+It does not wait for a reply, and normally returns <emphasis>
+True</emphasis>
+. If a compatible version of the Xkb extension is not available in the server,
+<emphasis>
+XkbSetAccessXTimeout</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='the_accessxfeedback_control'>
+<title>The AccessXFeedback Control</title>
+
+<para>
+Just as some keyboards can produce keyclicks to indicate when a key is pressed
+or repeating, Xkb can provide feedback for the controls by using special beep
+codes. Use the <emphasis>
+AccessXFeedback</emphasis>
+ control to configure the specific types of operations that generate feedback.
+</para>
+
+
+<para>
+There is no convenience function for modifying the <emphasis>
+AccessXFeedback</emphasis>
+ control, although the feedback as a whole can be enabled or disabled just as
+other boolean controls are (see section 10.1). Individual beep codes are turned
+on or off by modifying the following bits in the <emphasis>
+ax_options</emphasis>
+ field of an <emphasis>
+XkbControlsRec</emphasis>
+ structure and using <emphasis>
+XkbSetControls</emphasis>
+ (see section 10.10): <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>AccessXFeedback Masks</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Action</entry>
+ <entry>Beep Code</entry>
+ <entry>ax_options bit</entry>
+ </row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>LED turned on</entry>
+ <entry>High-pitched beep</entry>
+ <entry>XkbAX_IndicatorFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>LED turned off</entry>
+ <entry>Low-pitched beep</entry>
+ <entry>XkbAX_IndicatorFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>More than one LED changed state</entry>
+ <entry>Two high-pitched beeps</entry>
+ <entry>XkbAX_IndicatorFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>Control turned on</entry>
+ <entry>Rising tone</entry>
+ <entry>XkbAX_FeatureFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>Control turned off</entry>
+ <entry>Falling tone</entry>
+ <entry>XkbAX_FeatureFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>More than one control changed state</entry>
+ <entry>Two high-pitched beeps</entry>
+ <entry>XkbAX_FeatureFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys and BounceKeys about to be turned on or off</entry>
+ <entry>Three high-pitched beeps</entry>
+ <entry>XkbAX_SlowWarnFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys key pressed</entry>
+ <entry>Medium-pitched beep</entry>
+ <entry>XkbAX_SKPressFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys key accepted</entry>
+ <entry>Medium-pitched beep</entry>
+ <entry>XkbAX_SKAcceptFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>SlowKeys key rejected</entry>
+ <entry>Low-pitched beep</entry>
+ <entry>XkbAX_SKRejectFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>Accepted SlowKeys key released</entry>
+ <entry>Medium-pitched beep</entry>
+ <entry>XkbAX_SKReleaseFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>BounceKeys key rejected</entry>
+ <entry>Low-pitched beep</entry>
+ <entry>XkbAX_BKRejectFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>StickyKeys key latched</entry>
+ <entry>Low-pitched beep followed by high-pitched beep</entry>
+ <entry>XkbAX_StickyKeysFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>StickyKeys key locked</entry>
+ <entry>High-pitched beep</entry>
+ <entry>XkbAX_StickyKeysFBMask</entry>
+</row>
+<row rowsep='0'>
+ <entry>StickyKeys key unlocked</entry>
+ <entry>Low-pitched beep</entry>
+ <entry>XkbAX_StickyKeysFBMask</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Implementations that cannot generate continuous tones may generate multiple
+beeps instead of falling and rising tones; for example, they can generate a
+high-pitched beep followed by a low-pitched beep instead of a continuous
+falling tone. Other implementations can only ring the bell with one fixed
+pitch. In these cases, use the <emphasis>
+XkbAX_DumbBellFBMask</emphasis>
+ bit of <emphasis>
+ax_options</emphasis>
+ to indicate that the bell can only ring with a fixed pitch.
+</para>
+
+
+<para>
+When any of the above feedbacks occur, Xkb may generate a <emphasis>
+XkbBellNotify</emphasis>
+ event (see section 9.4). <!-- xref -->
+</para>
+
+
+</sect2>
+<sect2 id='accessxnotify_events'>
+<title>AccessXNotify Events</title>
+
+<para>
+The server can generate <emphasis>
+XkbAccessXNotify</emphasis>
+ events for some of the global keyboard controls. The structure for the
+<emphasis>
+XkbAccessXNotify</emphasis>
+ event type is as follows:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis> True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis> XkbAccessXNotify</emphasis> */
+ int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
+ int detail; /* XkbAXN_* */
+ KeyCode keycode; /* key of event */
+ int slowKeysDelay; /* current SlowKeys delay */
+ int debounceDelay; /* current debounce delay */
+} <emphasis>XkbAccessXNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+detail</emphasis>
+ field describes what AccessX event just occurred and can be any of the values
+in Table 10.4. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>AccessXNotify Events</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>detail</entry>
+ <entry>Reason</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbAXN_SKPress</entry>
+ <entry>A key was pressed when SlowKeys was enabled.</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAXN_SKAccept</entry>
+ <entry>A key was accepted (held longer than the SlowKeys delay).</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAXN_SKRelease</entry>
+ <entry>An accepted SlowKeys key was released.</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAXN_SKReject</entry>
+ <entry>A key was rejected (released before the SlowKeys delay
+expired).</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAXN_BKAccept</entry>
+ <entry>A key was accepted by BounceKeys.</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAXN_BKReject</entry>
+ <entry>A key was rejected (pressed before the BounceKeys delay
+expired).</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAXN_AXKWarning</entry>
+ <entry>AccessXKeys is about to turn on/off StickyKeys or BounceKeys.</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+keycode</emphasis>
+ field reports the keycode of the key for which the event occurred. If the
+action is related to <emphasis>
+SlowKeys</emphasis>
+, the <emphasis>
+slowKeysDelay</emphasis>
+ field contains the current <emphasis>
+SlowKeys</emphasis>
+ acceptance delay. If the action is related to <emphasis>
+BounceKeys</emphasis>
+, the <emphasis>
+debounceDelay</emphasis>
+ field contains the current <emphasis>
+BounceKeys</emphasis>
+ debounce delay.
+</para>
+
+<sect3 id='selecting_for_accessx_events'>
+<title>Selecting for AccessX Events</title>
+
+<para>
+To receive <emphasis>
+XkbAccessXNotify</emphasis>
+ events under all possible conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) and pass <emphasis> <!-- xref -->
+XkbAccesXNotifyMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbStateNotify</emphasis>
+ events only under certain conditions, use <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbAccessXNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying the desired state changes in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ using mask bits from Table 10.5. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>AccessXNotify Event Details</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>XkbAccessXNotify Event Details</entry>
+ <entry>Value</entry>
+ <entry>Circumstances</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbAXN_SKPressMask</entry>
+ <entry>(1&lt;&lt;0)</entry>
+ <entry>Slow key press notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_SKAcceptMask</entry>
+ <entry>(1&lt;&lt;1)</entry>
+ <entry>Slow key accept notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_SKRejectMask</entry>
+ <entry>(1&lt;&lt;2)</entry>
+ <entry>Slow key reject notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_SKReleaseMask</entry>
+ <entry>(1&lt;&lt;3)</entry>
+ <entry>Slow key release notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_BKAcceptMask</entry>
+ <entry>(1&lt;&lt;4)</entry>
+ <entry>Bounce key accept notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_BKRejectMask</entry>
+ <entry>(1&lt;&lt;5)</entry>
+ <entry>Bounce key reject notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_AXKWarningMask</entry>
+ <entry>(1&lt;&lt;6)</entry>
+ <entry>AccessX warning notification wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAXN_AllEventsMask</entry>
+ <entry>(0x7f)</entry>
+ <entry>All AccessX features notifications wanted</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect3>
+</sect2>
+<sect2 id='stickykeys_repeatkeys_and_mousekeys_events'>
+<title>StickyKeys, RepeatKeys, and MouseKeys Events</title>
+
+<para>
+The <emphasis>
+StickyKeys</emphasis>
+, <emphasis>
+RepeatKeys</emphasis>
+, and <emphasis>
+MouseKeys</emphasis>
+ controls do not generate specific events. Instead, the latching, unlatching,
+locking, or unlocking of modifiers using <emphasis>
+StickyKeys</emphasis>
+ generates <emphasis>
+XkbStateNotify</emphasis>
+ events as described in section 5.4. Repeating keys generate normal <emphasis> <!-- xref -->
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events, though the auto-repeat can be detected using <emphasis>
+DetectableAutorepeat</emphasis>
+ (see section 10.3.3). Finally, <emphasis> <!-- xref -->
+MouseKeys</emphasis>
+ generates pointer events identical to those of the core pointer device.
+</para>
+
+
+</sect2>
+<sect2 id='the_slowkeys_control'>
+<title>The SlowKeys Control</title>
+
+<para>
+Some users may accidentally bump keys while moving a hand or typing stick
+toward the key they want. Usually, the keys that are accidentally bumped are
+just hit for a very short period of time. The <emphasis>
+SlowKeys</emphasis>
+ control helps filter these accidental bumps by telling the server to wait a
+specified period, called the <emphasis>
+SlowKeys acceptance delay</emphasis>
+, before delivering key events. If the key is released before this period
+elapses, no key events are generated. Users can then bump any number of keys on
+their way to the one they want without accidentally getting those characters.
+Once they have reached the key they want, they can then hold the desired key
+long enough for the computer to accept it. <emphasis>
+SlowKeys</emphasis>
+ is a boolean control with one configurable attribute.
+</para>
+
+<para>
+When the <emphasis>
+SlowKeys</emphasis>
+ control is active, the server reports the initial key press, subsequent
+acceptance or rejection, and release of any key to interested clients by
+sending an appropriate <emphasis>
+AccessXNotify</emphasis>
+ event (see section 10.6.4). <!-- xref -->
+</para>
+
+<para>
+To get the <emphasis>
+SlowKeys</emphasis>
+ acceptance delay for a keyboard device, use <emphasis>
+XkbGetSlowKeysDelay</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetSlowKeysDelay</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ delay_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+delay_rtrn</emphasis>
+; /* backfilled with <emphasis>
+SlowKeys</emphasis>
+ delay, ms */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetSlowKeysDelay </emphasis>
+requests the attributes of the <emphasis>
+SlowKeys</emphasis>
+ control from the server, waits for a reply and backfills <emphasis>
+delay_rtrn </emphasis>
+with the <emphasis>
+SlowKeys</emphasis>
+ delay attribute. <emphasis>
+XkbGetSlowKeysDelay </emphasis>
+returns <emphasis>
+True</emphasis>
+ if successful; if a compatible version of the Xkb extension is not available
+in the server, <emphasis>
+XkbGetSlowKeysDelay</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+To set the <emphasis>
+SlowKeys</emphasis>
+ acceptance delay for a keyboard device, use <emphasis>
+XkbSetSlowKeysDelay</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetSlowKeysDelay</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ delay</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device to configure, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+delay</emphasis>
+; /* <emphasis>
+SlowKeys</emphasis>
+ delay, ms */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetSlowKeysDelay</emphasis>
+ sends a request to configure the <emphasis>
+SlowKeys</emphasis>
+ control to the server.<emphasis>
+ </emphasis>
+It does not wait for a reply, and normally returns <emphasis>
+True</emphasis>
+. Specifying a value of <emphasis>
+0</emphasis>
+ for the <emphasis>
+delay </emphasis>
+parameter causes <emphasis>
+XkbSetSlowKeys</emphasis>
+ to generate a <emphasis>
+BadValue</emphasis>
+ protocol error. If a compatible version of the Xkb extension is not available
+in the server <emphasis>
+XkbSetSlowKeysDelay</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='the_bouncekeys_control'>
+<title>The BounceKeys Control</title>
+
+<para>
+Some users may accidentally "bounce" on a key when they release it. They press
+it once, then accidentally press it again after they release it. The <emphasis>
+BounceKeys</emphasis>
+ control temporarily disables a key after it has been pressed, effectively
+"debouncing" the keyboard. The period of time the key is disabled after it is
+released is known as the <emphasis>
+BounceKeys delay</emphasis>
+. <emphasis>
+BounceKeys</emphasis>
+ is a boolean control.
+</para>
+
+
+<para>
+When the <emphasis>
+BounceKeys</emphasis>
+ control is active, the server reports acceptance or rejection of any key to
+interested clients by sending an appropriate <emphasis>
+AccessXNotify</emphasis>
+ event (see section 10.6.4). <!-- xref -->
+</para>
+
+
+<para>
+Use <emphasis>
+XkbGetBounceKeysDelay</emphasis>
+ to query the current <emphasis>
+BounceKeys</emphasis>
+ delay for a keyboard device.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetBounceKeysDelay</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ delay_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+delay_rtrn</emphasis>
+; /* backfilled with bounce keys delay, ms */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetBounceKeysDelay </emphasis>
+requests the attributes of the <emphasis>
+BounceKeys</emphasis>
+ control from the server, waits for a reply, and backfills <emphasis>
+delay_rtrn </emphasis>
+with the <emphasis>
+BounceKeys</emphasis>
+ delay attribute. <emphasis>
+XkbGetBounceKeysDelay </emphasis>
+returns<emphasis>
+ </emphasis>
+<emphasis>
+True</emphasis>
+ if successful; if a compatible version of the Xkb extension is not available
+in the server <emphasis>
+XkbGetSlowKeysDelay</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+To set the <emphasis>
+BounceKeys</emphasis>
+ delay for a keyboard device, use <emphasis>
+XkbSetBounceKeysDelay</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetBounceKeysDelay</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ delay</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ device_spec</emphasis>
+; /* device to configure, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+delay</emphasis>
+; /* bounce keys delay, ms */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetBounceKeysDelay</emphasis>
+ sends a request to configure the <emphasis>
+BounceKeys</emphasis>
+ control to the server.<emphasis>
+ </emphasis>
+It does not wait for a reply and normally returns <emphasis>
+True</emphasis>
+. Specifying a value of <emphasis>
+zero </emphasis>
+for the <emphasis>
+delay </emphasis>
+parameter causes <emphasis>
+XkbSetBounceKeysDelay</emphasis>
+ to generate a <emphasis>
+BadValue</emphasis>
+ protocol error. If a compatible version of the Xkb extension is not available
+in the server, <emphasis>
+XkbSetBounceKeysDelay</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+</sect2>
+<sect2 id='the_stickykeys_control'>
+<title>The StickyKeys Control</title>
+
+<para>
+Some people find it difficult or even impossible to press two keys at once. For
+example, a one-fingered typist or someone using a mouth stick cannot press the
+<emphasis>
+Shift</emphasis>
+ and <emphasis>
+1</emphasis>
+ keys at the same time. The <emphasis>
+StickyKeys</emphasis>
+ control solves this problem by changing the behavior of the modifier keys.
+With <emphasis>
+StickyKeys</emphasis>
+, the user can first press a modifier, release it, then press another key. For
+example, to get an exclamation point on a PC-style keyboard, the user can press
+the <emphasis>
+Shift</emphasis>
+ key, release it, and then press the <emphasis>
+1</emphasis>
+ key.
+</para>
+
+
+<para>
+<emphasis>
+StickyKeys</emphasis>
+ also allows users to lock modifier keys without requiring special locking
+keys. When <emphasis>
+StickyKeys</emphasis>
+ is enabled, a modifier is latched when the user presses it just once. The user
+can press a modifier twice in a row to lock it, and then unlock it by pressing
+it one more time.
+</para>
+
+
+<para>
+When a modifier is latched, it becomes unlatched when the user presses a
+nonmodifier key or a pointer button. For instance, to enter the sequence
+<emphasis>
+Shift</emphasis>
++<emphasis>
+Control</emphasis>
++<emphasis>
+Z</emphasis>
+ the user could press and release the <emphasis>
+Shift</emphasis>
+ key to latch it, then press and release the <emphasis>
+Control</emphasis>
+ key to latch it, and finally press and release the Z key. Because the
+<emphasis>
+Control</emphasis>
+ key is a modifier key, pressing it does not unlatch the <emphasis>
+Shift</emphasis>
+ key. Thus, after the user presses the <emphasis>
+Control</emphasis>
+ key, both the <emphasis>
+Shift</emphasis>
+ and <emphasis>
+Control</emphasis>
+ modifiers are latched. When the user presses the <emphasis>
+Z</emphasis>
+ key, the effect is as though the user had pressed <emphasis>
+Shift</emphasis>
++<emphasis>
+Control</emphasis>
++<emphasis>
+Z</emphasis>
+. In addition, because the <emphasis>
+Z</emphasis>
+ key is not a modifier key, the <emphasis>
+Shift</emphasis>
+ and <emphasis>
+Control</emphasis>
+ modifiers are unlatched.
+</para>
+
+
+<para>
+Locking a modifier key means that the modifier affects any key or pointer
+button the user presses until the user unlocks it or it is unlocked
+programmatically. For example, to enter the sequence ("XKB") on a keyboard
+where ‘(’ is a shifted ‘9’, ‘)’ is a shifted ‘0’, and ‘"’
+is a shifted single quote, the user could press and release the <emphasis>
+Shift</emphasis>
+ key twice to lock the <emphasis>
+Shift</emphasis>
+ modifier. Then, when the user presses the <emphasis>
+9</emphasis>
+, <emphasis>
+‘</emphasis>
+, <emphasis>
+x</emphasis>
+, <emphasis>
+k</emphasis>
+, <emphasis>
+b</emphasis>
+, <emphasis>
+‘</emphasis>
+, and <emphasis>
+0</emphasis>
+ keys in sequence, it generates ("XKB"). To unlock the <emphasis>
+Shift</emphasis>
+ modifier, the user can press and release the <emphasis>
+Shift</emphasis>
+ key.
+</para>
+
+
+<para>
+<emphasis>StickyKeys</emphasis>
+ is a boolean control with two separate attributes that may be individually
+configured: one to automatically disable it, and one to control the latching
+behavior of modifier keys.
+</para>
+
+<sect3 id='stickykeys_options'>
+<title>StickyKeys Options</title>
+
+<para>
+The <emphasis>
+StickyKeys</emphasis>
+ control has two options that can be accessed via the <emphasis>
+ax_options</emphasis>
+ of an <emphasis>
+XkbControlsRec</emphasis>
+ structure (see section 10.8). The first option, <emphasis>
+TwoKeys</emphasis>
+, specifies whether <emphasis>
+StickyKeys</emphasis>
+ should automatically turn off when two keys are pressed at the same time. This
+feature is useful for shared computers so people who do not want them do not
+need to turn <emphasis>
+StickyKeys</emphasis>
+ off if a previous user left <emphasis>
+StickyKeys</emphasis>
+ on. The second option, <emphasis>
+LatchToLock</emphasis>
+, specifies whether or not <emphasis>
+StickyKeys</emphasis>
+ locks a modifier when pressed twice in a row.
+</para>
+
+
+<para>
+Use <emphasis>
+XkbGetStickyKeysOptions</emphasis>
+ to query the current <emphasis>
+StickyKeys</emphasis>
+ attributes for a keyboard device.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetStickyKeysOptions</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec</emphasis>
+,<emphasis>
+ options_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+options_rtrn</emphasis>
+; /* backfilled with StickyKeys option mask */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetStickyKeysOptions </emphasis>
+requests the attributes of the <emphasis>
+StickyKeys</emphasis>
+ control from the server, waits for a reply, and backfills <emphasis>
+options_rtrn </emphasis>
+with a mask indicating whether the individual <emphasis>
+StickyKeys</emphasis>
+ options are on or off. Valid bits in <emphasis>
+options_rtrn</emphasis>
+ are:
+</para>
+
+<para>
+<programlisting>
+ <emphasis>XkbAX_TwoKeysMask</emphasis>
+ <emphasis>XkbAX_LatchToLockMask</emphasis>
+</programlisting>
+</para>
+
+<para>
+<emphasis>
+XkbGetStickyKeysOptions </emphasis>
+returns <emphasis>
+True</emphasis>
+ if successful; if a compatible version of the Xkb extension is not available
+in the server <emphasis>
+XkbGetStickyKeysOptions</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+To set the <emphasis>
+StickyKeys</emphasis>
+ attributes for a keyboard device, use <emphasis>
+XkbSetStickyKeysOptions</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetStickyKeysOptions</emphasis>
+(<emphasis>
+display</emphasis>
+,<emphasis>
+ device_spec, mask, values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device to configure, or XkbUseCoreKbd */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+mask</emphasis>
+; /* selects StickyKeys attributes to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+values;</emphasis>
+ /* values for selected attributes */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetStickyKeysOptions</emphasis>
+ sends a request to configure the <emphasis>
+StickyKeys</emphasis>
+ control to the server.<emphasis>
+ </emphasis>
+It does not wait for a reply and normally returns <emphasis>
+True</emphasis>
+. The valid bits to use for both the <emphasis>
+mask</emphasis>
+ and <emphasis>
+values</emphasis>
+ parameters are:
+</para>
+
+<para>
+<programlisting>
+ <emphasis>XkbAX_TwoKeysMask</emphasis>
+ <emphasis>XkbAX_LatchToLockMask</emphasis>
+</programlisting>
+</para>
+
+<para>
+ If a compatible version of the Xkb extension is not available in the server,
+<emphasis>
+XkbSetStickyKeysOptions</emphasis>
+ returns <emphasis>
+False</emphasis>
+.
+</para>
+
+</sect3>
+</sect2>
+</sect1>
+<sect1 id='controls_for_general_keyboard_mapping'>
+<title>Controls for General Keyboard Mapping</title>
+
+<para>
+There are several controls that apply to the keyboard mapping in general. They
+control handling of out-of-range group indices and how modifiers are processed
+and consumed in the server. These are:
+</para>
+
+<para>
+<programlisting>
+ <emphasis>GroupsWrap</emphasis>
+ <emphasis>IgnoreGroupLock</emphasis>
+ <emphasis>IgnoreLockMods</emphasis>
+ <emphasis>InternalMods </emphasis>
+</programlisting>
+</para>
+
+<para>
+<emphasis>
+IgnoreGroupLock</emphasis>
+ is a boolean control; the rest are always active.
+</para>
+
+
+<para>
+Without the modifier processing options provided by Xkb, passive grabs set via
+translations in a client (for example, <emphasis>
+Alt&lt;KeyPress&gt;space</emphasis>
+) do not trigger if any modifiers other than those specified by the translation
+are set. This results in problems in the user interface when either <emphasis>
+NumLock</emphasis>
+ or a secondary keyboard group is active. The <emphasis>
+IgnoreLockMods</emphasis>
+ and <emphasis>
+IgnoreGroupLock</emphasis>
+ controls make it possible to avoid this behavior without exhaustively
+specifying a grab for every possible modifier combination.
+</para>
+
+<sect2 id='the_groupswrap_control'>
+<title>The GroupsWrap Control</title>
+
+<para>
+The <emphasis>
+GroupsWrap</emphasis>
+ control determines how illegal groups are handled on a global basis. There are
+a number of valid keyboard sequences that can cause the effective group number
+to go out of range. When this happens, the group must be normalized back to a
+valid number. The <emphasis>
+GroupsWrap</emphasis>
+ control specifies how this is done.
+</para>
+
+
+<para>
+When dealing with group numbers, all computations are done using the group
+index, which is the group number minus one. There are three different
+algorithms; the <emphasis>
+GroupsWrap</emphasis>
+ control specifies which one is used:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>XkbRedirectIntoRange</para>
+ <para>
+All invalid group numbers are converted to a valid group number by taking the
+last four bits of the <emphasis>
+GroupsWrap</emphasis>
+ control and using them as the group index. If the result is still out of
+range, Group one is used.
+ </para>
+</listitem>
+<listitem>
+ <para>
+XkbClampIntoRange
+ </para>
+ <para>
+All invalid group numbers are converted to the nearest valid group number.
+Group numbers larger than the highest supported group number are mapped to the
+highest supported group; those less than one are mapped to group one.
+ </para>
+</listitem>
+<listitem>
+ <para>XkbWrapIntoRange</para>
+ <para>
+All invalid group numbers are converted to a valid group number using integer
+modulus applied to the group index.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+There are no convenience functions for manipulating the <emphasis>
+GroupsWrap</emphasis>
+ control. Manipulate the <emphasis>
+GroupsWrap</emphasis>
+ control via the <emphasis>
+groups_wrap</emphasis>
+ field in the <emphasis>
+XkbControlsRec</emphasis>
+ structure, then use <emphasis>
+XkbSetControls</emphasis>
+ and <emphasis>
+XkbGetControls</emphasis>
+ (see section 10.9 and section 10.10) to query and change this control. <!-- xref -->
+</para>
+
+<note><para>See also section 15.3.2 or a discussion of the related field, <!-- xref -->
+<emphasis>
+group_info</emphasis>
+, which also normalizes a group under certain circumstances.</para></note>
+
+</sect2>
+<sect2 id='the_ignorelockmods_control'>
+<title>The IgnoreLockMods Control</title>
+
+<para>
+The core protocol does not provide a way to exclude specific modifiers from
+grab calculations, with the result that locking modifiers sometimes have
+unanticipated side effects.
+</para>
+
+
+<para>
+The <emphasis>
+IgnoreLockMods</emphasis>
+ control specifies modifiers that should be excluded from grab calculations.
+These modifiers are also not reported in any core events except <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events that do not activate a passive grab and that do not occur while a grab
+is active.
+</para>
+
+
+<para>
+Manipulate the <emphasis>
+IgnoreLockMods</emphasis>
+ control via the <emphasis>
+ignore_lock</emphasis>
+ field in the <emphasis>
+XkbControlsRec</emphasis>
+ structure, then use <emphasis>
+XkbSetControls</emphasis>
+ and <emphasis>
+XkbGetControls</emphasis>
+ (see sections 10.9 and 10.10) to query and change this control. Alternatively, <!-- xref -->
+use <emphasis>
+XkbSetIgnoreLockMods</emphasis>
+.
+</para>
+
+
+<para>
+To set the modifiers that, if locked, are not to be reported in matching events
+to passive grabs, use <emphasis>
+XkbSetIgnoreLockMods.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetIgnoreLockMods</emphasis>
+(<emphasis>
+display, device_spec, affect_real, real_values, affect_virtual,
+virtual_values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ affect_real</emphasis>
+; /* mask of real modifiers affected by this call */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ real_values</emphasis>
+; /* values for affected real modifiers (1=&gt;set, 0=&gt;unset) */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ affect_virtual</emphasis>
+; /* mask of virtual modifiers affected by this call */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ virtual_values</emphasis>
+; /* values for affected virtual modifiers (1=&gt;set, 0=&gt;unset)
+*/
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetIgnoreLockMods</emphasis>
+ sends a request to the server to change the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control. <emphasis>
+affect_real</emphasis>
+ and <emphasis>
+real_values</emphasis>
+ are masks of real modifier bits indicating which real modifiers are to be
+added and removed from the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control. Modifiers selected by both <emphasis>
+affect_real</emphasis>
+ and <emphasis>
+real_values</emphasis>
+ are added to the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control; those selected by <emphasis>
+affect_real</emphasis>
+ but not by <emphasis>
+real_values</emphasis>
+ are removed from the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control. Valid values for <emphasis>
+affect_real</emphasis>
+ and <emphasis>
+real_values</emphasis>
+ consist of any combination of the eight core modifier bits: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+ - <emphasis>
+Mod5Mask</emphasis>
+. <emphasis>
+affect_virtual</emphasis>
+ and <emphasis>
+virtual_values</emphasis>
+ are masks of virtual modifier bits indicating which virtual modifiers are to
+be added and removed from the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control. Modifiers selected by both <emphasis>
+affect_virtual</emphasis>
+ and <emphasis>
+virtual_values</emphasis>
+ are added to the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control; those selected by <emphasis>
+affect_virtual</emphasis>
+ but not by <emphasis>
+virtual_values</emphasis>
+ are removed from the server’s <emphasis>
+IgnoreLockMods</emphasis>
+ control.<emphasis>
+ </emphasis>
+See section 7.1 for a discussion of virtual modifier masks to use in <emphasis> <!-- xref -->
+affect_virtual</emphasis>
+ and <emphasis>
+virtual_values</emphasis>
+. <emphasis>
+XkbSetIgnoreLockMods</emphasis>
+ does not wait for a reply from the server. It returns <emphasis>
+True</emphasis>
+ if the request was sent, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+</sect2>
+<sect2 id='the_ignoregrouplock_control'>
+<title>The IgnoreGroupLock Control</title>
+
+<para>
+The <emphasis>
+IgnoreGroupLock</emphasis>
+ control is a boolean control with no attributes. If enabled, it specifies that
+the locked state of the keyboard group should not be considered when activating
+passive grabs.
+</para>
+
+<para>
+Because <emphasis>
+IgnoreGroupLock</emphasis>
+ is a boolean control with no attributes, use the general boolean controls
+functions (see section 10.1) to change its state. <!-- xref -->
+</para>
+
+
+</sect2>
+<sect2 id='the_internalmods_control'>
+<title>The InternalMods Control</title>
+
+<para>
+The core protocol does not provide any means to prevent a modifier from being
+reported in events sent to clients; Xkb, however makes this possible via the
+<emphasis>
+InternalMods</emphasis>
+ control. It specifies modifiers that should be consumed by the server and not
+reported to clients. When a key is pressed and a modifier that has its bit set
+in the <emphasis>
+InternalMods</emphasis>
+ control is reported to the server, the server uses the modifier when
+determining the actions to apply for the key. The server then clears the bit,
+so it is not actually reported to the client. In addition, modifiers specified
+in the <emphasis>
+InternalMods</emphasis>
+ control are not used to determine grabs and are not used to calculate core
+protocol compatibility state.
+</para>
+
+
+<para>
+Manipulate the <emphasis>
+InternalMods</emphasis>
+ control via the <emphasis>
+internal</emphasis>
+ field in the <emphasis>
+XkbControlsRec</emphasis>
+ structure, using <emphasis>
+XkbSetControls</emphasis>
+ and <emphasis>
+XkbGetControls</emphasis>
+ (see sections10.9 and 10.10). Alternatively, use <emphasis> <!-- xref -->
+XkbSetServerInternalMods</emphasis>
+.
+</para>
+
+
+<para>
+To set the modifiers that are consumed by the server before events are
+delivered to the client, use <emphasis>
+XkbSetServerInternalMods.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetServerInternalMods</emphasis>
+(<emphasis>
+display, device_spec, affect_real, real_values, affect_virtual,
+virtual_values</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+display</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+;‘ /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ affect_real</emphasis>
+; /* mask of real modifiers affected by this call */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ real_values</emphasis>
+; /* values for affected real modifiers (1=&gt;set, 0=&gt;unset) */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ affect_virtual</emphasis>
+; /* mask of virtual modifiers affected by this call */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ virtual_values</emphasis>
+; /* values for affected virtual modifiers (1=&gt;set, 0=&gt;unset)
+*/
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetServerInternalMods</emphasis>
+ sends a request to the server to change the internal modifiers consumed by the
+server. <emphasis>
+affect_real</emphasis>
+ and <emphasis>
+real_values</emphasis>
+ are masks of real modifier bits indicating which real modifiers are to be
+added and removed from the server’s internal modifiers control. Modifiers
+selected by both <emphasis>
+affect_real</emphasis>
+ and <emphasis>
+real_values</emphasis>
+ are added to the server’s internal modifiers control; those selected by
+<emphasis>
+affect_real</emphasis>
+ but not by <emphasis>
+real_values</emphasis>
+ are removed from the server’s internal modifiers mask. Valid values for
+<emphasis>
+affect_real</emphasis>
+ and <emphasis>
+real_values</emphasis>
+ consist of any combination of the eight core modifier bits: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+ - <emphasis>
+Mod5Mask</emphasis>
+.<emphasis>
+ affect_virtual</emphasis>
+ and <emphasis>
+virtual_values</emphasis>
+ are masks of virtual modifier bits indicating which virtual modifiers are to
+be added and removed from the server’s internal modifiers control. Modifiers
+selected by both <emphasis>
+affect_virtual</emphasis>
+ and <emphasis>
+virtual_values</emphasis>
+ are added to the server’s internal modifiers control; those selected by
+<emphasis>
+affect_virtual</emphasis>
+ but not by <emphasis>
+virtual_values</emphasis>
+ are removed from the server’s internal modifiers control.<emphasis>
+ </emphasis>
+See section 7.1 for a discussion of virtual modifier masks to use in <emphasis> <!-- xref -->
+affect_virtual</emphasis>
+ and <emphasis>
+virtual_values</emphasis>
+.<emphasis>
+ XkbSetServerInternalMods</emphasis>
+ does not wait for a reply from the server. It returns <emphasis>
+True</emphasis>
+ if the request was sent and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='the_xkbcontrolsrec_structure'>
+<title>The XkbControlsRec Structure</title>
+
+<para>
+Many of the individual controls described in sections 10.1 through 10.7 may be
+manipulated via convenience functions discussed in those sections. Some of
+them, however, have no convenience functions. The <emphasis>
+XkbControlsRec</emphasis>
+ structure allows the manipulation of one or more of the controls in a single
+operation and to track changes to any of them in conjunction with the <emphasis>
+XkbGetControls</emphasis>
+ and <emphasis>
+XkbSetControls</emphasis>
+ functions. This is the only way to manipulate those controls that have no
+convenience functions.
+</para>
+
+
+<para>
+The <emphasis>
+XkbControlsRec</emphasis>
+ structure is defined as follows:
+</para>
+
+<para>
+<programlisting>
+#define XkbMaxLegalKeyCode 255
+#define XkbPerKeyBitArraySize ((XkbMaxLegalKeyCode+1)/8)
+</programlisting>
+</para>
+<para>
+<programlisting>
+typedef struct {
+ unsigned char mk_dflt_btn; /* default button for keyboard driven mouse */
+ unsigned char num_groups; /* number of keyboard groups */
+ unsigned char groups_wrap; /* how to wrap out-of-bounds groups */
+ XkbModsRec internal; /* defines server internal modifiers */
+ XkbModsRec ignore_lock; /* modifiers to ignore when checking for grab */
+ unsigned int enabled_ctrls; /* 1 bit =&gt; corresponding boolean control enabled */
+ unsigned short repeat_delay; /* ms delay until first repeat */
+ unsigned short repeat_interval; /* ms delay between repeats */
+ unsigned short slow_keys_delay; /* ms minimum time key must be down to be ok */
+ unsigned short debounce_delay; /* ms delay before key reactivated */
+ unsigned short mk_delay; /* ms delay to second mouse motion event */
+ unsigned short mk_interval; /* ms delay between repeat mouse events */
+ unsigned short mk_time_to_max; /* # intervals until constant mouse move */
+ unsigned short mk_max_speed; /* multiplier for maximum mouse speed */
+ short mk_curve; /* determines mouse move curve type */
+ unsigned short ax_options; /* 1 bit =&gt; Access X option enabled */
+ unsigned short ax_timeout; /* seconds until Access X disabled */
+ unsigned short axt_opts_mask; /* 1 bit =&gt; options to reset on Access X timeout */
+ unsigned short axt_opts_values; /* 1 bit =&gt; turn option on, 0=&gt; off */
+ unsigned int axt_ctrls_mask; /* which bits in <emphasis> enabled_ctrls</emphasis> to modify */
+ unsigned int axt_ctrls_values; /* values for new bits in <emphasis> enabled_ctrls</emphasis> */
+ unsigned char per_key_repeat[XkbPerKeyBitArraySize]; /* per key auto repeat */
+} <emphasis>XkbControlsRec</emphasis>, *XkbControlsPtr;
+</programlisting>
+</para>
+
+<para>
+The general-purpose functions that work with the <emphasis>
+XkbControlsRec</emphasis>
+ structure use a mask to specify which controls are to be manipulated. Table
+10.6 lists these controls, the masks used to select them in the general
+function calls (<emphasis>
+which</emphasis>
+ parameter), and the data fields in the <emphasis>
+XkbControlsRec</emphasis>
+ structure that comprise each of the individual controls. Also listed are the
+bit used to turn boolean controls on and off and the section where each control
+is described in more detail.
+</para>
+
+<table frame='none'>
+<title>Xkb Controls</title>
+<tgroup cols='5'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Control</entry>
+ <entry>Control Selection Mask (which parameter)</entry>
+ <entry>Relevant XkbControlsRec Data Fields</entry>
+ <entry>Boolean Control enabled_ctrls bit</entry>
+ <entry>Section</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>AccessXFeedback</entry>
+ <entry>XkbAccessXFeedbackMask</entry>
+ <entry>ax_options: XkbAX_*FBMask</entry>
+ <entry>XkbAccessXFeedbackMask</entry>
+ <entry>10.6.3</entry> <!-- xref -->
+ </row>
+ <row rowsep='0'>
+ <entry>AccessXKeys</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>XkbAccessXKeysMask</entry>
+ <entry>10.6.1</entry> <!-- xref -->
+ </row>
+ <row rowsep='0'>
+ <entry>AccessXTimeout</entry>
+ <entry>XkbAccessXTimeoutMask</entry>
+ <entry>
+ <para>ax_timeout</para>
+ <para>axt_opts_mask</para>
+ <para>axt_opts_values</para>
+ <para>axt_ctrls_mask</para>
+ <para>axt_ctrls_values</para>
+ </entry>
+ <entry>XkbAccessXTimeoutMask</entry>
+ <entry>10.6.2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>AudibleBell</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>XkbAudibleBellMask</entry>
+ <entry>9.2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>AutoReset</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>10.1.2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>BounceKeys</entry>
+ <entry>XkbBounceKeysMask</entry>
+ <entry>debounce_delay</entry>
+ <entry>XkbBounceKeysMask</entry>
+ <entry>10.6.7</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Detectable-Autorepeat</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>10.3.3</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>EnabledControls</entry>
+ <entry>XkbControlsEnabledMask</entry>
+ <entry>enabled_ctrls</entry>
+ <entry><emphasis>Non-Boolean Control</emphasis></entry>
+ <entry>10.1.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>GroupsWrap</entry>
+ <entry>XkbGroupsWrapMask</entry>
+ <entry>groups_wrap</entry>
+ <entry><emphasis>Non-Boolean Control</emphasis></entry>
+ <entry>10.7.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>IgnoreGroupLock</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>XkbIgnoreGroupLockMask</entry>
+ <entry>10.7.3</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>IgnoreLockMods</entry>
+ <entry>XkbIgnoreLockModsMask</entry>
+ <entry>ignore_lock</entry>
+ <entry><emphasis>Non-Boolean Control</emphasis></entry>
+ <entry>5.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>InternalMods</entry>
+ <entry>XkbInternalModsMask</entry>
+ <entry>internal</entry>
+ <entry><emphasis>Non-Boolean Control</emphasis></entry>
+ <entry>5.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>MouseKeys</entry>
+ <entry>XkbMouseKeysMask</entry>
+ <entry>mk_dflt_btn</entry>
+ <entry>XkbMouseKeysMask</entry>
+ <entry>10.5.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>MouseKeysAccel</entry>
+ <entry>XkbMouseKeysAccelMask</entry>
+ <entry>
+ <para>mk_delay</para>
+ <para>mk_interval</para>
+ <para>mk_time_to_max</para>
+ <para>mk_max_speed</para>
+ <para>mk_curve</para>
+ </entry>
+ <entry>XkbMouseKeysAccelMask</entry>
+ <entry>10.5.2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Overlay1</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>XkbOverlay1Mask</entry>
+ <entry>10.4</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Overlay2</entry>
+ <entry></entry>
+ <entry></entry>
+ <entry>XkbOverlay2Mask</entry>
+ <entry>10.4</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>PerKeyRepeat</entry>
+ <entry>XkbPerKeyRepeatMask</entry>
+ <entry>per_key_repeat</entry>
+ <entry><emphasis>Non-Boolean Control</emphasis></entry>
+ <entry>10.3.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>RepeatKeys</entry>
+ <entry>XkbRepeatKeysMask</entry>
+ <entry>
+ <para>repeat_delay</para>
+ <para>repeat_interval</para>
+ </entry>
+ <entry>XkbRepeatKeysMask</entry>
+ <entry>10.3</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>SlowKeys</entry>
+ <entry>XkbSlowKeysMask</entry>
+ <entry>slow_keys_delay</entry>
+ <entry>XkbSlowKeysMask</entry>
+ <entry>10.6.6</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>StickyKeys</entry>
+ <entry>XkbStickyKeysMask</entry>
+ <entry>
+ <para>ax_options:</para>
+ <para>XkbAX_TwoKeysMask</para>
+ <para>XkbAX_LatchToLockMask</para>
+ </entry>
+ <entry>XkbStickyKeysMask</entry>
+ <entry>10.6.8</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Table 10.7 shows the actual values for the individual mask bits used to select <!-- xref -->
+controls for modification and to enable and disable the control. Note that the
+same mask bit is used to specify general modifications to the parameters used
+to configure the control (<emphasis>
+which</emphasis>
+), and to enable and disable the control (<emphasis>
+enabled_ctrls</emphasis>
+). The anomalies in the table (no "ok" in column) are for controls that have no
+configurable attributes; and for controls that are not boolean controls and
+therefore cannot be enabled or disabled.
+</para>
+
+<table frame='none'>
+<title>Controls Mask Bits</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask Bit</entry>
+ <entry>which or changed_ctrls</entry>
+ <entry>enabled_ctrls</entry>
+ <entry>Value</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbRepeatKeysMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;0)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbSlowKeysMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;1)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbBounceKeysMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;2)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbStickyKeysMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;3)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbMouseKeysMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;4)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbMouseKeysAccelMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;5)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAccessXKeysMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;6)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAccessXTimeoutMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;7)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAccessXFeedbackMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;8)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAudibleBellMask</entry>
+ <entry></entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;9)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbOverlay1Mask</entry>
+ <entry></entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;10)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbOverlay2Mask</entry>
+ <entry></entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;11)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbIgnoreGroupLockMask</entry>
+ <entry></entry>
+ <entry>ok</entry>
+ <entry>(1L&lt;&lt;12)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbGroupsWrapMask</entry>
+ <entry>ok</entry>
+ <entry></entry>
+ <entry>(1L&lt;&lt;27)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbInternalModsMask</entry>
+ <entry>ok</entry>
+ <entry></entry>
+ <entry>(1L&lt;&lt;28)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbIgnoreLockModsMask</entry>
+ <entry>ok</entry>
+ <entry></entry>
+ <entry>(1L&lt;&lt;29)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbPerKeyRepeatMask</entry>
+ <entry>ok</entry>
+ <entry></entry>
+ <entry>(1L&lt;&lt;30)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbControlsEnabledMask</entry>
+ <entry>ok</entry>
+ <entry></entry>
+ <entry>(1L&lt;&lt;31)</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAccessXOptionsMask</entry>
+ <entry>ok</entry>
+ <entry>ok</entry>
+ <entry>(XkbStickyKeysMask | XkbAccessXFeedbackMask)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAllBooleanCtrlsMask</entry>
+ <entry></entry>
+ <entry>ok</entry>
+ <entry>(0x00001FFF) </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbAllControlsMask</entry>
+ <entry>ok</entry>
+ <entry></entry>
+ <entry>(0xF8001FFF)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The individual fields of the <emphasis>
+XkbControlsRec</emphasis>
+ structure are defined as follows.
+</para>
+
+<sect2>
+<title/>
+<sect3 id='mk_dflt_btn'>
+<title>mk_dflt_btn</title>
+
+<para>
+<emphasis>
+mk_dflt_btn is an attribute of the </emphasis>
+<emphasis>
+MouseKeys</emphasis>
+<emphasis>
+ control</emphasis>
+ (see section 10.5<emphasis> <!-- xref -->
+). It</emphasis>
+ specifies the mouse button number to use for keyboard simulated mouse button
+operations. Its value should be one of the core symbols <emphasis>
+Button1</emphasis>
+ - <emphasis>
+Button5</emphasis>
+.
+</para>
+
+
+</sect3>
+<sect3 id='num_groups'>
+<title>num_groups</title>
+
+<para>
+<emphasis>
+num_groups</emphasis>
+ is not a part of any control, but is reported in the <emphasis>
+XkbControlsRec</emphasis>
+ structure whenever any of its components are fetched from the server. It
+reports the number of groups the particular keyboard configuration uses and is
+computed automatically by the server whenever the keyboard mapping changes.
+</para>
+
+
+</sect3>
+<sect3 id='groups_wrap'>
+<title>groups_wrap</title>
+
+<para>
+<emphasis>
+groups_wrap</emphasis>
+ is an attribute of the <emphasis>
+GroupsWrap</emphasis>
+ control (see section 10.7.1). It specifies the handling of illegal groups on a <!-- xref -->
+global basis. Valid values for <emphasis>
+groups_wrap</emphasis>
+ are shown in Table 10.8.
+</para>
+
+<table frame='none'>
+<title>GroupsWrap options (groups_wrap field)</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>groups_wrap symbolic name</entry>
+ <entry>value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbWrapIntoRange</entry>
+ <entry>(0x00)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbClampIntoRange</entry>
+ <entry>(0x40)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbRedirectIntoRange</entry>
+ <entry>(0x80)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+When <emphasis>
+groups_wrap</emphasis>
+ is set to <emphasis>
+XkbRedirectIntoRange</emphasis>
+, its four low-order bits specify the index of the group to use.
+</para>
+
+
+</sect3>
+<sect3 id='internal'>
+<title>internal</title>
+
+<para>
+<emphasis>
+internal</emphasis>
+ is an attribute of the <emphasis>
+InternalMods</emphasis>
+ control (see section 10.7.4). It specifies modifiers to be consumed in the <!-- xref -->
+server and not passed on to clients when events are reported. Valid values
+consist of any combination of the eight core modifier bits: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+ - <emphasis>
+Mod5Mask</emphasis>
+.
+</para>
+
+
+</sect3>
+<sect3 id='ignore_lock'>
+<title>ignore_lock</title>
+
+<para>
+<emphasis>
+ignore_lock</emphasis>
+ is an attribute of the <emphasis>
+IgnoreLockMods</emphasis>
+ control (see section 10.7.2). It specifies modifiers to be ignored in grab <!-- xref -->
+calculations. Valid values consist of any combination of the eight core
+modifier bits: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+ - <emphasis>
+Mod5Mask</emphasis>
+.
+</para>
+
+
+</sect3>
+<sect3 id='enabled_ctrls'>
+<title>enabled_ctrls</title>
+
+<para>
+<emphasis>
+enabled_ctrls</emphasis>
+ is an attribute of the <emphasis>
+EnabledControls</emphasis>
+ control (see section 10.1.1). It contains one bit per boolean control. Each <!-- xref -->
+bit determines whether the corresponding control is enabled or disabled; a one
+bit means the control is enabled. The mask bits used to enable these controls
+are listed in Table 10.7, using only those masks with "ok" in the <emphasis>
+enabled_ctrls</emphasis>
+ column.
+</para>
+
+
+</sect3>
+<sect3 id='repeat_delay_and_repeat_interval'>
+<title>repeat_delay and repeat_interval</title>
+
+<para>
+<emphasis>
+repeat_delay</emphasis>
+ and <emphasis>
+repeat_interval</emphasis>
+ are attributes of the <emphasis>
+RepeatKeys</emphasis>
+ control (see section 10.3.2). <emphasis> <!-- xref -->
+repeat_delay</emphasis>
+ is the initial delay before a key begins repeating, in milliseconds; <emphasis>
+repeat_interval</emphasis>
+ is the delay between subsequent key events, in milliseconds.
+</para>
+
+
+</sect3>
+<sect3 id='slow_keys_delay'>
+<title>slow_keys_delay</title>
+
+<para>
+<emphasis>
+slow_keys_delay</emphasis>
+ is an attribute of the <emphasis>
+SlowKeys</emphasis>
+ control (see section 10.6.6). Its value specifies the <emphasis> <!-- xref -->
+SlowKeys</emphasis>
+ acceptance delay period in milliseconds before a key press is accepted by the
+server.
+</para>
+
+
+</sect3>
+<sect3 id='debounce_delay'>
+<title>debounce_delay</title>
+
+<para>
+<emphasis>
+debounce_delay</emphasis>
+ is an attribute of the <emphasis>
+BounceKeys</emphasis>
+ control (see section 10.6.7). Its value specifies the <emphasis> <!-- xref -->
+BounceKeys</emphasis>
+ delay period in milliseconds for which the key is disabled after having been
+pressed before another press of the same key is accepted by the server.
+</para>
+
+
+</sect3>
+<sect3 id='mk_delay_mk_interval_mk_time_to_max_mk_max_speed_and_mk_curve'>
+<title>mk_delay, mk_interval, mk_time_to_max, mk_max_speed, and mk_curve</title>
+
+<para>
+<emphasis>
+mk_delay</emphasis>
+, <emphasis>
+mk_interval</emphasis>
+, <emphasis>
+mk_time_to_max</emphasis>
+, <emphasis>
+mk_max_speed</emphasis>
+, and <emphasis>
+mk_curve</emphasis>
+ are attributes of the <emphasis>
+MouseKeysAccel</emphasis>
+ control. Refer to section 10.5.2 for a description of these fields and the <!-- xref -->
+units involved.
+</para>
+
+
+</sect3>
+<sect3 id='ax_options'>
+<title>ax_options</title>
+
+<para>
+The <emphasis>
+ax_options</emphasis>
+ field contains attributes used to configure two different controls, the
+<emphasis>
+StickyKeys</emphasis>
+ control (see section 10.6.8) and the <emphasis> <!-- xref -->
+AccessXFeedback</emphasis>
+ control (see section 10.6.3). The <emphasis> <!-- xref -->
+ax_options</emphasis>
+ field is a bitmask and may include any combination of the bits defined in
+Table 10.9. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>Access X Enable/Disable Bits (ax_options field)</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Access X Control</entry>
+ <entry>ax_options bit</entry>
+ <entry>value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>AccessXFeedback</entry>
+ <entry>XkbAX_SKPressFBMask</entry>
+ <entry>(1L&lt;&lt;0)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_SKAcceptFBMask</entry>
+ <entry>(1L &lt;&lt; 1)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_FeatureFBMask</entry>
+ <entry>(1L &lt;&lt; 2)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_SlowWarnFBMask</entry>
+ <entry>(1L &lt;&lt; 3)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_IndicatorFBMask</entry>
+ <entry>(1L &lt;&lt; 4)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_StickyKeysFBMask</entry>
+ <entry>(1L &lt;&lt; 5)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_SKReleaseFBMask</entry>
+ <entry>(1L &lt;&lt; 8)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_SKRejectFBMask</entry>
+ <entry>(1L &lt;&lt; 9)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_BKRejectFBMask</entry>
+ <entry>(1L &lt;&lt; 10)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_DumbBellFBMask</entry>
+ <entry>(1L &lt;&lt; 11)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>StickyKeys</entry>
+ <entry>XkbAX_TwoKeysMask</entry>
+ <entry>(1L &lt;&lt; 6)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_LatchToLockMask</entry>
+ <entry>(1L &lt;&lt; 7)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry></entry>
+ <entry>XkbAX_AllOptionsMask</entry>
+ <entry>(0xFFF)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The fields pertaining to each control are relevant only when the control is
+enabled (<emphasis>
+XkbAccessXFeedbackMask</emphasis>
+ or <emphasis>
+XkbStickyKeysMask</emphasis>
+ bit is turned on in the <emphasis>
+enabled_cntrls</emphasis>
+ field).
+</para>
+
+
+<para>
+Xkb provides a set of convenience macros for working with the <emphasis>
+ax_options</emphasis>
+ field of an <emphasis>
+XkbControlsRec</emphasis>
+ structure:
+</para>
+
+<para><programlisting>
+#define <emphasis>XkbAX_NeedOption</emphasis>
+(c,w) ((c)-&gt;ax_options&amp;(w))
+</programlisting></para>
+
+<para>
+The <emphasis>
+XkbAX_NeedOption</emphasis>
+ macro is useful for determining whether a particular AccessX option is enabled
+or not. It accepts a pointer to an <emphasis>
+XkbControlsRec</emphasis>
+ structure and a valid mask bit from Table 10.9. If the specified mask bit in
+the <emphasis>
+ax_options</emphasis>
+ field of the controls structure is set, the macro returns the mask bit.
+Otherwise, it returns zero. Thus,
+</para>
+
+
+<para>
+XkbAX_NeedOption(ctlrec, XkbAX_LatchToLockMask)
+</para>
+
+
+<para>
+is nonzero if the latch to lock transition for latching keys is enabled, and
+zero if it is disabled. Note that <emphasis>
+XkbAX_NeedOption</emphasis>
+ only determines whether or not the particular capability is configured to
+operate; the <emphasis>
+XkbAccessXFeedbackMask</emphasis>
+ bit must also be turned on in <emphasis>
+enabled_ctrls</emphasis>
+ for the capability to actually be functioning.
+</para>
+
+<para><programlisting>
+#define <emphasis>XkbAX_AnyFeedback</emphasis>
+(c) ((c)-&gt;enabled_ctrls&amp;XkbAccessXFeedbackMask)
+</programlisting></para>
+
+<para>
+The <emphasis>
+XkbAX_AnyFeeback</emphasis>
+ macro accepts a pointer to an <emphasis>
+XkbControlsRec</emphasis>
+ structure and tells whether the <emphasis>
+AccessXFeedback</emphasis>
+ control is enabled or not. If the <emphasis>
+AccessXFeedback</emphasis>
+ control is enabled, the macro returns <emphasis>
+XkbAccessXFeedbackMask</emphasis>
+. Otherwise, it returns zero.
+</para>
+
+<para><programlisting>
+#define <emphasis>XkbAX_NeedFeedback</emphasis>
+(c,w) (XkbAX_AnyFeedback(c)&amp;&amp;XkbAX_NeedOption(c,w))
+</programlisting></para>
+
+<para>
+The <emphasis>
+XkbAX_NeedFeedback</emphasis>
+ macro is useful for determining if both the <emphasis>
+AccessXFeedback</emphasis>
+ control and a particular AccessX feedback option are enabled. The macro
+accepts a pointer to an <emphasis>
+XkbControlsRec</emphasis>
+ structure and a feedback option from the table above. If both the <emphasis>
+AccessXFeedback</emphasis>
+ control and the specified feedback option are enabled, the macro returns
+<emphasis>
+True</emphasis>
+. Otherwise it returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+</sect3>
+<sect3
+id='ax_timeout_axt_opts_mask_axt_opts_values_axt_ctrls_mask_and_axt_ctrls_values'>
+<title>ax_timeout, axt_opts_mask, axt_opts_values, axt_ctrls_mask, and axt_ctrls_values</title>
+
+<para>
+<emphasis>
+ax_timeout</emphasis>
+, <emphasis>
+act_opts_mask</emphasis>
+, <emphasis>
+axt_opts_values</emphasis>
+, <emphasis>
+axt_ctrls_mask</emphasis>
+, and <emphasis>
+axt_ctrls_values</emphasis>
+ are attributes of the <emphasis>
+AccessXTimeout</emphasis>
+ control. Refer to section 10.6.2 for a description of these fields and the <!-- xref -->
+units involved.
+</para>
+
+
+</sect3>
+<sect3 id='per_key_repeat'>
+<title>per_key_repeat</title>
+
+<para>
+The <emphasis>
+per_key_repeat</emphasis>
+ field mirrors the <emphasis>
+auto_repeats</emphasis>
+ field of the core protocol <emphasis>
+XKeyboardState</emphasis>
+ structure: changing the <emphasis>
+auto_repeats</emphasis>
+ field automatically changes <emphasis>
+per_key_repeat</emphasis>
+ and vice versa. It is provided for convenience and to reduce protocol traffic.
+For example, to obtain the individual repeat key behavior as well as the repeat
+delay and rate, use <emphasis>
+XkbGetControls</emphasis>
+. If the <emphasis>
+per_key_repeat</emphasis>
+ were not in this structure, you would have to call both <emphasis>
+XGetKeyboardControl</emphasis>
+ and <emphasis>
+XkbGetControls</emphasis>
+ to get this information. The bits correspond to keycodes. The first seven keys
+(keycodes 1-7) are indicated in <emphasis>
+per_key_repeat</emphasis>
+[0], with bit position 0 (low order) corresponding to the fictitious keycode 0.
+Following array elements correspond to 8 keycodes per element. A 1 bit
+indicates that the key is a repeating key.
+</para>
+
+
+</sect3>
+</sect2>
+</sect1>
+<sect1 id='querying_controls'>
+<title>Querying Controls</title>
+
+<para>
+Use <emphasis>
+XkbGetControls</emphasis>
+ to find the current state of Xkb server controls.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetControls</emphasis>
+(<emphasis>
+display, which, xkb)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long<emphasis>
+ which</emphasis>
+; /* mask of controls requested */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr<emphasis>
+ xkb</emphasis>
+; /* keyboard description for controls information*/
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetControls</emphasis>
+ queries the server for the requested control information, waits for a reply,
+and then copies the server’s values for the requested information into the
+<emphasis>
+ctrls</emphasis>
+ structure of the <emphasis>
+xkb</emphasis>
+ argument. Only those components specified by the <emphasis>
+which</emphasis>
+ parameter are copied. Valid values for <emphasis>
+which</emphasis>
+ are any combination of the masks listed in Table 10.7 that have "ok" in the
+<emphasis>
+which</emphasis>
+ column.
+</para>
+
+
+<para>
+If <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls </emphasis>
+is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetControls</emphasis>
+ allocates and initializes it before obtaining the values specified by
+<emphasis>
+which</emphasis>
+. If <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetControls</emphasis>
+ modifies only those portions of <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls</emphasis>
+ corresponding to the values specified by <emphasis>
+which</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetControls</emphasis>
+ returns <emphasis>
+Success</emphasis>
+ if successful; otherwise, it returns <emphasis>
+BadAlloc</emphasis>
+ if it cannot obtain sufficient storage, <emphasis>
+BadMatch</emphasis>
+ if <emphasis>
+xkb</emphasis>
+ is <emphasis>
+NULL</emphasis>
+ or <emphasis>
+which</emphasis>
+ is empty, or <emphasis>
+BadImplementation</emphasis>
+.
+</para>
+
+
+<para>
+To free the <emphasis>
+ctrls</emphasis>
+ member of a keyboard description, use <emphasis>
+XkbFreeControls</emphasis>
+ (see section 10.12)
+</para>
+
+
+<para>
+The <emphasis>
+num_groups</emphasis>
+ field in the <emphasis>
+ctrls</emphasis>
+ structure is always filled in by <emphasis>
+XkbGetControls</emphasis>
+, regardless of which bits are selected by <emphasis>
+which</emphasis>
+.
+</para>
+
+
+</sect1>
+<sect1 id='changing_controls'>
+<title>Changing Controls</title>
+
+<para>
+There are two ways to make changes to controls: either change a local copy
+keyboard description and call <emphasis>
+XkbSetControls</emphasis>
+, or, to reduce network traffic, use an<emphasis>
+ XkbControlsChangesRec</emphasis>
+ structure and call <emphasis>
+XkbChangeControls</emphasis>
+.
+</para>
+
+
+<para>
+To change the state of one or more controls, first modify the <emphasis>
+ctrls</emphasis>
+ structure in a local copy of the keyboard description and then use <emphasis>
+XkbSetControls</emphasis>
+ to copy those changes to the X server.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetControls</emphasis>
+(<emphasis>
+display, which, xkb)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long <emphasis>
+ which </emphasis>
+; /* mask of controls to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* <emphasis>
+ctrls</emphasis>
+ field contains new values to be set */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+For each bit that is set in the <emphasis>
+which</emphasis>
+ parameter, <emphasis>
+XkbSetControls</emphasis>
+ sends the corresponding values from the <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls</emphasis>
+ field to the server. Valid values for <emphasis>
+which</emphasis>
+ are any combination of the masks listed in Table 10.7 that have "ok" in the
+<emphasis>
+which</emphasis>
+ column.
+</para>
+
+
+<para>
+If <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, the server does not support a compatible version of Xkb, or the Xkb extension
+has not been properly initialized, <emphasis>
+XkbSetControls</emphasis>
+ returns <emphasis>
+False</emphasis>
+. Otherwise, it sends the request to the X server and returns <emphasis>
+True</emphasis>
+.
+</para>
+
+
+<para>
+Note that changes to attributes of controls in the <emphasis>
+XkbControlsRec</emphasis>
+ structure are apparent only when the associated control is enabled, although
+the corresponding values are still updated in the X server. For example, the
+<emphasis>
+repeat_delay</emphasis>
+ and <emphasis>
+repeat_interval</emphasis>
+ fields are ignored unless the <emphasis>
+RepeatKeys</emphasis>
+ control is enabled (that is, the X server’s equivalent of <emphasis>
+xkb-&gt;ctrls</emphasis>
+ has <emphasis>
+XkbRepeatKeyMask</emphasis>
+ set in <emphasis>
+enabled_ctrls</emphasis>
+). It is permissible to modify the attributes of a control in one call to
+XkbSetControls and enable the control in a subsequent call. See section 10.1.1 <!-- xref -->
+for more information on enabling and disabling controls.
+</para>
+
+
+<para>
+Note that the <emphasis>
+enabled_ctrls</emphasis>
+ field is itself a control — the <emphasis>
+EnabledControls</emphasis>
+ control. As such, to set a specific configuration of enabled and disabled
+boolean controls, you must set <emphasis>
+enabled_ctrls</emphasis>
+ to the appropriate bits to enable only the controls you want and disable all
+others, then specify the <emphasis>
+XkbControlsEnabledMask</emphasis>
+ in a call to <emphasis>
+XkbSetControls</emphasis>
+. Because this is somewhat awkward if all you want to do is enable and disable
+controls, and not modify any of their attributes, a convenience function is
+also provided for this purpose (<emphasis>
+XkbChangeEnabledControls</emphasis>
+, section 10.1.1). <!-- xref -->
+</para>
+
+
+<sect2 id='the_xkbcontrolschangesrec_structure'>
+<title>The XkbControlsChangesRec Structure</title>
+
+<para>
+The <emphasis>
+XkbControlsChangesRec</emphasis>
+ structure allows applications to track modifications to an <emphasis>
+XkbControlsRec</emphasis>
+ structure and thereby reduce the amount of traffic sent to the server. The
+same <emphasis>
+XkbControlsChangesRec</emphasis>
+ structure may be used in several successive modifications to the same
+<emphasis>
+XkbControlsRec</emphasis>
+ structure, then subsequently used to cause all of the changes, and only the
+changes, to be propagated to the server. The <emphasis>
+XkbControlsChangesRec</emphasis>
+ structure is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct _XkbControlsChanges {
+ unsigned int changed_ctrls; /* bits indicating changed control data */
+ unsigned int enabled_ctrls_changes; /* bits indicating enabled/disabled controls */
+ Bool num_groups_changed; /* <emphasis> True</emphasis> if
+ number of keyboard groups changed */
+} <emphasis>XkbControlsChangesRec</emphasis>,*XkbControlsChangesPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+changed_ctrls</emphasis>
+ field is a mask specifying which logical sets of data in the controls
+structure have been modified. In this context, modified means <emphasis>
+set</emphasis>
+, that is, if a value is set to the same value it previously contained, it has
+still been modified, and is noted as changed. Valid values for <emphasis>
+changed_ctrls</emphasis>
+ are any combination of the masks listed in Table 10.7 that have "ok" in the
+<emphasis>
+changed_ctrls</emphasis>
+ column. Setting a bit implies the corresponding data fields from the "Relevant
+XkbControlsRec Data Fields" column in Table 10.6 have been modified. The
+<emphasis>
+enabled_ctrls_changes</emphasis>
+ field specifies which bits in the <emphasis>
+enabled_ctrls</emphasis>
+ field have changed. If the number of keyboard groups has changed, the
+<emphasis>num_groups_changed</emphasis>
+ field is set to <emphasis>True</emphasis>.
+</para>
+
+
+<para>
+If you have an Xkb description with controls that have been modified and an
+<emphasis>
+XkbControlsChangesRec</emphasis>
+ that describes the changes that have been made, the <emphasis>
+XkbChangeControls</emphasis>
+ function provides a flexible method for updating the controls in a server to
+match those in the changed keyboard description.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbChangeControls</emphasis>
+(<emphasis>
+dpy, xkb, changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description with changed <emphasis>
+xkb-&gt;ctrls</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbControlsChangesPtr <emphasis>
+changes</emphasis>
+; /* which parts of <emphasis>
+xkb-&gt;ctrls</emphasis>
+ have changed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbChangeControls</emphasis>
+ copies any controls fields specified by <emphasis>
+changes</emphasis>
+ from the keyboard description controls structure, <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls</emphasis>
+, to the server specified by <emphasis>
+dpy</emphasis>
+.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='tracking_changes_to_keyboard_controls'>
+<title>Tracking Changes to Keyboard Controls</title>
+
+<para>
+Whenever a field in the controls structure changes in the server’s keyboard
+description, the server sends an <emphasis>
+XkbControlsNotify</emphasis>
+ event to all interested clients.To receive <emphasis>
+XkbControlsNotify</emphasis>
+ events under all possible conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) and pass <emphasis>
+XkbControlsNotifyMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbControlsNotify</emphasis>
+ events only under certain conditions, use <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbControlsNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying the desired state changes in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ using mask bits from Table 10.7. <!-- xref -->
+</para>
+
+
+<para>
+The structure for the <emphasis>
+XkbControlsNotify</emphasis>
+ event is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis> True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis> XkbCompatMapNotify</emphasis> */
+ int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
+ unsigned int changed_ctrls; /* bits indicating which controls data have changed*/
+ unsigned int enabled_ctrls; /* controls currently enabled in server */
+ unsigned int enabled_ctrl_changes; /* bits indicating enabled/disabled controls */
+ int num_groups; /* current number of keyboard groups */
+ KeyCode keycode; /* != 0 =&gt; keycode of key causing change */
+ char event_type; /* Type of event causing change */
+ char req_major; /* major event code of event causing change */
+ char req_minor; /* minor event code of event causing change */
+} <emphasis>XkbControlsNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+changed_ctrls</emphasis>
+ field specifies the controls components that have changed and consists of bits
+taken from the masks defined in Table 10.7 with "ok" in the <emphasis>
+changed_ctrls</emphasis>
+ column.
+</para>
+
+
+<para>
+The controls currently enabled in the server are reported in the <emphasis>
+enabled_ctrls</emphasis>
+ field. If any controls were just enabled or disabled (that is, the contents of
+the <emphasis>
+enabled_ctrls</emphasis>
+ field changed), they are flagged in the <emphasis>
+enabled_ctrl_changes</emphasis>
+ field. The valid bits for these fields are the masks listed in Table 10.7 with
+"ok" in the <emphasis>
+enabled_ctrls</emphasis>
+ column. The <emphasis>
+num_groups</emphasis>
+ field reports the number of groups bound to the key belonging to the most
+number of groups and is automatically updated when the keyboard mapping changes.
+</para>
+
+
+<para>
+If the change was caused by a request from a client, the <emphasis>
+keycode</emphasis>
+ and <emphasis>
+event_type</emphasis>
+ fields are set to <emphasis>
+zero </emphasis>
+and the <emphasis>
+req_major</emphasis>
+ and <emphasis>
+req_minor</emphasis>
+ fields identify the request. The <emphasis>
+req_major</emphasis>
+ value is the same as the major extension opcode. Otherwise, <emphasis>
+event_type</emphasis>
+ is set to the type of event that caused the change (one of <emphasis>
+KeyPress</emphasis>
+, <emphasis>
+KeyRelease</emphasis>
+, <emphasis>
+DeviceKeyPress</emphasis>
+, <emphasis>
+DeviceKeyRelease</emphasis>
+, <emphasis>
+ButtonPress</emphasis>
+ or <emphasis>
+ButtonRelease</emphasis>
+), and <emphasis>
+req_major</emphasis>
+ and <emphasis>
+req_minor</emphasis>
+ are undefined. If <emphasis>
+event_type</emphasis>
+ is <emphasis>
+KeyPress</emphasis>
+, <emphasis>
+KeyRelease</emphasis>
+, <emphasis>
+DeviceKeyPress</emphasis>
+, or <emphasis>
+DeviceKeyRelease</emphasis>
+, the <emphasis>
+keycode</emphasis>
+ field is set to the key that caused the change. If <emphasis>
+event_type</emphasis>
+ is <emphasis>
+ButtonPress</emphasis>
+ or <emphasis>
+ButtonRelease</emphasis>
+, <emphasis>
+keycode</emphasis>
+ contains the button number.
+</para>
+
+
+<para>
+When a client receives an <emphasis>
+XkbControlsNotify</emphasis>
+ event, it can note the changes in a changes structure using <emphasis>
+XkbNoteControlsChanges</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbNoteControlsChanges</emphasis>
+(<emphasis>
+changes</emphasis>
+,<emphasis>
+ new</emphasis>
+,<emphasis>
+ wanted</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbControlsChangesPtr <emphasis>
+ changes</emphasis>
+; /* records changes indicated by new */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbControlsNotifyEvent * <emphasis>
+ new</emphasis>
+; /* tells which things have changed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ wanted</emphasis>
+; /* tells which parts of new to record in changes */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+wanted</emphasis>
+ parameter is a bitwise inclusive OR of bits taken from the set of masks
+specified in Table 10.7 with "ok" in the <emphasis>
+changed_ctrls</emphasis>
+ column. <emphasis>
+XkbNoteControlsChanges</emphasis>
+ copies any changes reported in <emphasis>
+new</emphasis>
+ and specified in <emphasis>
+wanted</emphasis>
+ into the changes record specified by <emphasis>
+old</emphasis>
+.
+</para>
+
+
+<para>
+Use <emphasis>
+XkbGetControlsChanges</emphasis>
+ to update a local copy of a keyboard description with the changes previously
+noted by one or more calls to <emphasis>
+XkbNoteControlsChanges.</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetControlsChanges</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ xkb</emphasis>
+,<emphasis>
+ changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* <emphasis>
+xkb-&gt;ctrls</emphasis>
+ will be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbNameChangesPtr <emphasis>
+changes</emphasis>
+; /* indicates which parts of <emphasis>
+xkb-&gt;ctrls</emphasis>
+ to update */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetControlsChanges</emphasis>
+ examines the <emphasis>
+changes</emphasis>
+ parameter, queries the server for the necessary information, and copies the
+results into the <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+ctrls</emphasis>
+ keyboard description. If the <emphasis>
+ctrls</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetControlsChanges</emphasis>
+ allocates and initializes it. To free the <emphasis>
+ctrls</emphasis>
+ field, use <emphasis>
+XkbFreeControls</emphasis>
+ (see section 10.12). <!-- xref -->
+</para>
+
+
+<para>
+<emphasis>
+XkbGetControlsChanges</emphasis>
+ returns <emphasis>
+Success</emphasis>
+ if successful and can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadImplementation,</emphasis>
+ and <emphasis>
+BadMatch</emphasis>
+ errors.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_an_xkbcontrolsrec'>
+<title>Allocating and Freeing an XkbControlsRec</title>
+
+<para>
+The need to allocate an <emphasis>
+XkbControlsRec</emphasis>
+ structure seldom arises; Xkb creates one when an application calls <emphasis>
+XkbGetControls</emphasis>
+ or a related function. For those situations where there is not an <emphasis>
+XkbControlsRec</emphasis>
+ structure allocated in the <emphasis>
+XkbDescRec</emphasis>
+, allocate one by calling <emphasis>
+XkbAllocControls</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocControls</emphasis>
+(<emphasis>
+xkb, which</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* Xkb description in which to allocate ctrls rec */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask of components of <emphasis>
+ctrls</emphasis>
+ to allocate */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocControls</emphasis>
+ allocates the <emphasis>
+ctrls</emphasis>
+ field of the <emphasis>
+xkb</emphasis>
+ parameter, initializes all fields to zero, and returns <emphasis>
+Success</emphasis>
+. If the <emphasis>
+ctrls</emphasis>
+ field is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbAllocControls</emphasis>
+ simply returns <emphasis>
+Success</emphasis>
+. If <emphasis>
+xkb</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbAllocControls</emphasis>
+ reports a <emphasis>
+BadMatch</emphasis>
+ error. If the <emphasis>
+ctrls</emphasis>
+ field could not be allocated, it reports a <emphasis>
+BadAlloc</emphasis>
+ error.
+</para>
+
+
+<para>
+The <emphasis>
+which</emphasis>
+ mask specifies the individual fields of the <emphasis>
+ctrls</emphasis>
+ structure to be allocated and can contain any of the valid masks defined in
+Table 10.7. Because none of the currently existing controls have any structures
+associated with them, which is currently of little practical value in this call.
+</para>
+
+
+<para>
+To free memory used by the <emphasis>
+ctrls</emphasis>
+ member of an <emphasis>
+XkbDescRec </emphasis>
+structure, use <emphasis>
+XkbFreeControls:</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeControls</emphasis>
+(<emphasis>
+xkb, which, free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr<emphasis>
+ xkb</emphasis>
+; /* Xkb description in which to free controls components */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of components of <emphasis>
+ctrls</emphasis>
+ to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+free_all</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; free everything + ctrls itself */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbFreeControls</emphasis>
+ frees the specified components of the <emphasis>
+ctrls</emphasis>
+ field in the <emphasis>
+xkb</emphasis>
+ keyboard description and sets the corresponding structure component values to
+<emphasis>
+NULL</emphasis>
+ or <emphasis>
+zero</emphasis>
+. The <emphasis>
+which</emphasis>
+ mask specifies the fields of <emphasis>
+ctrls</emphasis>
+ to be freed and can contain any of the controls components specified in Table
+10.7.
+</para>
+
+
+<para>
+If <emphasis>
+free_all</emphasis>
+ is <emphasis>
+True</emphasis>
+, <emphasis>
+XkbFreeControls</emphasis>
+ frees every non-<emphasis>
+NULL</emphasis>
+ structure component in the controls, frees the <emphasis>
+XkbControlsRec</emphasis>
+ structure referenced by the <emphasis>
+ctrls</emphasis>
+ member of <emphasis>
+xkb</emphasis>
+, and sets <emphasis>
+ctrls</emphasis>
+ to <emphasis>
+NULL.</emphasis>
+</para>
+
+</sect1>
+<sect1 id='the_miscellaneous_per_client_controls'>
+<title>The Miscellaneous Per-client Controls</title>
+
+<para>
+You can configure the boolean per-client controls which affect the state
+reported in button and key events. See section 12.1.1, 12.3, 12.5, and 16.3.11 <!-- xref -->
+of the XKB Protocol specification for more details.
+</para>
+
+
+<para>
+To get the current values of the <emphasis>
+per-client</emphasis>
+ controls, use <emphasis>
+XkbGetPerClientControls</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbGetPerClientControls</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+ctrls</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+ctrls</emphasis>
+; /* 1 bit =&gt; corresponding control is on */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetPerClientControls</emphasis>
+ backfills <emphasis>
+ctrls</emphasis>
+ with the <emphasis>
+per-client </emphasis>
+control attributes for this particular client. It returns <emphasis>
+True</emphasis>
+ if successful, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+
+<para>
+To change the current values of the <emphasis>
+per-client</emphasis>
+ control attributes, use <emphasis>
+XkbSetPerClientControls.</emphasis>
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetPerClientControls</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+ctrls</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+change</emphasis>
+; /* 1 bit =&gt; change control */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+value</emphasis>
+; /* 1 bit =&gt; control on */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetPerClientControls changes the per-client values for the controls selected
+by </emphasis>
+<emphasis>
+change to the corresponding value in value. Legal values for change and value
+are: XkbPCF_GrabsUseXKBStateMask, XkbPCF_LookupStateWhenGrabbed, and
+XkbPCF_SendEventUsesXKBState. More than one control may be changed at one time
+by OR-ing the values together. XkbSetPerClientControls backfills value with the
+</emphasis>
+<emphasis>
+per-client </emphasis>
+<emphasis>
+control attributes for this particular client. </emphasis>
+It returns <emphasis>
+True</emphasis>
+ if successful, and <emphasis>
+False</emphasis>
+ otherwise.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch11.xml b/specs/XKB/ch11.xml
new file mode 100644
index 00000000..fe05e9cb
--- /dev/null
+++ b/specs/XKB/ch11.xml
@@ -0,0 +1,572 @@
+<chapter id='x_library_controls'>
+<title>X Library Controls</title>
+
+<para>
+The Xkb extension is composed of two parts: a server extension, and a
+client-side X library extension. Chapter 10 discusses functions used to modify
+controls affecting the behavior of the server portion of the Xkb extension.
+This chapter discusses functions used to modify controls that affect only the
+behavior of the client portion of the extension; these controls are known as
+Library Controls.
+</para>
+
+
+<para>
+All of the Library Controls are boolean flags that may be enabled and disabled.
+The controls can be divided into several categories:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Controls affecting general string lookups
+ </para>
+</listitem>
+<listitem>
+ <para>
+Controls affecting compose processing
+ </para>
+</listitem>
+<listitem>
+ <para>
+Controls affecting event delivery
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+There are two types of string lookups performed by <emphasis>
+XLookupString</emphasis>
+. The first type involves translating a single keycode into a string; the
+controls in the first category affect this type of lookup. The second type
+involves translating a series of keysyms into a string; the controls in the
+second category affect this type of lookup.
+</para>
+
+
+<para>
+An Xkb implementation is required to support the programming interface for all
+of the controls. However, an implementation may choose not to support the
+semantics associated with the controls that deal with compose processing. In
+this case, a program that accesses these controls should still function
+normally; however, the feedback that would normally occur with the controls
+enabled may be missing.
+</para>
+
+<sect1 id='controls_affecting_keycode_to_string_translation'>
+<title>Controls Affecting Keycode-to-String Translation</title>
+
+<para>
+The first type of string lookups, which are here called <emphasis>
+simple string lookups</emphasis>
+, involves translating a single keycode into a string. Because these simple
+lookups involve only a single keycode, all of the information needed to do the
+translation is contained in the keyboard state in a single event. The controls
+affecting simple string lookups are:
+</para>
+
+<para><programlisting>
+ <emphasis>ForceLatin1Lookup</emphasis>
+ <emphasis>ConsumeLookupMods</emphasis>
+ <emphasis>LevelOneUsesShiftAndLock</emphasis>
+</programlisting></para>
+
+<sect2 id='forcelatin1lookup'>
+<title>ForceLatin1Lookup</title>
+
+<para>
+If the <emphasis>
+ForceLatin1Lookup</emphasis>
+ control is enabled, <emphasis>
+XLookupString</emphasis>
+ only returns strings using the Latin1 character set. If <emphasis>
+ForceLatin1Lookup</emphasis>
+ is not enabled, <emphasis>
+XLookupString</emphasis>
+ can return characters that are not in the Latin1 set. By default, this control
+is disabled, allowing characters outside of the Latin1 set to be returned.
+</para>
+
+
+</sect2>
+<sect2 id='consumelookupmods'>
+<title>ConsumeLookupMods</title>
+
+<para>
+Simple string lookups in <emphasis>
+XLookupString</emphasis>
+ involve two different translation phases. The first phase translates raw
+device keycodes to individual keysyms. The second phase attempts to map the
+resulting keysym into a string of one or more characters. In the first phase,
+some of the modifiers are normally used to determine the appropriate shift
+level for a key.
+</para>
+
+
+<para>
+The <emphasis>
+ConsumeLookupMods</emphasis>
+ control determines whether or not <emphasis>
+XLookupString</emphasis>
+ <emphasis>
+consumes</emphasis>
+ the modifiers it uses during the first phase of processing (mapping a keycode
+to a keysym). When a modifier is consumed, it is effectively removed from the
+working copy of the keyboard state information <emphasis>
+XLookupString</emphasis>
+ is using and appears to be unset for the remainder of the processing.
+</para>
+
+
+<para>
+If the <emphasis>
+ConsumeLookupMods</emphasis>
+ control is enabled, <emphasis>
+XLookupString</emphasis>
+ does not use the modifiers used to translate the keycode of the event to a
+keysym when it is determining the string associated with a keysym. For example,
+assume the keymap for the ‘A’ key only contains the shift modifier and the
+<emphasis>
+ConsumeLookupMods</emphasis>
+ control is enabled. If a user presses the <emphasis>
+Shift</emphasis>
+ key and the <emphasis>
+A</emphasis>
+ key while the <emphasis>
+Num_Lock</emphasis>
+ key is locked, <emphasis>
+XLookupString</emphasis>
+ uses the <emphasis>
+Shift</emphasis>
+ modifier when mapping the keycode for the ‘a’ key to the keysym for
+‘A’; subsequently, it only uses the <emphasis>
+NumLock</emphasis>
+ modifier when determining the string associated with the keysym ‘A’.
+</para>
+
+
+<para>
+If the <emphasis>
+ConsumeLookupMods</emphasis>
+ control is not enabled, <emphasis>
+XLookupString</emphasis>
+ uses all of the event modifiers to determine the string associated with a
+keysym. This behavior mirrors the behavior of <emphasis>
+XLookupString</emphasis>
+ in the core implementation.
+</para>
+
+
+<para>
+The <emphasis>
+ConsumeLookupMods</emphasis>
+ control is unset by default. For more information on modifier consumption,
+refer to Chapter 12.
+</para>
+
+
+</sect2>
+<sect2 id='alwaysconsumeshiftandlock'>
+<title>AlwaysConsumeShiftAndLock</title>
+
+<para>
+The <emphasis>
+AlwaysConsumeShiftAndLock</emphasis>
+ control, if enabled, forces <emphasis>
+XLookupString</emphasis>
+ to consume the <emphasis>
+Shift</emphasis>
+ and <emphasis>
+Lock</emphasis>
+ modifiers when processing all keys, even if the definition for the key type
+does not specify these modifiers. The <emphasis>
+AlwaysConsumeShiftAndLock</emphasis>
+ control is unset by default. See section 15.2 for a discussion of key types.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='controls_affecting_compose_processing'>
+<title>Controls Affecting Compose Processing</title>
+
+<para>
+The second type of string lookup performed by <emphasis>
+XLookupString</emphasis>
+ involves translating a series of keysyms into a string. Because these lookups
+can involve more than one key event, they require <emphasis>
+XLookupString</emphasis>
+ to retain some state information between successive calls. The process of
+mapping a series of keysyms to a string is known as <emphasis>
+compose processing</emphasis>
+. The controls affecting compose processing are:
+</para>
+
+<para><programlisting>
+<emphasis>ConsumeKeysOnComposeFail</emphasis>
+<emphasis>ComposeLED</emphasis>
+<emphasis>BeepOnComposeFail</emphasis>
+</programlisting></para>
+
+<para>
+Because different vendors have historically used different algorithms to
+implement compose processing, and these algorithms may be incompatible with the
+semantics required by the Xkb compose processing controls, implementation of
+the compose processing controls is optional in an Xkb implementation.
+</para>
+
+
+<sect2 id='consumekeysoncomposefail'>
+<title>ConsumeKeysOnComposeFail</title>
+
+<para>
+Some compose processing algorithms signal the start of a compose sequence by a
+key event meaning "start compose".
+<footnote><para>
+Another possibility is to have the compose processing simply be the result of a finite state acceptor; a compose sequence would never fail for a properly written finite state acceptor.
+</para></footnote>
+The subsequent key events should normally result in a valid composition yielding a
+valid translation to a string. If the subsequent key events do not have a valid
+translation, some decision must be made about what to do with the key events
+that were processed while attempting the compose. The <emphasis>
+ConsumeKeysOnComposeFail</emphasis>
+ control allows a client to specify what happens with the key events <emphasis>
+XLookupString</emphasis>
+ has been considering when it reaches a dead end in a compose sequence.
+</para>
+
+
+<para>
+If the <emphasis>
+ConsumeKeysOnComposeFail</emphasis>
+ control is set, all keys associated with a failed compose sequence should be
+consumed (discarded). If the <emphasis>
+ConsumeKeysOnComposeFail</emphasis>
+ control is not set, the key events associated with a failed compose sequence
+should be processed as a normal sequence of key events.
+</para>
+
+
+<para>
+The <emphasis>
+ConsumeKeysOnComposeFail</emphasis>
+ control is disabled by default.
+</para>
+
+
+</sect2>
+<sect2 id='composeled'>
+<title>ComposeLED</title>
+
+<para>
+The <emphasis>
+ComposeLED</emphasis>
+ control allows a client to specify whether or not an indicator should be set
+and cleared to provide feedback when compose processing is in progress. The
+control does not specify which indicator should be used; the mapping for this
+is up to the individual implementation. If the <emphasis>
+ComposeLED</emphasis>
+ control is enabled, it specifies that an indicator should be set when a
+compose sequence is in progress and cleared when one is not in progress. The
+<emphasis>
+ComposeLED</emphasis>
+ control is disabled by default.
+</para>
+
+
+<para>
+While the Xkb extension does not specify the type of type of indicator to be
+used when the <emphasis>
+ComposeLED</emphasis>
+ control is implemented, a consistent convention between implementations is to
+everyone’s benefit. If a named indicator is used for this purpose, the
+recommended name is "<emphasis>
+Compose</emphasis>
+". Note that some implementations may use an unnamed, custom hardware LED for
+this purpose.
+</para>
+
+
+</sect2>
+<sect2 id='beeponcomposefail'>
+<title>BeepOnComposeFail</title>
+
+<para>
+The <emphasis>
+BeepOnComposeFail</emphasis>
+ control allows a client to specify whether or not a bell should be activated
+to provide feedback when a compose sequence fails. The control does not specify
+the type of bell that should be used; the mapping for this is up to the
+individual implementation. If the <emphasis>
+BeepOnComposeFail</emphasis>
+ control is enabled, it specifies that a bell should be activated when a
+compose sequence fails. The <emphasis>
+BeepOnComposeFail</emphasis>
+ control is disabled by default. If implemented, the bell should be activated
+using <emphasis>
+XkbBell</emphasis>
+ or <emphasis>
+XkbDeviceBell</emphasis>
+.
+</para>
+
+
+<para>
+While the Xkb extension does not specify the type of bell to be used when the
+<emphasis>
+BeepOnComposeFail</emphasis>
+ control is implemented, a consistent convention between implementations is to
+everyone’s benefit. If a named bell is used for this purpose, the recommended
+name is "<emphasis>
+ComposeFail</emphasis>
+".
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='controls_effecting_event_delivery'>
+<title>Controls Effecting Event Delivery</title>
+
+<sect2 id='ignorenewkeyboards'>
+<title>IgnoreNewKeyboards</title>
+
+<para>
+When Xkb is initialized, it implicitly forces requests for <emphasis>
+NewKeyboardNotify</emphasis>
+ events. These events may be used by the Xkb library extension internally; they
+are normally translated into core protocol <emphasis>
+MappingNotify</emphasis>
+ events before being passed to the client. While delivering the event to the
+client is appropriate in most cases, it is not appropriate for some clients
+that maintain per-key data structures. This is because once the server has sent
+a <emphasis>
+NewKeyboardNotify</emphasis>
+ event, it is free to send the client events for all keys in the new range and
+that range may be outside of the per-key data structures the client is
+maintaining.
+</para>
+
+
+<para>
+The <emphasis>
+IgnoreNewKeyboards</emphasis>
+ control, if enabled, prevents Xkb from mapping <emphasis>
+NewKeyboardNotify</emphasis>
+ events to core <emphasis>
+MappingNotify</emphasis>
+ events and passing them to the client. The control is initially disabled.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='manipulating_the_library_controls'>
+<title>Manipulating the Library Controls</title>
+
+<para>
+The Library Controls are manipulated using functions that deal with bitmasks to
+indicate which controls to manipulate. The controls are identified by the masks
+defined in Table 11.1. <!-- xref -->
+</para>
+
+<table frame='none'>
+<title>Library Control Masks</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Library Control Mask</entry>
+ <entry>Value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbLC_ForceLatin1Lookup</entry>
+ <entry>(1 &lt;&lt; 0)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_ConsumeLookupMods</entry>
+ <entry>(1 &lt;&lt; 1)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_AlwaysConsumeShiftAndLock</entry>
+ <entry>(1 &lt;&lt; 2)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_IgnoreNewKeyboards</entry>
+ <entry>(1 &lt;&lt; 3)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_ConsumeKeysOnComposeFail</entry>
+ <entry>(1 &lt;&lt; 29)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_ComposeLED</entry>
+ <entry>(1 &lt;&lt; 30)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_BeepOnComposeFail</entry>
+ <entry>(1 &lt;&lt; 31)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbLC_AllControls</entry>
+ <entry>(0xc0000007)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<sect2 id='determining_which_library_controls_are_implemented'>
+<title>Determining Which Library Controls are Implemented</title>
+
+<para>
+To determine which Library Controls are actually
+implemented, use <emphasis>XkbXlibControlsImplemented</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned int <emphasis>
+XkbXlibControlsImplemented</emphasis>
+(<emphasis>
+display</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbXlibControlsImplemented</emphasis>
+ returns a bitmask indicating the controls actually implemented in the Xkb
+library and is composed of an inclusive OR of bits from Table 11.1.
+</para>
+
+
+</sect2>
+<sect2 id='determining_the_state_of_the_library_controls'>
+<title>Determining the State of the Library Controls</title>
+
+<para>
+To determine the current state of the Library Controls, use <emphasis>
+XkbGetXlibControls</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned int <emphasis>
+XkbGetXlibControls</emphasis>
+(<emphasis>
+display</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetXlibControls</emphasis>
+ returns the current state of the Library Controls as a bit mask that is an
+inclusive OR of the control masks from Table 11.1 for the controls that are
+enabled. For the optional compose processing controls, the fact that a control
+is enabled does not imply that it is actually implemented.
+</para>
+
+</sect2>
+<sect2 id='changing_the_state_of_the_library_controls'>
+<title>Changing the State of the Library Controls</title>
+
+<para>
+To change the state of the Library Controls, use
+<emphasis>XkbSetXlibControls</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetXlibControls</emphasis>
+(<emphasis>
+display, bits_to_change, values_for_bits</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long <emphasis>
+bits_to_change</emphasis>
+; /* selects controls to be modified */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned long <emphasis>
+values_for_bits</emphasis>
+; /* turns selected controls on (1) or off (0) */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetXlibControls</emphasis>
+ modifies the state of the controls selected by <emphasis>
+bits_to_change</emphasis>
+; only the controls selected by <emphasis>
+bits_to_change</emphasis>
+ are modified. If the bit corresponding to a control is on in <emphasis>
+bits_to_change</emphasis>
+ and also on in values_for_bits, the control is enabled. If the bit
+corresponding to a control is on in <emphasis>
+bits_to_change</emphasis>
+ but off in <emphasis>
+values_for_bits</emphasis>
+, the control is disabled. <emphasis>
+bits_to_change</emphasis>
+ should be an inclusive OR of bits from Table 11.1.
+</para>
+
+</sect2>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch12.xml b/specs/XKB/ch12.xml
new file mode 100644
index 00000000..1f10261c
--- /dev/null
+++ b/specs/XKB/ch12.xml
@@ -0,0 +1,841 @@
+<chapter id='interpreting_key_events'>
+<title>Interpreting Key Events</title>
+
+<para>
+Xkb provides functions to help developers interpret key events without having
+to directly interpret Xkb data structures. Xkb also modifies the behavior of
+several core X library functions.
+</para>
+
+<sect1 id='effects_of_xkb_on_the_core_x_library'>
+<title>Effects of Xkb on the Core X Library</title>
+
+<para>
+When support for Xkb is built into the X library, the <emphasis>
+XOpenDisplay</emphasis>
+ function looks for a compatible version of Xkb on the server. If it finds a
+compatible version, it initializes the extension and enables <emphasis>
+implicit support</emphasis>
+ for Xkb in a number of X library functions. This makes it possible for clients
+to take advantage of nearly all Xkb features without having to be rewritten or
+even recompiled, if they are built with shared libraries. This implicit support
+is invisible to most clients, but it can have side effects, so the extension
+includes ways to control or disable it.
+</para>
+
+
+<sect2 id='effects_of_xkb_on_event_state'>
+<title>Effects of Xkb on Event State</title>
+
+<para>
+Because <emphasis>
+XOpenDisplay</emphasis>
+ initializes Xkb, some events contain an Xkb description of the keyboard state
+instead of that normally used by the core protocol. See section 17.1.1 for more
+information about the differences between Xkb keyboard state and that reported
+by the core protocol.
+</para>
+
+
+</sect2>
+<sect2 id='effects_of_xkb_on_mappingnotify_events'>
+<title>Effects of Xkb on MappingNotify Events</title>
+
+<para>
+When Xkb is missing or disabled, the X library tracks changes to the keyboard
+mapping using <emphasis>
+MappingNotify</emphasis>
+ events. Whenever the keyboard mapping is changed, the server sends all clients
+a <emphasis>
+MappingNotify</emphasis>
+ event to report the change. When a client receives a <emphasis>
+MappingNotify</emphasis>
+ event, it is supposed to call <emphasis>
+XRefreshKeyboardMapping</emphasis>
+ to update the keyboard description used internally by the X library.
+</para>
+
+
+<para>
+The X Keyboard Extension uses <emphasis>
+XkbMapNotify</emphasis>
+ and <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events to track changes to the keyboard mapping. When an Xkb-aware client
+receives either event, it should call <emphasis>
+XkbRefreshKeyboardMapping</emphasis>
+ to update the keyboard description used internally by the X library. To avoid
+duplicate events, the X server does not send core protocol <emphasis>
+MappingNotify</emphasis>
+ events to a client that has selected for <emphasis>
+XkbMapNotify</emphasis>
+ events.
+</para>
+
+
+<para>
+The implicit support for Xkb selects for <emphasis>
+XkbMapNotify</emphasis>
+ events. This means that clients that do not explicitly use Xkb but that are
+using a version of the X library that has implicit support for Xkb do not
+receive <emphasis>
+MappingNotify</emphasis>
+ events over the wire. Clients that were not written with Xkb in mind do not
+recognize or properly handle the new Xkb events, so the implicit support
+converts them to <emphasis>
+MappingNotify</emphasis>
+ events that report approximately the same information, unless the client has
+explicitly selected for the Xkb version of the event.
+</para>
+
+
+<para>
+An Xkb-capable X server does not send events from keys that fall outside the
+legal range of keycodes expected by that client. Once the server sends a client
+an <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event, it reports events from all keys because it assumes that any client that
+has receieved an <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event expects key events from the new range of keycodes. The implicit support
+for Xkb asks for <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events, so the range of keycodes reported to the client might vary without the
+client’s knowledge. Most clients don’t really care about the range of legal
+keycodes, but some clients maintain information about each key and might have
+problems with events that come from unexpected keys. Such clients can set the
+<emphasis>
+XkbLC_IgnoreNewKeyboards</emphasis>
+ library control (see section 11.3.1) to prevent the implicit support from
+requesting notification of changes to the legal range of keycodes.
+</para>
+
+
+</sect2>
+<sect2 id='x_library_functions_affected_by_xkb'>
+<title>X Library Functions Affected by Xkb</title>
+
+<para>
+The following X library functions are modified by Xkb:
+</para>
+
+<para><programlisting>
+ <emphasis>XKeycodeToKeysym</emphasis>
+ <emphasis>XKeysymToKeycode</emphasis>
+ <emphasis>XLookupKeysym</emphasis>
+ <emphasis>XLookupString</emphasis>
+ <emphasis>XRefreshKeyboardMapping</emphasis>
+ <emphasis>XRebindKeysym</emphasis>
+</programlisting></para>
+
+<para>
+The implicit support for Xkb replaces a number of X library functions with
+versions that understand and use the X Keyboard Extension. In most cases, the
+semantics of the new versions are identical to those of the old, but there are
+occasional visible differences. This section lists all of the functions that
+are affected and the differences in behavior, if any, that are visible to
+clients.
+</para>
+
+
+<para>
+The <emphasis>
+XKeycodeToKeysym</emphasis>
+ function reports the keysym associated with a particular index for a single
+key. The index specifies a column of symbols in the core keyboard mapping (that
+is, as reported by the core protocol <emphasis>
+GetKeyboardMapping</emphasis>
+ request). The order of the symbols in the core mapping does not necessarily
+correspond to the order of the symbols used by Xkb; section 17.1.3 describes
+the differences.
+</para>
+
+
+<para>
+The <emphasis>
+XKeysymToKeycode</emphasis>
+ function reports a keycode to which a particular keysym is bound. When Xkb is
+missing or disabled, this function looks in each column of the core keyboard
+mapping in turn and returns the lowest numbered key that matches in the lowest
+numbered group. When Xkb is present, this function uses the Xkb ordering for
+symbols instead.
+</para>
+
+
+<para>
+The <emphasis>
+XLookupKeysym</emphasis>
+ function reports the symbol in a specific column of the key associated with an
+event. Whether or not Xkb is present, the column specifies an index into the
+core symbol mapping.
+</para>
+
+
+<para>
+The <emphasis>
+XLookupString</emphasis>
+ function reports the symbol and string associated with a key event, taking
+into account the keycode and keyboard state as reported in the event. When Xkb
+is disabled or missing, <emphasis>
+XLookupString</emphasis>
+ uses the rules specified by the core protocol and reports only ISO Latin-1
+characters. When Xkb is present, <emphasis>
+XLookupString</emphasis>
+ uses the explicit keyboard group, key types, and rules specified by Xkb. When
+Xkb is present, <emphasis>
+XLookupString</emphasis>
+ is allowed, but not required, to return strings in character sets other than
+ISO Latin-1, depending on the current locale. If any key bindings are defined,
+<emphasis>
+XLookupString</emphasis>
+ does not use any consumed modifiers (see sections 11.1.2 and 15.2) to
+determine matching bindings.
+</para>
+
+
+<para>
+The <emphasis>
+XRefreshKeyboardMapping</emphasis>
+ function updates the X library’s internal representation of the keyboard to
+reflect changes reported via <emphasis>
+MappingNotify</emphasis>
+ events. When Xkb is missing or disabled, this function reloads the entire
+modifier map or keyboard mapping. When Xkb is present, the implicit Xkb support
+keeps track of the changed components reported by each <emphasis>
+XkbMapNotify</emphasis>
+ event and updates only those pieces of the keyboard description that have
+changed. If the implicit support has not noted any keyboard mapping changes,
+<emphasis>
+XRefreshKeyboardMapping</emphasis>
+ updates the entire keyboard description.
+</para>
+
+
+<para>
+The <emphasis>
+XRebindKeysym</emphasis>
+ function associates a string with a keysym and a set of modifiers. Xkb does
+not directly change this function, but it does affect the way that the state
+reported in the event is compared to the state specified to <emphasis>
+XRebindKeysym</emphasis>
+. When Xkb is missing or disabled, <emphasis>
+XLookupString</emphasis>
+ returns the specified string if the modifiers in the event exactly match the
+modifiers from this call. When Xkb is present, any modifiers used to determine
+the keysym are consumed and are not used to look up the string.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='xkb_event_and_keymap_functions'>
+<title>Xkb Event and Keymap Functions</title>
+
+<para>
+To find the keysym bound to a particular key at a specified group and shift
+level, use <emphasis>XkbKeycodeToKeysym</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+KeySym <emphasis>
+XkbKeycodeToKeysym</emphasis>
+(<emphasis>
+dpy, kc, group, level</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * dpy; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode kc; /* key of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int group; /* group of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int level; /* shift level of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeycodeToKeysym</emphasis>
+ returns the keysym bound to a particular group and shift level for a
+particular key on the core keyboard. If <emphasis>
+kc</emphasis>
+ is not a legal keycode for the core keyboard, or if <emphasis>
+group</emphasis>
+ or <emphasis>
+level</emphasis>
+ are out of range for the specified key, <emphasis>
+XkbKeycodeToKeysym</emphasis>
+ returns <emphasis>
+NoSymbol</emphasis>
+.
+</para>
+
+
+<para>
+To find the set of modifiers bound to a particular keysym on the core keyboard,
+use <emphasis>
+XkbKeysymToModifiers</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned<emphasis>
+ </emphasis>
+int <emphasis>
+XkbKeysymToModifiers</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ ks</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym <emphasis>
+ ks</emphasis>
+; /* keysym of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeysymToModifiers</emphasis>
+ finds the set of modifiers currently bound to the keysym <emphasis>
+ks</emphasis>
+ on the core keyboard. The value returned is the mask of modifiers bound to the
+keysym <emphasis>
+ks</emphasis>
+. If no modifiers are bound to the keysym, <emphasis>
+XkbKeysymToModifiers</emphasis>
+ returns zero; otherwise, it returns the inclusive OR of zero or more of the
+following: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+, <emphasis>
+Mod2Mask</emphasis>
+, <emphasis>
+Mod3Mask</emphasis>
+, <emphasis>
+Mod4Mask,</emphasis>
+ and <emphasis>
+Mod5Mask</emphasis>
+.
+</para>
+
+
+<para>
+Use <emphasis>
+XkbLookupKeySym</emphasis>
+ to find the symbol associated with a key for a particular state.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbLookupKeySym</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ key</emphasis>
+,<emphasis>
+ state</emphasis>
+,<emphasis>
+ mods_rtrn</emphasis>
+,<emphasis>
+ sym_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+ key</emphasis>
+; /* key for which symbols are to be found */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ state</emphasis>
+; /* state for which symbol should be found */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+ mods_rtrn</emphasis>
+; /* backfilled with unconsumed modifiers */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym *<emphasis>
+ sym_rtrn</emphasis>
+; /* backfilled with symbol associated with key + state */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbLookupKeySym</emphasis>
+ is the equivalent of the core <emphasis>
+XLookupKeySym</emphasis>
+ function. For the core keyboard, given a keycode <emphasis>
+key</emphasis>
+ and an Xkb state <emphasis>
+state</emphasis>
+, <emphasis>
+XkbLookupKeySym</emphasis>
+ returns the symbol associated with the key in <emphasis>
+sym_rtrn</emphasis>
+ and the list of modifiers that should still be applied in <emphasis>
+mods_rtrn</emphasis>
+. The <emphasis>
+state</emphasis>
+ parameter is the state from a <emphasis>
+KeyPress</emphasis>
+ or <emphasis>
+KeyRelease</emphasis>
+ event. <emphasis>
+XkbLookupKeySym</emphasis>
+ returns <emphasis>
+True</emphasis>
+ if it succeeds.
+</para>
+
+
+<para>
+Use <emphasis>
+XkbLookupKeyBinding</emphasis>
+ to find the string bound to a key by <emphasis>
+XRebindKeySym</emphasis>
+. <emphasis>
+XkbLookupKeyBinding</emphasis>
+ is the equivalent of the core <emphasis>
+XLookupString</emphasis>
+ function.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbLookupKeyBinding</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ sym</emphasis>
+,<emphasis>
+ state</emphasis>
+,<emphasis>
+ buf</emphasis>
+,<emphasis>
+ nbytes</emphasis>
+,<emphasis>
+ extra_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym<emphasis>
+ sym</emphasis>
+; /* symbol to be looked up */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+state</emphasis>
+; /* state for which string is to be looked up */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ buf</emphasis>
+; /* buffer into which returned string is written */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ nbytes</emphasis>
+; /* size of buffer in bytes */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+ extra_rtrn</emphasis>
+; /* backfilled with number bytes overflow */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XRebindKeysym</emphasis>
+ binds an ASCII string to a specified keysym, so that the string and keysym are
+returned when the key is pressed and a specified list of modifiers are also
+being held down. <emphasis>
+XkbLookupKeyBinding</emphasis>
+ returns in <emphasis>
+buf</emphasis>
+ the string associated with the keysym <emphasis>
+sym</emphasis>
+ and modifier state <emphasis>
+state</emphasis>
+. <emphasis>
+buf</emphasis>
+ is <emphasis>
+NULL</emphasis>
+ terminated unless there’s an overflow. If the string returned is larger than
+<emphasis>
+nbytes</emphasis>
+, a count of bytes that does not fit into the buffer is returned in extra_rtrn.
+<emphasis>
+XkbTranslateKeySym</emphasis>
+ returns the number of bytes that it placed into <emphasis>
+buf</emphasis>
+.
+</para>
+
+
+<para>
+To find the string and symbol associated with a keysym for a given keyboard
+state, use <emphasis>
+XkbTranslateKeySym</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbTranslateKeySym</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ sym_inout</emphasis>
+,<emphasis>
+ mods</emphasis>
+,<emphasis>
+ buf</emphasis>
+,<emphasis>
+ nbytes</emphasis>
+, <emphasis>
+extra_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym * <emphasis>
+ sym_inout</emphasis>
+; /* symbol to be translated; result of translation */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ mods</emphasis>
+; /* modifiers to apply to <emphasis>
+sym_inout</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ buf</emphasis>
+; /* buffer into which returned string is written */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ nbytes</emphasis>
+; /* size of buffer in bytes */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int *<emphasis>
+ extra_rtrn</emphasis>
+; /* number of bytes overflow*/
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbTranslateKeySym</emphasis>
+ applies the transformations specified in <emphasis>
+mods</emphasis>
+ to the symbol specified by <emphasis>
+sym_inout</emphasis>
+. It returns in <emphasis>
+buf</emphasis>
+ the string, if any, associated with the keysym for the current locale. If the
+transformations in <emphasis>
+mods</emphasis>
+ changes the keysym, <emphasis>
+sym_inout</emphasis>
+ is updated accordingly. If the string returned is larger than <emphasis>
+nbytes</emphasis>
+, a count of bytes that does not fit into the buffer is returned in extra_rtrn.
+<emphasis>
+XkbTranslateKeySym</emphasis>
+ returns the number of bytes it placed into <emphasis>
+buf</emphasis>
+.
+</para>
+
+
+<para>
+To update the keyboard description that is internal to the X library, use
+<emphasis>
+XkbRefreshKeyboardMapping</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbRefreshKeyboardMapping</emphasis>
+(<emphasis>
+event)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbMapNotifyEvent * <emphasis>
+ event</emphasis>
+; /* event initiating remapping */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbRefreshKeyboardMapping</emphasis>
+ is the Xkb equivalent of the core <emphasis>
+XRefreshKeyboardMapping</emphasis>
+ function. It requests that the X server send the current key mapping
+information to this client. A client usually invokes <emphasis>
+XkbRefreshKeyboardMapping</emphasis>
+ after receiving an <emphasis>
+XkbMapNotify</emphasis>
+ event. <emphasis>
+XkbRefreshKeyboardMapping</emphasis>
+ returns <emphasis>
+Success</emphasis>
+ if it succeeds and <emphasis>
+BadMatch</emphasis>
+ if the event is not an Xkb event.
+</para>
+
+
+<para>
+The <emphasis>
+XkbMapNotify</emphasis>
+ event can be generated when some client calls <emphasis>
+XkbSetMap</emphasis>
+, <emphasis>
+XkbChangeMap</emphasis>
+, <emphasis>
+XkbGetKeyboardByName</emphasis>
+, or any of the standard X library functions that change the keyboard mapping
+or modifier mapping.
+</para>
+
+
+<para>
+To translate a keycode to a key symbol and modifiers, use <emphasis>
+XkbTranslateKeyCode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Booll <emphasis>
+XkbTranslateKeyCode</emphasis>
+(<emphasis>
+xkb, key, mods, mods_rtrn, keysym_rtrn)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description to use for translation */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+key</emphasis>
+; /* keycode to translate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+mods</emphasis>
+; /* modifiers to apply when translating <emphasis>
+key</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+mods_rtrn</emphasis>
+; /* backfilled with unconsumed modifiers */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym * <emphasis>
+keysym_rtrn</emphasis>
+; /* keysym resulting from translation */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+mods_rtrn</emphasis>
+ is backfilled with the modifiers consumed by the translation process.
+<emphasis>
+mods</emphasis>
+ is a bitwise inclusive OR of the legal modifier masks: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+, <emphasis>
+Mod2Mask</emphasis>
+, <emphasis>
+Mod3Mask</emphasis>
+, <emphasis>
+Mod4Mask</emphasis>
+, <emphasis>
+Mod5Mask</emphasis>
+.The <emphasis>
+AlwaysConsumeShiftAndLock</emphasis>
+ library control (see section 11.1.3), if enabled, causes <emphasis>
+XkbTranslateKeyCode</emphasis>
+ to consume shift and lock.<emphasis>
+ XkbTranslateKeyCode</emphasis>
+ returns <emphasis>
+True</emphasis>
+ if the translation resulted in a keysym, and <emphasis>
+False</emphasis>
+ if it resulted in <emphasis>
+NoSymbol</emphasis>
+.
+</para>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch13.xml b/specs/XKB/ch13.xml
new file mode 100644
index 00000000..f871b156
--- /dev/null
+++ b/specs/XKB/ch13.xml
@@ -0,0 +1,4146 @@
+<chapter id='keyboard_geometry'>
+<title>Keyboard Geometry</title>
+
+<para>
+The Xkb description of a keyboard includes an optional keyboard geometry that
+describes the physical appearance of the keyboard. Keyboard geometry describes
+the shape, location, and color of all keyboard keys or other visible keyboard
+components such as indicators. The information contained in a keyboard geometry
+is sufficient to allow a client program to draw an accurate two-dimensional
+image of the keyboard.
+</para>
+
+
+<para>
+You can retrieve a keyboard geometry from an X server that supports Xkb, or you
+can allocate it from scratch and initialize it in a client program. The
+keyboard geometry need not have any correspondence with the physical keyboard
+that is connected to the X server.
+</para>
+
+
+<para>
+Geometry measurements are specified in mm/10 units. The origin (0,0) is in the
+top left corner of the keyboard image. A component’s own origin is also its
+upper left corner. In some cases a component needs to be drawn rotated. For
+example, a special keyboard may have a section of keys arranged in rows in a
+rectangular area, but the entire rectangle may not be in alignment with the
+rest of the keyboard, and instead, it is rotated from horizontal by 30<emphasis>
+o</emphasis>
+. Rotation for a geometry object is specified in 1/10 o increments about its
+origin. An example of a keyboard with rotated sections is shown in Figure 13.1.
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-7.gif"/>
+ </imageobject>
+<caption>Rotated Keyboard Sections</caption>
+</mediaobject>
+
+
+<!-- <H5 CLASS="Figure">
+Rotated Keyboard Sections</H5>
+-->
+
+<para>
+Some geometry components include a <emphasis>
+priority</emphasis>
+, which indicates the order in which overlapping objects should be drawn.
+Objects should be drawn in order from highest priority (0) to lowest (255).
+</para>
+
+
+<para>
+The keyboard geometry’s top-level description is stored in a <emphasis>
+XkbGeometryRec</emphasis>
+ structure. This structure contains three types of information:
+</para>
+
+<orderedlist>
+ <listitem>
+ <para>
+Lists of items, not used to draw the basic keyboard, but indexed by the
+geometry descriptions that comprise the entire keyboard geometry (colors,
+geometry properties, key aliases, shapes)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A number of singleton items that describe the keyboard as a whole (keyboard
+name, width and height, a color for the keyboard as a whole, and a color for
+keyboard key labels)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A list of the keyboard’s sections and nonkey doodads
+ </para>
+ </listitem>
+</orderedlist>
+
+<para>
+The top-level geometry is described in more detail in the following.
+</para>
+
+
+<para>
+The lists of items used by components of the keyboard geometry description is
+as follows:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The top-level keyboard geometry description includes a list of up to <emphasis>
+MaxColors</emphasis>
+ (32) <emphasis>
+color names</emphasis>
+. A color name is a string whose interpretation is not specified by Xkb. The
+<emphasis>
+XkbColorRec</emphasis>
+ structure provides a field for this name as well as a pixel field. The pixel
+field is a convenient place for an application to store a pixel value or color
+definition, if it needs to. All other geometry data structures refer to colors
+using their indices in this global list.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The top-level keyboard geometry description includes a list of <emphasis>
+geometry properties</emphasis>
+. A geometry property associates an arbitrary string with an equally arbitrary
+name. Geometry properties can be used to provide hints to programs that display
+images of keyboards, but they are not interpreted by Xkb. No other geometry
+structures refer to geometry properties. As an example of a possible use of
+<emphasis>
+properties</emphasis>
+, consider the pause/break key on most PC keyboards: the "break" symbol is
+usually on the front of the key and is often a different color. A program might
+set a property to:
+ </para>
+ <para>
+LBL_PAUS = "{Pause/top/black,Break/front/red}"
+ </para>
+ <para>
+and use the property information to draw the key with a front label as well as
+a top label.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The top-level keyboard geometry description includes a list of <emphasis>
+key aliases</emphasis>
+ (see Chapter 18). Key aliases allow the keyboard layout designer to assign
+multiple key names to a single key.
+ </para>
+<note><para>Key aliases defined in the geometry component of a keyboard mapping
+override those defined in the keycodes component of the server database, which
+are stored in the <emphasis>
+XkbNamesRec</emphasis>
+ (<emphasis>
+xkb-&gt;names</emphasis>
+). Therefore, consider the key aliases defined by the geometry before
+considering key aliases supplied by the keycodes.</para></note>
+</listitem>
+<listitem>
+ <para>
+The top-level keyboard geometry description includes a list of <emphasis>
+shapes</emphasis>
+; other keyboard components refer to shapes by their index in this list. A
+shape consists of an arbitrary name of type Atom and one or more closed-polygon
+<emphasis>
+outlines</emphasis>
+. All points in an outline are specified relative to the origin of its
+enclosing shape, that is, whichever shape that contains this outline in its
+list of outlines. One outline is the primary outline. The primary outline is by
+default the first outline, or it can be optionally specified by the <emphasis>
+primary</emphasis>
+ field in the <emphasis>
+XkbShapeRec</emphasis>
+ structure. A keyboard display application can generate a simpler but still
+accurate keyboard image by displaying only the primary outlines for each shape.
+Nonrectangular keys must include a rectangular <emphasis>
+approximation</emphasis>
+ as one of the outlines associated with the shape. The approximation is not
+normally displayed but can be used by very simple keyboard display applications
+to generate a recognizable but degraded image of the keyboard.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The <emphasis>
+XkbGeometryRec</emphasis>
+ top-level geometry description contains the following information that
+pertains to the keyboard as a whole:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+A <emphasis>
+keyboard symbolic name</emphasis>
+ of type Atom to help users identify the keyboard.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The <emphasis>
+width</emphasis>
+ and <emphasis>
+height</emphasis>
+ of the keyboard, in mm/10. For nonrectangular keyboards, the width and height
+describe the smallest bounding box that encloses the outline of the keyboard.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The<emphasis>
+ base color</emphasis>
+ of the keyboard is the predominant color on the keyboard and is used as the
+default color for any components whose color is not explicitly specified.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The <emphasis>
+label color</emphasis>
+ is the color used to draw the labels on most of the keyboard keys.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The <emphasis>
+label font</emphasis>
+ is a string that describes the font used to draw labels on most keys; label
+fonts are arbitrary strings, because Xkb does not specify the format or name
+space for font names.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The keyboard is subdivided into named <emphasis>
+sections</emphasis>
+ of related keys and doodads. The sections and doodads on the keyboard are
+listed in the <emphasis>
+XkbGeometryRec</emphasis>
+ top-level keyboard geometry description. A section is composed of keys that
+are physically together and logically related. Figure 13.2 shows a keyboard
+that is divided into four sections. A <emphasis>
+doodad</emphasis>
+ describes some visible aspect of the keyboard that is not a key and is not a
+section.
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-8.gif"/>
+ </imageobject>
+<caption>Keyboard with Four Sections</caption>
+</mediaobject>
+
+<!--
+<H5 CLASS="Figure">
+Keyboard with Four Sections</H5>
+-->
+
+<sect1 id='shapes_and_outlines'>
+<title>Shapes and Outlines</title>
+
+<para>
+A <emphasis>
+shape</emphasis>
+, used to draw keyboard components and stored in a <emphasis>
+XkbShapeRec</emphasis>
+ structure, has:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+An arbitrary name of type Atom.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Bounds (two x and y coordinates) that describe the corners of a rectangle
+containing the shape’s top surface outline.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A list of one or more outlines (described below).
+ </para>
+</listitem>
+<listitem>
+ <para>
+Optional pointers to a primary and an approximation outline (described below).
+If either of these pointers is <emphasis>
+NULL</emphasis>
+, the default primary/approximation outline is the first one in the list of
+outlines for the shape.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+An <emphasis>
+outline</emphasis>
+, stored in a <emphasis>
+XkbOutlineRec</emphasis>
+ structure, is a list of one or more points that describes a single
+closed-polygon, as follows:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+A list with a single point describes a rectangle with one corner at the origin
+of the shape (0,0) and the opposite corner at the specified point.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A list of two points describes a rectangle with one corner at the position
+specified by the first point and the opposite corner at the position specified
+by the second point.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A list of three or more points describes an arbitrary polygon. If necessary,
+the polygon is automatically closed by connecting the last point in the list
+with the first.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A nonzero value for the <emphasis>
+corner_radius</emphasis>
+ field specifies that the corners of the polygon should be drawn as circles
+with the specified radius.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+All points in an outline are specified relative to the origin of the enclosing
+shape. Points in an outline may have negative values for the X and Y coordinate.
+</para>
+
+
+<para>
+One outline is the primary outline; a keyboard display application can generate
+a simple but still accurate keyboard image by displaying only the primary
+outlines for each shape. The default primary outline is the first in a
+shape’s list of outlines. If the <emphasis>
+primary</emphasis>
+ field of the <emphasis>
+XkbShapeRec</emphasis>
+ structure is not <emphasis>
+NULL</emphasis>
+, it points to the primary outline. A rectangular <emphasis>
+approximation</emphasis>
+ must be included for nonrectangular keys as one of the outlines associated
+with the shape; the approximation is not normally displayed but can be used by
+very simple keyboard display applications to generate a recognizable but
+degraded image of the keyboard.
+</para>
+
+</sect1>
+<sect1 id='sections'>
+<title>Sections</title>
+
+<para>
+As previously noted, a keyboard is subdivided into <emphasis>
+sections</emphasis>
+ of related keys. Each section has its own coordinate system — if a section
+is rotated, the coordinates of any components within the section are
+interpreted relative to the edges that were on the top and left before
+rotation. The components that make up a section, stored in a <emphasis>
+XkbSectionRec</emphasis>
+, include:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+An arbitrary name of type Atom.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A priority, to indicate drawing order. 0 is the highest priority, 255 the
+lowest.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Origin of the section, relative to the origin of the keyboard.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The width and height and the angle of rotation.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A list of <emphasis>
+rows</emphasis>
+. A row is a list of horizontally or vertically adjacent keys. Horizontal rows
+parallel the (prerotation) top of the section, and vertical rows parallel the
+(prerotation) left of the section. All keys in a horizontal row share a common
+top coordinate; all keys in a vertical row share a left coordinate. Figure 13.3
+shows the alpha section from the keyboard shown in Figure 13.2, divided into
+rows. Rows and keys are defined below.
+ </para>
+</listitem>
+</itemizedlist>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-9.gif"/>
+ </imageobject>
+ <caption>Rows in a Section</caption>
+</mediaobject>
+
+
+
+<!--
+<H5 CLASS="Figure">
+Rows in a Section</H5>
+-->
+<itemizedlist>
+<listitem>
+ <para>
+An optional list of <emphasis>
+doodads</emphasis>
+; any type of doodad can be enclosed within a section. Position and angle of
+rotation are relative to the origin and angle of rotation of the sections that
+contain them. Priority for doodads in a section is relative to the other
+components of the section, not to the keyboard as a whole.
+ </para>
+</listitem>
+<listitem>
+ <para>
+An optional <emphasis>
+overlay</emphasis>
+ with a name of type Atom and a list of overlay rows (described below).
+ </para>
+</listitem>
+<listitem>
+ <para>
+Bounds (two x and y coordinates) that describe the corners of a rectangle
+containing the entire section.
+ </para>
+</listitem>
+</itemizedlist>
+</sect1>
+<sect1 id='rows_and_keys'>
+<title>Rows and Keys</title>
+
+<para>
+A row description (<emphasis>
+XkbRowRec</emphasis>
+) consists of the coordinates of its origin relative to its enclosing section,
+a flag indicating whether the row is horizontal or vertical, and a list of keys
+in the row.
+</para>
+
+
+<para>
+A key description (<emphasis>
+XkbKeyRec</emphasis>
+) consists of a key name, a shape, a key color, and a gap. The key name should
+correspond to one of the keys named in the keyboard names description, the
+shape specifies the appearance of the key, and the key color specifies the
+color of the key (not the label on the key; the label color is stored in the
+<emphasis>
+XkbGeometryRec</emphasis>
+). Keys are normally drawn immediately adjacent to one another from left to
+right (or top to bottom) within a row. The gap field specifies the distance
+between a key and its predecessor.
+</para>
+
+
+</sect1>
+<sect1 id='doodads'>
+<title>Doodads</title>
+
+<para>
+Doodads can be global to the keyboard or part of a section. Doodads have
+symbolic names of arbitrary length. The only doodad name whose interpretation
+is specified by Xkb is "Edges", which, if present, describes the outline of the
+entire keyboard.
+</para>
+
+
+<para>
+Each doodad’s origin is stored in fields named <emphasis>
+left</emphasis>
+ and <emphasis>
+top</emphasis>
+, which are the coordinates of the doodad’s origin relative to its enclosing
+object, whether it be a section or the top-level keyboard. The priority for
+doodads that are listed in the top-level geometry is relative to the other
+doodads listed in the top-level geometry and the sections listed in the
+top-level geometry. The priority for doodads listed in a section are relative
+to the other components of the section. Each doodad is stored in a structure
+with a <emphasis>
+type</emphasis>
+ field, which specifies the type of doodad.
+</para>
+
+<para>
+Xkb supports five types of doodads:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+An <emphasis>
+indicator doodad</emphasis>
+ describes one of the physical keyboard indicators. Indicator doodads specify
+the shape of the indicator, the indicator color when it is lit (<emphasis>
+on_color</emphasis>
+) and the indicator color when it is dark (<emphasis>
+off_color</emphasis>
+).
+ </para>
+</listitem>
+<listitem>
+ <para>
+An <emphasis>
+outline doodad</emphasis>
+ describes some aspect of the keyboard to be drawn as one or more hollow,
+closed polygons. Outline doodads specify the shape, color, and angle of
+rotation about the doodad origin at which they should be drawn.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A <emphasis>
+solid doodad</emphasis>
+ describes some aspect of the keyboard to be drawn as one or more filled
+polygons. Solid doodads specify the shape, color, and angle of rotation about
+the doodad origin at which they should be drawn.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A <emphasis>
+text doodad</emphasis>
+ describes a text label somewhere on the keyboard. Text doodads specify the
+label string, the font and color to use when drawing the label, and the angle
+of rotation of the doodad about its origin.
+ </para>
+</listitem>
+<listitem>
+ <para>
+A <emphasis>
+logo doodad </emphasis>
+is a catch-all, which describes some other visible element of the keyboard. A
+logo doodad is essentially an outline doodad with an additional symbolic name
+that describes the element to be drawn. If a keyboard display program
+recognizes the symbolic name, it can draw something appropriate within the
+bounding region of the shape specified in the doodad. If the symbolic name does
+not describe a recognizable image, it should draw an outline using the
+specified shape, outline, and angle of rotation. The Xkb extension does not
+specify the interpretation of logo names.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+The structures these doodads are stored in and the values of the <emphasis>
+type</emphasis>
+ fields are shown in Table 13.1.
+</para>
+
+<table frame='none'>
+<title>Doodad Types</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Doodad</entry>
+ <entry>Structure</entry>
+ <entry>Type</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>
+indicator doodad</emphasis>
+</entry>
+ <entry><emphasis>
+XkbIndicatorDoodadRec</emphasis>
+</entry>
+ <entry><emphasis>
+XkbIndicatorDoodad</emphasis>
+</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>
+outline doodad</emphasis>
+</entry>
+ <entry><emphasis>
+XkbShapeDoodadRec</emphasis>
+</entry>
+ <entry><emphasis>
+XkbOutlineDoodad</emphasis>
+</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>
+solid doodad</emphasis>
+</entry>
+ <entry><emphasis>
+XkbShapeDoodadRec</emphasis>
+</entry>
+ <entry><emphasis>
+XkbSolidDoodad</emphasis>
+</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>
+text doodad</emphasis>
+</entry>
+ <entry><emphasis>
+XkbTextDoodadRec</emphasis>
+</entry>
+ <entry><emphasis>
+XkbTextDoodad</emphasis>
+</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>
+logo doodad</emphasis>
+</entry>
+ <entry><emphasis>
+XkbLogoDoodadRec</emphasis>
+</entry>
+ <entry><emphasis>
+XkbLogoDoodad</emphasis>
+</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+<sect1 id='overlay_rows_and_overlay_keys'>
+<title>Overlay Rows and Overlay Keys</title>
+
+<para>
+An <emphasis>
+overlay row</emphasis>
+ (<emphasis>
+XkbOverlayRowRec</emphasis>
+) contains a pointer to the row it overlays and a list of <emphasis>
+overlay keys</emphasis>
+.
+</para>
+
+
+<para>
+Each overlay key definition (<emphasis>
+XkbOverlayKeyRec</emphasis>
+) indicates a key that can yield multiple keycodes and consists of a field
+named <emphasis>
+under</emphasis>
+, which specifies the primary name of the key and a field named <emphasis>
+over</emphasis>
+, which specifies the name for the key when the overlay keycode is selected.
+The key specified in <emphasis>
+under</emphasis>
+ must be a member of the section that contains the overlay key definition,
+while the key specified in over must not be.
+</para>
+
+
+</sect1>
+<sect1 id='drawing_a_keyboard_representation'>
+<title>Drawing a Keyboard Representation</title>
+
+<para>
+To draw a representation of the keyboard, draw in the following order:
+</para>
+
+<para><programlisting>
+ Draw the top-level keyboard as a rectangle, using its width and height.
+ For each component (section or doodad) of the top-level geometry, in priority order:
+ If component is a section
+ For each row, in the order it appears in the section
+ Draw keys in the order they appear in the row
+ Draw doodads within the section in priority order.
+ Else draw doodad
+</programlisting></para>
+
+</sect1>
+<sect1 id='geometry_data_structures'>
+<title>Geometry Data Structures</title>
+
+<para>
+In the following figures, a solid arrow denotes a pointer to an array of
+structures or a singleton structure. A dotted arrow denotes an index or a
+pointer into the array.
+</para>
+
+<!--
+<MAP NAME="XKBlib-10">
+</MAP>
+-->
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-10.gif"/>
+ </imageobject>
+<caption>Xkb Geometry Data Structures</caption>
+</mediaobject>
+
+<!--
+<H5 CLASS="Figure">
+Xkb Geometry Data Structures</H5>
+<P CLASS="SmallBody">
+&nbsp;</P>
+<MAP NAME="XKBlib-11">
+</MAP>
+-->
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-11.gif"/>
+ </imageobject>
+<caption>Xkb Geometry Data Structures (Doodads)</caption>
+</mediaobject>
+
+<!--
+<H5 CLASS="Figure">
+Xkb Geometry Data Structures (Doodads)</H5>
+-->
+
+<!--
+<MAP NAME="XKBlib-12">
+</MAP>
+-->
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-12.gif"/>
+ </imageobject>
+<caption>Xkb Geometry Data Structures (Overlays)</caption>
+</mediaobject>
+
+<!--
+<H5 CLASS="Figure">
+Xkb Geometry Data Structures (Overlays)</H5>
+-->
+<para><programlisting>
+typedef struct _XkbGeometry { /* top-level keyboard geometry structure */
+ Atom name; /* keyboard name */
+ unsigned short width_mm; /* keyboard width in <emphasis> mm</emphasis> /<emphasis> 10</emphasis> */
+ unsigned short height_mm; /* keyboard height in <emphasis> mm</emphasis> /<emphasis> 10</emphasis> */
+ char * label_font; /* font for key labels */
+ XkbColorPtr label_color; /* color for key labels - pointer into colors array */
+ XkbColorPtr base_color; /* color for basic keyboard - pointer into colors array */
+ unsigned short sz_properties; /* size of properties array */
+ unsigned short sz_colors; /* size of colors array */
+ unsigned short sz_shapes; /* size of shapes array */
+ unsigned short sz_sections; /* size of sections array */
+ unsigned short sz_doodads; /* size of doodads array */
+ unsigned short sz_key_aliases; /* size of key aliases array */
+ unsigned short num_properties; /* number of properties in the properties array */
+ unsigned short num_colors; /* number of colors in the colors array */
+ unsigned short num_shapes; /* number of shapes in the shapes array */
+ unsigned short num_sections; /* number of sections in the sections array */
+ unsigned short num_doodads; /* number of doodads in the doodads array */
+ unsigned short num_key_aliases; /* number of key aliases in the key */
+ XkbPropertyPtr properties; /* properties array */
+ XkbColorPtr colors; /* colors array */
+ XkbShapePtr shapes; /* shapes array */
+ XkbSectionPtr sections; /* sections array */
+ XkbDoodadPtr doodads; /* doodads array */
+ XkbKeyAliasPtr key_aliases; /* key aliases array */
+} <emphasis>XkbGeometryRec</emphasis>*XkbGeometryPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+doodads</emphasis>
+ array is only for doodads not contained in any of the <emphasis>
+sections</emphasis>
+ that has its own <emphasis>
+doodads</emphasis>
+. The key aliases contained in the <emphasis>
+key_aliases</emphasis>
+ array take precedence over any defined in the keycodes component of the
+keyboard description.
+</para>
+
+<para><programlisting>
+typedef struct _XkbProperty {
+ char * name; /* property name */
+ char * value; /* property value */
+} <emphasis>XkbPropertyRec</emphasis>,*XkbPropertyPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbColor {
+ unsigned int pixel; /* color */
+ char * spec; /* color name */
+} <emphasis>XkbColorRec</emphasis>,*XkbColorPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbKeyAliasRec {
+ char real[XkbKeyNameLength]; /* real name of the key */
+ char alias[XkbKeyNameLength]; /* alias for the key */
+} <emphasis>XkbKeyAliasRec</emphasis>,*XkbKeyAliasPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbPoint { /* x,y coordinates */
+ short x;
+ short y;
+} <emphasis>XkbPointRec</emphasis>, *XkbPointPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbOutline {
+ unsigned short num_points; /* number of points in the outline */
+ unsigned short sz_points; /* size of the points array */
+ unsigned short corner_radius; /* draw corners as circles with this radius */
+ XkbPointPtr points; /* array of points defining the outline */
+} <emphasis>XkbOutlineRec</emphasis>, *XkbOutlinePtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbBounds {
+ short x1,y1; /* upper left corner of the bounds,
+ in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short x2,y2; /* lower right corner of the bounds, in
+ <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+} <emphasis>XkbBoundsRec</emphasis>, *XkbBoundsPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbShape {
+ Atom name; /* shape’s name */
+ unsigned short num_outlines; /* number of outlines for the shape */
+ unsigned short sz_outlines; /* size of the outlines array */
+ XkbOutlinePtr outlines; /* array of outlines for the shape */
+ XkbOutlinePtr approx; /* pointer into the array to the approximating outline */
+ XkbOutlinePtr primary; /* pointer into the array to the primary outline */
+ XkbBoundsRec bounds; /* bounding box for the shape; encompasses all outlines */
+} <emphasis>XkbShapeRec</emphasis>, *XkbShapePtr;
+</programlisting></para>
+
+<para>
+If <emphasis>
+approx</emphasis>
+ and/or <emphasis>
+primary</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, the default value is used. The default primary outline is the first element
+in the outlines array, as is the default approximating outline.
+</para>
+
+<para><programlisting>
+typedef struct _XkbKey { /* key in a row */
+ XkbKeyNameRec name; /* key name */
+ short gap; /* gap in <emphasis>mm</emphasis>/<emphasis>10</emphasis> from previous key in row */
+ unsigned char shape_ndx; /* index of shape for key */
+ unsigned char color_ndx; /* index of color for key body */
+} <emphasis>XkbKeyRec</emphasis>, *XkbKeyPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbRow { /* row in a section */
+ short top; /* top coordinate of row origin, relative to section’s origin */
+ short left; /* left coordinate of row origin, relative to section’s origin */
+ unsigned short num_keys; /* number of keys in the keys array */
+ unsigned short sz_keys; /* size of the keys array */
+ int vertical; /* <emphasis>True</emphasis> =&gt;vertical row,
+ <emphasis> False</emphasis> =&gt;horizontal row */
+ XkbKeyPtr keys; /* array of keys in the row*/
+ XkbBoundsRec bounds; /* bounding box for the row */
+} <emphasis>XkbRowRec</emphasis>, *XkbRowPtr;
+</programlisting></para>
+
+<para>
+<emphasis>
+top</emphasis>
+ and <emphasis>
+left</emphasis>
+ are in <emphasis>
+mm</emphasis>
+/<emphasis>
+10</emphasis>
+.
+</para>
+
+<para><programlisting>
+typedef struct _XkbOverlayRec {
+ Atom name; /* overlay name */
+ XkbSectionPtr section_under; /* the section under this overlay */
+ unsigned short num_rows; /* number of rows in the rows array */
+ unsigned short sz_rows; /* size of the rows array */
+ XkbOverlayRowPtr rows; /* array of rows in the overlay */
+ XkbBoundsPtr bounds; /* bounding box for the overlay */
+} <emphasis>XkbOverlayRec</emphasis>,*XkbOverlayPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbOverlayRow {
+ unsigned short row_under; /* index into the row under this overlay row */
+ unsigned short num_keys; /* number of keys in the keys array */
+ unsigned short sz_keys; /* size of the keys array */
+ XkbOverlayKeyPtr keys; /* array of keys in the overlay row */
+} <emphasis>XkbOverlayRowRec</emphasis>,*XkbOverlayRowPtr;
+</programlisting></para>
+
+<para>
+<emphasis>
+row_under</emphasis>
+ is an index into the array of <emphasis>
+rows</emphasis>
+ in the section under this overlay. The section under this overlay row is the
+one pointed to by <emphasis>
+section_under</emphasis>
+ in this overlay row’s <emphasis>
+XkbOverlayRec</emphasis>
+.
+</para>
+
+<para><programlisting>
+typedef struct _XkbOverlayKey {
+ XkbKeyNameRec over; /* name of this overlay key */
+ XkbKeyNameRec under; /* name of the key under this overlay key */
+} <emphasis>XkbOverlayKeyRec</emphasis>,*XkbOverlayKeyPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbSection {
+ Atom name; /* section name */
+ unsigned char priority; /* drawing priority, 0=&gt;highest, 255=&gt;lowest */
+ short top; /* top coordinate of section origin */
+ short left; /* left coordinate of row origin */
+ unsigned short width; /* section width, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ unsigned short height; /* section height, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short angle; /* angle of section rotation, counterclockwise */
+ unsigned short num_rows; /* number of rows in the rows array */
+ unsigned short num_doodads; /* number of doodads in the doodads array */
+ unsigned short num_overlays; /* number of overlays in the overlays array */
+ unsigned short sz_rows; /* size of the rows array */
+ unsigned short sz_doodads; /* size of the doodads array */
+ unsigned short sz_overlays; /* size of the overlays array */
+ XkbRowPtr rows; /* section rows array */
+ XkbDoodadPtr doodads; /* section doodads array */
+ XkbBoundsRec bounds; /* bounding box for the section, before rotation*/
+ XkbOverlayPtr overlays; /* section overlays array */
+} <emphasis>XkbSectionRec</emphasis>, *XkbSectionPtr;
+</programlisting></para>
+
+<para>
+<emphasis>
+top</emphasis>
+ and <emphasis>
+left</emphasis>
+ are the origin of the section, relative to the origin of the keyboard, in
+<emphasis>
+mm</emphasis>
+/<emphasis>
+10</emphasis>
+. <emphasis>
+angle</emphasis>
+ is in <emphasis>
+1</emphasis>
+/<emphasis>
+10</emphasis>
+ degrees.
+</para>
+
+<sect2 id='doodadrec_structures'>
+<title>DoodadRec Structures</title>
+
+<para>
+The doodad arrays in the <emphasis>
+XkbGeometryRec</emphasis>
+ and the <emphasis>
+XkbSectionRec</emphasis>
+ may contain any of the doodad structures and types shown in Table 13.1.
+</para>
+
+
+<para>
+The doodad structures form a union:
+</para>
+
+<para><programlisting>
+typedef union _XkbDoodad {
+ XkbAnyDoodadRec any;
+ XkbShapeDoodadRec shape;
+ XkbTextDoodadRec text;
+ XkbIndicatorDoodadRec indicator;
+ XkbLogoDoodadRec logo;
+} <emphasis>XkbDoodadRec</emphasis>, *XkbDoodadPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+top</emphasis>
+ and <emphasis>
+left</emphasis>
+ coordinates of each doodad are the coordinates of the origin of the doodad
+relative to the keyboard’s origin if the doodad is in the <emphasis>
+XkbGeometryRec</emphasis>
+ doodad array, and with respect to the section’s origin if the doodad is in a
+<emphasis>
+XkbSectionRec</emphasis>
+ doodad array. The <emphasis>
+color_ndx</emphasis>
+ or <emphasis>
+on_color_ndx</emphasis>
+ and <emphasis>
+off_color_ndx</emphasis>
+ fields are color indices into the <emphasis>
+XkbGeometryRec</emphasis>
+’s color array and are the colors to draw the doodads with. Similarly, the
+<emphasis>
+shape_ndx</emphasis>
+ fields are indices into the <emphasis>
+XkbGeometryRec</emphasis>
+’s shape array.
+</para>
+
+<para><programlisting>
+typedef struct _XkbShapeDoodad {
+ Atom name; /* doodad name */
+ unsigned char type; /* <emphasis>XkbOutlineDoodad</emphasis>
+ or <emphasis>XkbSolidDoodad</emphasis> */
+ unsigned char priority; /* drawing priority,
+ 0=&gt;highest, 255=&gt;lowest */
+ short top; /* top coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short left; /* left coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short angle; /* angle of rotation, clockwise, in <emphasis>1</emphasis>/<emphasis>10</emphasis> degrees */
+ unsigned short color_ndx; /* doodad color */
+ unsigned short shape_ndx; /* doodad shape */
+} <emphasis>XkbShapeDoodadRec</emphasis>, *XkbShapeDoodadPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbTextDoodad {
+ Atom name; /* doodad name */
+ unsigned char type; /* <emphasis> XkbTextDoodad</emphasis> */
+ unsigned char priority; /* drawing priority,
+ 0=&gt;highest, 255=&gt;lowest */
+ short top; /* top coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short left; /* left coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short angle; /* angle of rotation, clockwise, in <emphasis>1</emphasis>/<emphasis>10</emphasis> degrees */
+ short width; /* width in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short height; /* height in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ unsigned short color_ndx; /* doodad color */
+ char * text; /* doodad text */
+ char * font; /* arbitrary font name for doodad text */
+} <emphasis>XkbTextDoodadRec</emphasis>, *XkbTextDoodadPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbIndicatorDoodad {
+ Atom name; /* doodad name */
+ unsigned char type; /* <emphasis>XkbIndicatorDoodad</emphasis> */
+ unsigned char priority; /* drawing priority, 0=&gt;highest, 255=&gt;lowest */
+ short top; /* top coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short left; /* left coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short angle; /* angle of rotation, clockwise, in <emphasis>1</emphasis>/<emphasis>10</emphasis> degrees */
+ unsigned short shape_ndx; /* doodad shape */
+ unsigned short on_color_ndx; /* color for doodad if indicator is on */
+ unsigned short off_color_ndx; /* color for doodad if indicator is off */
+} <emphasis>XkbIndicatorDoodadRec</emphasis>, *XkbIndicatorDoodadPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbLogoDoodad {
+ Atom name; /* doodad name */
+ unsigned char type; /* <emphasis> XkbLogoDoodad</emphasis> */
+ unsigned char priority; /* drawing priority, 0=&gt;highest, 255=&gt;lowest */
+ short top; /* top coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short left; /* left coordinate, in <emphasis>mm</emphasis>/<emphasis>10</emphasis> */
+ short angle; /* angle of rotation, clockwise, in <emphasis>1</emphasis>/<emphasis>10</emphasis> degrees */
+ unsigned short color_ndx; /* doodad color */
+ unsigned short shape_ndx; /* doodad shape */
+ char * logo_name; /* text for logo */
+} <emphasis>XkbLogoDoodadRec</emphasis>, *XkbLogoDoodadPtr
+</programlisting></para>
+
+</sect2>
+</sect1>
+<sect1 id='getting_keyboard_geometry_from_the_server'>
+<title>Getting Keyboard Geometry From the Server</title>
+
+<para>
+You can load a keyboard geometry as part of the keyboard description returned
+by <emphasis>
+XkbGetKeyboard</emphasis>
+. However, if a keyboard description has been previously loaded, you can
+instead obtain the geometry by calling the <emphasis>
+XkbGetGeometry</emphasis>
+. In this case, the geometry returned is the one associated with the keyboard
+whose device ID is contained in the keyboard description.
+</para>
+
+<para>
+To load a keyboard geometry if you already have the keyboard description, use
+<emphasis>XkbGetGeometry</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetGeometry</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description that contains the ID for the keyboard and into
+which the geometry should be loaded */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetGeometry</emphasis>
+ can return <emphasis>
+BadValue</emphasis>
+, <emphasis>
+BadImplementation</emphasis>
+, <emphasis>
+BadName</emphasis>
+, <emphasis>
+BadAlloc,</emphasis>
+ or <emphasis>
+BadLength</emphasis>
+ errors or <emphasis>
+Success</emphasis>
+ if it succeeds.
+</para>
+
+<para>
+It is also possible to load a keyboard geometry by name. The X server maintains
+a database of keyboard components (see Chapter 20). To load a keyboard geometry
+description from this database by name, use <emphasis>
+XkbGetNamedGeometry</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetNamedGeometry</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ xkb</emphasis>
+,<emphasis>
+ name</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description into which the geometry should be loaded */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+name</emphasis>
+; /* name of the geometry to be loaded */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetNamedGeometry</emphasis>
+ can return <emphasis>
+BadName</emphasis>
+ if the <emphasis>
+name</emphasis>
+ cannot be found.
+</para>
+
+</sect1>
+<sect1 id='using_keyboard_geometry'>
+<title>Using Keyboard Geometry</title>
+
+<para>
+Xkb provides a number of convenience functions to help use a keyboard geometry.
+These include functions to return the bounding box of a shape’s top surface
+and to update the bounding box of a shape row or section.
+</para>
+
+<para>
+A shape is made up of a number of outlines. Each outline is a polygon made up
+of a number of points. The bounding box of a shape is a rectangle that contains
+all the outlines of that shape.
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-13.gif"/>
+ </imageobject>
+<caption>Key Surface, Shape Outlines, and Bounding Box</caption>
+ </mediaobject>
+
+
+<!--
+<H5 CLASS="Figure">
+Key Surface, Shape Outlines, and Bounding Box</H5>
+-->
+
+<para>
+To determine the bounding box of the top surface of a shape, use <emphasis>
+XkbComputeShapeTop</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbComputeShapeTop</emphasis>
+(<emphasis>
+shape</emphasis>
+,<emphasis>
+ bounds_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbShapePtr <emphasis>
+ shape</emphasis>
+; /* shape to be examined */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbBoundsPtr <emphasis>
+ bounds_rtrn</emphasis>
+ /* backfilled with the bounding box for the shape */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbComputeShapeTop</emphasis>
+ returns a <emphasis>
+BoundsRec</emphasis>
+ that contains two x and y coordinates. These coordinates describe the corners
+of a rectangle that contains the outline that describes the top surface of the
+shape. The top surface is defined to be the approximating outline if the
+<emphasis>
+approx</emphasis>
+ field of <emphasis>
+shape</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+. If <emphasis>
+approx</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, the top surface is defined as the last outline in the <emphasis>
+shape</emphasis>
+’s array of outlines. <emphasis>
+XkbComputeShapeTop</emphasis>
+ returns <emphasis>
+False</emphasis>
+ if <emphasis>
+shape</emphasis>
+ is <emphasis>
+NULL</emphasis>
+ or if there are no outlines for the shape; otherwise, it returns
+<emphasis>True</emphasis>.
+</para>
+
+
+<para>
+A <emphasis>
+ShapeRec</emphasis>
+ contains a <emphasis>
+BoundsRec</emphasis>
+ that describes the bounds of the shape. If you add or delete an outline to or
+from a shape, the bounding box must be updated. To update the bounding box of a
+shape, use <emphasis>XkbComputeShapeBounds</emphasis>.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbComputeShapeBounds</emphasis>
+(<emphasis>
+shape</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbShapePtr <emphasis>
+ shape</emphasis>
+; /* shape to be examined */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbComputeShapeBounds</emphasis>
+ updates the <emphasis>
+BoundsRec</emphasis>
+ contained in the <emphasis>
+shape</emphasis>
+ by examining all the outlines of the shape and setting the <emphasis>
+BoundsRec</emphasis>
+ to the minimum x and minimum y, and maximum x and maximum y values found in
+those outlines. <emphasis>
+XkbComputeShapeBounds</emphasis>
+ returns <emphasis>
+False</emphasis>
+ if <emphasis>
+shape</emphasis>
+ is <emphasis>
+NULL</emphasis>
+ or if there are no outlines for the shape; otherwise, it returns <emphasis>
+True</emphasis>
+.
+</para>
+
+<para>
+ If you add or delete a key to or from a row, or if you update the shape of one
+of the keys in that row, you may need to update the bounding box of that row.
+To update the bounding box of a row, use <emphasis>XkbComputeRowBounds</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbComputeRowBounds</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ section</emphasis>
+,<emphasis>
+ row</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry that contains the <emphasis>
+section</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section that contains the row */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+row</emphasis>
+; /* row to be examined and updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbComputeRowBounds</emphasis>
+ checks the bounds of all keys in the <emphasis>
+row </emphasis>
+and updates the bounding box of the row if necessary. <emphasis>
+XkbComputeRowBounds</emphasis>
+ returns <emphasis>
+False</emphasis>
+ if any of the arguments is <emphasis>
+NULL</emphasis>
+; otherwise, it returns <emphasis>
+True</emphasis>
+.
+</para>
+
+<para>
+ If you add or delete a row to or from a section, or if you change the geometry
+of any of the rows in that section, you may need to update the bounding box for
+that section. To update the bounding box of a section, use
+<emphasis>XkbComputeSectionBounds</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbComputeSectionBounds</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ section</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry that contains the <emphasis>
+section</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section to be examined and updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbComputeSectionBounds</emphasis>
+ examines all the rows of the <emphasis>
+section</emphasis>
+ and updates the bounding box of that section so that it contains all rows.
+<emphasis>
+XkbComputeSectionBounds</emphasis>
+ returns <emphasis>
+False</emphasis>
+ if any of the arguments is <emphasis>
+NULL</emphasis>
+; otherwise, it returns <emphasis>
+True</emphasis>
+.
+</para>
+
+<para>
+Keys that can generate multiple keycodes may be associated with multiple names.
+Such keys have a primary name and an alternate name. To find the alternate name
+by using the primary name for a key that is part of an overlay, use <emphasis>
+XkbFindOverlayForKey</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+char * <emphasis>
+XkbFindOverlayForKey</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ section</emphasis>
+,<emphasis>
+ under</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry that contains the <emphasis>
+section</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section to be searched for matching keys */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ under</emphasis>
+. /* primary name of the key to be considered */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbFindOverlayForKey</emphasis>
+ uses the primary name of the key, <emphasis>
+under</emphasis>
+, to look up the alternate name, which it returns.
+</para>
+
+
+</sect1>
+<sect1 id='adding_elements_to_a_keyboard_geometry'>
+<title>Adding Elements to a Keyboard Geometry</title>
+
+<para>
+Xkb provides functions to add a single new element to the top-level keyboard
+geometry. In each case the <emphasis>
+num_ </emphasis>
+<emphasis>
+*</emphasis>
+ fields of the corresponding structure is incremented by 1. These functions do
+not change <emphasis>
+sz_</emphasis>
+<emphasis>
+*</emphasis>
+ unless there is no more room in the array. Some of these functions fill in the
+values of the element’s structure from the arguments. For other functions,
+you must explicitly write code to fill the structure’s elements.
+</para>
+
+
+<para>
+The top-level geometry description includes a list of <emphasis>
+geometry properties</emphasis>
+. A geometry property associates an arbitrary string with an equally arbitrary
+name. Programs that display images of keyboards can use geometry properties as
+hints, but they are not interpreted by Xkb. No other geometry structures refer
+to geometry properties.
+</para>
+
+
+<para>
+To add one property to an existing keyboard geometry description, use <emphasis>
+XkbAddGeomProperty</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbPropertyPtr <emphasis>
+XkbAddGeomProperty</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ name</emphasis>
+,<emphasis>
+ value</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ name</emphasis>
+; /* name of the new property */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ value</emphasis>
+; /* value for the new property */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddGeomProperty</emphasis>
+ adds one property with the specified <emphasis>
+name</emphasis>
+ and <emphasis>
+value</emphasis>
+ to the keyboard geometry specified by geom.<emphasis>
+ </emphasis>
+<emphasis>
+XkbAddGeomProperty</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the property. To allocate space for an arbitrary number of properties, use the
+XkbAllocGeomProps function.
+</para>
+
+
+<para>
+To add one key alias to an existing keyboard geometry description, use
+<emphasis>
+XkbAddGeomKeyAlias</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbKeyAliasPtr <emphasis>
+XkbAddGeomKeyAlias</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ alias, real</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ alias</emphasis>
+; /* alias to be added */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ real</emphasis>
+; /* real name to be bound to the new alias */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddGeomKeyAlias</emphasis>
+ adds one key alias with the value alias to the geometry geom, and associates
+it with the key whose real name is real. <emphasis>
+XkbAddGeomKeyAlias</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the alias. To allocate space for an arbitrary number of aliases, use the
+XkbAllocGeomKeyAliases function.
+</para>
+
+
+<para>
+To add one color name to an existing keyboard geometry description, use
+<emphasis>
+XkbAddGeomColor</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbColorPtr <emphasis>
+XkbAddGeomColor</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ spec</emphasis>
+,<emphasis>
+ pixel</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ spec</emphasis>
+; /* color to be added */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ pixel</emphasis>
+; /* color to be added */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddGeomColor</emphasis>
+ adds the specified color <emphasis>
+name</emphasis>
+ and <emphasis>
+pixel</emphasis>
+ to the specified geometry <emphasis>
+geom</emphasis>
+. The top-level geometry description includes a list of up to <emphasis>
+MaxColors</emphasis>
+ (32) <emphasis>
+color names</emphasis>
+. A color <emphasis>
+name</emphasis>
+ is a string whose interpretation is not specified by Xkb and neither is the
+<emphasis>
+pixel</emphasis>
+ value’s interpretation. All other geometry data structures refer to colors
+using their indices in this global list or pointers to colors in this list.
+<emphasis>
+XkbAddGeomColor</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the color. To allocate space for an arbitrary number of colors to a geometry,
+use the <emphasis>
+XkbAllocGeomColors</emphasis>
+ function.
+</para>
+
+<para>
+To add one outline to an existing shape, use <emphasis>
+XkbAddGeomOutline</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbOutlinePtr <emphasis>
+XkbAddGeomOutline</emphasis>
+(<emphasis>
+shape</emphasis>
+,<emphasis>
+ sz_points</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbShapePtr <emphasis>
+ shape</emphasis>
+; /* shape to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_points</emphasis>
+; /* number of points to be reserved */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+An outline consists of an arbitrary number of points. <emphasis>
+XkbAddGeomOutline</emphasis>
+ adds an outline to the specified <emphasis>
+shape</emphasis>
+ by reserving <emphasis>
+sz_points</emphasis>
+ points for it. The new outline is allocated and zeroed. <emphasis>
+XkbAddGeomOutline</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space. To
+allocate space for an arbitrary number of outlines to a shape, use
+XkbAllocGeomOutlines.
+</para>
+
+
+<para>
+To add a shape to a keyboard geometry, use <emphasis>
+XkbAddGeomShape</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbShapePtr <emphasis>
+XkbAddGeomShape</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ name</emphasis>
+,<emphasis>
+ sz_outlines</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+ name</emphasis>
+; /* name of the new shape */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_outlines</emphasis>
+; /* number of outlines to be reserved */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+A geometry contains an arbitrary number of shapes, each of which is made up of
+an arbitrary number of outlines. <emphasis>
+XkbAddGeomShape</emphasis>
+ adds a shape to a geometry <emphasis>
+geom</emphasis>
+ by allocating space for <emphasis>
+sz_outlines</emphasis>
+ outlines for it and giving it the name specified by name. If a shape with name
+<emphasis>
+name</emphasis>
+ already exists in the geometry, a pointer to the existing shape is returned.
+<emphasis>
+XkbAddGeomShape</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space. To
+allocate space for an arbitrary number of geometry shapes, use <emphasis>
+XkbAllocGeomShapes</emphasis>
+.
+</para>
+
+
+<para>
+To add one key at the end of an existing row of keys, use <emphasis>
+XkbAddGeomKey</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbKeyPtr <emphasis>
+XkbAddGeomKey</emphasis>
+(<emphasis>
+row</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+ row</emphasis>
+; /* row to be updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+Keys are grouped into rows. <emphasis>
+XkbAddGeomKey</emphasis>
+ adds one key to the end of the specified <emphasis>
+row</emphasis>
+. The key is allocated and zeroed. <emphasis>
+XkbAddGeomKey</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if <emphasis>
+row</emphasis>
+ is empty or if it was not able to allocate space for the key. To allocate
+space for an arbitrary number of keys to a row, use XkbAllocGeomKeys.
+</para>
+
+
+<para>
+To add one section to an existing keyboard geometry, use <emphasis>
+XkbAddGeomSection</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbSectionPtr <emphasis>
+XkbAddGeomSection</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ name</emphasis>
+,<emphasis>
+ sz_rows</emphasis>
+,<emphasis>
+ sz_doodads</emphasis>
+,<emphasis>
+ sz_overlays</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+ name</emphasis>
+; /* name of the new section */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_rows</emphasis>
+; /* number of rows to reserve in the section */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_doodads</emphasis>
+; /* number of doodads to reserve in the section */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_overlays</emphasis>
+; /* number of overlays to reserve in the section */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+A keyboard geometry contains an arbitrary number of sections. <emphasis>
+XkbAddGeomSection</emphasis>
+ adds one section to an existing keyboard geometry <emphasis>
+geom</emphasis>
+. The new section contains space for the number of rows, doodads, and overlays
+specified by <emphasis>
+sz_rows</emphasis>
+, <emphasis>
+sz_doodads</emphasis>
+, and <emphasis>
+sz_overlays</emphasis>
+. The new section is allocated and zeroed and given the name specified by
+<emphasis>
+name</emphasis>
+. If a section with name <emphasis>
+name</emphasis>
+ already exists in the geometry, a pointer to the existing section is
+returned.<emphasis>
+ XkbAddGeomSection</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the section. To allocate space for an arbitrary number of sections to a
+geometry, use XkbAllocGeomSections.
+</para>
+
+
+<para>
+To add a row to a section, use <emphasis>
+XkbAddGeomRow</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbRowPtr <emphasis>
+XkbAddGeomRow</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ sz_keys</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+sz_keys</emphasis>
+; /* number of keys to be reserved */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+One of the components of a keyboard geometry section is one or more rows of
+keys. <emphasis>
+XkbAddGeomRow</emphasis>
+ adds one row to the specified <emphasis>
+section</emphasis>
+. The newly created row contains space for the number of keys specified in
+<emphasis>
+sz_keys</emphasis>
+. They are allocated and zeroed, but otherwise uninitialized. <emphasis>
+XkbAddGeomRow</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the row. To allocate space for an arbitrary number of rows to a section, use
+the XkbAllocGeomRows function.
+</para>
+
+
+<para>
+To add one doodad to a section of a keyboard geometry or to the top-level
+geometry, use <emphasis>
+XkbAddGeomDoodad</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDoodadPtr <emphasis>
+XkbAddGeomDoodad</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ section</emphasis>
+,<emphasis>
+ name</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to which the doodad is added */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section, if any, to which the doodad is added */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+ name</emphasis>
+; /* name of the new doodad */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+A <emphasis>
+doodad</emphasis>
+ describes some visible aspect of the keyboard that is not a key and is not a
+section. <emphasis>
+XkbAddGeomDoodad</emphasis>
+ adds a doodad with name specified by name to the geometry <emphasis>
+geom</emphasis>
+ if section is <emphasis>
+NULL</emphasis>
+ or to the section of the geometry specified by section if <emphasis>
+section</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+. <emphasis>
+XkbAddGeomDoodad</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the doodad. If there is already a doodad with the name <emphasis>
+name</emphasis>
+ in the doodad array for the geometry (if <emphasis>
+section</emphasis>
+ is <emphasis>
+NULL</emphasis>
+) or the section (if <emphasis>
+section</emphasis>
+ is non-<emphasis>
+NULL</emphasis>
+), a pointer to that doodad is returned. To allocate space for an arbitrary
+number of doodads to a section, use the XkbAllocGeomSectionDoodads function. To
+allocate space for an arbitrary number of doodads to a keyboard geometry, use
+the XkbAllocGeomDoodads function.
+</para>
+
+
+<para>
+To add one overlay to a section, use <emphasis>
+XkbAddGeomOverlay</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbOverlayPtr <emphasis>
+XkbAddGeomOverlay</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ name</emphasis>
+,<emphasis>
+ sz_rows</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section to which an overlay will be added */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Atom <emphasis>
+ name</emphasis>
+; /* name of the overlay */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_rows</emphasis>
+; /* number of rows to reserve in the overlay */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddGeomOverlay</emphasis>
+ adds an overlay with the specified name to the specified <emphasis>
+section</emphasis>
+. The new overlay is created with space allocated for sz_rows rows. If an
+overlay with name <emphasis>
+name</emphasis>
+ already exists in the section, a pointer to the existing overlay is
+returned.<emphasis>
+ XkbAddGeomOverlay</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the overlay. To allocate space for an arbitrary number of overlays to a
+section, use the XkbAllocGeomOverlay function.
+</para>
+
+
+<para>
+To add a row to an existing overlay, use <emphasis>
+XkbAddGeomOverlayRow</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbOverlayRowPtr <emphasis>
+XkbAddGeomOverlayRow</emphasis>
+(<emphasis>
+overlay</emphasis>
+,<emphasis>
+ row_under, sz_keys</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbOverlayPtr <emphasis>
+ overlay</emphasis>
+; /* overlay to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+ row_under</emphasis>
+; /* row to be overlayed in the section <emphasis>
+overlay</emphasis>
+ overlays */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ sz_keys</emphasis>
+; /* number of keys to reserve in the row */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddGeomOverlayRow</emphasis>
+ adds one row to the <emphasis>
+overlay</emphasis>
+. The new row contains space for <emphasis>
+sz_keys</emphasis>
+ keys. If <emphasis>
+row_under</emphasis>
+ specifies a row that doesn’t exist on the underlying section, <emphasis>
+XkbAddGeomOverlayRow</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ and doesn’t change the overlay.<emphasis>
+ XkbAddGeomOverlayRow</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+ if any of the parameters is empty or if it was not able to allocate space for
+the overlay.
+</para>
+
+
+<para>
+To add a key to an existing overlay row, use <emphasis>
+XkbAddGeomOverlayKey</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbOverlayKeyPtr <emphasis>
+XkbAddGeomOverlayKey</emphasis>
+(<emphasis>
+overlay</emphasis>
+,<emphasis>
+ row, under</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbOverlayPtr <emphasis>
+ overlay</emphasis>
+; /* overlay to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+ row</emphasis>
+; /* row in overlay to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ under</emphasis>
+; /* primary name of the key to be considered */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddGeomOverlayKey</emphasis>
+ adds one key to the <emphasis>
+row</emphasis>
+ in the <emphasis>
+overlay</emphasis>
+. If there is no key named <emphasis>
+under</emphasis>
+ in the row of the underlying section, <emphasis>
+XkbAddGeomOverlayKey</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_geometry_components'>
+<title>Allocating and Freeing Geometry Components</title>
+
+<para>
+Xkb provides a number of functions to allocate and free subcomponents of a
+keyboard geometry. Use these functions to create or modify keyboard geometries.
+Note that these functions merely allocate space for the new element(s), and it
+is up to you to fill in the values explicitly in your code. These allocation
+functions increase <emphasis>
+sz_</emphasis>
+<emphasis>
+*</emphasis>
+ but never touch <emphasis>
+num_</emphasis>
+<emphasis>
+*</emphasis>
+ (unless there is an allocation failure, in which case they reset both
+<emphasis>
+sz_</emphasis>
+<emphasis>
+*</emphasis>
+ and <emphasis>
+num_</emphasis>
+<emphasis>
+*</emphasis>
+ to zero). These functions return <emphasis>
+Success</emphasis>
+ if they succeed, <emphasis>
+BadAlloc</emphasis>
+ if they are not able to allocate space, or <emphasis>
+BadValue</emphasis>
+ if a parameter is not as expected.
+</para>
+
+
+<para>
+To allocate space for an arbitrary number of outlines to a shape, use
+XkbAllocGeomOutlines.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomOutlines</emphasis>
+(<emphasis>
+shape</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbShapePtr <emphasis>
+shape</emphasis>
+; /* shape for which outlines should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new outlines required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomOutlines</emphasis>
+ allocates space for <emphasis>
+num_needed</emphasis>
+ outlines in the specified <emphasis>
+shape</emphasis>
+. The outlines are not initialized.
+</para>
+
+
+<para>
+To free geometry outlines, use <emphasis>
+XkbFreeGeomOutlines</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomOutlines</emphasis>
+(<emphasis>
+shape</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbShapePtr <emphasis>
+ shape</emphasis>
+; /* shape in which outlines should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first outline to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of outlines to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all outlines are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all outlines are freed regardless of the value of first or count. Otherwise,
+count outlines are freed beginning with the one specified by first.
+</para>
+
+
+<para>
+To allocate space for an arbitrary number of keys to a row, use
+XkbAllocGeomKeys.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomKeys</emphasis>
+(<emphasis>
+row</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+ row</emphasis>
+; /* row to which keys should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new keys required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomKeys</emphasis>
+ allocates num_needed keys and adds them to the row. No initialization of the
+keys is done.
+</para>
+
+
+<para>
+To free geometry keys, use <emphasis>
+XkbFreeGeomKeys</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomKeys</emphasis>
+(<emphasis>
+row</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+ row</emphasis>
+; /* row in which keys should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first key to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of keys to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all keys are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all keys are freed regardless of the value of first or count. Otherwise,
+count keys are freed beginning with the one specified by first.
+</para>
+
+
+<para>
+To allocate geometry properties, use <emphasis>
+XkbAllocGeomProps</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomProps</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry for which properties should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new properties required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomProps</emphasis>
+ allocates space for num_needed properties and adds them to the specified
+geometry <emphasis>
+geom</emphasis>
+. No initialization of the properties is done. A geometry property associates
+an arbitrary string with an equally arbitrary name. Geometry properties can be
+used to provide hints to programs that display images of keyboards, but they
+are not interpreted by Xkb. No other geometry structures refer to geometry
+properties.
+</para>
+
+
+<para>
+To free geometry properties, use <emphasis>
+XkbFreeGeomProperties</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomProperties</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry in which properties should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first property to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of properties to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all properties are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all properties are freed regardless of the value of first or count.
+Otherwise, count properties are freed beginning with the one specified by first.
+</para>
+
+
+<para>
+To allocate geometry key aliases, use <emphasis>
+XkbAllocGeomKeyAliases</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomKeyAliases</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry for which key aliases should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new key aliases required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomKeyAliases</emphasis>
+ allocates space for num_needed key aliases and adds them to the specified
+geometry <emphasis>
+geom</emphasis>
+. A key alias is a pair of strings that associates an alternate name for a key
+with the real name for that key.
+</para>
+
+
+<para>
+To free geometry key aliases, use <emphasis>
+XkbFreeGeomKeyAliases</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomKeyAliases</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ first</emphasis>
+, <emphasis>
+count</emphasis>
+, <emphasis>
+free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry in which key aliases should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first key alias to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of key aliases to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all key aliases are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all aliases in the top level of the specified geometry <emphasis>
+geom</emphasis>
+ are freed regardless of the value of first or count. Otherwise, count aliases
+in <emphasis>
+geom</emphasis>
+ are freed beginning with the one specified by first.
+</para>
+
+
+<para>
+To allocate geometry colors, use <emphasis>
+XkbAllocGeomColors</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomColors</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry for which colors should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new colors required. */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomColors</emphasis>
+ allocates space for num_needed colors and adds them to the specified geometry
+<emphasis>
+geom</emphasis>
+. A color name is a string whose interpretation is not specified by Xkb. All
+other geometry data structures refer to colors using their indices in this
+global list or pointers to colors in this list.
+</para>
+
+
+<para>
+To free geometry colors, use <emphasis>
+XkbFreeGeomColors</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomColors</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry in which colors should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first color to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of colors to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all colors are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all colors are freed regardless of the value of first or count. Otherwise,
+count colors are freed beginning with the one specified by first.
+</para>
+
+
+<para>
+To allocate points in an outline, use <emphasis>
+XkbAllocGeomPoints</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomPoints</emphasis>
+(<emphasis>
+outline</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbOutlinePtr <emphasis>
+ outline</emphasis>
+; /* outline for which points should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new points required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomPoints</emphasis>
+ allocates space for <emphasis>
+num_needed</emphasis>
+ points in the specified <emphasis>
+outline</emphasis>
+. The points are not initialized.
+</para>
+
+
+<para>
+To free points in a outline, use <emphasis>
+XkbFreeGeomPoints</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomPoints</emphasis>
+(<emphasis>
+outline</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbOutlinePtr <emphasis>
+ outline</emphasis>
+; /* outline in which points should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first point to be freed. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of points to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all points are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all points are freed regardless of the value of first and count. Otherwise,
+the number of points specified by count are freed, beginning with the point
+specified by first in the specified outline.
+</para>
+
+
+<para>
+To allocate space for an arbitrary number of geometry shapes, use <emphasis>
+XkbAllocGeomShapes</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomShapes</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry for which shapes should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new shapes required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomShapes</emphasis>
+ allocates space for <emphasis>
+num_needed</emphasis>
+ shapes in the specified geometry <emphasis>
+geom</emphasis>
+. The shapes are not initialized.
+</para>
+
+
+<para>
+To free geometry shapes, use <emphasis>
+XkbFreeGeomShapes</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomShapes</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ f ree_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry in which shapes should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first shape to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of shapes to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all shapes are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all shapes in the geometry are freed regardless of the values of first and
+count. Otherwise, count shapes are freed, beginning with the shape specified by
+first.
+</para>
+
+
+<para>
+To allocate geometry sections, use <emphasis>
+XkbAllocGeomSections</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomSections</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /*geometry for which sections should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new sections required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomSections</emphasis>
+ allocates num_needed sections and adds them to the geometry geom. No
+initialization of the sections is done.
+</para>
+
+
+<para>
+To free geometry sections, use <emphasis>
+XkbFreeGeomSections</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomSections</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry in which sections should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first section to be freed. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of sections to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all sections are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all sections are freed regardless of the value of first and count. Otherwise,
+the number of sections specified by count are freed, beginning with the section
+specified by first in the specified geometry.
+</para>
+
+
+<para>
+To allocate rows in a section, use <emphasis>
+XkbAllocGeomRows</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomRows</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+section</emphasis>
+; /* section for which rows should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new rows required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomRows</emphasis>
+ allocates num_needed rows and adds them to the section. No initialization of
+the rows is done.
+</para>
+
+
+<para>
+To free rows in a section, use <emphasis>
+XkbFreeGeomRows</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomRows</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section in which rows should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first row to be freed. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of rows to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all rows are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all rows are freed regardless of the value of first and count. Otherwise, the
+number of rows specified by count are freed, beginning with the row specified
+by first in the specified section.
+</para>
+
+
+<para>
+To allocate overlays in a section, use <emphasis>
+XkbAllocGeomOverlays</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomOverlays</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+section</emphasis>
+; /* section for which overlays should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new overlays required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomRows</emphasis>
+ allocates num_needed overlays and adds them to the section. No initialization
+of the overlays is done.
+</para>
+
+
+<para>
+To free rows in an section, use <emphasis>
+XkbFreeGeomOverlays</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomOverlays</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section in which overlays should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first overlay to be freed. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of overlays to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all overlays are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all overlays are freed regardless of the value of first and count. Otherwise,
+the number of overlays specified by count are freed, beginning with the overlay
+specified by first in the specified section.
+</para>
+
+
+<para>
+To allocate rows in a overlay, use <emphasis>
+XkbAllocGeomOverlayRows</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomOverlayRows</emphasis>
+(<emphasis>
+overlay</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+overlay</emphasis>
+; /* section for which rows should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new rows required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomOverlayRows</emphasis>
+ allocates num_needed rows and adds them to the overlay. No initialization of
+the rows is done.
+</para>
+
+
+<para>
+To free rows in an overlay, use <emphasis>
+XkbFreeGeomOverlayRows</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomOverlayRows</emphasis>
+(<emphasis>
+overlay</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ overlay</emphasis>
+; /* section in which rows should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first row to be freed. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of rows to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all rows are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all rows are freed regardless of the value of first and count. Otherwise, the
+number of rows specified by count are freed, beginning with the row specified
+by first in the specified overlay.
+</para>
+
+
+<para>
+To allocate keys in an overlay row, use <emphasis>
+XkbAllocGeomOverlayKeys</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomOverlayKeys</emphasis>
+(<emphasis>
+row</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+row</emphasis>
+; /* section for which rows should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new rows required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomOverlayKeys</emphasis>
+ allocates num_needed keys and adds them to the row. No initialization of the
+keys is done.
+</para>
+
+
+<para>
+To free keys in an overlay row, use <emphasis>
+XkbFreeGeomOverlayKeys</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomOverlayKeys</emphasis>
+(<emphasis>
+row</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRowPtr <emphasis>
+ row</emphasis>
+; /* row in which keys should be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ first</emphasis>
+; /* first key to be freed. */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of keys to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all keys are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, all keys are freed regardless of the value of first and count. Otherwise, the
+number of keys specified by count are freed, beginning with the key specified
+by first in the specified row.
+</para>
+
+
+<para>
+To allocate doodads that are global to a keyboard geometry, use <emphasis>
+XkbAllocGeomDoodads</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomDoodads</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry for which doodads should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new doodads required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomDoodads</emphasis>
+ allocates num_needed doodads and adds them to the specified geometry <emphasis>
+geom</emphasis>
+. No initialization of the doodads is done.
+</para>
+
+
+<para>
+To allocate doodads that are specific to a section, use <emphasis>
+XkbAllocGeomSectionDoodads</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeomSectionDoodads</emphasis>
+(<emphasis>
+section</emphasis>
+,<emphasis>
+ num_needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSectionPtr <emphasis>
+ section</emphasis>
+; /* section for which doodads should be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_needed</emphasis>
+; /* number of new doodads required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeomSectionDoodads</emphasis>
+ allocates num_needed doodads and adds them to the specified <emphasis>
+section</emphasis>
+. No initialization of the doodads is done.
+</para>
+
+
+<para>
+To free geometry doodads, use <emphasis>
+XkbFreeGeomDoodads</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeomDoodads</emphasis>
+(<emphasis>
+doodads</emphasis>
+,<emphasis>
+ count</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDoodadPtr <emphasis>
+ doodads</emphasis>
+; /* doodads to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ count</emphasis>
+; /* number of doodads to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; all doodads are freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If <emphasis>
+free_all</emphasis>
+ is <emphasis>
+True</emphasis>
+, all doodads in the array are freed, regardless of the value of count.
+Otherwise, count doodads are freed.
+</para>
+
+
+<para>
+To allocate an entire geometry, use <emphasis>
+XkbAllocGeometry</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocGeometry</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ sizes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description for which geometry is to be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometrySizesPtr<emphasis>
+ sizes</emphasis>
+; /* initial sizes for all geometry components */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocGeometry</emphasis>
+ allocates a keyboard geometry and adds it to the keyboard description
+specified by xkb. The keyboard description should be obtained via the
+XkbGetKeyboard or XkbAllockeyboard functions. The sizes parameter specifies the
+number of elements to be reserved for the subcomponents of the keyboard
+geometry and can be zero or more. These subcomponents include the properties,
+colors, shapes, sections, and doodads.
+</para>
+
+
+<para>
+To free an entire geometry, use <emphasis>
+XkbFreeGeometry</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeGeometry</emphasis>
+(<emphasis>
+geom</emphasis>
+,<emphasis>
+ which</emphasis>
+,<emphasis>
+ free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbGeometryPtr <emphasis>
+ geom</emphasis>
+; /* geometry to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ which</emphasis>
+; /* mask of geometry components to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all;</emphasis>
+ /* <emphasis>
+True</emphasis>
+ =&gt; the entire geometry is freed. */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The values of which and free_all determine how much of the specified geometry
+is freed. The valid values for which are:
+</para>
+
+<para><programlisting>
+#define XkbGeomPropertiesMask (1&lt;&lt;0)
+#define XkbGeomColorsMask (1&lt;&lt;1)
+#define XkbGeomShapesMask (1&lt;&lt;2)
+#define XkbGeomSectionsMask (1&lt;&lt;3)
+#define XkbGeomDoodadsMask (1&lt;&lt;4)
+#define XkbGeomAllMask (0x1f)
+</programlisting></para>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, the entire geometry is freed regardless of the value of which. Otherwise, the
+portions of the geometry specified by which are freed.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch14.xml b/specs/XKB/ch14.xml
new file mode 100644
index 00000000..cc3ee002
--- /dev/null
+++ b/specs/XKB/ch14.xml
@@ -0,0 +1,1637 @@
+<chapter id='xkb_keyboard_mapping'>
+<title>Xkb Keyboard Mapping</title>
+
+<para>
+The Xkb keyboard mapping contains all the information the server and clients
+need to interpret key events. This chapter provides an overview of the
+terminology used to describe an Xkb keyboard mapping and introduces common
+utilities for manipulating the keyboard mapping.
+</para>
+
+
+<para>
+The mapping consists of two components, a server map and a client map. The
+<emphasis>
+client</emphasis>
+ map is the collection of information a client needs to interpret key events
+from the keyboard. It contains a global list of key types and an array of key
+symbol maps, each of which describes the symbols bound to a key and the rules
+to be used to interpret those symbols. The <emphasis>
+server</emphasis>
+ map contains the information the server needs to interpret key events. This
+includes actions and behaviors for each key, explicit components for a key, and
+the virtual modifiers and the per-key virtual modifier mapping.
+</para>
+
+
+<para>
+For detailed information on particular components of the keyboard map, refer to
+Chapter 15, "Xkb Client Keyboard Mapping" and Chapter 16, "Xkb Server Keyboard
+Mapping."
+</para>
+
+<sect1 id='notation_and_terminology'>
+<title>Notation and Terminology</title>
+
+<para>
+The graphic characters or control functions that may be accessed by one key are
+logically arranged in groups and levels, where <emphasis>
+group</emphasis>
+ and <emphasis>
+level</emphasis>
+ are defined as in the ISO9995 standard:
+</para>
+
+<variablelist>
+ <varlistentry>
+ <term>Group:</term>
+ <listitem>
+ <para>
+A logical state of a keyboard providing access to a collection of
+graphic characters. Usually these graphic characters logically belong together
+and may be arranged on several levels within a group.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Level:</term>
+ <listitem>
+ <para>
+One of several states (normally 2 or 3) governing which graphic
+character is produced when a graphic key is actuated. In certain cases the
+level may also affect function keys.
+ </para>
+ </listitem>
+ </varlistentry>
+</variablelist>
+
+<para>
+These definitions, taken from the ISO standard, refer to graphic keys and
+characters. In the context of Xkb, Group and Level are not constrained to
+graphic keys and characters; they may be used with any key to access any
+character the key is capable of generating.
+</para>
+
+
+<para>
+Level is often referred to as "Shift Level". Levels are numbered sequentially
+starting at one.
+</para>
+
+<note><para>Shift level is derived from the modifier state, but not necessarily
+in the same way for all keys. For example, the <emphasis>
+Shift</emphasis>
+ modifier selects shift level 2 on most keys, but for keypad keys the modifier
+bound to <emphasis>
+Num_Lock</emphasis>
+ (that is, the <emphasis>
+NumLock</emphasis>
+ virtual modifier) also selects shift level 2.</para></note>
+
+<para>
+For example, consider the following key (the gray characters indicate symbols
+that are implied or expected but are not actually engraved on the key):
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-14.gif"/>
+ </imageobject>
+<caption>Shift Levels and Groups</caption>
+ </mediaobject>
+
+
+<!--
+<H5 CLASS="Figure">
+Shift Levels and Groups</H5>
+-->
+
+<para>
+This key has two groups, indicated by the columns, and each group has two shift
+levels. For the first group (Group1), the symbol shift level one is <emphasis>
+a</emphasis>
+, and the symbol for shift level two is <emphasis>
+A</emphasis>
+. For the second group, the symbol for shift level one is <emphasis>
+æ</emphasis>
+, and the symbol for shift level two is <emphasis>
+Æ</emphasis>
+.
+</para>
+
+<sect2 id='core_implementation'>
+<title>Core Implementation</title>
+
+<para>
+The standard interpretation rules for the core X keymap only allow clients to
+access keys such as the one shown in Figure 14.1. That is, clients using the
+standard interpretation rules can only access one of four keysyms for any given
+<emphasis>
+KeyPress</emphasis>
+ event — two different symbols in two different groups.
+</para>
+
+
+<para>
+In general, the <emphasis>
+Shift</emphasis>
+ modifier, the <emphasis>
+Lock</emphasis>
+ modifier, and the modifier bound to the <emphasis>
+Num_Lock</emphasis>
+ key are used to change between shift level 1 and shift level 2. To switch
+between groups, the core implementation uses the modifier bound to the
+<emphasis>
+Mode_switch</emphasis>
+ key. When the <emphasis>
+Mode_switch</emphasis>
+ modifier is set, the keyboard is logically in Group 2. When the <emphasis>
+Mode_switch</emphasis>
+ modifier is not set, the keyboard is logically in Group 1.
+</para>
+
+
+<para>
+The core implementation does not clearly specify the behavior of keys. For
+example, the locking behavior of the <emphasis>
+CapsLock</emphasis>
+ and <emphasis>
+Num_Lock</emphasis>
+ keys depends on the vendor.
+</para>
+
+
+</sect2>
+<sect2 id='xkb_implementation'>
+<title>Xkb Implementation</title>
+
+<para>
+Xkb extends the core implementation by providing access to up to four keyboard
+groups with up to 63 shift levels per key
+<footnote><para>
+The core implementation restricts the number of symbols per key to 255.
+With four groups, this allows for up to 63 symbols (or shift levels) per
+group. Most keys will only have a few shift levels.
+</para></footnote>. In
+addition, Xkb provides precise specifications regarding the behavior of keys.
+In Xkb, modifier state and the current group are independent (with the
+exception of compatibility mapping, discussed in Chapter 17).
+</para>
+
+
+<para>
+Xkb handles switching between groups via key actions, independent of any
+modifier state information. Key actions are in the server map component and are
+described in detail in section 16.1.4.
+</para>
+
+
+<para>
+Xkb handles shift levels by associating a key type with each group on each key.
+Each key type defines the shift levels available for the groups on keys of its
+type and specifies the modifier combinations necessary to access each level.
+</para>
+
+
+<para>
+For example, Xkb allows key types where the <emphasis>
+Control</emphasis>
+ modifier can be used to access the shift level two of a key. Key types are in
+the client map component and are described in detail in section 15.2. <!-- xref -->
+</para>
+
+
+<para>
+Xkb provides precise specification of the behavior of a key using key
+behaviors. Key behaviors are in the server map component and are described in
+detail in section 16.2. <!-- xref -->
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='getting_map_components_from_the_server'>
+<title>Getting Map Components from the Server</title>
+
+<para>
+Xkb provides two functions to obtain the keyboard mapping components from the
+server. The first function, <emphasis>
+XkbGetMap</emphasis>
+, allocates an <emphasis>
+XkbDescRec</emphasis>
+ structure, retrieves mapping components from the server, and stores them in
+the <emphasis>
+XkbDescRec</emphasis>
+ structure it just allocated. The second function, <emphasis>
+XkbGetUpdatedMap</emphasis>
+, retrieves mapping components from the server and stores them in an <emphasis>
+XkbDescRec</emphasis>
+ structure that has previously been allocated.
+</para>
+
+
+<para>
+To allocate an <emphasis>
+XkbDescRec</emphasis>
+ structure and populate it with the server’s keyboard client map and server
+map, use <emphasis>
+XkbGetMap. XkbGetMap </emphasis>
+is similar to <emphasis>
+XkbGetKeyboard</emphasis>
+ (see section 6.2), but is used only for obtaining the address of an <emphasis>
+XkbDescRec</emphasis>
+ structure that is populated with keyboard mapping components. It allows finer
+control over which substructures of the keyboard mapping components are to be
+populated. <emphasis>
+XkbGetKeyboard</emphasis>
+ always returns fully populated components, while <emphasis>
+XkbGetMap</emphasis>
+ can be instructed to return a partially populated component.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDescPtr <emphasis>
+XkbGetMap</emphasis>
+(<emphasis>
+display, which, device_spec</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ which</emphasis>
+; /* mask selecting subcomponents to populate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ device_spec</emphasis>
+; /* device_id, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+which</emphasis>
+ mask is a bitwise inclusive OR of the masks defined in Table 14.1. Only those
+portions of the keyboard server map and the keyboard client maps that are
+specified in <emphasis>
+which</emphasis>
+ are allocated and populated.
+</para>
+
+
+<para>
+In addition to allocating and obtaining the server map and the client map,
+<emphasis>
+XkbGetMap</emphasis>
+ also sets the <emphasis>
+device_spec</emphasis>
+, the <emphasis>
+min_key_code</emphasis>
+<emphasis>
+, </emphasis>
+and <emphasis>
+max_key_code</emphasis>
+ fields of the keyboard description.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetMap</emphasis>
+ is synchronous; it queries the server for the desired information, waits for a
+reply, and then returns. If successful<emphasis>
+, XkbGetMap</emphasis>
+ returns a pointer to the <emphasis>
+XkbDescRec</emphasis>
+ structure it allocated. If unsuccessful, <emphasis>
+XkbGetMap</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+. When unsuccessful, one of the following protocol errors is also generated:
+<emphasis>
+BadAlloc</emphasis>
+ (unable to allocate the <emphasis>
+XkbDescRec</emphasis>
+ structure), <emphasis>
+BadValue</emphasis>
+ (some mask bits in <emphasis>
+which</emphasis>
+ are undefined)<emphasis>
+,</emphasis>
+ or <emphasis>
+BadImplementation</emphasis>
+ (a compatible version of the Xkb extension is not available in the server). To
+free the returned data, use <emphasis>
+XkbFreeClientMap</emphasis>
+.
+</para>
+
+
+<para>
+Xkb also provides convenience functions to get partial component definitions
+from the server. These functions are specified in the "convenience functions"
+column in Table 14.1. Refer to the sections listed in the table for more
+information on these functions.
+</para>
+
+<table frame='none'>
+<title>Xkb Mapping Component Masks and Convenience Functions</title>
+<tgroup cols='6'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Value</entry>
+ <entry>Map</entry>
+ <entry>Fields</entry>
+ <entry>Convenience Functions</entry>
+ <entry>Section</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeyTypesMask</emphasis></entry>
+ <entry>(1&lt;&lt;0)</entry>
+ <entry>client</entry>
+ <entry>
+ <para><emphasis>types</emphasis></para>
+ <para><emphasis>size_types</emphasis></para>
+ <para><emphasis>num_types</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis>XkbGetKeyTypes</emphasis></para>
+ <para><emphasis>XkbResizeKeyType</emphasis></para>
+ <para><emphasis>XkbCopyKeyType</emphasis></para>
+ <para><emphasis>XkbCopyKeyTypes</emphasis></para>
+ </entry>
+ <entry>15.2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeySymsMask</emphasis></entry>
+ <entry>(1&lt;&lt;1)</entry>
+ <entry>client</entry>
+ <entry>
+ <para><emphasis>syms</emphasis></para>
+ <para><emphasis>size_syms</emphasis></para>
+ <para><emphasis>num_syms</emphasis></para>
+ <para><emphasis>key_sym_map</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis>XkbGetKeySyms</emphasis></para>
+ <para><emphasis>XkbResizeKeySyms</emphasis></para>
+ <para><emphasis>XkbChangeTypesOfKey</emphasis></para>
+ </entry>
+ <entry>15.3</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbModifierMapMask</emphasis></entry>
+ <entry>(1&lt;&lt;2)</entry>
+ <entry>client</entry>
+ <entry><emphasis>modmap</emphasis></entry>
+ <entry><emphasis>XkbGetKeyModifierMap</emphasis></entry>
+ <entry>15.4</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbExplicitComponentsMask</emphasis></entry>
+ <entry>(1&lt;&lt;3)</entry>
+ <entry>server</entry>
+ <entry><emphasis>explicit</emphasis></entry>
+ <entry><emphasis>XkbGetKeyExplicitComponents</emphasis></entry>
+ <entry>16.3</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeyActionsMask</emphasis></entry>
+ <entry>(1&lt;&lt;4)</entry>
+ <entry>server</entry>
+ <entry>
+ <para><emphasis>key_acts</emphasis></para>
+ <para><emphasis>acts</emphasis></para>
+ <para><emphasis>num_acts</emphasis></para>
+ <para><emphasis>size_acts</emphasis></para>
+ </entry>
+ <entry>
+ <para><emphasis>XkbGetKeyActions</emphasis></para>
+ <para><emphasis>XkbResizeKeyActions</emphasis></para>
+ </entry>
+ <entry>16.1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeyBehaviorsMask</emphasis></entry>
+ <entry>(1&lt;&lt;5)</entry>
+ <entry>server</entry>
+ <entry><emphasis>behaviors</emphasis></entry>
+ <entry><emphasis>XkbGetKeyBehaviors</emphasis></entry>
+ <entry>16.2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbVirtualModsMask</emphasis></entry>
+ <entry>(1&lt;&lt;6)</entry>
+ <entry>server</entry>
+ <entry><emphasis>vmods</emphasis></entry>
+ <entry><emphasis>XkbGetVirtualMods</emphasis></entry>
+ <entry>16.4</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbVirtualModMapMask</emphasis></entry>
+ <entry>(1&lt;&lt;7)</entry>
+ <entry>server</entry>
+ <entry><emphasis>vmodmap</emphasis></entry>
+ <entry><emphasis>XkbGetVirtualModMap</emphasis></entry>
+ <entry>16.4</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Xkb defines combinations of these masks for convenience:
+</para>
+
+<para><programlisting>
+#define XkbResizableInfoMask (XkbKeyTypesMask)
+#define XkbAllClientInfoMask (XkbKeyTypesMask | XkbKeySymsMask |
+ XkbModifierMapMask)
+#define XkbAllServerInfoMask (XkbExplicitComponentsMask |
+ XkbKeyActionsMask| XkbKeyBehaviorsMask |
+ XkbVirtualModsMask | XkbVirtualModMapMask)
+#define XkbAllMapComponentsMask (XkbAllClientInfoMask|XkbAllServerInfoMask)
+</programlisting></para>
+
+<para>
+Key types, symbol maps, and actions are all interrelated: changes in one
+require changes in the others. The convenience functions make it easier to edit
+these components and handle the interdependencies.
+</para>
+
+
+<para>
+To update the client or server map information in an existing keyboard
+description, use <emphasis>XkbGetUpdatedMap</emphasis>.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetUpdatedMap</emphasis>
+(<emphasis>
+display, which, xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask selecting subcomponents to populate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description to be updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+which</emphasis>
+ parameter is a bitwise inclusive OR of the masks in Table 14.1. If the needed
+components of the <emphasis>
+xkb</emphasis>
+ structure are not already allocated, <emphasis>
+XkbGetUpdatedMap</emphasis>
+ allocates them. <emphasis>
+XkbGetUpdatedMap</emphasis>
+ fetches the requested information for the device specified in the <emphasis>
+XkbDescRec</emphasis>
+ passed in the <emphasis>
+xkb</emphasis>
+ parameter.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetUpdatedMap</emphasis>
+ is synchronous; it queries the server for the desired information, waits for a
+reply, and then returns. If successful<emphasis>
+, XkbGetUpdatedMap</emphasis>
+ returns <emphasis>
+Success</emphasis>
+. If unsuccessful, <emphasis>
+XkbGetUpdatedMap</emphasis>
+ returns one of the following: <emphasis>
+BadAlloc</emphasis>
+ (unable to allocate a component in the <emphasis>
+XkbDescRec</emphasis>
+ structure), <emphasis>
+BadValue</emphasis>
+ (some mask bits in <emphasis>
+which</emphasis>
+ are undefined), <emphasis>
+BadImplementation</emphasis>
+ (a compatible version of the Xkb extension is not available in the server or
+the reply from the server was invalid).
+</para>
+
+</sect1>
+<sect1 id='changing_map_components_in_the_server'>
+<title>Changing Map Components in the Server</title>
+
+<para>
+There are two ways to make changes to map components: either change a local
+copy of the keyboard map and call <emphasis>
+XkbSetMap</emphasis>
+ to send the modified map to the server, or, to reduce network traffic, use
+an<emphasis>
+ XkbMapChangesRec</emphasis>
+ structure and call <emphasis>XkbChangeMap</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetMap</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ which</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask selecting subcomponents to update */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* description from which new values are taken */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+Use <emphasis>
+XkbSetMap</emphasis>
+ to send a complete new set of values for entire components (for example, all
+symbols, all actions, and so on) to the server. The <emphasis>
+which</emphasis>
+ parameter specifies the components to be sent to the server, and is a bitwise
+inclusive OR of the masks listed in Table 14.1. The <emphasis>
+xkb</emphasis>
+ parameter is a pointer to an <emphasis>
+XkbDescRec</emphasis>
+ structure and contains the information to be copied to the server. For each
+bit set in the <emphasis>
+which</emphasis>
+ parameter, <emphasis>
+XkbSetMap</emphasis>
+ takes the corresponding structure values from the <emphasis>
+xkb</emphasis>
+ parameter and sends it to the server specified by <emphasis>
+dpy</emphasis>.
+</para>
+
+<para>
+If any components specified by <emphasis>
+which</emphasis>
+ are not present in the <emphasis>
+xkb</emphasis>
+ parameter, <emphasis>
+XkbSetMap</emphasis>
+ returns <emphasis>
+False</emphasis>
+. Otherwise, it sends the update request to the server and returns <emphasis>
+True</emphasis>
+. <emphasis>
+XkbSetMap</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadLength</emphasis>
+, and <emphasis>
+BadValue</emphasis>
+ protocol errors.
+</para>
+
+
+<para>
+Key types, symbol maps, and actions are all interrelated; changes in one
+require changes in the others. Xkb provides functions to make it easier to edit
+these components and handle the interdependencies. Table 14.1 lists these
+helper functions and provides a pointer to where they are defined.
+</para>
+
+
+<sect2 id='the_xkbmapchangesrec_structure'>
+<title>The XkbMapChangesRec Structure</title>
+
+<para>
+Use the <emphasis>
+XkbMapChangesRec</emphasis>
+ structure to identify and track partial modifications to the mapping
+components and to reduce the amount of traffic between the server and clients.
+</para>
+
+<para><programlisting>
+typedef struct _XkbMapChanges {
+ unsigned short changed; /* identifies valid components
+ in structure */
+ KeyCode min_key_code; /* lowest numbered keycode for
+ device */
+ KeyCode max_key_code; /* highest numbered keycode for
+ device */
+ unsigned char first_type; /* index of first key <emphasis>type</emphasis>
+ modified */
+ unsigned char num_types; /* # types modified */
+ KeyCode first_key_sym; /* first key whose <emphasis>key_sym_map</emphasis>
+ changed */
+ unsigned char num_key_syms; /* # <emphasis>key_sym_map</emphasis>
+ entries changed */
+ KeyCode first_key_act; /* first key whose <emphasis>key_acts</emphasis>
+ entry changed */
+ unsigned char num_key_acts; /* # <emphasis>key_acts</emphasis>
+ entries changed */
+ KeyCode first_key_behavior; /* first key whose <emphasis>behaviors</emphasis>
+ changed */
+ unsigned char num_key_behaviors; /* # <emphasis>behaviors</emphasis>
+ entries changed */
+ KeyCode first_key_explicit; /* first key whose <emphasis>explicit</emphasis>
+ entry changed */
+ unsigned char num_key_explicit; /* # <emphasis> explicit</emphasis>
+ entries changed */
+ KeyCode first_modmap_key; /* first key whose <emphasis>modmap</emphasis>
+ entry changed */
+ unsigned char num_modmap_keys; /* # <emphasis>modmap</emphasis>
+ entries changed */
+ KeyCode first_vmodmap_key; /* first key whose <emphasis>vmodmap</emphasis>
+ changed */
+ unsigned char num_vmodmap_keys; /* # <emphasis> vmodmap</emphasis>
+ entries changed */
+ unsigned char pad1; /* reserved */
+ unsigned short vmods; /* mask indicating which <emphasis>vmods</emphasis>
+ changed */
+} <emphasis>XkbMapChangesRec</emphasis>,*XkbMapChangesPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+changed</emphasis>
+ field identifies the map components that have changed in an <emphasis>
+XkbDescRec</emphasis>
+ structure and may contain any of the bits in Table 14.1, which are also shown
+in Table 14.2. Every 1 bit in <emphasis>
+changed</emphasis>
+ also identifies which other fields in the <emphasis>
+XkbMapChangesRec</emphasis>
+ structure contain valid values, as indicated in Table 14.2. The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields are for reference only; they are ignored on any requests sent to the
+server and are always updated by the server whenever it returns the data for an
+<emphasis>
+XkbMapChangesRec</emphasis>
+.
+</para>
+
+<table frame='none'>
+<title>XkbMapChangesRec Masks</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Valid XkbMapChangesRec Fields</entry>
+ <entry>XkbDescRec Field Containing Changed Data</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeyTypesMask</emphasis></entry>
+ <entry>
+<para>first_type</para>,
+<para>num_types</para>
+ </entry>
+ <entry>
+<para>map-&gt;type[first_type] ..</para>
+<para>map-&gt;type[first_type + num_types - 1]</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeySymsMask</emphasis></entry>
+ <entry>
+<para>first_key_sym</para>,
+<para>num_key_syms</para>
+ </entry>
+ <entry>
+<para>map-&gt;key_sym_map[first_key_sym] ..</para>
+<para>map-&gt;key_sym_map[first_key_sym + num_key_syms - 1]</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbModifierMapMask</emphasis></entry>
+ <entry>
+<para>first_modmap_key</para>,
+<para>num_modmap_keys</para>
+ </entry>
+ <entry>
+<para>map-&gt;modmap[first_modmap_key] ..</para>
+<para>map-&gt;modmap[first_modmap_key + num_modmap_keys-1]</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbExplicitComponentsMask</emphasis></entry>
+ <entry>
+<para>first_key_explicit</para>,
+<para>num_key_explicit</para>
+ </entry>
+ <entry>
+<para>server-&gt;explicit[first_key_explicit] ..</para>
+<para>server-&gt;explicit[first_key_explicit + num_key_explicit - 1]</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeyActionsMask</emphasis></entry>
+ <entry>
+<para>first_key_act,</para>
+<para>num_key_acts</para>
+ </entry>
+ <entry>
+<para>server-&gt;key_acts[first_key_act] ..</para>
+<para>server-&gt;key_acts[first_key_act + num_key_acts - 1]</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKeyBehaviorsMask</emphasis></entry>
+ <entry>
+<para>first_key_behavior,</para>
+<para>num_key_behaviors</para>
+ </entry>
+ <entry>
+<para>server-&gt;behaviors[first_key_behavior] ..</para>
+<para>server-&gt;behaviors[first_key_behavior + num_key_behaviors - 1]</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbVirtuawModsMask</emphasis></entry>
+ <entry>vmods</entry>
+ <entry>server-&gt;vmods[*]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbVirtualModMapMask</emphasis></entry>
+ <entry>
+<para>first_vmodmap_key,</para>
+<para>num_vmodmap_keys</para>
+ </entry>
+ <entry>
+<para>server-&gt;vmodmap[first_vmodmap_key] ..</para>
+<para>server-&gt;vmodmap[first_vmodmap_key + num_vmodmap_keys - 1]</para>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+To update only partial components of a keyboard description, modify the
+appropriate fields in the server and map components of a local copy of the
+keyboard description, then call <emphasis>
+XkbChangeMap</emphasis>
+ with an <emphasis>
+XkbMapChangesRec</emphasis>
+ structure indicating which components have changed.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbChangeMap</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ xkb</emphasis>
+,<emphasis>
+ changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* description from which new values are taken */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbMapChangesPtr <emphasis>
+ changes</emphasis>
+; /*identifies component parts to update */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbChangeMap</emphasis>
+ copies any components specified by the <emphasis>
+changes</emphasis>
+ structure from the keyboard description, <emphasis>
+xkb</emphasis>
+, to the X server specified by <emphasis>
+dpy</emphasis>
+.
+</para>
+
+
+<para>
+If any components specified by <emphasis>
+changes</emphasis>
+ are not present in the <emphasis>
+xkb</emphasis>
+ parameter, <emphasis>
+XkbChangeMap</emphasis>
+ returns <emphasis>
+False</emphasis>
+. Otherwise, it sends a request to the server and returns <emphasis>
+True</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbChangeMap</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadLength</emphasis>
+, and <emphasis>
+BadValue</emphasis>
+ protocol errors.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='tracking_changes_to_map_components'>
+<title>Tracking Changes to Map Components</title>
+
+<para>
+The Xkb extension reports <emphasis>
+XkbMapNotify</emphasis>
+ events to clients wanting notification whenever a map component of the Xkb
+description for a device changes. There are many different types of Xkb
+keyboard map changes. Xkb uses an event detail mask to identify each type of
+change. The event detail masks are identical to the masks listed in Table 14.1.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbMapNotify</emphasis>
+ events under all possible conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) and pass <emphasis>
+XkbMapNotifyMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbMapNotify</emphasis>
+ events only under certain conditions, use <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbMapNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying the desired map changes in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ using mask bits from Table 14.1.
+</para>
+
+
+<para>
+The structure for <emphasis>
+XkbMapNotify</emphasis>
+ events is:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis>True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis> XkbMapNotify</emphasis> */
+ int device; /* Xkb device ID, will not be <emphasis>XkbUseCoreKbd</emphasis> */
+ unsigned int changed; /* identifies valid fields in rest of event */
+ unsigned int resized; /* reserved */
+ int first_type; /* index of first key <emphasis> type</emphasis> modified */
+ int num_types /* # types modified */
+ KeyCode min_key_code; /* minimum keycode for device */
+ KeyCode max_key_code; /* maximum keycode for device */
+ KeyCode first_key_sym; /* first key whose <emphasis>key_sym_map</emphasis> changed */
+ KeyCode first_key_act; /* first key whose <emphasis> key_acts</emphasis> entry changed */
+ KeyCode first_key_behavior; /* first key whose <emphasis> behaviors</emphasis> changed */
+ KeyCode first_key_explicit; /* first key whose <emphasis> explicit </emphasis> entry changed */
+ KeyCode first_modmap_key; /* first key whose <emphasis> modmap</emphasis> entry changed */
+ KeyCode first_vmodmap_key; /* # <emphasis> modmap</emphasis> entries changed */
+ int num_key_syms; /* # <emphasis>key_sym_map</emphasis> entries changed */
+ int num_key_acts; /* # <emphasis> key_acts</emphasis> entries changed */
+ int num_key_behaviors; /* # <emphasis> behaviors</emphasis> entries changed */
+ int num_key_explicit; /* # <emphasis> explicit</emphasis> entries changed */
+ int num_modmap_keys; /* # <emphasis> modmap</emphasis> entries changed */
+ int num_vmodmap_keys; /* # <emphasis> vmodmap</emphasis> entries changed */
+ unsigned in t vmods; /* mask indicating which <emphasis> vmods</emphasis> changed */
+} <emphasis>XkbMapNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+changed</emphasis>
+ field specifies the map components that have changed and is the bitwise
+inclusive OR of the mask bits defined in Table 14.1. The other fields in this
+event are interpreted as the like-named fields in an <emphasis>
+XkbMapChangesRec</emphasis>
+ (see section 14.3.1). The <emphasis>
+XkbMapNotifyEvent</emphasis>
+ structure also has an additional <emphasis>
+resized</emphasis>
+ field that is reserved for future use.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_client_and_server_maps'>
+<title>Allocating and Freeing Client and Server Maps</title>
+
+<para>
+Calling <emphasis>
+XkbGetMap</emphasis>
+ (see section 14.2) should be sufficient for most applications to get client
+and server maps. As a result, most applications do not need to directly
+allocate client and server maps.
+</para>
+
+
+<para>
+If you change the number of key types or construct map components without
+loading the necessary components from the X server, do not allocate any map
+components directly using <emphasis>
+malloc</emphasis>
+ or <emphasis>
+Xmalloc</emphasis>
+. Instead, use the Xkb allocators, <emphasis>
+XkbAllocClientMap,</emphasis>
+ and <emphasis>
+XkbAllocServerMap</emphasis>
+.
+</para>
+
+
+<para>
+Similarly, use the Xkb destructors, <emphasis>
+XkbFreeClientMap,</emphasis>
+ and <emphasis>
+XkbFreeServerMap</emphasis>
+ instead of <emphasis>
+free</emphasis>
+ or <emphasis>
+Xfree</emphasis>
+.
+</para>
+
+
+<sect2 id='allocating_an_empty_client_map'>
+<title>Allocating an Empty Client Map</title>
+
+<para>
+To allocate and initialize an empty client map description record, use
+<emphasis>
+XkbAllocClientMap.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocClientMap</emphasis>
+(<emphasis>
+xkb, which, type_count</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description in which to allocate client map */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask selecting map components to allocate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ type_count</emphasis>
+; /* value of <emphasis>
+num_types</emphasis>
+ field in map to be allocated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocClientMap</emphasis>
+ allocates and initializes an empty client map in the <emphasis>
+map</emphasis>
+ field of the keyboard description specified by <emphasis>
+xkb</emphasis>
+. The <emphasis>
+which</emphasis>
+ parameter specifies the particular components of the client map structure to
+allocate and is a mask composed by a bitwise inclusive OR of one or more of the
+masks shown in Table 14.3.
+</para>
+
+<table frame='none'>
+<title>XkbAllocClientMap Masks</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Effect</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbKeyTypesMask</entry>
+ <entry>
+The <emphasis>
+type_count </emphasis>
+field specifies the number of entries to preallocate for the <emphasis>
+types</emphasis>
+ field of the client map. If the <emphasis>
+type_count </emphasis>
+field is less than <emphasis>
+XkbNumRequiredTypes</emphasis>
+ (see section 15.2.1), returns <emphasis>
+BadValue</emphasis>.
+</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbKeySymsMask</entry>
+<entry>
+The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter are used to allocate the <emphasis>
+syms</emphasis>
+ and <emphasis>
+key_sym_map</emphasis>
+ fields of the client map. The fields are allocated to contain the maximum
+number of entries necessary for <emphasis>
+max_key_code</emphasis>
+ - <emphasis>
+min_key_code</emphasis>
+ + 1 keys.
+</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbModifierMapMask</entry>
+<entry>
+The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter are used to allocate the <emphasis>
+modmap</emphasis>
+ field of the client map. The field is allocated to contain the maximum number
+of entries necessary for <emphasis>
+max_key_code</emphasis>
+ - <emphasis>
+min_key_code</emphasis>
+ + 1 keys.
+</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<note><para>The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter must be legal values if the <emphasis>
+XkbKeySymsMask</emphasis>
+ or <emphasis>
+XkbModifierMapMask</emphasis>
+ masks are set in the <emphasis>
+which</emphasis>
+ parameter. If they are not valid, <emphasis>
+XkbAllocClientMap</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. </para></note>
+
+<para>
+If the client map of the keyboard description is not <emphasis>
+NULL</emphasis>
+, and any fields are already allocated in the client map, <emphasis>
+XkbAllocClientMap</emphasis>
+ does not overwrite the existing values; it simply ignores that part of the
+request. The only exception is the <emphasis>
+types</emphasis>
+ array. If <emphasis>
+type_count</emphasis>
+ is greater than the current <emphasis>
+num_types</emphasis>
+ field of the client map, <emphasis>
+XkbAllocClientMap</emphasis>
+ resizes the <emphasis>
+types</emphasis>
+ array and resets the <emphasis>
+num_types</emphasis>
+ field accordingly.
+</para>
+
+
+<para>
+If <emphasis>
+XkbAllocClientMap</emphasis>
+ is successful, it returns <emphasis>
+Success</emphasis>
+. Otherwise, it can return either <emphasis>
+BadMatch</emphasis>
+, <emphasis>
+BadAlloc</emphasis>
+, or <emphasis>
+BadValue</emphasis>
+ errors.
+</para>
+
+
+</sect2>
+<sect2 id='freeing_a_client_map'>
+<title>Freeing a Client Map</title>
+
+<para>
+To free memory used by the client map member of an <emphasis>
+XkbDescRec</emphasis>
+ structure, use <emphasis>
+XkbFreeClientMap.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeClientMap</emphasis>
+(<emphasis>
+xkb, which, free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description containing client map to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask identifying components of map to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; free all client components and map itself */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbFreeClientMap</emphasis>
+ frees the components of client map specified by <emphasis>
+which</emphasis>
+ in the <emphasis>
+XkbDescRec</emphasis>
+ structure specified by the <emphasis>
+xkb</emphasis>
+ parameter and sets the corresponding structure component values to <emphasis>
+NULL</emphasis>
+. The <emphasis>
+which</emphasis>
+ parameter specifies a combination of the client map masks shown in Table 14.3.
+</para>
+
+
+<para>
+If <emphasis>
+free_all</emphasis>
+ is <emphasis>
+True</emphasis>
+, <emphasis>
+which</emphasis>
+ is ignored; <emphasis>
+XkbFreeClientMap</emphasis>
+ frees every non-<emphasis>
+NULL</emphasis>
+ structure component in the client map, frees the <emphasis>
+XkbClientMapRec</emphasis>
+ structure referenced by the <emphasis>
+map</emphasis>
+ member of the <emphasis>
+xkb</emphasis>
+ parameter, and sets the <emphasis>
+map</emphasis>
+ member to <emphasis>
+NULL.</emphasis>
+</para>
+
+
+</sect2>
+<sect2 id='allocating_an_empty_server_map'>
+<title>Allocating an Empty Server Map</title>
+
+<para>
+To allocate and initialize an empty server map description record, use
+<emphasis>
+XkbAllocServerMap.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocServerMap</emphasis>
+(<emphasis>
+xkb, which, count_acts</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description in which to allocate server map */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask selecting map components to allocate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ count_acts</emphasis>
+; /* value of <emphasis>
+num_acts</emphasis>
+ field in map to be allocated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocServerMap</emphasis>
+ allocates and initializes an empty server map in the <emphasis>
+server</emphasis>
+ field of the keyboard description specified by <emphasis>
+xkb</emphasis>
+. The <emphasis>
+which</emphasis>
+ parameter specifies the particular components of the server map structure to
+allocate, as specified in Table 14.4.
+</para>
+
+<table frame='none'>
+<title>XkbAllocServerMap Masks</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Effect</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbExplicitComponentsMask</entry>
+ <entry>
+The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter are used to allocate the <emphasis>
+explicit </emphasis>
+field of the server map.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbKeyActionsMask</entry>
+ <entry>
+The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter are used to allocate the <emphasis>
+key_acts </emphasis>
+field of the server map. The <emphasis>
+count_acts</emphasis>
+ parameter is used to allocate the <emphasis>
+acts</emphasis>
+ field of the server map.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbKeyBehaviorsMask</entry>
+ <entry>
+The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter are used to allocate the <emphasis>
+behaviors </emphasis>
+field of the server map.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbVirtualModMapMask</entry>
+ <entry>
+The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb </emphasis>
+parameter are used to allocate the <emphasis>
+vmodmap </emphasis>
+field of the server map.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<note><para>The <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ fields of the <emphasis>
+xkb</emphasis>
+ parameter must be legal values. If they are not valid, <emphasis>
+XkbAllocServerMap</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. </para></note>
+
+<para>
+If the server map of the keyboard description is not <emphasis>
+NULL</emphasis>
+ and any fields are already allocated in the server map, <emphasis>
+XkbAllocServerMap</emphasis>
+ does not overwrite the existing values. The only exception is with the
+<emphasis>
+acts </emphasis>
+array. If the <emphasis>
+count_acts </emphasis>
+parameter is greater than the current <emphasis>
+num_acts </emphasis>
+field of the server map, <emphasis>
+XkbAllocServerMap</emphasis>
+ resizes the <emphasis>
+acts </emphasis>
+array and resets the <emphasis>
+num_acts </emphasis>
+field accordingly.
+</para>
+
+
+<para>
+If <emphasis>
+XkbAllocServerMap</emphasis>
+ is successful, it returns <emphasis>
+Success</emphasis>
+. Otherwise, it can return either <emphasis>
+BadMatch</emphasis>
+ or <emphasis>
+BadAlloc</emphasis>
+ errors.
+</para>
+
+
+</sect2>
+<sect2 id='freeing_a_server_map'>
+<title>Freeing a Server Map</title>
+
+<para>
+To free memory used by the server member of an <emphasis>
+XkbDescRec</emphasis>
+ structure, use <emphasis>
+XkbFreeServerMap.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeServerMap</emphasis>
+(<emphasis>
+xkb, which, free_all</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description containing server map to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask identifying components of map to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_all</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; free all server map components and server itself */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+XkbFreeServerMap</emphasis>
+ function frees the specified components of server map in the <emphasis>
+XkbDescRec</emphasis>
+ structure specified by the <emphasis>
+xkb</emphasis>
+ parameter and sets the corresponding structure component values to <emphasis>
+NULL</emphasis>
+. The <emphasis>
+which</emphasis>
+ parameter specifies a combination of the server map masks and is a bitwise
+inclusive OR of the masks listed in Table 14.4. If <emphasis>
+free_all</emphasis>
+ is <emphasis>
+True</emphasis>
+, <emphasis>
+which</emphasis>
+ is ignored and <emphasis>
+XkbFreeServerMap</emphasis>
+ frees every non-<emphasis>
+NULL</emphasis>
+ structure component in the server map, frees the <emphasis>
+XkbServerMapRec</emphasis>
+ structure referenced by the <emphasis>
+server</emphasis>
+ member of the <emphasis>
+xkb</emphasis>
+ parameter, and sets the <emphasis>
+server</emphasis>
+ member to <emphasis>
+NULL.</emphasis>
+</para>
+
+</sect2>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch15.xml b/specs/XKB/ch15.xml
new file mode 100644
index 00000000..59e65ffa
--- /dev/null
+++ b/specs/XKB/ch15.xml
@@ -0,0 +1,2600 @@
+<chapter id='xkb_client_keyboard_mapping'>
+<title>Xkb Client Keyboard Mapping</title>
+
+<para>
+The Xkb client map for a keyboard is the collection of information a client
+needs to interpret key events from the keyboard. It contains a global list of
+key types and an array of key symbol maps, each of which describes the symbols
+bound to a key and the rules to be used to interpret those symbols.
+</para>
+
+
+<para>
+Figure 15.1 shows the relationships between elements in the client map:
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-15.gif"/>
+ </imageobject>
+<caption>Xkb Client Map</caption>
+ </mediaobject>
+
+
+<!--
+<H5 CLASS="Figure">
+Xkb Client Map</H5>
+-->
+
+<sect1 id='the_xkbclientmaprec_structure'>
+<title>The XkbClientMapRec Structure</title>
+
+<para>
+The <emphasis>
+map </emphasis>
+field of the complete Xkb keyboard description (see section 6.1) is a pointer
+to the Xkb client map, which is of type <emphasis>
+XkbClientMapRec</emphasis>
+:
+</para>
+
+<para><programlisting>
+typedef struct { /* Client Map */
+ unsigned char size_types; /* # occupied entries in <emphasis> types</emphasis> */
+ unsigned char num_types; /* # entries in <emphasis>types</emphasis> */
+ XkbKeyTypePtr types; /* vector of key types used by this keymap */
+ unsigned short size_syms; /* length of the <emphasis>syms</emphasis> array */
+ unsigned short num_syms; /* # entries in <emphasis>syms</emphasis> */
+ KeySym * syms; /* linear 2d tables of keysyms, 1 per key */
+ XkbSymMapPtr key_sym_map; /* 1 per keycode, maps keycode to <emphasis>syms</emphasis> */
+ unsigned char * modmap; /* 1 per keycode, real mods bound to key */
+} <emphasis>XkbClientMapRec</emphasis>, *XkbClientMapPtr;
+</programlisting></para>
+
+<para>
+The following sections describe each of the elements of the <emphasis>
+XkbClientMapRec</emphasis>
+ structure in more detail.
+</para>
+
+
+</sect1>
+<sect1 id='key_types'>
+<title>Key Types</title>
+
+<para>
+Key types are used to determine the shift level of a key given the current
+state of the keyboard. The set of all possible key types for the Xkb keyboard
+description are held in the <emphasis>
+types</emphasis>
+ field of the client map, whose total size is stored in <emphasis>
+size_types</emphasis>
+, and whose total number of valid entries is stored in <emphasis>
+num_types</emphasis>
+. Key types are defined using the following structures:
+</para>
+
+<para><programlisting>
+typedef struct { /* Key Type */
+ XkbModsRec mods; /* modifiers used to compute shift
+ level */
+ unsigned char num_levels; /* total # shift levels, do not
+ modify directly */
+ unsigned char map_count; /* # entries in <emphasis>map</emphasis>,
+ <emphasis> preserve</emphasis>
+ (if non-<emphasis> NULL</emphasis>) */
+ XkbKTMapEntryPtr map; /* vector of modifiers for each
+ shift level */
+ XkbModsPtr preserve; /* mods to preserve for corresponding
+ <emphasis>map</emphasis> entry */
+ Atom name; /* name of key type */
+ Atom * level_names; /* array of names of each shift level */
+} <emphasis>XkbKeyTypeRec</emphasis>, *XkbKeyTypePtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct { /* Modifiers for a key type */
+ Bool active; /* <emphasis> True</emphasis> =&gt; entry
+ active when determining shift level */
+ unsigned char level; /* shift level if modifiers match <emphasis> mods</emphasis> */
+ XkbModsRec mods; /* mods needed for this level to be
+ selected */
+} <emphasis>XkbKTMapEntryRec</emphasis>,*XkbKTMapEntryPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+mods</emphasis>
+ field of a key type is an <emphasis>
+XkbModsRec</emphasis>
+ (see section 7.2) specifying the modifiers the key type uses when calculating
+the shift level, and can be composed of both the core modifiers and virtual
+modifiers. To set the modifiers associated with a key type, modify the
+<emphasis>
+real_mods</emphasis>
+ and <emphasis>
+vmods</emphasis>
+ fields of the <emphasis>
+mods</emphasis>
+ <emphasis>
+XkbModsRec</emphasis>
+ accordingly. The <emphasis>
+mask</emphasis>
+ field of the <emphasis>
+XkbModsRec</emphasis>
+ is reserved for use by Xkb and is calculated from the <emphasis>
+real_mods</emphasis>
+ and <emphasis>
+vmods</emphasis>
+ fields.
+</para>
+
+
+<para>
+The <emphasis>
+num_levels</emphasis>
+ field holds the total number of shift levels for the key type. Xkb uses
+<emphasis>
+num_levels</emphasis>
+ to ensure the array of symbols bound to a key is large enough. Do not modify
+<emphasis>
+num_levels</emphasis>
+ directly to change the number if shift levels for a key type. Instead, use
+<emphasis>
+XkbResizeKeyType</emphasis>
+ (see section 15.2.3).
+</para>
+
+
+<para>
+The <emphasis>
+map</emphasis>
+ field is a vector of <emphasis>
+XkbKTMapEntryRec</emphasis>
+ structures, with <emphasis>
+map_count</emphasis>
+ entries, that specify the modifier combinations for each possible shift level.
+Each map entry contains an <emphasis>
+active</emphasis>
+ field, a <emphasis>
+mods</emphasis>
+ field, and a <emphasis>
+level</emphasis>
+ field. The <emphasis>
+active</emphasis>
+ field determines whether the modifier combination listed in the <emphasis>
+mods</emphasis>
+ field should be considered when determining shift level. If <emphasis>
+active</emphasis>
+ is <emphasis>
+False</emphasis>
+, this <emphasis>
+map</emphasis>
+ entry is ignored. If <emphasis>
+active</emphasis>
+ is <emphasis>
+True</emphasis>
+, the <emphasis>
+level</emphasis>
+ field of the <emphasis>
+map </emphasis>
+entry specifies the shift level to use when the current modifier combination
+matches the combination specified in the <emphasis>
+mods</emphasis>
+ field of the <emphasis>
+map</emphasis>
+ entry.
+</para>
+
+
+<para>
+Any combination of modifiers not explicitly listed somewhere in the <emphasis>
+map</emphasis>
+ yields shift level one. In addition, <emphasis>
+map</emphasis>
+ entries specifying unbound virtual modifiers are not considered.
+</para>
+
+
+<para>
+Any modifiers specified in <emphasis>
+mods</emphasis>
+ are normally <emphasis>
+consumed</emphasis>
+ by <emphasis>
+XkbTranslateKeyCode</emphasis>
+ (see section 12.1.3). For those rare occasions a modifier <emphasis>
+should</emphasis>
+ be considered despite having been used to look up a symbol, key types include
+an optional <emphasis>
+preserve</emphasis>
+ field. If a <emphasis>
+preserve</emphasis>
+ member of a key type is not <emphasis>
+NULL</emphasis>
+, it represents a list of modifiers where each entry corresponds directly to
+one of the key type’s <emphasis>
+map</emphasis>
+. Each entry lists the modifiers that should <emphasis>
+not</emphasis>
+ be consumed if the matching map entry is used to determine shift level.
+</para>
+
+
+<para>
+Each shift level has a name and these names are held in the <emphasis>
+level_names</emphasis>
+ array, whose length is <emphasis>
+num_levels</emphasis>
+. The type itself also has a name, which is held in the <emphasis>
+name</emphasis>
+ field.
+</para>
+
+
+<para>
+For example, consider how the server handles the following possible symbolic
+description of a possible key type (note that the format used to specify
+keyboard mappings in the server database is not specified by the Xkb extension,
+although this format is one possible example):
+</para>
+
+<table frame='none'>
+<title>Example Key Type</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Symbolic Description</entry>
+ <entry>Key Type Data Structure</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>type "ALPHATHREE" {</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].name</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>modifiers = Shift+Lock+LevelThree;</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].mods</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>map[None]= Level1;</emphasis></entry>
+ <entry>Xkb-&gt;map-&gt;types[i].map[0]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>map[Lock]= Level1;</emphasis></entry>
+ <entry>Xkb-&gt;map-&gt;types[i].map[1]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>map[Shift]= Level2;</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].map[2]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>map[LevelThree]= Level3;</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].map[3]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>map[Shift+LevelThree]= Level3;</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].map[4]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>preserve[None]= None;</emphasis></entry>
+ <entry>Xkb-&gt;map-&gt;types[i].perserve[0]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>preserve[Lock]= Lock;</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].preserve[1]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>preserve[Shift]= None;</emphasis></entry>
+ <entry>Xkb-&gt;map-&gt;types[i].preserve[2]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>preserve[LevelThree]= None;</emphasis></entry>
+ <entry>Xkb-&gt;map-&gt;types[i].preserve[3]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>preserve[Shift+Level3]= None;</emphasis> </entry>
+ <entry>Xkb-&gt;map-&gt;types[i].preserve[4]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>level_name[Level1]= "Base";</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].level_names[0]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>level_name[Level2]= "Caps";</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].level_names[1]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>level_name[Level3]= "Level3";</entry>
+ <entry>Xkb-&gt;map-&gt;types[i].level_names[2]</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>};</entry>
+ <entry></entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+name</emphasis>
+ of the example key type is "ALPHATHREE," and the modifiers it pays attention
+to are <emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+, and the virtual modifier <emphasis>
+LevelThree</emphasis>
+. There are three shift levels. The name of shift level one is "Base," the name
+of shift level two is "Caps," and the name of shift level three is "Level3."
+</para>
+
+
+<para>
+Given the combination of the <emphasis>
+map</emphasis>
+ and <emphasis>
+preserve</emphasis>
+ specifications, there are five <emphasis>
+map</emphasis>
+ entries. The first map entry specifies that shift level one is to be used if
+no modifiers are set. The second entry specifies the <emphasis>
+Lock</emphasis>
+ modifier alone also yields shift level one. The third entry specifies the
+<emphasis>
+Shift</emphasis>
+ modifier alone yields shift level two. The fourth and fifth entries specify
+that the virtual <emphasis>
+LevelThree</emphasis>
+ modifier alone, or in combination with the <emphasis>
+Shift</emphasis>
+ modifier, yields shift level three.
+</para>
+
+<note><para>Shift level three can be reached only if the virtual modifier
+<emphasis>
+LevelThree</emphasis>
+ is bound to a real modifier (see section 16.4). If <emphasis>
+LevelThree</emphasis>
+ is not bound to a real modifier, the <emphasis>
+map</emphasis>
+ entries associated with it are ignored.</para></note>
+
+<para>
+Because the <emphasis>
+Lock</emphasis>
+ modifier is to be preserved for further event processing, the <emphasis>
+preserve</emphasis>
+ list is not <emphasis>
+NULL</emphasis>
+ and parallels the <emphasis>
+map</emphasis>
+ list. All <emphasis>
+preserve</emphasis>
+ entries, except for the one corresponding to the <emphasis>
+map</emphasis>
+ entry that specifies the <emphasis>
+Lock </emphasis>
+modifier, do not list any modifiers. For the <emphasis>
+map</emphasis>
+ entry that specifies the <emphasis>
+Lock</emphasis>
+ modifier, the corresponding <emphasis>
+preserve</emphasis>
+ list entry lists the <emphasis>
+Lock</emphasis>
+ modifier, meaning do not consume the <emphasis>
+Lock</emphasis>
+ modifier. In this particular case, the preserved modifier is passed to Xlib
+translation functions and causes them to notice that the <emphasis>
+Lock</emphasis>
+ modifier is set; consequently, the Xlib functions apply the appropriate
+capitalization rules to the symbol. Because this preserve entry is set only for
+a modifier that yields shift level one, the capitalization occurs only for
+level-one symbols.
+</para>
+
+
+<sect2 id='the_canonical_key_types'>
+<title>The Canonical Key Types</title>
+
+<para>
+Xkb allows up to <emphasis>
+XkbMaxKeyTypes</emphasis>
+ (255) key types to be defined, but requires at least <emphasis>
+XkbNumRequiredTypes</emphasis>
+ (4) predefined types to be in a key map. These predefined key types are
+referred to as the canonical key types and describe the types of keys available
+on most keyboards. The definitions for the canonical key types are held in the
+first <emphasis>
+XkbNumRequiredTypes</emphasis>
+ entries of the <emphasis>
+types</emphasis>
+ field of the client map and are indexed using the following constants:
+</para>
+
+<para><programlisting>
+ <emphasis>XkbOneLevelIndex</emphasis>
+ <emphasis>XkbTwoLevelIndex</emphasis>
+ <emphasis>XkbAlphabeticIndex</emphasis>
+ <emphasis>XkbKeypadIndex</emphasis>
+</programlisting></para>
+
+<sect3 id='one_level'>
+<title>ONE_LEVEL</title>
+
+<para>
+The ONE_LEVEL key type describes groups that have only one symbol. The default
+ONE_LEVEL key type has no map entries and does not pay attention to any
+modifiers. A symbolic representation of this key type could look like the
+following:
+</para>
+
+<literallayout>
+type "ONE_LEVEL" {
+ modifiers = None;
+ map[None]= Level1;
+ level_name[Level1]= "Any";
+};
+</literallayout>
+
+<para>
+The description of the ONE_LEVEL key type is stored in the <emphasis>
+types</emphasis>
+[<emphasis>
+XkbOneLevelIndex</emphasis>
+] entry of the client key map.
+</para>
+
+
+</sect3>
+<sect3 id='two_level'>
+<title>TWO_LEVEL</title>
+
+<para>
+The TWO_LEVEL key type describes groups that consist of two symbols but are
+neither alphabetic nor numeric keypad keys. The default TWO_LEVEL type uses
+only the <emphasis>
+Shift</emphasis>
+ modifier. It returns shift level two if <emphasis>
+Shift</emphasis>
+ is set, and level one if it is not. A symbolic representation of this key type
+could look like the following:
+</para>
+
+<literallayout>
+type "TWO_LEVEL" {
+ modifiers = Shift;
+ map[Shift]= Level2;
+ level_name[Level1]= "Base";
+ level_name[Level2]= "Shift";
+};
+</literallayout>
+
+<para>
+The description of the TWO_LEVEL key type is stored in the <emphasis>
+types</emphasis>
+[<emphasis>
+XkbTwoLevelIndex</emphasis>
+] entry of the client key map.
+</para>
+
+
+</sect3>
+<sect3 id='alphabetic'>
+<title>ALPHABETIC</title>
+
+<para>
+The ALPHABETIC key type describes groups consisting of two symbols: the
+lowercase form of a symbol followed by the uppercase form of the same symbol.
+The default ALPHABETIC type implements locale-sensitive "Shift cancels
+CapsLock" behavior using both the <emphasis>
+Shift</emphasis>
+ and <emphasis>
+Lock</emphasis>
+ modifiers as follows:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+If <emphasis>
+Shift</emphasis>
+ and <emphasis>
+Lock</emphasis>
+ are both set, the default ALPHABETIC type yields level one.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If <emphasis>
+Shift</emphasis>
+ alone is set, it yields level two.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If <emphasis>
+Lock</emphasis>
+ alone is set, it yields level one, but preserves the <emphasis>
+Lock</emphasis>
+ modifier so Xlib notices and applies the appropriate capitalization rules. The
+Xlib functions are locale-sensitive and apply different capitalization rules
+for different locales.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If neither <emphasis>
+Shift</emphasis>
+ nor <emphasis>
+Lock</emphasis>
+ is set, it yields level one.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+A symbolic representation of this key type could look like the following:
+</para>
+
+<literallayout>
+type "ALPHABETIC" {
+ modifiers = Shift+Lock;
+ map[Shift]= Level2;
+ preserve[Lock]= Lock;
+ level_name[Level1]= "Base";
+ level_name[Level2]= "Caps";
+};
+</literallayout>
+
+<para>
+The description of the ALPHABETIC key type is stored in the <emphasis>
+types</emphasis>
+[<emphasis>
+XkbAlphabeticIndex</emphasis>
+] entry of the client key map.
+</para>
+
+
+</sect3>
+<sect3 id='keypad'>
+<title>KEYPAD</title>
+
+<para>
+The KEYPAD key type describes groups that consist of two symbols, at least one
+of which is a numeric keypad symbol. The numeric keypad symbol is assumed to
+reside at level two. The default KEYPAD key type implements "Shift cancels
+NumLock" behavior using the Shift modifier and the real modifier bound to the
+virtual modifier named "NumLock," known as the <emphasis>
+NumLock</emphasis>
+ modifier, as follows:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+If <emphasis>
+Shift</emphasis>
+ and <emphasis>
+NumLock</emphasis>
+ are both set, the default KEYPAD type yields level one.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If <emphasis>
+Shift</emphasis>
+ alone is set, it yields level two.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If <emphasis>
+NumLock</emphasis>
+ alone is set, it yields level two.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If neither <emphasis>
+Shift</emphasis>
+ nor <emphasis>
+NumLock</emphasis>
+ is set, it yields level one.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+A symbolic representation of this key type could look like the following:
+</para>
+
+<literallayout>
+type "KEYPAD" {
+ modifiers = Shift+NumLock;
+ map[None]= Level1;
+ map[Shift]= Level2;
+ map[NumLock]= Level2;
+ map[Shift+NumLock]= Level1;
+ level_name[Level1]= "Base";
+ level_name[Level2]= "Caps";
+};
+</literallayout>
+
+<para>
+The description of the KEYPAD key type is stored in the <emphasis>
+types</emphasis>
+[<emphasis>
+XkbKeypadIndex</emphasis>
+] entry of the client key map.
+</para>
+
+
+</sect3>
+<sect3 id='initializing_the_canonical_key_types_in_a_new_client_map'>
+<title>Initializing the Canonical Key Types in a New Client Map</title>
+
+<para>
+To set the definitions of the canonical key types in a client map to their
+default values, use <emphasis>
+XkbInitCanonicalKeyTypes.</emphasis>
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbInitCanonicalKeyTypes</emphasis>
+(<emphasis>
+xkb, which, keypadVMod</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description containing client map to initialize */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of types to initialize */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+keypadVMod</emphasis>
+; /* index of NumLock virtual modifier */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbInitCanonicalKeyTypes</emphasis>
+ initializes the first <emphasis>
+XkbNumRequiredTypes</emphasis>
+ key types of the keyboard specified by the <emphasis>
+xkb</emphasis>
+ parameter to their default values. The <emphasis>
+which</emphasis>
+ parameter specifies what canonical key types to initialize and is a bitwise
+inclusive OR of the following masks: <emphasis>
+XkbOneLevelMask</emphasis>
+, <emphasis>
+XkbTwoLevelMask</emphasis>
+, <emphasis>
+XkbAlphabeticMask</emphasis>
+, and <emphasis>
+XkbKeypadMask</emphasis>
+. Only those canonical types specified by the <emphasis>
+which</emphasis>
+ mask are initialized.
+</para>
+
+
+<para>
+If <emphasis>
+XkbKeypadMask</emphasis>
+ is set in the <emphasis>
+which</emphasis>
+ parameter, <emphasis>
+XkbInitCanonicalKeyTypes</emphasis>
+ looks up the <emphasis>
+NumLock</emphasis>
+ named virtual modifier to determine which virtual modifier to use when
+initializing the KEYPAD key type. If the <emphasis>
+NumLock</emphasis>
+ virtual modifier does not exist, <emphasis>
+XkbInitCanonicalKeyTypes</emphasis>
+ creates it.
+</para>
+
+
+<para>
+<emphasis>
+XkbInitCanonicalKeyTypes</emphasis>
+ normally returns Success. It returns <emphasis>
+BadAccess</emphasis>
+ if the Xkb extension has not been properly initialized, and <emphasis>
+BadAccess</emphasis>
+ if the <emphasis>
+xkb</emphasis>
+ parameter is not valid.
+</para>
+
+
+
+</sect3>
+</sect2>
+<sect2 id='getting_key_types_from_the_server'>
+<title>Getting Key Types from the Server</title>
+
+<para>
+To obtain the list of available key types in the server’s keyboard mapping,
+use <emphasis>
+XkbGetKeyTypes</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeyTypes</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ first</emphasis>
+; /* index to first type to get, 0 =&gt; 1st type */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num</emphasis>
+; /* number of key types to be returned */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description containing client map to update */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+<note><para><emphasis>
+XkbGetKeyTypes</emphasis>
+ is used to obtain descriptions of the key types themselves, not the key types
+bound to individual keys. To obtain the key types bound to an individual key,
+refer to the <emphasis>
+key_sym_map</emphasis>
+ field of the client map (see section 15.3.1).</para></note>
+
+<para>
+<emphasis>
+XkbGetKeyTypes</emphasis>
+ queries the server for the desired types, waits for a reply, and returns the
+desired types in the <emphasis>
+xkb-&gt;map-&gt;types</emphasis>
+. If successful, it returns Success.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetKeyTypes</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+ if the Xkb extension has not been properly initialized and <emphasis>
+BadValue</emphasis>
+ if the combination of <emphasis>
+first</emphasis>
+ and <emphasis>
+num</emphasis>
+ results in numbers out of valid range.
+</para>
+
+
+</sect2>
+<sect2 id='changing_the_number_of_levels_in_a_key_type'>
+<title>Changing the Number of Levels in a Key Type</title>
+
+<para>
+To change the number of levels in a key type, use <emphasis>
+XkbResizeKeyType</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbResizeKeyType</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ type_ndx</emphasis>
+,<emphasis>
+ map_count</emphasis>
+,<emphasis>
+ want_preserve</emphasis>
+,<emphasis>
+ new_num_lvls</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr<emphasis>
+ xkb</emphasis>
+; /* keyboard description containing client map to update */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ type_ndx</emphasis>
+; /* index in xkb-&gt;map-&gt;types of type to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+map_count</emphasis>
+; /* total # of map entries needed for the type */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+want_preserve</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; list of preserved modifiers is necessary */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ new_num_lvls</emphasis>
+; /* new max # of levels for type */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbResizeKeyType</emphasis>
+ changes the type specified by <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+map-&gt;types</emphasis>
+[<emphasis>
+type_ndx</emphasis>
+], and reallocates the symbols and actions bound to all keys that use the type,
+if necessary. <emphasis>
+XkbResizeKeyType</emphasis>
+ updates only the local copy of the types in <emphasis>
+xkb</emphasis>
+; to update the server’s copy for the physical device, use <emphasis>
+XkbSetMap</emphasis>
+ or <emphasis>
+XkbChangeMap</emphasis>
+ after calling <emphasis>
+XkbResizeKeyType</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+map_count</emphasis>
+ parameter specifies the total number of map entries needed for the type, and
+can be zero or greater. If <emphasis>
+map_count</emphasis>
+ is zero, <emphasis>
+XkbResizeKeyType</emphasis>
+ frees the existing <emphasis>
+map</emphasis>
+ and <emphasis>
+preserve</emphasis>
+ entries for the type if they exist and sets them to <emphasis>
+NULL</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+want_preserve</emphasis>
+ parameter specifies whether a <emphasis>
+preserve</emphasis>
+ list for the key should be created. If <emphasis>
+want_preserve</emphasis>
+ is <emphasis>
+True</emphasis>
+, the <emphasis>
+preserve</emphasis>
+ list with <emphasis>
+map_count</emphasis>
+ entries is allocated or reallocated if it already exists. Otherwise, if
+<emphasis>
+want_preserve</emphasis>
+ is <emphasis>
+False</emphasis>
+, the <emphasis>
+preserve</emphasis>
+ field is freed if necessary and set to <emphasis>
+NULL</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+new_num_lvls</emphasis>
+ parameter specifies the new maximum number of shift levels for the type and is
+used to calculate and resize the symbols and actions bound to all keys that use
+the type.
+</para>
+
+
+<para>
+If <emphasis>
+type_ndx</emphasis>
+ does not specify a legal type, <emphasis>
+new_num_lvls</emphasis>
+ is less than 1, or the <emphasis>
+map_count</emphasis>
+ is less than zero, <emphasis>
+XkbResizeKeyType</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If <emphasis>
+XkbResizeKeyType</emphasis>
+ encounters any problems with allocation, it returns <emphasis>
+BadAlloc</emphasis>
+. Otherwise, it returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='copying_key_types'>
+<title>Copying Key Types</title>
+
+<para>
+Use <emphasis>
+XkbCopyKeyType</emphasis>
+ and <emphasis>
+XkbCopyKeyTypes</emphasis>
+ to copy one or more <emphasis>
+XkbKeyTypeRec</emphasis>
+ structures.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbCopyKeyType</emphasis>
+(<emphasis>
+from</emphasis>
+,<emphasis>
+ into</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbKeyTypePtr <emphasis>
+ from</emphasis>
+; /* pointer to XkbKeyTypeRec to be copied */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbKeyTypePtr <emphasis>
+ into</emphasis>
+; /* pointer to XkbKeyTypeRec to be changed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbCopyKeyType</emphasis>
+ copies the key type specified by <emphasis>
+from</emphasis>
+ to the key type specified by <emphasis>
+into</emphasis>
+. Both must point to legal <emphasis>
+XkbKeyTypeRec</emphasis>
+ structures. Xkb assumes <emphasis>
+from</emphasis>
+ and <emphasis>
+into</emphasis>
+ point to different places. As a result, overlaps can be fatal. <emphasis>
+XkbCopyKeyType</emphasis>
+ frees any existing <emphasis>
+map</emphasis>
+, <emphasis>
+preserve</emphasis>
+, and <emphasis>
+level_names</emphasis>
+ in <emphasis>
+into</emphasis>
+ prior to copying. If any allocation errors occur while copying <emphasis>
+from</emphasis>
+ to <emphasis>
+into</emphasis>
+, <emphasis>
+XkbCopyKeyType</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+. Otherwise, <emphasis>
+XkbCopyKeyType</emphasis>
+ copies <emphasis>
+from</emphasis>
+ to <emphasis>
+into</emphasis>
+ and returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbCopyKeyTypes</emphasis>
+(<emphasis>
+from</emphasis>
+,<emphasis>
+ into</emphasis>
+, <emphasis>
+num_types</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbKeyTypePtr <emphasis>
+ from</emphasis>
+; /* pointer to array of XkbKeyTypeRecs to copy */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbKeyTypePtr <emphasis>
+ into</emphasis>
+; /* pointer to array of XkbKeyTypeRecs to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_types</emphasis>
+; /* number of types to copy */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbCopyKeyTypes</emphasis>
+ copies <emphasis>
+num_types</emphasis>
+ <emphasis>
+XkbKeyTypeRec</emphasis>
+ structures from the array specified by <emphasis>
+from</emphasis>
+ into the array specified by <emphasis>
+into</emphasis>
+. It is intended for copying between, rather than within, keyboard
+descriptions, so it doesn’t check for overlaps. The same rules that apply to
+the <emphasis>
+from</emphasis>
+ and <emphasis>
+into</emphasis>
+ parameters in <emphasis>
+XkbCopyKeyType</emphasis>
+ apply to each entry of the <emphasis>
+from</emphasis>
+ and <emphasis>
+into</emphasis>
+ arrays of <emphasis>
+XkbCopyKeyTypes</emphasis>
+. If any allocation errors occur while copying <emphasis>
+from</emphasis>
+ to <emphasis>
+into</emphasis>
+, <emphasis>
+XkbCopyKeyTypes</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+. Otherwise, <emphasis>
+XkbCopyKeyTypes</emphasis>
+ copies <emphasis>
+from</emphasis>
+ to <emphasis>
+into</emphasis>
+ and returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='key_symbol_map'>
+<title>Key Symbol Map</title>
+
+<para>
+The entire list of key symbols for the keyboard mapping is held in the
+<emphasis>
+syms</emphasis>
+ field of the client map. Whereas the core keyboard mapping is a
+two-dimensional array of <emphasis>
+KeySyms</emphasis>
+ whose rows are indexed by keycode, the <emphasis>
+syms</emphasis>
+ field of Xkb is a linear list of <emphasis>
+KeySyms</emphasis>
+ that needs to be indexed uniquely for each key. This section describes the key
+symbol map and the methods for determining the symbols bound to a key.
+</para>
+
+
+<para>
+The reason the <emphasis>
+syms</emphasis>
+ field is a linear list of <emphasis>
+KeySyms</emphasis>
+ is to reduce the memory consumption associated with a keymap; because Xkb
+allows individual keys to have multiple shift levels and a different number of
+groups per key, a single two-dimensional array of <emphasis>
+KeySyms</emphasis>
+ would potentially be very large and sparse. Instead, Xkb provides a small
+two-dimensional array of <emphasis>
+KeySyms</emphasis>
+ for each key. To store all of these individual arrays, Xkb concatenates each
+array together in the <emphasis>
+syms</emphasis>
+ field of the client map.
+</para>
+
+
+<para>
+In order to determine which <emphasis>
+KeySyms</emphasis>
+ in the <emphasis>
+syms</emphasis>
+ field are associated with each keycode, the client map contains an array of
+key symbol mappings, held in the <emphasis>
+key_sym_map</emphasis>
+ field. The <emphasis>
+key_sym_map</emphasis>
+ field is an array of <emphasis>
+XkbSymMapRec</emphasis>
+ structures indexed by keycode. The <emphasis>
+key_sym_map</emphasis>
+ array has <emphasis>
+min_key_code</emphasis>
+ unused entries at the start to allow direct indexing using a keycode. All
+keycodes falling between the minimum and maximum legal keycodes, inclusive,
+have <emphasis>
+key_sym_map</emphasis>
+ arrays, whether or not any key actually yields that code. The <emphasis>
+KeySymMapRec</emphasis>
+ structure is defined as follows:
+</para>
+
+<para><programlisting>
+#define XkbNumKbdGroups 4
+#define XkbMaxKbdGroup (XkbNumKbdGroups-1)
+</programlisting></para>
+
+<para><programlisting>
+typedef struct { /* map to keysyms for a single keycode */
+ unsigned char kt_index[XkbNumKbdGroups]; /* key type index for each group */
+ unsigned char group_info; /* # of groups and out of range group handling */
+ unsigned char width; /* max # of shift levels for key */
+ unsigned short offset; /* index to keysym table in <emphasis> syms</emphasis> array */
+} <emphasis>XkbSymMapRec</emphasis>, *XkbSymMapPtr;
+</programlisting></para>
+
+<para>
+These fields are described in detail in the following sections.
+</para>
+
+
+<sect2 id='per_key_key_type_indices'>
+<title>Per-Key Key Type Indices</title>
+
+<para>
+The <emphasis>
+kt_index</emphasis>
+ array of the <emphasis>
+XkbSymMapRec</emphasis>
+ structure contains the indices of the key types (see section 15.2) for each
+possible group of symbols associated with the key. To obtain the index of a key
+type or the pointer to a key type, Xkb provides the following macros, to access
+the key types:
+</para>
+
+<note><para>The array of key types is of fixed width and is large enough to
+hold key types for the maximum legal number of groups (<emphasis>
+XkbNumKbdGroups</emphasis>
+, currently four); if a key has fewer than <emphasis>
+XkbNumKbdGroups</emphasis>
+ groups, the extra key types are reported but ignored.</para></note>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyTypeIndex</emphasis>
+(<emphasis>
+xkb, keycode, group</emphasis>
+) /* macro*/
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+group</emphasis>
+; /* group index */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyTypeIndex</emphasis>
+ computes an index into the <emphasis>
+types</emphasis>
+ vector of the client map in <emphasis>
+xkb</emphasis>
+ from the given <emphasis>
+keycode</emphasis>
+ and <emphasis>
+group</emphasis>
+ index.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbKeyTypePtr <emphasis>
+XkbKeyType</emphasis>
+(<emphasis>
+xkb, keycode, group</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+group</emphasis>
+; /* group index */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyType</emphasis>
+ returns a pointer to the key type in the <emphasis>
+types</emphasis>
+ vector of the client map in <emphasis>
+xkb</emphasis>
+ corresponding to the given <emphasis>
+keycode</emphasis>
+ and <emphasis>
+group</emphasis>
+ index.
+</para>
+
+
+</sect2>
+<sect2 id='per_key_group_information'>
+<title>Per-Key Group Information</title>
+
+<para>
+The <emphasis>
+group_info</emphasis>
+ field of an <emphasis>
+XkbSymMapRec</emphasis>
+ is an encoded value containing the number of groups of symbols bound to the
+key as well as the specification of the treatment of out-of-range groups. It is
+legal for a key to have zero groups, in which case it also has zero symbols and
+all events from that key yield <emphasis>
+NoSymbol</emphasis>
+. To obtain the number of groups of symbols bound to the key, use <emphasis>
+XkbKeyNumGroups</emphasis>
+. To change the number of groups bound to a key, use <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ (see section 15.3.6). To obtain a mask that determines the treatment of
+out-of-range groups, use <emphasis>
+XkbKeyGroupInfo</emphasis>
+ and <emphasis>
+XkbOutOfRangeGroupInfo</emphasis>
+.
+</para>
+
+
+<para>
+The keyboard controls (see Chapter 10) contain a <emphasis>
+groups_wrap</emphasis>
+ field specifying the handling of illegal groups on a global basis. That is,
+when the user performs an action causing the effective group to go out of the
+legal range, the <emphasis>
+groups_wrap</emphasis>
+ field specifies how to normalize the effective keyboard group to a group that
+is legal for the keyboard as a whole, but there is no guarantee that the
+normalized group will be within the range of legal groups for any individual
+key. The per-key <emphasis>
+group_info</emphasis>
+ field specifies how a key treats a legal effective group if the key does not
+have a type specified for the group of concern. For example, the <emphasis>
+Enter</emphasis>
+ key usually has just one group defined. If the user performs an action causing
+the global keyboard group to change to <emphasis>
+Group2</emphasis>
+, the <emphasis>
+group_info</emphasis>
+ field for the <emphasis>
+Enter</emphasis>
+ key describes how to handle this situation.
+</para>
+
+
+<para>
+Out-of-range groups for individual keys are mapped to a legal group using the
+same options as are used for the overall keyboard group. The particular type of
+mapping used is controlled by the bits set in the <emphasis>
+group_info</emphasis>
+ flag, as shown in Table 15.2. See section 10.7.1 for more details on the
+normalization methods in this table.
+</para>
+
+<table frame='none'>
+<title>group_info Range Normalization</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Bits set in group_info</entry>
+ <entry>Normalization method</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbRedirectIntoRange</entry>
+ <entry>XkbRedirectIntoRange</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbClampIntoRange</entry>
+ <entry>XkbClampIntoRange</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>none of the above</entry>
+ <entry>XkbWrapIntoRange</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Xkb provides the following macros to access group information:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyNumGroups</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyNumGroups</emphasis>
+ returns the number of groups of symbols bound to the key corresponding to
+<emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned char <emphasis>
+XkbKeyGroupInfo</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /*macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyGroupInfo</emphasis>
+ returns the <emphasis>
+group_info</emphasis>
+ field from the <emphasis>
+XkbSymMapRec</emphasis>
+ structure associated with the key corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned char <emphasis>
+XkbOutOfRangeGroupInfo</emphasis>
+(<emphasis>
+grp_inf</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned char <emphasis>
+grp_inf</emphasis>
+; /* group_info field of <emphasis>
+XkbSymMapRec</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbOutOfRangeGroupInfo</emphasis>
+ returns only the out-of-range processing information from the <emphasis>
+group_info</emphasis>
+ field of an <emphasis>
+XkbSymMapRec</emphasis>
+ structure.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned char <emphasis>
+XkbOutOfRangeGroupNumber</emphasis>
+(<emphasis>
+grp_inf</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned char <emphasis>
+grp_inf</emphasis>
+; /* group_info field of <emphasis>
+XkbSymMapRec</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbOutOfRangeGroupNumber</emphasis>
+ returns the out-of-range group number, represented as a group index, from the
+<emphasis>
+group_info</emphasis>
+ field of an <emphasis>
+XkbSymMapRec</emphasis>
+ structure.
+</para>
+
+
+</sect2>
+<sect2 id='key_width'>
+<title>Key Width</title>
+
+<para>
+The maximum number of shift levels for a type is also referred to as the width
+of a key type. The <emphasis>
+width</emphasis>
+ field of the <emphasis>
+key_sym_map</emphasis>
+ entry for a key contains the width of the widest type associated with the key.
+The <emphasis>
+width </emphasis>
+field cannot be explicitly changed; it is updated automatically whenever the
+symbols or set of types bound to a key are changed.
+</para>
+
+
+</sect2>
+<sect2 id='offset_in_to_the_symbol_map'>
+<title>Offset in to the Symbol Map</title>
+
+<para>
+The key width and number of groups associated with a key are used to form a
+small two-dimensional array of <emphasis>
+KeySyms</emphasis>
+ for a key. This array may be different sizes for different keys. The array for
+a single key is stored as a linear list, in row-major order. The arrays for all
+of the keys are stored in the <emphasis>
+syms</emphasis>
+ field of the client map. There is one row for each group associated with a key
+and one column for each level. The index corresponding to a given group and
+shift level is computed as:
+</para>
+
+<literallayout>
+ idx = group_index * key_width + shift_level
+</literallayout>
+
+<para>
+The <emphasis>
+offset</emphasis>
+ field of the <emphasis>
+key_sym_map</emphasis>
+ entry for a key is used to access the beginning of the array.
+</para>
+
+
+<para>
+Xkb provides the following macros for accessing the <emphasis>
+width</emphasis>
+ and <emphasis>
+offset</emphasis>
+ for individual keys, as well as macros for accessing the two-dimensional array
+of symbols bound to the key:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyGroupsWidth</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyGroupsWidth</emphasis>
+ computes the maximum width associated with the key corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyGroupWidth</emphasis>
+(<emphasis>
+xkb, keycode, grp</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+grp</emphasis>
+; /* group of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyGroupWidth</emphasis>
+ computes the width of the type associated with the group <emphasis>
+grp</emphasis>
+ for the key corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeySymsOffset</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeySymsOffset</emphasis>
+ returns the offset of the two-dimensional array of keysyms for the key
+corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyNumSyms</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyNumSyms</emphasis>
+ returns the total number of keysyms for the key corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+KeySym * <emphasis>
+XkbKeySymsPtr</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeySymsPtr</emphasis>
+ returns the pointer to the two-dimensional array of keysyms for the key
+corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+KeySym <emphasis>
+XkbKeySymEntry</emphasis>
+(<emphasis>
+xkb, keycode, shift, grp</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+shift</emphasis>
+; /* shift level of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+grp</emphasis>
+; /* group of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeySymEntry</emphasis>
+ returns the <emphasis>
+keysym</emphasis>
+ corresponding to shift level <emphasis>
+shift</emphasis>
+ and group <emphasis>
+grp</emphasis>
+ from the two-dimensional array of keysyms for the key corresponding to
+<emphasis>
+keycode</emphasis>
+</para>
+
+
+</sect2>
+<sect2 id='getting_the_symbol_map_for_keys_from_the_server'>
+<title>Getting the Symbol Map for Keys from the Server</title>
+
+<para>
+To obtain the symbols for a subset of the keys in a keyboard description, use
+<emphasis>
+XkbGetKeySyms</emphasis>
+:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeySyms</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+, <emphasis>
+num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ first</emphasis>
+; /* keycode of first key to get */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ num</emphasis>
+; /* number of keycodes for which syms desired */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description to be updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeySyms</emphasis>
+ sends a request to the server to obtain the set of keysyms bound to <emphasis>
+num</emphasis>
+ keys starting with the key whose keycode is <emphasis>
+first</emphasis>
+. It waits for a reply and returns the keysyms in the <emphasis>
+map.syms</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+. If successful, <emphasis>
+XkbGetKeySyms</emphasis>
+ returns <emphasis>
+Success</emphasis>
+. The <emphasis>
+xkb</emphasis>
+ parameter must be a pointer to a valid Xkb keyboard description.
+</para>
+
+
+<para>
+If the client <emphasis>
+map</emphasis>
+ in the <emphasis>
+xkb</emphasis>
+ parameter has not been allocated, <emphasis>
+XkbGetKeySyms</emphasis>
+ allocates and initializes it before obtaining the symbols.
+</para>
+
+
+<para>
+If a compatible version of Xkb is not available in the server or the Xkb
+extension has not been properly initialized, <emphasis>
+XkbGetKeySyms</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+. If <emphasis>
+num</emphasis>
+ is less than 1 or greater than <emphasis>
+XkbMaxKeyCount</emphasis>
+, <emphasis>
+XkbGetKeySyms</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If any allocation errors occur, <emphasis>
+XkbGetKeySyms</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='changing_the_number_of_groups_and_types_bound_to_a_key'>
+<title>Changing the Number of Groups and Types Bound to a Key</title>
+
+<para>
+To change the number of groups and the types bound to a key, use <emphasis>
+XkbChangeTypesOfKey</emphasis>
+.
+</para>
+
+
+<para>
+Status <emphasis>
+XkbChangeTypesOfKey</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ key</emphasis>
+,<emphasis>
+ n_groups</emphasis>
+,<emphasis>
+ groups</emphasis>
+,<emphasis>
+ new_types_in</emphasis>
+,<emphasis>
+ p_changes</emphasis>
+)
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description to be changed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ key</emphasis>
+; /* keycode for key of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ n_groups</emphasis>
+; /* new number of groups for key */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+groups</emphasis>
+; /* mask indicating groups to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+new_types_in</emphasis>
+; /* indices for new groups specified in <emphasis>
+groups</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbMapChangesPtr <emphasis>
+p_changes</emphasis>
+; /* notes changes made to <emphasis>
+xkb</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbChangeTypesOfKey</emphasis>
+ reallocates the symbols and actions bound to the key, if necessary, and
+initializes any new symbols or actions to <emphasis>
+NoSymbol</emphasis>
+ or <emphasis>
+NoAction</emphasis>
+, as appropriate. If the <emphasis>
+p_changes</emphasis>
+ parameter is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ adds the <emphasis>
+XkbKeySymsMask</emphasis>
+ to the <emphasis>
+changes</emphasis>
+ field of <emphasis>
+p_changes</emphasis>
+ and modifies the <emphasis>
+first_key_sym</emphasis>
+ and <emphasis>
+num_key_syms</emphasis>
+ fields of <emphasis>
+p_changes</emphasis>
+ to include the <emphasis>
+key</emphasis>
+ that was changed. See section 14.3.1 for more information on the <emphasis>
+XkbMapChangesPtr</emphasis>
+ structure. If successful, <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+n_groups</emphasis>
+ parameter specifies the new number of groups for the key. The <emphasis>
+groups</emphasis>
+ parameter is a mask specifying the groups for which new types are supplied and
+is a bitwise inclusive OR of the following masks: <emphasis>
+XkbGroup1Mask</emphasis>
+, <emphasis>
+XkbGroup2Mask</emphasis>
+, <emphasis>
+XkbGroup3Mask</emphasis>
+, and <emphasis>
+XkbGroup4Mask</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+new_types_in</emphasis>
+ parameter is an integer array of length <emphasis>
+n_groups</emphasis>
+. Each entry represents the type to use for the associated group and is an
+index into <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+map-&gt;types</emphasis>
+. The <emphasis>
+new_types_in</emphasis>
+ array is indexed by group index; if <emphasis>
+n_groups</emphasis>
+ is four and <emphasis>
+groups</emphasis>
+ only has <emphasis>
+Group1Mask</emphasis>
+ and <emphasis>
+Group3Mask</emphasis>
+ set, <emphasis>
+new_types_in</emphasis>
+ looks like this:
+</para>
+
+<literallayout>
+ new_types_in[0] = type for Group1
+ new_types_in[1] = ignored
+ new_types_in[2] = type for Group3
+ new_types_in[3] = ignored
+</literallayout>
+
+<para>
+For convenience, Xkb provides the following constants to use as indices to the
+groups:
+</para>
+
+<table frame='none'>
+<title>Group Index Constants</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Constant Name</entry>
+ <entry>Value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbGroup1Index</entry>
+ <entry>0</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup2Index</entry>
+ <entry>1</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup3Index</entry>
+ <entry>2</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGroup4Index</entry>
+ <entry>3</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+If the Xkb extension has not been properly initialized, <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+. If the <emphasis>
+xkb</emphasis>
+ parameter it not valid (that is, it is <emphasis>
+NULL</emphasis>
+ or it does not contain a valid client map), <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ returns <emphasis>
+Bad</emphasis>
+Match. If the <emphasis>
+key</emphasis>
+ is not a valid keycode, <emphasis>
+n_groups</emphasis>
+ is greater than <emphasis>
+XkbNumKbdGroups</emphasis>
+, or the <emphasis>
+groups</emphasis>
+ mask does not contain any of the valid group mask bits, <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If it is necessary to resize the key symbols or key actions arrays and any
+allocation errors occur, <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='changing_the_number_of_symbols_bound_to_a_key'>
+<title>Changing the Number of Symbols Bound to a Key</title>
+
+<para>
+To change the number of symbols bound to a key, use <emphasis>
+XkbResizeKeySyms</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+KeySym *<emphasis>
+XkbResizeKeySyms</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ key</emphasis>
+,<emphasis>
+ needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescRec *<emphasis>
+ xkb</emphasis>
+; /* keyboard description to be changed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ key</emphasis>
+; /* keycode for key to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ needed</emphasis>
+; /* new number of keysyms required for key */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbResizeKeySyms</emphasis>
+ reserves the space needed for <emphasis>
+needed</emphasis>
+ keysyms and returns a pointer to the beginning of the new array that holds the
+keysyms. It adjusts the <emphasis>
+offset</emphasis>
+ field of the <emphasis>
+key_sym_map</emphasis>
+ entry for the key if necessary and can also change the <emphasis>
+syms</emphasis>
+, <emphasis>
+num_syms</emphasis>
+, and <emphasis>
+size_syms</emphasis>
+ fields of <emphasis>
+xkb</emphasis>
+-<emphasis>
+&gt;map</emphasis>
+ if it is necessary to reallocate the <emphasis>
+syms</emphasis>
+ array. <emphasis>
+XkbResizeKeySyms</emphasis>
+ does not modify either the width or number of groups associated with the key.
+</para>
+
+
+<para>
+If <emphasis>
+needed</emphasis>
+ is greater than the current number of keysyms for the key, <emphasis>
+XkbResizeKeySyms</emphasis>
+ initializes all new keysyms in the array to <emphasis>
+NoSymbol</emphasis>
+.
+</para>
+
+
+<para>
+Because the number of symbols needed by a key is normally computed as width *
+number of groups, and <emphasis>
+XkbResizeKeySyms</emphasis>
+ does not modify either the width or number of groups for the key, a
+discrepancy exists upon return from <emphasis>
+XkbResizeKeySyms</emphasis>
+ between the space allocated for the keysyms and the number required. The
+unused entries in the list of symbols returned by <emphasis>
+XkbResizeKeySyms</emphasis>
+ are not preserved across future calls to any of the map editing functions, so
+you must update the key symbol mapping (which updates the width and number of
+groups for the key) before calling another allocator function. A call to
+<emphasis>
+XkbChangeTypesOfKey</emphasis>
+ will update the mapping.
+</para>
+
+
+<para>
+If any allocation errors occur while resizing the number of symbols bound to
+the key, <emphasis>
+XkbResizeKeySyms</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+.
+</para>
+
+<note><para>A change to the number of symbols bound to a key should be
+accompanied by a change in the number of actions bound to a key. Refer to
+section 16.1.16 for more information on changing the number of actions bound to
+a key.</para></note>
+
+
+</sect2>
+</sect1>
+<sect1 id='the_per_key_modifier_map'>
+<title>The Per-Key Modifier Map</title>
+
+<para>
+The <emphasis>
+modmap</emphasis>
+ entry of the client map is an array, indexed by keycode, specifying the real
+modifiers bound to a key. Each entry is a mask composed of a bitwise inclusive
+OR of the legal real modifiers: <emphasis>
+ShiftMask</emphasis>
+, <emphasis>
+LockMask</emphasis>
+, <emphasis>
+ControlMask</emphasis>
+, <emphasis>
+Mod1Mask</emphasis>
+, <emphasis>
+Mod2Mask</emphasis>
+, <emphasis>
+Mod3Mask</emphasis>
+, <emphasis>
+Mod4Mask</emphasis>
+, and <emphasis>
+Mod5Mask</emphasis>
+. If a bit is set in a <emphasis>
+modmap</emphasis>
+ entry, the corresponding key is bound to that modifier.
+</para>
+
+
+<para>
+Pressing or releasing the key bound to a modifier changes the modifier set and
+unset state. The particular manner in which the modifier set and unset state
+changes is determined by the behavior and actions assigned to the key (see
+Chapter 16).
+</para>
+
+
+<sect2 id='getting_the_per_key_modifier_map_from_the_server'>
+<title>Getting the Per-Key Modifier Map from the Server</title>
+
+<para>
+To update the modifier map for one or more of the keys in a keyboard
+description, use <emphasis>
+XkbGetKeyModifierMap</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeyModifierMap</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+first</emphasis>
+; /* keycode of first key to get */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num</emphasis>
+; /* number of keys for which information is desired */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description to update */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyModifierMap</emphasis>
+ sends a request to the server for the modifier mappings for <emphasis>
+num</emphasis>
+ keys starting with the key whose keycode is <emphasis>
+first</emphasis>
+. It waits for a reply and places the results in the <emphasis>
+xkb</emphasis>
+-&gt;map-&gt;modmap array. If successful, <emphasis>
+XkbGetKeyModifier</emphasis>
+ returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+<para>
+If the map component of the <emphasis>
+xkb</emphasis>
+ parameter has not been allocated, <emphasis>
+XkbGetKeyModifierMap</emphasis>
+ allocates and initializes it.
+</para>
+
+
+<para>
+If a compatible version of Xkb is not available in the server or the Xkb
+extension has not been properly initialized, <emphasis>
+XkbGetKeySyms</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+. If any allocation errors occur while obtaining the modifier map, <emphasis>
+XkbGetKeyModifierMap</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+</sect2>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch16.xml b/specs/XKB/ch16.xml
new file mode 100644
index 00000000..6b0f42b1
--- /dev/null
+++ b/specs/XKB/ch16.xml
@@ -0,0 +1,4794 @@
+<chapter id='xkb_server_keyboard_mapping'>
+<title>Xkb Server Keyboard Mapping</title>
+
+<para>
+The <emphasis>
+server</emphasis>
+ field of the complete Xkb keyboard description (see section 6.1) is a pointer
+to the Xkb server map.
+</para>
+
+
+<para>
+Figure 16.1 shows the relationships between elements in the server map:
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-16.gif"/>
+ </imageobject>
+<caption>Server Map Relationships</caption>
+ </mediaobject>
+
+
+<!--
+<H5 CLASS="Figure">
+Server Map Relationships</H5>
+-->
+
+<para>
+The Xkb server map contains the information the server needs to interpret key
+events and is of type <emphasis>
+XkbServerMapRec</emphasis>
+:
+</para>
+
+<para><programlisting>
+#define XkbNumVirtualMods 16
+</programlisting></para>
+
+<para><programlisting>
+typedef struct { /* Server Map */
+ unsigned short num_acts; /* # of occupied entries in <emphasis> acts</emphasis> */
+ unsigned short size_acts; /* # of entries in <emphasis> acts</emphasis> */
+ XkbAction * acts; /* linear 2d tables of key actions, 1 per keycode */
+ XkbBehavior * behaviors; /* key behaviors,1 per keycode */
+ unsigned short * key_acts; /* index into <emphasis> acts</emphasis> , 1 per keycode */
+ unsigned char * explicit; /* explicit overrides of core remapping, 1 per key */
+ unsigned char vmods[XkbNumVirtualMods]; /* real mods bound to virtual mods */
+ unsigned short * vmodmap; /* virtual mods bound to key, 1 per keycode*/
+} <emphasis>XkbServerMapRec</emphasis>, *XkbServerMapPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+num_acts</emphasis>
+, <emphasis>
+size_acts</emphasis>
+, <emphasis>
+acts</emphasis>
+, and <emphasis>
+key_acts</emphasis>
+ fields specify the key actions, defined in section 16.1. The <emphasis>
+behaviors</emphasis>
+ field describes the behavior for each key and is defined in section 16.2. The
+<emphasis>
+explicit</emphasis>
+ field describes the explicit components for a key and is defined in section
+16.3. The <emphasis>
+vmods</emphasis>
+ and the <emphasis>
+vmodmap</emphasis>
+ fields describe the virtual modifiers and the per-key virtual modifier mapping
+and are defined in section 16.4.
+</para>
+
+<sect1 id='key_actions'>
+<title>Key Actions</title>
+
+<para>
+A key action defines the effect key presses and releases have on the internal
+state of the server. For example, the expected key action associated with
+pressing the <emphasis>
+Shift</emphasis>
+ key is to set the <emphasis>
+Shift</emphasis>
+ modifier. There is zero or one key action associated with each keysym bound to
+each key.
+</para>
+
+
+<para>
+Just as the entire list of key symbols for the keyboard mapping is held in the
+<emphasis>
+syms</emphasis>
+ field of the client map, the entire list of key actions for the keyboard
+mapping is held in the <emphasis>
+acts</emphasis>
+ array of the server map. The total size of <emphasis>
+acts</emphasis>
+ is specified by <emphasis>
+size_acts</emphasis>
+, and the number of entries is specified by <emphasis>
+num_acts</emphasis>.
+</para>
+
+
+<para>
+The <emphasis>
+key_acts</emphasis>
+ array, indexed by keycode, describes the actions associated with a key. The
+<emphasis>
+key_acts</emphasis>
+ array has <emphasis>
+min_key_code</emphasis>
+ unused entries at the start to allow direct indexing using a keycode. If a
+<emphasis>
+key_acts</emphasis>
+ entry is <emphasis>
+zero</emphasis>
+, it means the key does not have any actions associated with it. If an entry is
+not <emphasis>
+zero</emphasis>
+, the entry represents an index into the <emphasis>
+acts</emphasis>
+ field of the server map, much as the <emphasis>
+offset</emphasis>
+ field of a <emphasis>
+KeySymMapRec</emphasis>
+ structure is an index into the <emphasis>
+syms</emphasis>
+ field of the client map.
+</para>
+
+<para>
+The reason the <emphasis>
+acts</emphasis>
+ field is a linear list of <emphasis>
+XkbAction</emphasis>
+s is to reduce the memory consumption associated with a keymap. Because Xkb
+allows individual keys to have multiple shift levels and a different number of
+groups per key, a single two-dimensional array of <emphasis>
+KeySyms</emphasis>
+ would potentially be very large and sparse. Instead, Xkb provides a small
+two-dimensional array of <emphasis>
+XkbAction</emphasis>
+s for each key. To store all of these individual arrays, Xkb concatenates each
+array together in the <emphasis>
+acts</emphasis>
+ field of the server map.
+</para>
+
+
+<para>
+The key action structures consist only of fields of type char or unsigned char.
+This is done to optimize data transfer when the server sends bytes over the
+wire. If the fields are anything but bytes, the server has to sift through all
+of the actions and swap any nonbyte fields. Because they consist of nothing but
+bytes, it can just copy them out.
+</para>
+
+
+<para>
+Xkb provides the following macros, to simplify accessing information pertaining
+to key actions:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbKeyHasActions</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyHasActions</emphasis>
+ returns <emphasis>
+True</emphasis>
+ if the key corresponding to <emphasis>
+keycode</emphasis>
+ has any actions associated with it; otherwise, it returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyNumActions</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyNumActions</emphasis>
+ computes the number of actions associated with the key corresponding to
+<emphasis>
+keycode</emphasis>
+. This should be the same value as the result of <emphasis>
+XkbKeyNumSyms</emphasis>
+ (see section 15.3.3).
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbKeyActionPtr <emphasis>
+XkbKeyActionsPtr</emphasis>
+(<emphasis>
+xkb, keycode</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyActionsPtr</emphasis>
+ returns a pointer to the two-dimensional array of key actions associated with
+the key corresponding to <emphasis>
+keycode</emphasis>
+. Use<emphasis>
+ XkbKeyActionsPtr</emphasis>
+ only if the key actually has some actions associated with it, that is,
+<emphasis>
+XkbKeyNumActions</emphasis>
+(xkb, keycode) returns something greater than zero.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbAction <emphasis>
+XkbKeyAction</emphasis>
+(<emphasis>
+xkb, keycode, idx</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+idx</emphasis>
+; /* index for group and shift level */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyAction</emphasis>
+ returns the key action indexed by <emphasis>
+idx</emphasis>
+ in the two-dimensional array of key actions associated with the key
+corresponding to <emphasis>
+keycode</emphasis>
+. <emphasis>
+idx</emphasis>
+ may be computed from the group and shift level of interest as follows:
+</para>
+
+<literallayout>
+ idx = group_index * key_width + shift_level
+</literallayout>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbAction <emphasis>
+XkbKeyActionEntry</emphasis>
+(<emphasis>
+xkb, keycode, shift, grp</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+keycode</emphasis>
+; /* keycode of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+shift</emphasis>
+; /* shift level within group */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+grp</emphasis>
+; /* group index for group of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyActionEntry</emphasis>
+ returns the key action corresponding to group <emphasis>
+grp</emphasis>
+ and shift level <emphasis>
+lvl</emphasis>
+ from the two-dimensional table of key actions associated with the key
+corresponding to <emphasis>
+keycode</emphasis>
+.
+</para>
+
+
+<sect2 id='the_xkbaction_structure'>
+<title>The XkbAction Structure</title>
+
+<para>
+The description for an action is held in an <emphasis>
+XkbAction</emphasis>
+ structure, which is a union of all possible Xkb action types:
+</para>
+
+<para><programlisting>
+typedef union _XkbAction {
+ XkbAnyAction any;
+ XkbModAction mods;
+ XkbGroupAction group;
+ XkbISOAction iso;
+ XkbPtrAction ptr;
+ XkbPtrBtnAction btn;
+ XkbPtrDfltAction dflt;
+ XkbSwitchScreenAction screen;
+ XkbCtrlsAction ctrls;
+ XkbMessageAction msg;
+ XkbRedirectKeyAction redirect;
+ XkbDeviceBtnAction devbtn;
+ XkbDeviceValuatorAction devval;
+ unsigned char type;
+} <emphasis>XkbAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field is provided for convenience and is the same as the type field in the
+individual structures. The following sections describe the individual
+structures for each action in detail.
+</para>
+
+
+</sect2>
+<sect2 id='the_xkbanyaction_structure'>
+<title>The XkbAnyAction Structure</title>
+
+<para>
+The <emphasis>
+XkbAnyAction</emphasis>
+ structure is a convenience structure that refers to any of the actions:
+</para>
+
+<para><programlisting>
+#define XkbAnyActionDataSize 7
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbAnyAction {
+ unsigned char type; /* type of action; determines interpretation for data */
+ unsigned char data[XkbAnyActionDataSize];
+} <emphasis>XkbAnyAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+data</emphasis>
+ field represents a structure for an action, and its interpretation depends on
+the <emphasis>
+type</emphasis>
+ field. The valid values for the <emphasis>
+type</emphasis>
+ field, and the data structures associated with them are shown in Table 16.1:
+</para>
+
+<table frame='none'>
+<title>Action Types</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Structure for Data</entry>
+ <entry>XkbAction Union Member</entry>
+ <entry>Section</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_NoAction</emphasis></entry>
+ <entry>
+<emphasis>XkbSA_NoAction</emphasis>
+ means the server does not perform an action for the key; this action does not
+have an associated data structure.
+ </entry>
+ <entry>any</entry>
+ <entry></entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XkbSA_SetMods</emphasis></para>
+<para><emphasis>XkbSA_LatchMods</emphasis></para>
+<para><emphasis>XkbSA_LockMods</emphasis></para>
+ </entry>
+ <entry><para><emphasis>XkbModAction</emphasis></para></entry>
+ <entry>mods</entry>
+ <entry>16.1.3</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XkbSA_SetGroup</emphasis></para>
+<para><emphasis>XkbSA_LatchGroup</emphasis></para>
+<para><emphasis>XkbSA_LockGroup</emphasis></para>
+ </entry>
+ <entry><emphasis>XkbGroupAction</emphasis></entry>
+ <entry>group</entry>
+ <entry>16.1.4</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_MovePtr</emphasis></entry>
+ <entry><emphasis>XkbPtrAction</emphasis></entry>
+ <entry>ptr</entry>
+ <entry>16.1.5</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XKbSA_PtrBtn</emphasis></para>
+<para><emphasis>XkbSA_LockPtrBtn</emphasis></para>
+ </entry>
+ <entry><emphasis>XkbPtrBtnAction</emphasis></entry><entry>btn</entry>
+ <entry>16.1.6</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetPtrDflt</emphasis></entry>
+ <entry><emphasis>XkbPtrDfltAction</emphasis></entry>
+ <entry>dflt</entry>
+ <entry>16.1.7</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISOLock</emphasis></entry>
+ <entry><emphasis>XkbISOAction</emphasis></entry>
+ <entry>iso</entry>
+ <entry>16.1.8</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SwitchScreen</emphasis></entry>
+ <entry><emphasis>XkbSwitchScreenAction</emphasis></entry>
+ <entry>screen</entry>
+ <entry>16.1.9</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XkbSA_SetControls</emphasis></para>
+<para><emphasis>XkbSA_LockControls</emphasis></para>
+ </entry>
+ <entry><emphasis>XkbCtrlsAction</emphasis></entry>
+ <entry>ctrls</entry>
+ <entry>16.1.10</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ActionMessage</emphasis></entry>
+ <entry><emphasis>XkbMessgeAction</emphasis></entry>
+ <entry>msg</entry>
+ <entry>16.1.11</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_RedirectKey</emphasis></entry>
+ <entry><emphasis>XkbRedirectKeyAction</emphasis></entry>
+ <entry>redirect</entry>
+ <entry>16.1.12</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>
+<para><emphasis>XkbSA_DeviceBtn</emphasis></para>
+<para><emphasis>XKbSA_LockDeviceBtn</emphasis></para>
+ </entry>
+ <entry><emphasis>XkbDeviceBtnAction</emphasis></entry>
+ <entry>devbtn</entry>
+ <entry>16.1.13</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_DeviceValuator</emphasis></entry>
+ <entry><emphasis>XkbDeviceValuatorAction</emphasis></entry>
+ <entry>devval</entry>
+ <entry>16.1.14</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect2>
+<sect2 id='actions_for_changing_modifiers_state'>
+<title>Actions for Changing Modifiers’ State</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbModAction</emphasis>
+ structure change the state of the modifiers when keys are pressed and released
+(see Chapter 7 for a discussion of modifiers):
+</para>
+
+<para><programlisting>
+typedef struct _XkbModAction {
+ unsigned char type; /* <emphasis> XkbSA_{Set|Latch|Lock}Mods</emphasis> */
+ unsigned char flags; /* with <emphasis> type</emphasis> , controls the effect on modifiers */
+ unsigned char mask; /* same as <emphasis> mask</emphasis> field of a modifier description */
+ unsigned char real_mods; /* same as <emphasis> real_mods</emphasis> field of a modifier description */
+ unsigned char vmods1; /* derived from <emphasis> vmods</emphasis> field of a modifier description */
+ unsigned char vmods2; /* derived from <emphasis> vmods</emphasis> field of a modifier description */
+} <emphasis>XkbModAction</emphasis>;
+</programlisting></para>
+
+<para>
+In the following description, the term <emphasis>
+action modifiers</emphasis>
+ means the real modifier bits associated with this action. Depending on the
+value of <emphasis>
+flags</emphasis>
+ (see Table 16.3), these are designated either in the <emphasis>
+mask</emphasis>
+ field of the <emphasis>
+XkbModAction</emphasis>
+ structure itself or the real modifiers bound to the key for which the action
+is being used. In the latter case, this is the client <emphasis>
+map</emphasis>
+-&gt;<emphasis>
+modmap</emphasis>
+[<emphasis>
+keycode</emphasis>
+] field.
+</para>
+
+
+<para>
+The <emphasis>
+type</emphasis>
+ field can have any of the values shown in Table 16.2.
+</para>
+
+<table frame='none'>
+<title>Modifier Action Types</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetMods</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+A key press adds any action modifiers to the keyboard’s base modifiers.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A key release clears any action modifiers in the keyboard’s base modifiers,
+provided no other key affecting the same modifiers is logically down.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If no other keys are physically depressed when this key is released, and
+<emphasis>
+XkbSA_ClearLocks</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, the key release unlocks any action modifiers.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LatchMods</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+Key press and key release events have the same effect as for <emphasis>
+XkbSA_SetMods</emphasis>
+; if no keys are physically depressed when this key is released, key release
+events have the following additional effects:
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Modifiers unlocked due to <emphasis>
+XkbSA_ClearLocks</emphasis>
+ have no further effect.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If <emphasis>
+XkbSA_LatchToLock</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, a key release locks and then unlatches any remaining action modifiers
+that are already latched.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A key release latches any action modifiers not used by the <emphasis>
+XkbSA_ClearLocks</emphasis>
+ and <emphasis>
+XkbSA_LatchToLock</emphasis>
+ flags.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockMods</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+A key press sets the base state of any action modifiers. If <emphasis>
+XkbSA_LockNoLock</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, a key press also sets the locked state of any action modifiers.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A key release clears any action modifiers in the keyboard’s base modifiers,
+provided no other key that affects the same modifiers is down. If <emphasis>
+XkbSA_LockNoUnlock</emphasis>
+ is not set in the <emphasis>
+flags</emphasis>
+ field, and any of the action modifiers were locked before the corresponding
+key press occurred, a key release unlocks them.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.3. A general meaning is given in the table, but the exact meaning depends on
+the action <emphasis>type</emphasis>.
+</para>
+
+<table frame='none'>
+<title>Modifier Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_UseModMapMods</emphasis></entry>
+ <entry>
+If set, the action modifiers are determined by the modifiers bound by the
+modifier mapping of the key. Otherwise, the action modifiers are set to the
+modifiers specified by the <emphasis>
+mask</emphasis>
+, <emphasis>
+real_mods</emphasis>
+, <emphasis>
+vmod1</emphasis>
+, and <emphasis>
+vmod2</emphasis>
+ fields.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ClearLocks</emphasis></entry>
+ <entry>
+If set and no keys are physically depressed when this key transition
+occurs, the server unlocks any action modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LatchToLock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LatchMods</emphasis>
+, the server locks the action modifiers if they are already latched.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoLock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockMods</emphasis>
+, the server only unlocks the action modifiers.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoUnlock</emphasis></entry>
+ <entry>
+If set, and the action is <emphasis>
+XkbSA_LockMods</emphasis>
+, the server only locks the action modifiers.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+If <emphasis>
+XkbSA_UseModMapMods</emphasis>
+ is not set in the <emphasis>
+flags</emphasis>
+ field, the <emphasis>
+mask</emphasis>
+, <emphasis>
+real_mods</emphasis>
+, <emphasis>
+vmods1</emphasis>
+, and <emphasis>
+vmods2 </emphasis>
+fields are used to determine the action modifiers. Otherwise they are ignored
+and the modifiers bound to the key (client <emphasis>
+map</emphasis>
+-&gt;<emphasis>
+modmap</emphasis>
+[<emphasis>
+keycode</emphasis>
+]) are used instead.
+</para>
+
+
+<para>
+The <emphasis>
+mask</emphasis>
+, <emphasis>
+real_mods</emphasis>
+, <emphasis>
+vmods1</emphasis>
+, and <emphasis>
+vmods2</emphasis>
+ fields represent the components of an Xkb modifier description (see section
+7.2). While the <emphasis>
+mask</emphasis>
+ and <emphasis>
+real_mods</emphasis>
+ fields correspond directly to the <emphasis>
+mask</emphasis>
+ and <emphasis>
+real_mods</emphasis>
+ fields of an Xkb modifier description, the <emphasis>
+vmods1</emphasis>
+ and <emphasis>
+vmods2</emphasis>
+ fields are combined to correspond to the <emphasis>
+vmods</emphasis>
+ field of an Xkb modifier description. Xkb provides the following macros, to
+convert between the two formats:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned short <emphasis>
+XkbModActionVMods</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbAction <emphasis>
+act</emphasis>
+; /* action from which to extract virtual mods */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbModActionVMods</emphasis>
+ returns the <emphasis>
+vmods1</emphasis>
+ and <emphasis>
+vmods2</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ converted to the <emphasis>
+vmods</emphasis>
+ format of an Xkb modifier description.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSetModActionVMods</emphasis>
+(<emphasis>
+act, vmods</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbAction <emphasis>
+act</emphasis>
+; /* action in which to set vmods */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned short <emphasis>
+vmods</emphasis>
+; /* virtual mods to set */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetModActionVMods</emphasis>
+ sets the <emphasis>
+vmods1</emphasis>
+ and <emphasis>
+vmods2</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ using the <emphasis>
+vmods</emphasis>
+ format of an Xkb modifier description.
+</para>
+
+<note><para>Despite the fact that the first parameter of these two macros is of
+type XkbAction, these macros may be used only with Actions of type <emphasis>
+XkbModAction</emphasis>
+ and <emphasis>
+XkbISOAction</emphasis>
+.</para></note>
+
+
+</sect2>
+<sect2 id='actions_for_changing_group_state'>
+<title>Actions for Changing Group State</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbGroupAction</emphasis>
+ structure change the current group state when keys are pressed and released
+(see Chapter 5 for a description of groups and keyboard state):
+</para>
+
+<para><programlisting>
+typedef struct _XkbGroupAction {
+ unsigned char type; /* <emphasis> XkbSA_{Set|Latch|Lock}Group</emphasis> */
+ unsigned char flags; /* with <emphasis> type</emphasis> , controls the effect on groups */
+ char group_XXX; /* represents a group index or delta */
+} <emphasis>XkbGroupAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field can have any of the following values:
+</para>
+
+<table frame='none'>
+<title>Group Action Types</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetGroup</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If the <emphasis>
+XkbSA_GroupAbsolute</emphasis>
+ bit is set in the <emphasis>
+flags</emphasis>
+ field, key press events change the base keyboard group to the group specified
+by the <emphasis>
+group_XXX</emphasis>
+ field. Otherwise, key press events change the base keyboard group by adding
+the <emphasis>
+group_XXX</emphasis>
+ field to the base keyboard group. In either case, the resulting effective
+keyboard group is brought back into range depending on the value of the
+<emphasis>
+groups_wrap</emphasis>
+ field of the controls structure (see section 10.7.1).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If a key with an <emphasis>
+XkbSA_ISOLock</emphasis>
+ action (see section 16.1.8) is pressed while this key is down, the key release
+of this key has no effect. Otherwise, the key release cancels the effects of
+the key press.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If the <emphasis>
+XkbSA_ClearLocks</emphasis>
+ bit is set in the flags field, and no keys are physically depressed when this
+key is released, the key release also sets the locked keyboard group to
+<emphasis>
+Group1</emphasis>
+.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LatchGroup</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+Key press and key release events have the same effect as for <emphasis>
+XkbSA_SetGroup</emphasis>
+; if no keys are physically depressed when this key is released, key release
+events have the following additional effects.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If the <emphasis>
+XkbSA_LatchToLock</emphasis>
+ bit is set in the <emphasis>
+flags</emphasis>
+ field and the latched keyboard group index is nonzero, the key release adds
+the delta applied by the corresponding key press to the locked keyboard group
+and subtracts it from the latched keyboard group. The locked and effective
+keyboard group are brought back into range according to the value of the
+<emphasis>
+groups_wrap</emphasis>
+ field of the controls structure.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Otherwise, the key press adds the key press delta to the latched keyboard group.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockGroup</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If the <emphasis>
+XkbSA_GroupAbsolute</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, key press events set the locked keyboard group to the group specified
+by the <emphasis>
+group_XXX</emphasis>
+ field. Otherwise, key press events add the group specified by the <emphasis>
+group_XXX</emphasis>
+ field to the locked keyboard group. In either case, the resulting locked and
+effective keyboard groups are brought back into range depending on the value of
+the <emphasis>
+groups_wrap</emphasis>
+ field of the controls structure.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A key release has no effect.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.5. A general meaning is given in the table, but the exact meaning depends on
+the action <emphasis>
+type</emphasis>
+.
+</para>
+
+<table frame='none'>
+<title>Group Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ClearLocks</emphasis></entry>
+ <entry>
+If set and no keys are physically depressed when this key transition occurs,
+the server sets the locked keyboard group to <emphasis>
+Group1</emphasis>
+ on a key release.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LatchToLock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+SA_LatchGroup</emphasis>
+, the server locks the action group if it is already latched.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_GroupAbsolute</emphasis></entry>
+ <entry>
+If set, the <emphasis>
+group_XXX</emphasis>
+ field represents an absolute group number. Otherwise, it represents a group
+delta to be added to the current group to determine the new group number.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+group_XXX</emphasis>
+ field represents a signed character. Xkb provides the following macros to
+convert between a signed integer value and a signed character:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbSAGroup</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbAction <emphasis>
+act</emphasis>
+; /* action from which to extract group */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSAGroup</emphasis>
+ returns the <emphasis>
+group_XXX</emphasis>
+ field of <emphasis>
+act</emphasis>
+ converted to a signed int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSASetGroup</emphasis>
+(<emphasis>
+act, grp</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbAction <emphasis>
+act</emphasis>
+; /* action from which to set group */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+grp</emphasis>
+; /* group index to set in <emphasis>
+group_XXX</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSASetGroup</emphasis>
+ sets the <emphasis>
+group_XXX</emphasis>
+ field of <emphasis>
+act</emphasis>
+ from the group index <emphasis>
+grp</emphasis>
+.
+</para>
+
+<note><para>Despite the fact that the first parameter of these two macros is of
+type XkbAction, these macros may only be used with Actions of type <emphasis>
+XkbGroupAction</emphasis>
+ and <emphasis>
+XkbISOAction</emphasis>
+.</para></note>
+
+
+</sect2>
+<sect2 id='actions_for_moving_the_pointer'>
+<title>Actions for Moving the Pointer</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbPtrAction</emphasis>
+ structure move the pointer when keys are pressed and released:
+</para>
+
+<para><programlisting>
+typedef struct _XkbPtrAction {
+ unsigned char type; /* <emphasis> XkbSA_MovePtr</emphasis> */
+ unsigned char flags; /* determines type of pointer motion */
+ unsigned char high_XXX; /* x coordinate, high bits*/
+ unsigned char low_XXX; /* y coordinate, low bits */
+ unsigned char high_YYY; /* x coordinate, high bits */
+ unsigned char low_YYY; /* y coordinate, low bits */
+} <emphasis>XkbPtrAction</emphasis>;
+</programlisting></para>
+
+<para>
+If the <emphasis>
+MouseKeys</emphasis>
+ control is not enabled (see section 10.5.1), <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events are treated as though the action is <emphasis>
+XkbSA_NoAction</emphasis>.
+</para>
+
+<para>
+If the <emphasis>
+MouseKeys</emphasis>
+ control is enabled, a server action of type <emphasis>
+XkbSA_MovePtr</emphasis>
+ instructs the server to generate core pointer <emphasis>
+MotionNotify</emphasis>
+ events rather than the usual <emphasis>
+KeyPress</emphasis>
+ event, and the corresponding <emphasis>
+KeyRelease</emphasis>
+ event disables any mouse keys timers that were created as a result of handling
+the <emphasis>
+XkbSA_MovePtr</emphasis>
+ action.
+</para>
+
+
+<para>
+The <emphasis>
+type</emphasis>
+ field of the <emphasis>
+XkbPtrAction</emphasis>
+ structure is always <emphasis>
+XkbSA_MovePtr</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is a bitwise inclusive OR of the masks shown in Table 16.6.
+</para>
+
+<table frame='none'>
+<title>Pointer Action Types</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Action Type</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_NoAcceleration</emphasis></entry>
+ <entry>
+If not set, and the <emphasis>
+MouseKeysAccel</emphasis>
+ control is enabled (see section 10.5.2), the <emphasis>
+KeyPress</emphasis>
+ initiates a mouse keys timer for this key; every time the timer expires, the
+cursor moves.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_MoveAbsoluteX</emphasis></entry>
+ <entry>If set, the X portion of the structure specifies the new pointer X
+coordinate. Otherwise, the X portion is added to the current pointer X
+coordinate to determine the new pointer X coordinate.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_MoveAbsoluteY</emphasis></entry>
+ <entry>
+If set, the Y portion of the structure specifies the new
+pointer Y coordinate. Otherwise, the Y portion is added
+to the current pointer Y coordinate to determine the new pointer Y coordinate.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Each of the X and Y coordinantes of the <emphasis>
+XkbPtrAction</emphasis>
+ structure is composed of two signed 16-bit values, that is, the X coordinate
+is composed of <emphasis>
+high_XXX</emphasis>
+ and <emphasis>
+low_XXX</emphasis>
+, and similarly for the Y coordinate. Xkb provides the following macros, to
+convert between a signed integer and two signed 16-bit values in <emphasis>
+XkbPtrAction</emphasis>
+ structures:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbPtrActionX</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbPtrAction <emphasis>
+act</emphasis>
+; /* action from which to extract X */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbPtrActionX</emphasis>
+ returns the <emphasis>
+high_XXX</emphasis>
+ and <emphasis>
+low_XXX</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ converted to a signed int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbPtrActionY</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbPtrAction <emphasis>
+act</emphasis>
+; /* action from which to extract Y */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbPtrActionY</emphasis>
+ returns the <emphasis>
+high_YYY</emphasis>
+ and <emphasis>
+low_YYY</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ converted to a signed int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSetPtrActionX</emphasis>
+(<emphasis>
+act</emphasis>
+, <emphasis>
+x</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbPtrAction <emphasis>
+act</emphasis>
+; /* action in which to set X */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+x; </emphasis>
+ /* new value to set */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetPtrActionX</emphasis>
+ sets the <emphasis>
+high_XXX</emphasis>
+ and <emphasis>
+low_XXX</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ from the signed integer value <emphasis>
+x</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSetPtrActionY</emphasis>
+(<emphasis>
+act, y</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbPtrAction <emphasis>
+act</emphasis>
+; /* action in which to set Y */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+y</emphasis>
+; /* new value to set */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetPtrActionX</emphasis>
+ sets the <emphasis>
+high_YYY</emphasis>
+ and <emphasis>
+low_YYY</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ from the signed integer value <emphasis>
+y</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='actions_for_simulating_pointer_button_press_and_release'>
+<title>Actions for Simulating Pointer Button Press and Release</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbPtrBtnAction</emphasis>
+ structure simulate the press and release of pointer buttons when keys are
+pressed and released:
+</para>
+
+<para><programlisting>
+typedef struct _XkbPtrBtnAction {
+ unsigned char type; /*<emphasis> XkbSA_PtrBtn, XkbSA_LockPtrBtn</emphasis> */
+ unsigned char flags; /* with <emphasis> type</emphasis> , controls the effect on pointer buttons*/
+ unsigned char count; /* controls number of ButtonPress and ButtonRelease events */
+ unsigned char button; /* pointer button to simulate */
+} <emphasis>XkbPtrBtnAction</emphasis>;
+</programlisting></para>
+
+<para>
+If the <emphasis>
+MouseKeys</emphasis>
+ (see section 10.5.1) control is not enabled, <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events are treated as though the action is <emphasis>
+XkbSA_NoAction</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+type</emphasis>
+ field can have any one of the values shown in Table 16.7.
+</para>
+
+<table frame='none'>
+<title>Pointer Button Action Types</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_PtrBtn</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If<emphasis>
+ XkbSA_UseDfltButton</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, the event is generated for the pointer button specified by the
+<emphasis>
+mk_dflt_btn</emphasis>
+ attribute of the <emphasis>
+MouseKeys</emphasis>
+ control (see section 10.5.1). Otherwise, the event is generated for the button
+specified by the <emphasis>
+button</emphasis>
+ field.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If the mouse button specified for this action is logically down, the key press
+and corresponding key release are ignored and have no effect. Otherwise, a key
+press causes one or more core pointer button events instead of the usual
+<emphasis>
+KeyPress</emphasis>
+ event. If <emphasis>
+count</emphasis>
+ is <emphasis>
+zero</emphasis>
+, a key press generates a single <emphasis>
+ButtonPress</emphasis>
+ event; if <emphasis>
+count</emphasis>
+ is greater than <emphasis>
+zero</emphasis>
+, a key press generates <emphasis>
+count</emphasis>
+ pairs of <emphasis>
+ButtonPress</emphasis>
+ and <emphasis>
+ButtonRelease</emphasis>
+ events.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If <emphasis>
+count</emphasis>
+ is <emphasis>
+zero</emphasis>
+, a key release generates a core pointer <emphasis>
+ButtonRelease</emphasis>
+ that matches the event generated by the corresponding <emphasis>
+KeyPress</emphasis>
+; if <emphasis>
+count</emphasis>
+ is nonzero, a key release does not cause a <emphasis>
+ButtonRelease</emphasis>
+ event. A key release never generates a key <emphasis>
+KeyRelease</emphasis>
+ event.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockPtrBtn</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If the button specified by the <emphasis>
+MouseKeys</emphasis>
+ default button<emphasis>
+ </emphasis>
+or <emphasis>
+button</emphasis>
+ is not locked, a key press causes a <emphasis>
+ButtonPress</emphasis>
+ event instead of a <emphasis>
+KeyPress</emphasis>
+ event and locks the button. If the button is already locked or if <emphasis>
+XkbSA_LockNoUnlock</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, a key press is ignored and has no effect.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If the corresponding key press was ignored, and if <emphasis>
+XkbSA_LockNoLock</emphasis>
+ is not set in the <emphasis>
+flags</emphasis>
+ field, a key release generates a <emphasis>
+ButtonRelease</emphasis>
+ event instead of a <emphasis>
+KeyRelease</emphasis>
+ event and unlocks the specified button. If the corresponding key press locked
+a button, the key release is ignored and has no effect.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.8. A general meaning is given in the table, but the exact meaning depends on
+the action <emphasis>
+type.</emphasis>
+:
+</para>
+
+<table frame='none'>
+<title>Pointer Button Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_UseDfltButton</emphasis></entry>
+ <entry>
+If set, the action uses the pointer button specified by the <emphasis>
+mk_dflt_btn</emphasis>
+ attribute of the <emphasis>
+MouseKeys</emphasis>
+ control (see section 10.5.1). Otherwise, the action uses the pointer button
+specified by the<emphasis>
+ button </emphasis>
+field.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoLock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockPtrBtn</emphasis>
+, the server only unlocks the pointer button.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoUnlock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockPtrBtn</emphasis>
+, the server only locks the pointer button.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect2>
+<sect2 id='actions_for_changing_the_pointer_button_simulated'>
+<title>Actions for Changing the Pointer Button Simulated</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbPtrDfltAction</emphasis>
+ structure change the <emphasis>
+mk_dflt_btn</emphasis>
+ attribute of the <emphasis>
+MouseKeys</emphasis>
+ control (see section 10.5.1):
+</para>
+
+<para><programlisting>
+typedef struct _XkbPtrDfltAction {
+ unsigned char type; /* <emphasis> XkbSA_SetPtrDflt</emphasis> */
+ unsigned char flags; /* controls the pointer button number */
+ unsigned char affect; /* <emphasis> XkbSA_AffectDfltBtn</emphasis> */
+ char valueXXX; /* new default button member */
+} <emphasis>XkbPtrDfltAction</emphasis>;
+</programlisting></para>
+
+<para>
+If the <emphasis>
+MouseKeys</emphasis>
+ control is not enabled, <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events are treated as though the action is <emphasis>
+XkbSA_NoAction</emphasis>
+. Otherwise, this action changes the <emphasis>
+mk_dflt_btn</emphasis>
+ attribute of the <emphasis>
+MouseKeys</emphasis>
+ control.
+</para>
+
+
+<para>
+The <emphasis>
+type</emphasis>
+ field of the <emphasis>
+XkbPtrDfltAction</emphasis>
+ structure should always be <emphasis>
+XkbSA_SetPtrDflt</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the values shown in Table
+16.9 (currently there is only one value defined).
+</para>
+
+<table frame='none'>
+<title>Pointer Default Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_DfltBtnAbsolute</emphasis></entry>
+ <entry>
+If set, the <emphasis>
+value</emphasis>
+ field represents an absolute pointer button. Otherwise, the <emphasis>
+value</emphasis>
+ field represents the amount to be added to the current default button.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+affect</emphasis>
+ field specifies what changes as a result of this action. The only valid value
+for the <emphasis>
+affect</emphasis>
+ field is <emphasis>XkbSA_AffectDfltBtn</emphasis>.
+</para>
+
+<para>
+The <emphasis>
+valueXXX</emphasis>
+ field is a signed character that represents the new button value for the
+<emphasis>
+mk_dflt_btn</emphasis>
+ attribute of the <emphasis>
+MouseKeys</emphasis>
+ control (see section 10.5.1). If <emphasis>
+XkbSA_DfltBtnAbsolute</emphasis>
+ is set in <emphasis>
+flags</emphasis>
+, <emphasis>
+valueXXX</emphasis>
+ specifies the button to be used; otherwise, <emphasis>
+valueXXX</emphasis>
+ specifies the amount to be added to the current default button. In either
+case, illegal button choices are wrapped back around into range. Xkb provides
+the following macros, to convert between the integer and signed character
+values in <emphasis>
+XkbPtrDfltAction</emphasis>
+ structures:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbSAPtrDfltValue</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbAction <emphasis>
+act</emphasis>
+; /* action from which to extract group */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSAPtrDfltValue</emphasis>
+ returns the <emphasis>
+valueXXX</emphasis>
+ field of <emphasis>
+act</emphasis>
+ converted to a signed int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSASetPtrDfltValue</emphasis>
+(<emphasis>
+act, val</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbPtrDfltAction <emphasis>
+act</emphasis>
+; /* action in which to set <emphasis>
+valueXXX</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+val</emphasis>
+; /* value to set in <emphasis>
+valueXXX</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSASetPtrDfltValue</emphasis>
+ sets the <emphasis>
+valueXXX</emphasis>
+ field of <emphasis>
+act</emphasis>
+ from <emphasis>
+val</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='actions_for_locking_modifiers_and_group'>
+<title>Actions for Locking Modifiers and Group</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbISOAction</emphasis>
+ structure lock modifiers and the group according to the ISO9995 specification.
+</para>
+
+
+<para>
+Operated by itself, the <emphasis>
+XkbISOAction</emphasis>
+ is just a caps lock. Operated simultaneously with another modifier key, it
+transforms the other key into a locking key. For example, press <emphasis>
+ISO_Lock</emphasis>
+, press and release <emphasis>
+Control_L</emphasis>
+, release <emphasis>
+ISO_Lock</emphasis>
+ ends up locking the <emphasis>
+Control</emphasis>
+ modifier.
+</para>
+
+
+<para>
+The default behavior is to convert:
+</para>
+
+<literallayout>
+ {Set,Latch}Mods to: LockMods
+ {Set,Latch}Group to: LockGroup
+ SetPtrBtn to: LockPtrBtn
+ SetControls to: LockControls
+</literallayout>
+
+<para>
+The <emphasis>
+affects</emphasis>
+ field allows you to turn those effects on or off individually. Set <emphasis>
+XkbSA_ISONoAffectMods</emphasis>
+ to disable the first, <emphasis>
+XkbSA_ISONoAffectGroup</emphasis>
+ to disable the second, and so forth.
+</para>
+
+<para><programlisting>
+typedef struct _XkbISOAction {
+ unsigned char type; /* <emphasis>XkbSA_ISOLock</emphasis> */
+ unsigned char flags; /* controls changes to group or modifier state */
+ unsigned char mask; /* same as <emphasis>mask</emphasis> field of a modifier description */
+ unsigned char real_mods; /* same as <emphasis>real_mods</emphasis> field of a modifier description */
+ char group_XXX; /* group index or delta group */
+ unsigned char affect; /* specifies whether to affect mods, group, ptrbtn, or controls*/
+ unsigned char vmods1; /* derived from <emphasis>vmods</emphasis> field of a modifier description */
+ unsigned char vmods2; /* derived from <emphasis>vmods</emphasis> field of a modifier description */
+} <emphasis>XkbISOAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field of the <emphasis>
+XkbISOAction</emphasis>
+ structure should always be <emphasis>
+XkbSA_ISOLock</emphasis>
+.
+</para>
+
+
+<para>
+The interpretation of the <emphasis>
+flags</emphasis>
+ field depends on whether the <emphasis>
+XkbSA_ISODfltIsGroup</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field or not.
+</para>
+
+
+<para>
+If the <emphasis>
+XkbSA_ISODfltIsGroup</emphasis>
+ is set in the <emphasis>
+flags</emphasis>
+ field, the action is used to change the group state. The remaining valid bits
+of the <emphasis>
+flags</emphasis>
+ field are composed of a bitwise inclusive OR using the masks shown in Table
+16.10.
+</para>
+
+<table frame='none'>
+<title>ISO Action Flags when XkbSA_ISODfltIsGroup is Set</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISODfltIsGroup</emphasis></entry>
+ <entry>
+ <para>
+If set, the action is used to change the base group state. Must be set for the
+remaining bits in this table to carry their interpretations.
+ </para>
+ <para>
+A key press sets the base group as specified by the <emphasis>
+group_XXX</emphasis>
+ field and the <emphasis>
+XkbSA_GroupAbsolute</emphasis>
+ bit of the <emphasis>
+flags</emphasis>
+ field (see section Note). If no other actions are transformed by the <emphasis>
+XkbISO_Lock</emphasis>
+ action, a key release locks the group. Otherwise, a key release clears group
+set by the key press.
+ </para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_GroupAbsolute</emphasis></entry>
+ <entry>
+If set, the <emphasis>
+group_XXX</emphasis>
+ field represents an absolute group number. Otherwise, it represents a group
+delta to be added to the current group to determine the new group number.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectMods</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_SetMods</emphasis>
+ or <emphasis>
+XkbSA_LatchMods</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockMod</emphasis>
+ actions instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectGroup</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_SetGroup</emphasis>
+ or <emphasis>
+XkbSA_LatchGroup</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockGroup</emphasis>
+ actions instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectPtr</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_PtrBtn</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockPtrBtn</emphasis>
+ actions instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectCtrls</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_SetControls</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockControls</emphasis>
+ actions instead.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+If the <emphasis>
+XkbSA_ISODfltIsGroup</emphasis>
+ is not set in the <emphasis>
+flags</emphasis>
+ field, the action is used to change the modifier state and the remaining valid
+bits of the <emphasis>
+flags</emphasis>
+ field are composed of a bitwise inclusive OR using the masks shown in Table
+16.11.
+</para>
+
+<table frame='none'>
+<title>ISO Action Flags when XkbSA_ISODfltIsGroup is Not Set</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISODfltIsGroup</emphasis> </entry>
+ <entry>
+ <para>
+If not set, action is used to change the base modifier state. Must not be set
+for the remaining bits in this table to carry their interpretations.
+ </para>
+ <para>
+A key press sets the action modifiers in the keyboard’s base modifiers using
+the <emphasis>
+mask</emphasis>
+, <emphasis>
+real_mods</emphasis>
+, <emphasis>
+vmods1</emphasis>
+, and <emphasis>
+vmods2 </emphasis>
+fields (see section 16.1.3). If no other actions are transformed by the
+<emphasis>
+XkbISO_Lock</emphasis>
+ action, a key release locks the action modifiers. Otherwise, a key release
+clears the base modifiers set by the key press.
+ </para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_UseModMapMods</emphasis></entry>
+ <entry>
+If set, the action modifiers are determined by the modifiers bound by the
+modifier mapping of the key. Otherwise, the action modifiers are set to the
+modifiers specified by the <emphasis>
+mask</emphasis>
+, <emphasis>
+real_mods</emphasis>
+, <emphasis>
+vmod1</emphasis>
+, and <emphasis>
+vmod2</emphasis>
+ fields.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoLock</emphasis></entry>
+ <entry>If set, the server only unlocks the action modifiers.</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoUnlock</emphasis></entry>
+ <entry>If set, the server only locks the action modifiers. </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectMods</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_SetMods</emphasis>
+ or <emphasis>
+XkbSA_LatchMods</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockMod</emphasis>
+ actions instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectGroup</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_SetGroup</emphasis>
+ or <emphasis>
+XkbSA_LatchGroup</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockGroup</emphasis>
+ actions instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectPtr</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_PtrBtn</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockPtrBtn</emphasis>
+ actions instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectCtrls</emphasis></entry>
+ <entry>
+If not set, any <emphasis>
+XkbSA_SetControls</emphasis>
+ actions that occur simultaneously with the <emphasis>
+XkbSA_ISOLock</emphasis>
+ action are treated as <emphasis>
+XkbSA_LockControls</emphasis>
+ actions instead.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+group_XXX</emphasis>
+ field represents a signed character. Xkb provides macros to convert between a
+signed integer value and a signed character as shown in section Note.
+</para>
+
+
+<para>
+The <emphasis>
+mask</emphasis>
+, <emphasis>
+real_mods</emphasis>
+, <emphasis>
+vmods1</emphasis>
+, and <emphasis>
+vmods2</emphasis>
+ fields represent the components of an Xkb modifier description (see section
+7.2). While the <emphasis>
+mask</emphasis>
+ and <emphasis>
+real_mods</emphasis>
+ fields correspond directly to the <emphasis>
+mask</emphasis>
+ and <emphasis>
+real_mods</emphasis>
+ fields of an Xkb modifier description, the <emphasis>
+vmods1</emphasis>
+ and <emphasis>
+vmods2</emphasis>
+ fields are combined to correspond to the <emphasis>
+vmods</emphasis>
+ field of an Xkb modifier description. Xkb provides macros to convert between
+the two formats as shown in section 16.1.3.
+</para>
+
+
+<para>
+The <emphasis>
+affect</emphasis>
+ field is composed of a bitwise inclusive OR using the masks shown in Table
+16.11.
+</para>
+
+<table frame='none'>
+<title>ISO Action Affect Field Values</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Affect</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISODNoAffectMods</emphasis></entry>
+ <entry>
+If <emphasis>
+XkbSA_ISONoAffectMods</emphasis>
+ is not set, any <emphasis>
+SA_SetMods</emphasis>
+ or <emphasis>
+SA_LatchMods</emphasis>
+ actions occurring simultaneously with the <emphasis>
+XkbISOAction</emphasis>
+ are treated as <emphasis>
+SA_LockMods</emphasis>
+ instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectGroup</emphasis></entry>
+ <entry>
+If <emphasis>
+XkbSA_ISONoAffectGroup</emphasis>
+ is not set, any <emphasis>
+SA_SetGroup</emphasis>
+ or <emphasis>
+SA_LatchGroup</emphasis>
+ actions occurring simultaneously with the <emphasis>
+XkbISOAction</emphasis>
+ are treated as <emphasis>
+SA_LockGroup</emphasis>
+ instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectPtr</emphasis></entry>
+ <entry>
+If <emphasis>
+XkbSA_ISONoAffectPtr</emphasis>
+ is not set, any <emphasis>
+SA_PtrBtn</emphasis>
+ actions occurring simultaneously with the <emphasis>
+XkbISOAction</emphasis>
+ are treated as <emphasis>
+SA_LockPtrBtn</emphasis>
+ instead.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_ISONoAffectCtrls</emphasis></entry>
+ <entry>
+If <emphasis>
+XkbSA_ISONoAffectCtrls</emphasis>
+ is not set, any <emphasis>
+SA_SetControls</emphasis>
+ actions occurring simultaneously with the <emphasis>
+XkbISOAction</emphasis>
+ are treated as <emphasis>
+SA_LockControls</emphasis>
+ instead.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect2>
+<sect2 id='actions_for_changing_the_active_screen'>
+<title>Actions for Changing the Active Screen</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbSwitchScreen</emphasis>
+ action structure change the active screen on a multiscreen display:
+</para>
+
+<note><para>This action is optional. Servers are free to ignore the action or
+any of its flags if they do not support the requested behavior. If the action
+is ignored, it behaves like <emphasis>
+XkbSA_NoAction</emphasis>
+. Otherwise, key press and key release events do not generate an event.
+</para></note>
+
+<para><programlisting>
+typedef struct _XkbSwitchScreenAction {
+ unsigned char type; /* <emphasis> XkbSA_SwitchScreen</emphasis> */
+ unsigned char flags; /* controls screen switching */
+ char screenXXX; /* screen number or delta */
+} <emphasis>XkbSwitchScreenAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field of the <emphasis>
+XkbSwitchScreenAction</emphasis>
+ structure should always be <emphasis>
+XkbSA_SwitchScreen</emphasis>.
+</para>
+
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.13.
+</para>
+
+<table frame='none'>
+<title>Switch Screen Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SwitchAbsolute</emphasis></entry>
+ <entry>
+If set, the <emphasis>
+screenXXX</emphasis>
+ field represents the index of the new screen. Otherwise, it represents an
+offset from the current screen to the new screen.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SwitchApplication</emphasis></entry>
+ <entry>
+If not set, the action should switch to another screen on the same
+server. Otherwise, it should switch to another X server or application that
+shares the same physical display.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+screenXXX</emphasis>
+ field is a signed character value that represents either the relative or
+absolute screen index, depending on the state of the <emphasis>
+XkbSA_SwitchAbsolute</emphasis>
+ bit in the <emphasis>
+flags</emphasis>
+ field. Xkb provides the following macros to convert between the integer and
+signed character value for screen numbers in <emphasis>
+XkbSwitchScreenAction</emphasis>
+ structures:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbSAScreen</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSwitchScreenAction <emphasis>
+act</emphasis>
+; /* action from which to extract screen */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSAScreen</emphasis>
+ returns the <emphasis>
+screenXXX</emphasis>
+ field of <emphasis>
+act</emphasis>
+ converted to a signed int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSASetScreen</emphasis>
+(<emphasis>
+act, s</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSwitchScreenAction <emphasis>
+act</emphasis>
+; /* action in which to set <emphasis>
+screenXXX</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+s</emphasis>
+; /* value to set in <emphasis>
+screenXXX</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSASetScreen</emphasis>
+ sets the <emphasis>
+screenXXX</emphasis>
+ field of <emphasis>
+act</emphasis>
+ from <emphasis>
+s</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='actions_for_changing_boolean_controls_state'>
+<title>Actions for Changing Boolean Controls State</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbCtrlsAction</emphasis>
+ structure change the state of the boolean controls (see section 10.1):
+</para>
+
+<para><programlisting>
+typedef struct _XkbCtrlsAction {
+ unsigned char type; /* <emphasis> XkbSA_SetControls,
+ XkbSA_LockControls</emphasis> */
+ unsigned char flags; /* with <emphasis> type</emphasis>,
+ controls enabling and disabling of controls */
+ unsigned char ctrls3; /* <emphasis>ctrls0</emphasis> through
+ <emphasis> ctrls3</emphasis> represent the boolean controls */
+ unsigned char ctrls2; /* <emphasis>ctrls0</emphasis> through
+ <emphasis> ctrls3</emphasis> represent the boolean controls */
+ unsigned char ctrls1; /* <emphasis>ctrls0</emphasis> through
+ <emphasis> ctrls3</emphasis> represent the boolean controls */
+ unsigned char ctrls0; /* <emphasis>ctrls0</emphasis> through
+ <emphasis> ctrls3</emphasis> represent the boolean controls */
+} <emphasis>XkbCtrlsAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field can have any one of the values shown in Table 16.14.
+</para>
+
+<table frame='none'>
+<title>Controls Action Types</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetControls</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+A key press enables any boolean controls specified in the <emphasis>
+ctrls</emphasis>
+ fields that were not already enabled at the time of the key press.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+A key release disables any controls enabled by the key press.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+This action can cause <emphasis>
+XkbControlsNotify</emphasis>
+ events (see section 10.1).
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockControls</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If the <emphasis>
+XkbSA_LockNoLock</emphasis>
+ bit is not set in the <emphasis>
+flags</emphasis>
+ field, a key press enables any controls specified in the <emphasis>
+ctrls</emphasis>
+ fields that were not already enabled at the time of the key press.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If the <emphasis>
+XkbSA_LockNoUnlock</emphasis>
+ bit is not set in the <emphasis>
+flags</emphasis>
+ field, a key release disables any controls specified in the <emphasis>
+ctrls</emphasis>
+ fields that were not already disabled at the time of the key press.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+This action can cause <emphasis>
+XkbControlsNotify</emphasis>
+ events (see section 10.1).
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.15.
+</para>
+
+<table frame='none'>
+<title>Control Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoLock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockControls</emphasis>
+, the server only disables controls.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoUnlock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockControls</emphasis>
+, the server only enables controls.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+XkbSA_SetControls</emphasis>
+ action implements a key that enables a boolean control when pressed and
+disables it when released. The <emphasis>
+XkbSA_LockControls</emphasis>
+ action is used to implement a key that toggles the state of a boolean control
+each time it is pressed and released. The <emphasis>
+XkbSA_LockNoLock</emphasis>
+ and <emphasis>
+XkbSA_LockNoUnlock</emphasis>
+ flags allow modifying the toggling behavior to only unlock or only lock the
+boolean control.
+</para>
+
+
+<para>
+The <emphasis>
+ctrls0</emphasis>
+, <emphasis>
+ctrls1</emphasis>
+, <emphasis>
+ctrls2</emphasis>
+, and <emphasis>
+ctrls3</emphasis>
+ fields represent the boolean controls in the <emphasis>
+enabled_ctrls</emphasis>
+ field of the controls structure (see section 10.1). Xkb provides the following
+macros, to convert between the two formats:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned int <emphasis>
+XkbActionCtrls</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbCtrlsAction <emphasis>
+act</emphasis>
+; /* action from which to extract controls */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbActionCtrls</emphasis>
+ returns the <emphasis>
+ctrls</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ converted to an unsigned int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSAActionSetCtrls</emphasis>
+(<emphasis>
+act, ctrls</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbCtrlsAction <emphasis>
+act</emphasis>
+; /* action in which to set ctrls0-ctrls3 */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ctrls</emphasis>
+; /* value to set in ctrls0-ctrls3 */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSAActionSetCtrls</emphasis>
+ sets the <emphasis>
+ctrls0</emphasis>
+ through <emphasis>
+ctrls3</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ from <emphasis>
+ctrls</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='actions_for_generating_messages'>
+<title>Actions for Generating Messages</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbMessageAction</emphasis>
+ structure generate <emphasis>
+XkbActionMessage</emphasis>
+ events:
+</para>
+
+<para><programlisting>
+#define XkbActionMessageLength 6
+</programlisting></para>
+<para><programlisting>
+typedef struct _XkbMessageAction {
+ unsigned char type; /* <emphasis> XkbSA_ActionMessage</emphasis> */
+ unsigned char flags; /* controls event generation via key presses and releases */
+ unsigned char message[XkbActionMessageLength]; /* message */
+} <emphasis>XkbMessageAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field of the <emphasis>
+XkbMessageAction</emphasis>
+ structure should always be <emphasis>
+XkbSA_ActionMessage</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.16.
+</para>
+
+<table frame='none'>
+<title>Message Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_MessageOnPress</emphasis></entry>
+ <entry>
+If set, key press events generate an <emphasis>
+XkbActionMessage</emphasis>
+ event that reports the keycode, event type, and contents of the <emphasis>
+message</emphasis>
+ field.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_MessageOnRelease</emphasis></entry>
+ <entry>
+If set, key release events generate an <emphasis>
+XkbActionMessage</emphasis>
+ event that reports the keycode, event type, and contents of the <emphasis>
+message</emphasis>
+ field.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_MessageGenKeyEvent</emphasis></entry>
+ <entry>
+If set, key press and key release events generate <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events, regardless of whether they generate <emphasis>
+XkbActionMessage</emphasis>
+ events.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+message</emphasis>
+ field is an array of <emphasis>
+XkbActionMessageLength</emphasis>
+ unsigned characters and may be set to anything the keymap designer wishes.
+</para>
+
+<sect3 id='detecting_key_action_messages'>
+<title>Detecting Key Action Messages</title>
+
+<para>
+To receive <emphasis>
+XkbActionMessage</emphasis>
+ events by calling either <emphasis>
+XkbSelectEvents</emphasis>
+ or <emphasis>
+XkbSelectEventDetails</emphasis>
+ (see section 4.3).
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbActionMessage</emphasis>
+ events under all possible conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+ and pass <emphasis>
+XkbActionMessageMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+XkbActionMessage</emphasis>
+ event has no event details. However, you can call <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbActionMessage</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying <emphasis>
+XkbAllActionMessageMask</emphasis>
+ in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits.</emphasis>
+ This has the same effect as a call to <emphasis>
+XkbSelectEvents</emphasis>.
+</para>
+
+
+<para>
+The structure for the <emphasis>
+XkbActionMessage</emphasis>
+ event is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct _XkbActionMessage {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis>True</emphasis> =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis>XkbActionMessage</emphasis> */
+ int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
+ KeyCode keycode; /* keycode of key triggering event */
+ Bool press; /* <emphasis>True</emphasis> =&gt; key press,
+ <emphasis>False</emphasis> =&gt; release */
+ Bool key_event_follows; /* <emphasis>True</emphasis> =&gt; KeyPress/KeyRelease follows */
+ char message[XkbActionMessageLength+1]; /* message text */
+} <emphasis>XkbActionMessageEvent</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+keycode</emphasis>
+ is the keycode of the key that was pressed or released. The <emphasis>
+press</emphasis>
+ field specifies whether the event was the result of a key press or key
+release.
+</para>
+
+
+<para>
+The <emphasis>
+key_event_follows</emphasis>
+ specifies whether a <emphasis>
+KeyPress</emphasis>
+ (if <emphasis>
+press</emphasis>
+ is <emphasis>
+True</emphasis>
+) or <emphasis>
+KeyRelease</emphasis>
+ (if <emphasis>
+press</emphasis>
+ is <emphasis>
+False</emphasis>
+) event is also sent to the client. As with all other Xkb events, <emphasis>
+XkbActionMessageEvent</emphasis>
+s are delivered to all clients requesting them, regardless of the current
+keyboard focus. However, the <emphasis>
+KeyPress</emphasis>
+ or <emphasis>
+KeyRelease</emphasis>
+ event that conditionally follows an <emphasis>
+XkbActionMessageEvent</emphasis>
+ is sent only to the client selected by the current keyboard focus. <emphasis>
+key_event_follows</emphasis>
+ is <emphasis>
+True</emphasis>
+ only for the client that is actually sent the following <emphasis>
+KeyPress</emphasis>
+ or <emphasis>
+KeyRelease</emphasis>
+ event.
+</para>
+
+
+<para>
+The <emphasis>
+message</emphasis>
+ field is set to the message specified in the action and is guaranteed to be
+<emphasis>
+NULL</emphasis>
+-terminated; the Xkb extension forces a <emphasis>
+NULL</emphasis>
+ into <emphasis>
+message</emphasis>
+[<emphasis>
+XkbActionMessageLength</emphasis>
+].
+</para>
+
+
+</sect3>
+</sect2>
+<sect2 id='actions_for_generating_a_different_keycode'>
+<title>Actions for Generating a Different Keycode</title>
+
+<para>
+Actions associated with the <emphasis>
+XkbRedirectKeyAction</emphasis>
+ structure generate <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events containing a keycode different from the key that was pressed or
+released:
+</para>
+
+<para><programlisting>
+typedef struct _XkbRedirectKeyAction {
+ unsigned char type; /* <emphasis> XkbSA_RedirectKey</emphasis> */
+ unsigned char new_key; /* keycode to be put in event */
+ unsigned char mods_mask; /* mask of real mods to be reset */
+ unsigned char mods; /* mask of real mods to take values from */
+ unsigned char vmods_mask0; /* first half of mask of virtual mods to be reset */
+ unsigned char vmods_mask1; /* other half of mask of virtual mods to be reset */
+ unsigned char vmods0; /* first half of mask of virtual mods to take values from */
+ unsigned char vmods1; /* other half of mask of virtual mods to take values from */
+} <emphasis>XkbRedirectKeyAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field for the <emphasis>
+XkbRedirectKeyAction</emphasis>
+ structure should always be <emphasis>
+XkbSA_RedirectKey</emphasis>
+.
+</para>
+
+
+<para>
+Key presses cause a <emphasis>
+KeyPress</emphasis>
+ event for the key specified by the <emphasis>
+new_key</emphasis>
+ field instead of the actual key. The state reported in this event reports the
+current effective modifiers changed as follows: any real modifiers selected by
+the <emphasis>
+mods_mask</emphasis>
+ field are set to corresponding values from the <emphasis>
+mods</emphasis>
+ field. Any real modifiers bound to the virtual modifiers specified by the
+<emphasis>
+vmods_mask0</emphasis>
+ and <emphasis>
+vmods_mask1</emphasis>
+ fields are either set or cleared, depending on the corresponding values in the
+<emphasis>
+vmods0</emphasis>
+ and <emphasis>
+vmods1</emphasis>
+ fields. If the real and virtual modifier definitions specify conflicting
+values for a single modifier, the real modifier definition has priority.
+</para>
+
+
+<para>
+Key releases cause a <emphasis>
+KeyRelease</emphasis>
+ event for the key specified by the <emphasis>
+new_key</emphasis>
+ field instead of the actual key. The state for this event consists of the
+effective keyboard modifiers at the time of the release, changed as described
+previously.
+</para>
+
+
+<para>
+The <emphasis>
+XkbSA_RedirectKey</emphasis>
+ action normally redirects to another key on the same device as the key that
+caused the event, unless that device does not belong to the input extension
+<emphasis>
+KeyClass</emphasis>
+, in which case this action causes an event on the core keyboard device. (The
+input extension categorizes devices by breaking them into classes. Keyboards,
+and other input devices with keys, are classified as KeyClass devices by the
+input extension.)
+</para>
+
+
+<para>
+The <emphasis>
+vmods_mask0</emphasis>
+ and <emphasis>
+vmods_mask1</emphasis>
+ fields actually represent one <emphasis>
+vmods_mask</emphasis>
+ value, as described in Chapter 7. Xkb provides the following macros, to
+convert between the two formats:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned int <emphasis>
+XkbSARedirectVModsMask</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRedirectKeyAction <emphasis>
+act</emphasis>
+; /* action from which to extract vmods */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSARedirectVModsMask</emphasis>
+ returns the <emphasis>
+vmods_mask0</emphasis>
+ and <emphasis>
+vmods_mask1</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ converted to an unsigned int.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSARedirectSetVModsMask</emphasis>
+(<emphasis>
+act, vm</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRedirectKeyAction <emphasis>
+act</emphasis>
+; /* action in which to set vmods */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+vm</emphasis>
+; /* new value for virtual modifier mask */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSARedirectSetVModsMask</emphasis>
+ sets the <emphasis>
+vmods_mask0</emphasis>
+ and <emphasis>
+vmods_mask1</emphasis>
+ fields of <emphasis>
+act</emphasis>
+ from <emphasis>
+vm</emphasis>
+.
+</para>
+
+
+<para>
+Similarly, the <emphasis>
+vmods0</emphasis>
+ and <emphasis>
+vmods1</emphasis>
+ fields actually represent one <emphasis>
+vmods </emphasis>
+value, as described in Chapter 7. To convert between the two formats, Xkb
+provides the following convenience macros:
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+unsigned int <emphasis>
+XkbSARedirectVMods</emphasis>
+(<emphasis>
+act</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRedirectKeyAction <emphasis>
+act</emphasis>
+; /* action from which to extract vmods */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<literallayout>
+ <emphasis>XkbSARedirectVModsMask</emphasis> returns the <emphasis>vmods0</emphasis>
+ and <emphasis>vmods1</emphasis> fields of <emphasis>act</emphasis>
+ converted to an unsigned int.
+</literallayout>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbSARedirectSetVMods</emphasis>
+(<emphasis>
+act, vm</emphasis>
+) /* macro */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbRedirectKeyAction <emphasis>
+act</emphasis>
+; /* action in which to set vmods */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+v</emphasis>
+; /* new value for virtual modifiers */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+<literallayout>
+ <emphasis> XkbSARedirectSetVModsMask</emphasis> sets the <emphasis>vmods0</emphasis>
+ and <emphasis>vmods1</emphasis> of <emphasis>act</emphasis> from <emphasis>v</emphasis>.
+</literallayout>
+
+</sect2>
+<sect2 id='actions_for_generating_devicebuttonpress_and_devicebuttonrelease'>
+<title>Actions for Generating DeviceButtonPress and DeviceButtonRelease</title>
+
+<para>
+Actions associated with <emphasis>
+XkbDeviceBtnAction</emphasis>
+ structures generate <emphasis>
+DeviceButtonPress</emphasis>
+ and <emphasis>
+DeviceButtonRelease</emphasis>
+ events instead of normal <emphasis>
+KeyPress</emphasis>
+ and <emphasis>
+KeyRelease</emphasis>
+ events:
+</para>
+
+<para><programlisting>
+typedef struct _XkbDeviceBtnAction {
+ unsigned char type; /* <emphasis> XkbSA_DeviceBtn, XkbSA_LockDeviceBtn</emphasis> */
+ unsigned char flags; /* with <emphasis> type</emphasis> , specifies locking or unlocking */
+ unsigned char count; /* controls number of DeviceButtonPress and Release events */
+ unsigned char button; /* index of button on <emphasis> device</emphasis> */
+ unsigned char device; /* device ID of an X input extension device */
+} <emphasis>XkbDeviceBtnAction</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field can have any one of the values shown in Table 16.17.
+</para>
+
+<table frame='none'>
+<title>Device Button Action Types</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_DeviceBtn</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If the button specified by this action is logically down, the key press and
+corresponding release are ignored and have no effect. If the device or button
+specified by this action are illegal, this action behaves like <emphasis>
+XkbSA_NoAction</emphasis>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Otherwise, key presses cause one or more input extension device events instead
+of the usual key press event. If the <emphasis>
+count</emphasis>
+ field is zero, a key press generates a single <emphasis>
+DeviceButtonPress</emphasis>
+ event. If count is greater than zero, a key press event generates <emphasis>
+count</emphasis>
+ pairs of <emphasis>
+DeviceButtonPress</emphasis>
+ and <emphasis>
+DeviceButtonRelease</emphasis>
+ events.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If <emphasis>
+count</emphasis>
+ is zero, a key release generates an input extension <emphasis>
+DeviceButtonRelease</emphasis>
+ event that matches the event generated by the corresponding key press. If
+<emphasis>
+count</emphasis>
+ is nonzero, a key release does not cause a <emphasis>
+DeviceButtonRelease</emphasis>
+ event. Key releases never cause <emphasis>
+KeyRelease</emphasis>
+ events.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockDeviceBtn</emphasis></entry>
+ <entry>
+<itemizedlist>
+ <listitem>
+ <para>
+If the device or button specified by this action are illegal, this action
+behaves like <emphasis>XkbSA_NoAction</emphasis>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Otherwise, if the specified button is not locked and the <emphasis>
+XkbSA_LockNoLock</emphasis>
+ bit is not set in the <emphasis>
+flags</emphasis>
+ field, a key press generates an input extension <emphasis>
+DeviceButtonPress</emphasis>
+ event instead of a <emphasis>
+KeyPress</emphasis>
+ event and locks the button. If the button is already locked or if <emphasis>
+XkbSA_LockNoLock</emphasis>
+ bit is set in the <emphasis>
+flags</emphasis>
+ field, the key press is ignored and has no effect.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If the corresponding key press was ignored, and if the <emphasis>
+XkbSA_LockNoUnlock</emphasis>
+ bit is not set in the <emphasis>
+flags</emphasis>
+ field, a key release generates an input extension <emphasis>
+DeviceButtonRelease</emphasis>
+ event instead of a <emphasis>
+KeyRelease</emphasis>
+ event and unlocks the button. If the corresponding key press locked a button,
+the key release is ignored and has no effect.
+ </para>
+ </listitem>
+</itemizedlist>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+flags</emphasis>
+ field is composed of the bitwise inclusive OR of the masks shown in Table
+16.18.
+</para>
+
+<table frame='none'>
+<title>Device Button Action Flags</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Flag</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoLock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockDeviceBtn</emphasis>
+, the server only unlocks the button.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_LockNoUnlock</emphasis></entry>
+ <entry>
+If set, and the action type is <emphasis>
+XkbSA_LockDeviceBtn</emphasis>
+, the server only locks the button.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect2>
+<sect2 id='actions_for_simulating_events_from_device_valuators'>
+<title>Actions for Simulating Events from Device Valuators</title>
+
+<para>
+A <emphasis>
+valuator</emphasis>
+ manipulates a range of values for some entity, like a mouse axis, a slider or
+a dial. Actions associated with <emphasis>
+XkbDeviceValuatorAction</emphasis>
+ structures are used to simulate events from one or two input extension device
+valuators.
+</para>
+
+<para><programlisting>
+typedef struct _XkbDeviceValuatorAction {
+ unsigned char type; /*<emphasis> XkbSA_DeviceValuator</emphasis> */
+ unsigned char device; /* device ID */
+ unsigned char v1_what; /* determines how valuator is to behave for valuator 1 */
+ unsigned char v1_ndx; /* specifies a real valuator */
+ unsigned char v1_value; /* the value for valuator 1 */
+ unsigned char v2_what; /* determines how valuator is to behave for valuator 2 */
+ unsigned char v2_ndx; /* specifies a real valuator */
+ unsigned char v2_value; /* the value for valuator 1 */
+} <emphasis>XkbDeviceValuatorAction</emphasis>;
+</programlisting></para>
+
+<para>
+If <emphasis>
+device</emphasis>
+ is illegal or if neither <emphasis>
+v1_ndx</emphasis>
+ nor <emphasis>
+v2_ndx</emphasis>
+ specifies a legal valuator, this action behaves like <emphasis>
+XkbSA_NoAction</emphasis>.
+</para>
+
+
+<para>
+The low four bits of <emphasis>
+v1_what</emphasis>
+ and <emphasis>
+v2_what</emphasis>
+ specify the corresponding scale value (denoted <emphasis>
+val&lt;n&gt;Scale</emphasis>
+ in Table 16.17), if needed. The high four bits of <emphasis>
+v1_what</emphasis>
+ and <emphasis>
+v2_what</emphasis>
+ specify the operation to perform to set the values. The high four bits of
+<emphasis>
+v1_what</emphasis>
+ and <emphasis>
+v2_what</emphasis>
+ can have the values shown in Table 16.17; the use of <emphasis>
+val&lt;n&gt;Scale</emphasis>
+ is shown in that table also.
+</para>
+
+<table frame='none'>
+<title>Device Valuator v&lt;n&gt;_what High Bits Values</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Value of high bits</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_IgnoreVal</emphasis></entry>
+ <entry>No action</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetValMin</emphasis></entry>
+ <entry>
+<emphasis>v&lt;n&gt;_value</emphasis> is set to its minimum legal value.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetValCenter</emphasis></entry>
+ <entry>
+<emphasis>v&lt;n&gt;_value</emphasis>is centered (to (max-min)/2).
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetValMax</emphasis></entry>
+ <entry>
+<emphasis>v&lt;n&gt;_value</emphasis> is set to its maximum legal value.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetValRelative</emphasis></entry>
+ <entry>
+<emphasis>v&lt;n&gt;_value</emphasis> * (2
+<emphasis>val&lt;n&gt;Scale</emphasis>) is added to
+<emphasis>v&lt;n&gt;_value</emphasis>.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSA_SetValAbsolute</emphasis></entry>
+ <entry>
+<emphasis>v&lt;n&gt;_value</emphasis>
+ is set to (2 <emphasis>val&lt;n&gt;Scale</emphasis>).
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Illegal values for <emphasis>
+XkbSA_SetValRelative</emphasis>
+ or <emphasis>
+XkbSA_SetValAbsolute</emphasis>
+ are clamped into range. Note that all of these possibilities are legal for
+absolute valuators. For relative valuators, only <emphasis>
+XkbSA_SetValRelative</emphasis>
+ is permitted. Part of the input extension description of a device is the range
+of legal values for all absolute valuators, whence the maximum and minimum
+legal values shown in Table 16.17.
+</para>
+
+
+<para>
+The following two masks are provided as a convenience to select either portion
+of <emphasis>
+v1_what</emphasis>
+ or <emphasis>
+v2_what</emphasis>
+:
+</para>
+
+<literallayout>
+ #define XkbSA_ValOpMask (0x70)
+ #define XkbSA_ValScaleMask (0x07)
+</literallayout>
+
+<para>
+<emphasis>
+v1_ndx</emphasis>
+ and <emphasis>
+v2_ndx</emphasis>
+ specify valuators that actually exists. For example, most mice have two
+valuators (x and y axes) so the only legal values for a mouse would be 0 and 1.
+For a dial box with eight dials, any value in the range 0..7 would be correct.
+</para>
+
+
+</sect2>
+<sect2 id='obtaining_key_actions_for_keys_from_the_server'>
+<title>Obtaining Key Actions for Keys from the Server</title>
+
+<para>
+To update the actions (the <emphasis>
+key_acts</emphasis>
+ array) for a subset of the keys in a keyboard description, use <emphasis>
+XkbGetKeyActions</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeyActions</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+, <emphasis>
+num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+first</emphasis>
+; /* keycode of first key of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num</emphasis>
+; /* number of keys desired */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* pointer to keyboard description where result is stored */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyActions</emphasis>
+ sends a request to the server to obtain the actions for <emphasis>
+num</emphasis>
+ keys on the keyboard starting with key <emphasis>
+first</emphasis>
+. It waits for a reply and returns the actions in the <emphasis>
+server</emphasis>
+-&gt;<emphasis>
+key_acts</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+. If successful, <emphasis>
+XkbGetKeyActions</emphasis>
+ returns <emphasis>
+Success</emphasis>
+. The <emphasis>
+xkb</emphasis>
+ parameter must be a pointer to a valid Xkb keyboard description.
+</para>
+
+
+<para>
+If the <emphasis>
+server</emphasis>
+ map in the <emphasis>
+xkb</emphasis>
+ parameter has not been allocated, <emphasis>
+XkbGetKeyActions</emphasis>
+ allocates and initializes it before obtaining the actions.
+</para>
+
+
+<para>
+If the server does not have a compatible version of Xkb, or the Xkb extension
+has not been properly initialized, <emphasis>
+XkbGetKeyActions</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+. If <emphasis>
+num</emphasis>
+ is less than 1 or greater than <emphasis>
+XkbMaxKeyCount</emphasis>
+, <emphasis>
+XkbGetKeyActions</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If any allocation errors occur, <emphasis>
+XkbGetKeyActions</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+
+
+</sect2>
+<sect2 id='changing_the_number_of_actions_bound_to_a_key'>
+<title>Changing the Number of Actions Bound to a Key</title>
+
+<para>
+To change the number of actions bound to a key, use <emphasis>
+XkbResizeKeyAction</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbAction *<emphasis>
+XkbResizeKeyActions</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ key</emphasis>
+,<emphasis>
+ needed</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescRec *<emphasis>
+ xkb</emphasis>
+; /* keyboard description to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ key</emphasis>
+; /* keycode of key to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ needed</emphasis>
+; /* new number of actions required */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+xkb</emphasis>
+ parameter points to the keyboard description containing the <emphasis>
+key</emphasis>
+ whose number of actions is to be changed. The <emphasis>
+key</emphasis>
+ parameter is the keycode of the key to change, and <emphasis>
+needed</emphasis>
+ specifies the new number of actions required for the key.
+</para>
+
+
+<para>
+<emphasis>
+XkbResizeKeyActions</emphasis>
+ reserves the space needed for the actions and returns a pointer to the
+beginning of the new array that holds the actions. It can change the <emphasis>
+acts</emphasis>
+, <emphasis>
+num_acts</emphasis>
+, and <emphasis>
+size_acts</emphasis>
+ fields of <emphasis>
+xkb</emphasis>
+-&gt;<emphasis>
+server</emphasis>
+ if it is necessary to reallocate the <emphasis>
+acts </emphasis>
+array.
+</para>
+
+
+<para>
+If <emphasis>
+needed</emphasis>
+ is greater than the current number of keysyms for the key, <emphasis>
+XkbResizeKeyActions</emphasis>
+ initializes all new actions in the array to <emphasis>
+NoAction</emphasis>
+.
+</para>
+
+
+<para>
+Because the number of actions needed by a key is normally computed as width *
+number of groups, and <emphasis>
+XkbResizeKeyActions</emphasis>
+ does not modify either the width or number of groups for the key, a
+discrepancy exists on return from <emphasis>
+XkbResizeKeyActions</emphasis>
+ between the space allocated for the actions and the number required. The
+unused entries in the list of actions returned by <emphasis>
+XkbResizeKeyActions</emphasis>
+ are not preserved across future calls to any of the map editing functions, so
+you must update the key actions (which updates the width and number of groups
+for the key) before calling another allocator function. A call to <emphasis>
+XkbChangeTypesOfKey</emphasis>
+ updates these.
+</para>
+
+
+<para>
+If any allocation errors occur while resizing the number of actions bound to
+the key, <emphasis>
+XkbResizeKeyActions</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+.
+</para>
+
+<note><para>A change to the number of actions bound to a key should be
+accompanied by a change in the number of symbols bound to a key. Refer to
+section 15.3.7 for more information on changing the number of symbols bound to
+a key.</para></note>
+
+
+</sect2>
+</sect1>
+<sect1 id='key_behavior'>
+<title>Key Behavior</title>
+
+<para>
+Key behavior refers to the demeanor of a key. For example, the expected
+behavior of the <emphasis>
+CapsLock</emphasis>
+ key is that it logically locks when pressed, and then logically unlocks when
+pressed again.
+</para>
+
+
+<sect2 id='radio_groups2'>
+<title>Radio Groups</title>
+
+<para>
+Keys that belong to the same radio group have the <emphasis>
+XkbKB_RadioGroup</emphasis>
+ type in the <emphasis>
+type</emphasis>
+ field and the radio group index specified in the <emphasis>
+data</emphasis>
+ field in the <emphasis>
+XkbBehavior</emphasis>
+ structure. If the radio group has a name in the <emphasis>
+XkbNamesRec</emphasis>
+ structure, the radio group index is the index into the <emphasis>
+radio_group</emphasis>
+ array in the <emphasis>
+XkbNamesRec</emphasis>
+ structure. A radio group key when pressed stays logically down until another
+key in the radio group is pressed, when the first key becomes logically up and
+the new key becomes logically down. Setting the <emphasis>
+XkbKB_RGAllowNone</emphasis>
+ bit in the behavior for all of the keys of the radio group means that pressing
+the logically down member of the radio group causes it to logically release, in
+which case none of the keys of the radio group would be logically down. If
+<emphasis>
+XkbKB_RGAllowNone</emphasis>
+ is not set, there is no way to release the logically down member of the group.
+</para>
+
+
+<para>
+The low five bits of the <emphasis>
+data</emphasis>
+ field of the <emphasis>
+XkbBehavior</emphasis>
+ structure are the group number, the high three bits are flags. The only flag
+currently defined is:
+</para>
+
+<para><programlisting>
+#define XkbRG_AllowNone 0x80
+</programlisting></para>
+
+</sect2>
+<sect2 id='the_xkbbehavior_structure'>
+<title>The XkbBehavior Structure</title>
+
+<para>
+The <emphasis>
+behaviors</emphasis>
+ field of the server map is an array of <emphasis>
+XkbBehavior</emphasis>
+ structures, indexed by keycode, and contains the behavior for each key. The
+<emphasis>
+XkbBehavior</emphasis>
+ structure is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct _XkbBehavior {
+ unsigned char type; /* behavior type + optional
+ <emphasis> XkbKB_Permanent</emphasis> bit */
+ unsigned char data;
+} <emphasis>XkbBehavior</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field specifies the Xkb behavior, and the value of the <emphasis>
+data</emphasis>
+ field depends on the <emphasis>
+type</emphasis>
+. Xkb supports the key behaviors shown in Table 16.20.
+</para>
+
+<table frame='none'>
+<title>Key Behaviors</title>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Type</entry>
+ <entry>Effect</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKB_Default</emphasis></entry>
+ <entry>
+Press and release events are processed normally. The <emphasis>
+data</emphasis>
+ field is unused.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKB_Lock</emphasis></entry>
+ <entry>
+If a key is logically up (that is, the corresponding bit of the core key map is
+cleared) when it is pressed, the key press is processed normally and the
+corresponding release is ignored. If the key is logically down when pressed,
+the key press is ignored but the corresponding release is processed normally.
+The <emphasis>
+data</emphasis>
+ field is unused.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKB_RadioGroup</emphasis></entry>
+ <entry>
+ <para>
+If another member of the radio group is logically down (all members of the
+radio group have the same index, specified in <emphasis>
+data</emphasis>
+) when a key is pressed, the server synthesizes a key release for the member
+that is logically down and then processes the new key press event normally.
+ </para>
+ <para>
+If the key itself is logically down when pressed, the key press event is
+ignored, but the processing of the corresponding key release depends on the
+value of the <emphasis>
+Xkb_RGAllowNone</emphasis>
+ bit in <emphasis>
+flags</emphasis>
+. If it is set, the key release is processed normally; otherwise, the key
+release is also ignored.
+ </para>
+ <para>
+All other key release events are ignored.
+ </para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKB_Overlay1</emphasis></entry>
+ <entry>
+If the <emphasis>
+Overlay1</emphasis>
+ control is enabled (see section 10.4), <emphasis>
+data</emphasis>
+ is interpreted as a keycode, and events from this key are reported as if they
+came from <emphasis>
+data</emphasis>
+’s keycode. Otherwise, press and release events are processed normally.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbKB_Overlay2</emphasis></entry>
+ <entry>
+If the <emphasis>
+Overlay2</emphasis>
+ control is enabled (see section 10.4), <emphasis>
+data</emphasis>
+ is interpreted as a keycode, and events from this key are reported as if they
+came from <emphasis>
+data</emphasis>
+’s keycode. Otherwise, press and release events are processed normally.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+Xkb also provides the mask, <emphasis>
+XkbKB_Permanent</emphasis>
+ to specify whether the key behavior type should be simulated by Xkb or whether
+the key behavior describes an unalterable physical, electrical, or software
+aspect of the keyboard. If the <emphasis>
+XkbKB_Permanent</emphasis>
+ bit is not set in the <emphasis>
+type</emphasis>
+ field, Xkb simulates the behavior in software. Otherwise, Xkb relies upon the
+keyboard to implement the behavior.
+</para>
+
+
+</sect2>
+<sect2 id='obtaining_key_behaviors_for_keys_from_the_server'>
+<title>Obtaining Key Behaviors for Keys from the Server</title>
+
+<para>
+To obtain the behaviors (the <emphasis>
+behaviors</emphasis>
+ array) for a subset of the keys in a keyboard description from the server, use
+<emphasis>
+XkbGetKeyBehaviors</emphasis>
+:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeyBehaviors</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+first</emphasis>
+; /* keycode of first key to get */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num</emphasis>
+; /* number of keys for which behaviors are desired */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description to contain the result */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyBehaviors</emphasis>
+ sends a request to the server to obtain the behaviors for <emphasis>
+num</emphasis>
+ keys on the keyboard starting with the key whose keycode is <emphasis>
+first</emphasis>
+. It waits for a reply and returns the behaviors in the <emphasis>
+server</emphasis>
+-&gt;<emphasis>
+behaviors</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+. If successful, <emphasis>
+XkbGetKeyBehaviors</emphasis>
+ returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+<para>
+If the <emphasis>
+server</emphasis>
+ map in the <emphasis>
+xkb</emphasis>
+ parameter has not been allocated, <emphasis>
+XkbGetKeyBehaviors</emphasis>
+ allocates and initializes it before obtaining the actions.
+</para>
+
+
+<para>
+If the server does not have a compatible version of Xkb, or the Xkb extension
+has not been properly initialized, <emphasis>
+XkbGetKeyBehaviors</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+. If <emphasis>
+num</emphasis>
+ is less than 1 or greater than <emphasis>
+XkbMaxKeyCount</emphasis>
+, <emphasis>
+XkbGetKeyBehaviors</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If any allocation errors occur, <emphasis>
+XkbGetKeyBehaviors</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='explicit_components_avoiding_automatic_remapping_by_the_server'>
+<title>Explicit Components—Avoiding Automatic Remapping by the Server</title>
+
+<para>
+Whenever a client remaps the keyboard using core protocol requests, Xkb
+examines the map to determine likely default values for the components that
+cannot be specified using the core protocol (see section 17.1.2 for more
+information on how Xkb chooses the default values).
+</para>
+
+
+<para>
+This automatic remapping might replace definitions explicitly requested by an
+application, so the Xkb keyboard description defines an explicit components
+mask for each key. Any aspects of the automatic remapping listed in the
+explicit components mask for a key are not changed by the automatic keyboard
+mapping.
+</para>
+
+
+<para>
+The explicit components masks are held in the <emphasis>
+explicit</emphasis>
+ field of the server map, which is an array indexed by keycode. Each entry in
+this array is a mask that is a bitwise inclusive OR of the values shown in
+Table 16.21.
+</para>
+
+<table frame='none'>
+<title>Explicit Component Masks</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Bit in Explicit Mask</entry>
+ <entry>Value</entry>
+ <entry>Protects Against</entry>
+</row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitKeyType1</emphasis></entry>
+ <entry>(1&lt;&lt;0)</entry>
+ <entry>
+Automatic determination of the key type associated with <emphasis>
+Group1.</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitKeyType2</emphasis></entry>
+ <entry>(1&lt;&lt;1)</entry>
+ <entry>
+Automatic determination of the key type associated with <emphasis>
+Group2.</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitKeyType3</emphasis></entry>
+ <entry>(1&lt;&lt;2)</entry>
+ <entry>
+Automatic determination of the key type associated with <emphasis>
+Group3.</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitKeyType4</emphasis></entry>
+ <entry>(1&lt;&lt;3)</entry>
+ <entry>
+Automatic determination of the key type associated with <emphasis>
+Group4.</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitInterpret</emphasis></entry>
+ <entry>(1&lt;&lt;4)</entry>
+ <entry>
+Application of any of the fields of a symbol interpretation to the
+key in question.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitAutoRepeat</emphasis></entry>
+ <entry>(1&lt;&lt;5)</entry>
+ <entry>Automatic determination of auto-repeat status for the key, as
+specified in a symbol interpretation.</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitBehavior</emphasis></entry>
+ <entry>(1&lt;&lt;6)</entry>
+ <entry>
+Automatic assignment of the <emphasis>
+XkbKB_Lock</emphasis>
+ behavior to the key, if the <emphasis>
+XkbSI_LockingKey</emphasis>
+ flag is set in a symbol interpretation.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>ExplicitVModMap</emphasis></entry>
+ <entry>(1&lt;&lt;7)</entry>
+ <entry>
+Automatic determination of the virtual modifier map for the key
+based on the actions assigned to the key and the symbol interpretations that
+match the key.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<sect2 id='obtaining_explicit_components_for_keys_from_the_server'>
+<title>Obtaining Explicit Components for Keys from the Server</title>
+
+<para>
+To obtain the explicit components (the <emphasis>
+explicit</emphasis>
+ array) for a subset of the keys in a keyboard description, use <emphasis>
+XkbGetKeyExplicitComponents</emphasis>.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+first</emphasis>
+; /* keycode of first key to fetch */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num</emphasis>
+; /* number of keys for which to get explicit info */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description in which to put results */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+ sends a request to the server to obtain the explicit components for <emphasis>
+num</emphasis>
+ keys on the keyboard starting with key <emphasis>
+first</emphasis>
+. It waits for a reply and returns the explicit components in the <emphasis>
+server</emphasis>
+-&gt;<emphasis>
+explicit</emphasis>
+ array of <emphasis>
+xkb</emphasis>
+. If successful, <emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+ returns <emphasis>
+Success</emphasis>
+. The <emphasis>
+xkb</emphasis>
+ parameter must be a pointer to a valid Xkb keyboard description.
+</para>
+
+
+<para>
+If the <emphasis>
+server</emphasis>
+ map in the <emphasis>
+xkb</emphasis>
+ parameter has not been allocated, <emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+ allocates and initializes it before obtaining the actions.
+</para>
+
+
+<para>
+If the server does not have a compatible version of Xkb, or the Xkb extension
+has not been properly initialized, <emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+ returns <emphasis>
+BadMatch</emphasis>
+. If <emphasis>
+num</emphasis>
+ is less than 1 or greater than <emphasis>
+XkbMaxKeyCount</emphasis>
+, <emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If any allocation errors occur, <emphasis>
+XkbGetKeyExplicitComponents</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='virtual_modifier_mapping'>
+<title>Virtual Modifier Mapping</title>
+
+<para>
+The <emphasis>
+vmods</emphasis>
+ member of the server map is a fixed-length array containing <emphasis>
+XkbNumVirtualMods</emphasis>
+ entries. Each entry corresponds to a virtual modifier and provides the binding
+of the virtual modifier to the real modifier bits. Each entry in the <emphasis>
+vmods</emphasis>
+ array is a bitwise inclusive OR of the legal modifier masks:
+</para>
+
+<literallayout>
+ <emphasis>ShiftMask</emphasis>
+ <emphasis>LockMask</emphasis>
+ <emphasis>ControlMask</emphasis>
+ <emphasis>Mod1Mask</emphasis>
+ <emphasis>Mod2Mask</emphasis>
+ <emphasis>Mod3Mask</emphasis>
+ <emphasis>Mod4Mask</emphasis>
+ <emphasis>Mod5Mask</emphasis>
+</literallayout>
+
+<para>
+The <emphasis>
+vmodmap</emphasis>
+ member of the server map is similar to the <emphasis>
+modmap</emphasis>
+ array of the client map (see section 15.4), but is used to define the virtual
+modifier mapping for each key. Like the <emphasis>
+modmap</emphasis>
+ member, it is indexed by keycode, and each entry is a mask representing the
+virtual modifiers bound to the corresponding key:
+</para>
+
+<itemizedlist>
+ <listitem>
+ <para>
+Each of the bits in a <emphasis>
+vmodmap</emphasis>
+ entry represents an index into the <emphasis>
+vmods</emphasis>
+ member. That is, bit 0 of a <emphasis>
+vmodmap</emphasis>
+ entry refers to index 0 of the <emphasis>
+vmods</emphasis>
+ array, bit 1 refers to index 1, and so on.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+If a bit is set in the <emphasis>
+vmodmap</emphasis>
+ entry for a key, that key is bound to the corresponding virtual modifier in
+the <emphasis>
+vmods</emphasis>
+ array.
+ </para>
+ </listitem>
+</itemizedlist>
+
+<para>
+The <emphasis>
+vmodmap</emphasis>
+ and <emphasis>
+vmods</emphasis>
+ members of the server map are the "master" virtual modifier definitions. Xkb
+automatically propagates any changes to these fields to all other fields that
+use virtual modifier mappings.
+</para>
+
+
+<para>
+The overall relationship of fields dealing with virtual modifiers in an Xkb
+keyboard description are shown in Figure 16.2.
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-17.gif"/>
+ </imageobject>
+<caption>Virtual Modifier Relationships</caption>
+</mediaobject>
+
+
+
+<!--
+<H5 CLASS="Figure">
+Virtual Modifier Relationships</H5>
+-->
+
+<sect2 id='obtaining_virtual_modifier_bindings_from_the_server'>
+<title>Obtaining Virtual Modifier Bindings from the Server</title>
+
+<para>
+To obtain a subset of the virtual modifier bindings (the <emphasis>
+vmods</emphasis>
+ array) in a keyboard description, use <emphasis>
+XkbGetVirtualMods</emphasis>
+:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetVirtualMods</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ which</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask indicating virtual modifier bindings to get */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description where results will be placed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetVirtualMods</emphasis>
+ sends a request to the server to obtain the <emphasis>
+vmods</emphasis>
+ entries for the virtual modifiers specified in the mask, <emphasis>
+which</emphasis>
+, and waits for a reply. See section 7.1 for a description of how to determine
+the virtual modifier mask. For each bit set in <emphasis>
+which</emphasis>
+, <emphasis>
+XkbGetVirtualMods</emphasis>
+ updates the corresponding virtual modifier definition in the <emphasis>
+server-&gt;vmods</emphasis>
+ array of <emphasis>
+xkb</emphasis>
+. The <emphasis>
+xkb</emphasis>
+ parameter must be a pointer to a valid Xkb keyboard description. If
+successful, <emphasis>
+XkbGetVirtualMods</emphasis>
+ returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+<para>
+If the <emphasis>
+server</emphasis>
+ map has not been allocated in the <emphasis>
+xkb</emphasis>
+ parameter, <emphasis>
+XkbGetVirtualMods</emphasis>
+ allocates and initializes it before obtaining the virtual modifier bindings.
+</para>
+
+
+<para>
+If the server does not have a compatible version of Xkb, or the Xkb extension
+has not been properly initialized, <emphasis>
+XkbGetVirtualMods</emphasis>
+ returns <emphasis>
+BadMatch</emphasis>
+. Any errors in allocation cause <emphasis>
+XkbGetVirtualMods </emphasis>
+to return <emphasis>
+BadAlloc</emphasis>.
+</para>
+
+
+</sect2>
+<sect2 id='obtaining_per_key_virtual_modifier_mappings_from_the_server'>
+<title>Obtaining Per-Key Virtual Modifier Mappings from the Server</title>
+
+<para>
+To obtain the virtual modifier map (the <emphasis>
+vmodmap</emphasis>
+ array) for a subset of the keys in a keyboard description, use <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ first</emphasis>
+,<emphasis>
+ num</emphasis>
+,<emphasis>
+ xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display *<emphasis>
+ dpy</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+first</emphasis>
+; /* keycode of first key to fetch */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num</emphasis>
+; /* # keys for which virtual mod maps are desired */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* Xkb description where results will be placed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyVirutalModmap </emphasis>
+sends a request to the server to obtain the virtual modifier mappings for
+<emphasis>
+num</emphasis>
+ keys on the keyboard starting with key <emphasis>
+first</emphasis>
+. It waits for a reply and returns the virtual modifier mappings in the
+<emphasis>
+server</emphasis>
+-&gt;<emphasis>
+vmodmap</emphasis>
+ array of <emphasis>
+xkb</emphasis>
+. If successful, <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+ returns <emphasis>
+Success</emphasis>
+. The <emphasis>
+xkb</emphasis>
+ parameter must be a pointer to a valid Xkb keyboard description
+</para>
+
+
+<para>
+If the <emphasis>
+server</emphasis>
+ map in the <emphasis>
+xkb</emphasis>
+ parameter has not been allocated, <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+ allocates and initializes it before obtaining the virtual modifier mappings.
+</para>
+
+
+<para>
+If the server does not have a compatible version of Xkb, or the Xkb extension
+has not been properly initialized, <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+ returns <emphasis>
+BadMatch</emphasis>
+. If <emphasis>
+num</emphasis>
+ is less than 1 or greater than <emphasis>
+XkbMaxKeyCount</emphasis>
+, <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+ returns <emphasis>
+BadValue</emphasis>
+. If any allocation errors occur, <emphasis>
+XkbGetKeyVirtualModMap</emphasis>
+ returns <emphasis>
+BadAlloc</emphasis>
+.
+</para>
+
+</sect2>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch17.xml b/specs/XKB/ch17.xml
new file mode 100644
index 00000000..219805b1
--- /dev/null
+++ b/specs/XKB/ch17.xml
@@ -0,0 +1,1789 @@
+<chapter id='the_xkb_compatibility_map'>
+<title>The Xkb Compatibility Map</title>
+
+<para>
+As shown in Figure 17.1, the X server is normally dealing with more than one
+client, each of which may be receiving events from the keyboard, and each of
+which may issue requests to modify the keyboard in some manner. Each client may
+be either Xkb-unaware, Xkb-capable, or Xkb-aware. The server itself may be
+either Xkb-aware or Xkb-unaware. If the server is Xkb-unaware, Xkb state and
+keyboard mappings are not involved in any manner, and Xkb-aware clients may not
+issue Xkb requests to the server. If the server is Xkb-aware, the server must
+be able to deliver events and accept requests in which the keyboard state and
+mapping are compatible with the mode in which the client is operating.
+Consequently, for some situations, conversions must be made between Xkb state /
+keyboard mappings and core protocol state / keyboard mappings, and vice versa.
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-18.gif"/>
+ </imageobject>
+ <caption>Server Interaction with Types of Clients</caption>
+</mediaobject>
+
+
+
+<para>
+In addition to these situations involving a single server, there are cases
+where a client that deals with multiple servers may need to configure keyboards
+on different servers to be similar and the different servers may not all be
+Xkb-aware. Finally, a client may be dealing with descriptions of keyboards
+(files, and so on) that are based on core protocol and therefore may need to be
+able to map these descriptions to Xkb descriptions.
+</para>
+
+
+<para>
+An Xkb-aware server maintains keyboard state and mapping as an Xkb keyboard
+state and an Xkb keyboard mapping plus a compatibility map used to convert from
+Xkb components to core components and vice versa. In addition, the server also
+maintains a core keyboard mapping that approximates the Xkb keyboard mapping.
+The core keyboard mapping may be updated piecemeal, on a per-key basis. When
+the server receives a core protocol <emphasis>
+ChangeKeyboardMapping</emphasis>
+ or <emphasis>
+SetModifierMapping</emphasis>
+ request, it updates its core keyboard mapping, then uses the compatibility map
+to update its Xkb keyboard mapping. When the server receives an <emphasis>
+XkbSetMap</emphasis>
+ request, it updates those portions of its Xkb keyboard mapping specified by
+the request, then uses its compatibility map to update the corresponding parts
+of its core keyboard map. Consequently, the server’s Xkb keyboard map and
+also its core keyboard map may contain components that were set directly and
+others that were computed. Figure 17.2 illustrates these relationships.
+</para>
+
+<note><para>The core keyboard map is contained only in the server, not in any
+client-side data structures.</para></note>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-19.gif"/>
+ </imageobject>
+ <caption>Server Derivation of State and Keyboard Mapping Components</caption>
+</mediaobject>
+
+
+
+<para>
+There are three kinds of compatibility transformations made by the server:
+</para>
+
+<orderedlist>
+ <listitem>
+ <para><emphasis role='bold'>Xkb State to Core State</emphasis></para>
+ <para>
+Keyboard state information reported to a client in the state field of various
+core events may be translated from the Xkb keyboard state maintained by the
+server, which includes a group number, to core protocol state, which does
+not.
+ </para>
+ <para>
+In addition, whenever the Xkb state is retrieved, the <emphasis>
+compat_state</emphasis>
+, <emphasis>
+compat_grab_mods</emphasis>
+, and <emphasis>
+compat_lookup_mods</emphasis>
+ fields of the <emphasis>
+XkbStateRec</emphasis>
+ returned indicate the result of applying the compatibility map to the current
+Xkb state in the server.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis role='bold'>Core Keyboard Mapping to Xkb Keyboard Mapping</emphasis></para>
+ <para>
+After core protocol requests received by the server to change the keyboard
+mapping (<emphasis>
+ChangeKeyboardMapping</emphasis>
+ and <emphasis>
+SetModifierMapping</emphasis>
+) have been applied to the server’s core keyboard map, the results must be
+transformed to achieve an equivalent change of the Xkb keyboard mapping
+maintained by the server.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis role='bold'>Xkb Keyboard Mapping to Core Keyboard Mapping</emphasis></para>
+ <para>
+After Xkb protocol requests received by the server to change the keyboard
+mapping (<emphasis>
+XkbSetMap</emphasis>
+) have been applied to the server’s Xkb keyboard map, the results are
+transformed to achieve an approximately equivalent change to the core keyboard
+mapping maintained by the server.
+ </para>
+ </listitem>
+</orderedlist>
+
+<para>
+This chapter discusses how a client may modify the compatibility map so that
+subsequent transformations have a particular result.
+</para>
+
+
+<sect1 id='the_xkbcompatmap_structure'>
+<title>The XkbCompatMap Structure</title>
+
+<para>
+All configurable aspects of mapping Xkb state and configuration to and from
+core protocol state and configuration are defined by a compatibility map,
+contained in an <emphasis>
+XkbCompatMap</emphasis>
+ structure; plus a set of explicit override controls used to prevent particular
+components of type 2 (core-to-Xkb keyboard mapping) transformations from
+automatically occurring. These explicit override controls are maintained in a
+separate data structure discussed in section 16.3. <!-- xref -->
+</para>
+
+
+<para>
+The <emphasis>
+compat</emphasis>
+ member of an Xkb keyboard description (<emphasis>
+XkbDescRec</emphasis>
+) points to the<emphasis>
+ XkbCompatMap</emphasis>
+ structure:
+</para>
+
+<para><programlisting>
+typedef struct _XkbCompatMapRec {
+ XkbSymInterpretPtr sym_interpret; /* symbol based key semantics*/
+ XkbModsRec groups[XkbNumKbdGroups]; /* group =&gt; modifier map */
+ unsigned short num_si; /* # structures used in
+ <emphasis>sym_interpret</emphasis> */
+ unsigned short size_si; /* # structures allocated in
+ <emphasis>sym_interpret</emphasis> */
+} <emphasis>XkbCompatMapRec</emphasis>, *XkbCompatMapPtr;
+</programlisting></para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-20.gif"/>
+ </imageobject>
+ <caption>Xkb Compatibility Data Structures</caption>
+</mediaobject>
+
+
+<para>
+The subsections that follow discuss how the compatibility map and explicit
+override controls are used in each of the three cases where compatibility
+transformations are made.
+</para>
+
+<sect2 id='xkb_state_to_core_protocol_state_transformation'>
+<title>Xkb State to Core Protocol State Transformation</title>
+
+<para>
+As shown in Figure 17.3, there are four <emphasis>
+group compatibility maps</emphasis>
+ (contained in <emphasis>
+groups</emphasis>
+ [0..3]) in the <emphasis>
+XkbCompatMapRec</emphasis>
+ structure, one per possible Xkb group. Each group compatibility map is a
+modifier definition (see section 7.2 for a description of modifier
+definitions). The <emphasis>
+mask</emphasis>
+ component of the definition specifies which real modifiers should be set in
+the core protocol state field when the corresponding group is active. Because
+only one group is active at any one time, only one of the four possible
+transformations is ever applied at any one point in time. If the device
+described by the <emphasis>
+XkbDescRec</emphasis>
+ does not support four groups, the extra groups fields are present, but
+undefined.
+</para>
+
+<para>
+Normally, the Xkb-aware server reports keyboard state in the <emphasis>
+state</emphasis>
+ member of events such as a <emphasis>
+KeyPress</emphasis>
+ event and <emphasis>
+ButtonPress</emphasis>
+ event, encoded as follows:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+ <row rowsep='0'>
+ <entry>bits</entry>
+ <entry>meaning</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>15</entry>
+ <entry>0</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>13-14</entry>
+ <entry>Group index</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>8-12</entry>
+ <entry>Pointer Buttons</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>0-7</entry>
+ <entry>Modifiers</entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+For Xkb-unaware clients, only core protocol keyboard information may be
+reported. Because core protocol does not define the group index, the group
+index is mapped to modifier bits as specified by the <emphasis>
+groups</emphasis>
+[group index] field of the compatibility map (the bits set in the compatibility
+map are ORed into bits 0-7 of the state), and bits 13-14 are reported in the
+event as zero.
+</para>
+
+</sect2>
+<sect2 id='core_keyboard_mapping_to_xkb_keyboard_mapping_transformation'>
+<title>Core Keyboard Mapping to Xkb Keyboard Mapping Transformation</title>
+
+<para>
+When a core protocol keyboard mapping request is received by the server, the
+server’s core keyboard map is updated, and then the Xkb map maintained by the
+server is updated. Because a client may have explicitly configured some of the
+Xkb keyboard mapping in the server, this automatic regeneration of the Xkb
+keyboard mapping from the core protocol keyboard mapping should not modify any
+components of the Xkb keyboard mapping that were explicitly set by a client.
+The client must set explicit override controls to prevent this from happening
+(see section 16.3). The core-to-Xkb mapping is done as follows:
+</para>
+
+<orderedlist>
+ <listitem>
+ <para>
+Map the symbols from the keys in the core keyboard map to groups and symbols on
+keys in the Xkb keyboard map. The core keyboard mapping is of fixed width, so
+each key in the core mapping has the same number of symbols associated with it.
+The Xkb mapping allows a different number of symbols to be associated with each
+key; those symbols may be divided into a different number of groups (1-4) for
+each key. For each key, this process therefore involves partitioning the fixed
+number of symbols from the core mapping into a set of variable-length groups
+with a variable number of symbols in each group. For example, if the core
+protocol map is of width five, the partition for one key might result in one
+group with two symbols and another with three symbols. A different key might
+result in two groups with two symbols plus a third group with one symbol. The
+core protocol map requires at least two symbols in each of the first two
+groups.
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>
+For each changed key, determine the number of groups represented in the new
+core keyboard map. This results in a tentative group count for each key in the
+Xkb map.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+For each changed key, determine the number of symbols in each of the groups
+found in step 1a. There is one explicit override control associated with each
+of the four possible groups for each Xkb key, <emphasis>
+ExplicitKeyType1</emphasis>
+ through <emphasis>
+ExplicitKeyType4</emphasis>
+. If no explicit override control is set for a group, the number of symbols
+used for that group from the core map is two. If the explicit override control
+is set for a group on the key, the number of symbols used for that Xkb group
+from the core map is the width of the Xkb group with one exception: because of
+the core protocol requirement for at least two symbols in each of groups one
+and two, the number of symbols used for groups one and two is the maximum of 2
+or the width of the Xkb group.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+For each changed key, assign the symbols in the core map to the appropriate
+group on the key. If the total number of symbols required by the Xkb map for a
+particular key needs more symbols than the core protocol map contains, the
+additional symbols are taken to be <emphasis>
+NoSymbol</emphasis>
+ keysyms appended to the end of the core set. If the core map contains more
+symbols than are needed by the Xkb map, trailing symbols in the core map are
+discarded. In the absence of an explicit override for group one or two, symbols
+are assigned in order by group; the first symbols in the core map are assigned
+to group one, in order, followed by group two, and so on. For example, if the
+core map contained eight symbols per key, and a particular Xkb map contained 2
+symbols for G1 and G2 and three for G3, the symbols would be assigned as (G is
+group, L is shift level):
+ </para>
+<literallayout>
+ G1L1 G1L2 G2L1 G2L2 G3L1 G3L2 G3L3
+</literallayout>
+ <para>
+If an explicit override control is set for group one or two, the symbols are
+taken from the core set in a somewhat different order. The first four symbols
+from the core set are assigned to G1L1, G1L2, G2L1, G2L2, respectively. If
+group one requires more symbols, they are taken next, and then any additional
+symbols needed by group two. Group three and four symbols are taken in complete
+sequence after group two. For example, a key with four groups and three symbols
+in each group would take symbols from the core set in the following order:
+ </para>
+<literallayout>
+G1L1 G1L2 G2L1 G2L2 G1L3 G2L3 G3L1 G3L2 G3L3 G4L1 G4L2 G4L3
+</literallayout>
+ <para>
+As previously noted, the core protocol map requires at lease two symbols in
+groups one and two. Because of this, if an explicit override control for an Xkb
+key is set and group one and / or group two is of width one, it is not possible
+to generate the symbols taken from the core protocol set and assigned to
+position G1L2 and / or G2L2.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+For each group on each changed key, assign a key type appropriate for the
+symbols in the group.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+For each changed key, remove any empty or redundant groups.
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ <listitem>
+ <para>
+At this point, the groups and their associated symbols have been assigned to
+the corresponding key definitions in the Xkb map.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Apply symbol interpretations to modify key operation. This phase is completely
+skipped if the <emphasis>
+ExplicitInterpret</emphasis>
+ override control bit is set in the explicit controls mask for the Xkb key (see
+section 16.3).
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>
+For each symbol on each changed key, attempt to match the symbol and modifiers
+from the Xkb map to a symbol interpretation describing how to generate the
+symbol.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+When a match is found in step 2a, apply the symbol interpretation to change the
+semantics associated with the symbol in the Xkb key map. If no match is found,
+apply a default interpretation.
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+</orderedlist>
+
+<para>
+The symbol interpretations used in step 2 are configurable and may be specified
+using <emphasis>
+XkbSymInterpretRec</emphasis>
+ structures referenced by the <emphasis>
+sym_interpret</emphasis>
+ field of an <emphasis>
+XkbCompatMapRec</emphasis>
+ (see Figure 17.3).
+</para>
+
+<sect3 id='symbol_interpretations_the_xkbsyminterpretrec_structure'>
+<title>Symbol Interpretations — the XkbSymInterpretRec Structure</title>
+
+<para>
+Symbol interpretations are used to guide the X server when it modifies the Xkb
+keymap in step 2. An initial set of symbol interpretations is loaded by the
+server when it starts. A client may add new ones using <emphasis>
+XkbSetCompatMap</emphasis>
+ (see section 17.4).
+</para>
+
+
+<para>
+Symbol interpretations result in key semantics being set. When a symbol
+interpretation is applied, the following components of server key event
+processing may be modified for the particular key involved:
+</para>
+
+<literallayout>
+ Virtual modifier map
+ Auto repeat
+ Key behavior (may be set to <emphasis>XkbKB_Lock</emphasis>)
+ Key action (see section 16.1)
+</literallayout>
+
+<para>
+The <emphasis>XkbSymInterpretRec</emphasis>
+structure specifies a symbol interpretation:
+</para>
+
+<para><programlisting>
+typedef struct {
+ KeySym sym; /* keysym of interest or <emphasis>NULL</emphasis> */
+ unsigned char flags; /* <emphasis>XkbSI_AutoRepeat, XkbSI_LockingKey</emphasis> */
+ unsigned char match; /* specifies how mods is interpreted */
+ unsigned char mods; /* modifier bits, correspond to eight real modifiers */
+ unsigned char virtual_mod; /* 1 modifier to add to key virtual mod map */
+ XkbAnyAction act; /* action to bind to symbol position on key */
+} <emphasis>XkbSymInterpretRec</emphasis>,*XkbSymInterpretPtr;
+</programlisting></para>
+
+<para>
+If <emphasis>
+sym</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+, it limits the symbol interpretation to keys on which that particular keysym
+is selected by the modifiers matching the criteria specified by <emphasis>
+mods</emphasis>
+ and <emphasis>
+match</emphasis>
+. If <emphasis>
+sym</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, the interpretation may be applied to any symbol selected on a key when the
+modifiers match the criteria specified by <emphasis>
+mods</emphasis>
+ and <emphasis>
+match</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>match</emphasis>
+must be one of the values shown in Table 17.1 and specifies how the real
+modifiers specified in <emphasis>mods</emphasis>
+are to be interpreted.
+</para>
+
+<table frame='none'>
+<title>Symbol Interpretation Match Criteria</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='1'>
+ <entry>Match Criteria</entry>
+ <entry>Value</entry>
+ <entry>Effect</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='1'>
+ <entry><emphasis>XkbSI_NoneOf</emphasis></entry>
+ <entry>(0)</entry>
+ <entry>
+None of the bits that are on in <emphasis>mods</emphasis>
+ can be set, but other bits can be.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSI_AnyOfOrNone</emphasis></entry>
+ <entry>(1)</entry>
+ <entry>
+Zero or more of the bits that are on in <emphasis>
+mods</emphasis>
+ can be set, as well as others.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSI_AnyOf</emphasis></entry>
+ <entry>(2)</entry>
+ <entry>
+One or more of the bits that are on in <emphasis>
+mods</emphasis>
+ can be set, as well as any others.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSI_AllOf</emphasis></entry>
+ <entry>(3)</entry>
+ <entry>
+All of the bits that are on in <emphasis>
+mods</emphasis>
+ must be set, but others may be set as well.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSI_Exactly</emphasis></entry>
+ <entry>(4)</entry>
+ <entry>
+All of the bits that are on in <emphasis>
+mods</emphasis>
+ must be set, and no other bits may be set.
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+In addition to the above bits, <emphasis>
+match</emphasis>
+ may contain the <emphasis>
+XkbSI_LevelOneOnly</emphasis>
+ bit, in which case the modifier match criteria specified by <emphasis>
+mods</emphasis>
+ and <emphasis>
+match</emphasis>
+ applies only if <emphasis>
+sym</emphasis>
+ is in level one of its group; otherwise, <emphasis>
+mods</emphasis>
+ and <emphasis>
+match</emphasis>
+ are ignored and the symbol matches a condition where no modifiers are set.
+</para>
+
+<para><programlisting>
+#define XkbSI_LevelOneOnly (0x80)
+/* use mods + match only if sym is level 1 */
+</programlisting></para>
+
+<para>
+If no matching symbol interpretation is found, the server uses a default
+interpretation where:
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='2'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>sym</emphasis> =</entry>
+ <entry>0</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>flags</emphasis> =</entry>
+ <entry><emphasis>XkbSI_AutoRepeat</emphasis></entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>match</emphasis> =</entry>
+ <entry><emphasis>XkbSI_AnyOfOrNone</emphasis></entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>mods</emphasis> =</entry>
+ <entry>0</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>virtual_mod</emphasis> =</entry>
+ <entry><emphasis>XkbNoModifier</emphasis></entry>
+ </row>
+ <row rowsep='0'>
+
+ <entry><emphasis>act</emphasis> =</entry>
+ <entry><emphasis>SA_NoAction</emphasis></entry>
+ </row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+When a matching symbol interpretation is found in step 2a, the interpretation
+is applied to modify the Xkb map as follows.
+</para>
+
+<para>
+The <emphasis>
+act</emphasis>
+ field specifies a single action to be bound to the symbol position; any key
+event that selects the symbol causes the action to be taken. Valid actions are
+defined in section 16.1.
+</para>
+
+
+<para>
+If the Xkb keyboard map for the key does not have its <emphasis>
+ExplicitVModMap</emphasis>
+ control set, the <emphasis>
+XkbSI_LevelOneOnly</emphasis>
+ bit and symbol position are examined. If the <emphasis>
+XkbSI_LevelOneOnly</emphasis>
+ bit is not set in <emphasis>
+match</emphasis>
+ or the symbol is in position G1L1, the <emphasis>
+virtual_mod</emphasis>
+ field is examined. If <emphasis>
+virtual_mod</emphasis>
+ is not <emphasis>
+XkbNoModifier</emphasis>
+, <emphasis>
+virtual_mod</emphasis>
+ specifies a single virtual modifier to be added to the virtual modifier map
+for the key.<emphasis>
+ virtual_mod</emphasis>
+ is specified as an index in the range [0..15].
+</para>
+
+
+<para>
+If the matching symbol is in position G1L1 of the key, two bits in the flags
+field potentially specify additional behavior modifications:
+</para>
+
+<para><programlisting>
+#define XkbSI_AutoRepeat (1&lt;&lt;0)
+ /* key repeats if sym is in position G1L1 */
+#define XkbSI_LockingKey (1&lt;&lt;1)
+ /* set <emphasis> KB_Lock</emphasis>
+ behavior if sym is in psn G1L1 */
+</programlisting></para>
+
+<para>
+If the Xkb keyboard map for the key does not have its <emphasis>
+ExplicitAutoRepeat</emphasis>
+ control set, its auto repeat behavior is set based on the value of the
+<emphasis>
+XkbSI_AutoRepeat</emphasis>
+ bit. If the <emphasis>
+XkbSI_AutoRepeat</emphasis>
+ bit is set, the auto-repeat behavior of the key is turned on; otherwise, it is
+turned off.
+</para>
+
+
+<para>
+If the Xkb keyboard map for the key does not have its <emphasis>
+ExplicitBehavior</emphasis>
+ control set, its locking behavior is set based on the value of the <emphasis>
+XkbSI_LockingKey</emphasis>
+ bit. If <emphasis>
+XkbSI_LockingKey</emphasis>
+ is set, the key behavior is set to <emphasis>
+KB_Lock</emphasis>
+; otherwise, it is turned off (see section 16.3).
+</para>
+
+
+</sect3>
+</sect2>
+<sect2 id='xkb_keyboard_mapping_to_core_keyboard_mapping_transformations'>
+<title>Xkb Keyboard Mapping to Core Keyboard Mapping Transformations</title>
+
+<para>
+Whenever the server processes Xkb requests to change the keyboard mapping, it
+discards the affected portion of its core keyboard mapping and regenerates it
+based on the new Xkb mapping.
+</para>
+
+
+<para>
+When the Xkb mapping for a key is transformed to a core protocol mapping, the
+symbols for the core map are taken in the following order from the Xkb map:
+</para>
+
+
+<para>
+G1L1 G1L2 G2L1 G2L2 G1L3-n G2L3-n G3L1-n G4L1-n
+</para>
+
+
+<para>
+If group one is of width one in the Xkb map, G1L2 is taken to be NoSymbol;
+similarly, if group two is of width one in the Xkb map, G2L2 is taken to be
+NoSymbol.
+</para>
+
+
+<para>
+If the Xkb key map for a particular key has fewer groups than the core
+keyboard, the symbols for group one are repeated to fill in the missing core
+components. For example, an Xkb key with a single width-three group would be
+mapped to a core mapping counting three groups as:
+</para>
+
+
+<para>
+G1L1 G1L2 G1L1 G1L2 G1L3 G1L3 G1L1 G1L2 G1L3
+</para>
+
+
+<para>
+When a core keyboard map entry is generated from an Xkb keyboard map entry, a
+modifier mapping is generated as well. The modifier mapping contains all of the
+modifiers affected by any of the actions associated with the key combined with
+all of the real modifiers associated with any of the virtual modifiers bound to
+the key. In addition, if any of the actions associated with the key affect any
+component of the keyboard group, all of the modifiers in the <emphasis>
+mask</emphasis>
+ field of all of the group compatibility maps are added to the modifier mapping
+as well. While an <emphasis>
+XkbSA_ISOLock</emphasis>
+ action can theoretically affect any modifier, if the Xkb mapping for a key
+specifies an <emphasis>
+XkbSA_ISOLock</emphasis>
+ action, only the modifiers or group that are set by default are added to the
+modifier mapping.
+</para>
+
+
+</sect2>
+</sect1>
+<sect1 id='getting_compatibility_map_components_from_the_server'>
+<title>Getting Compatibility Map Components From the Server</title>
+
+<para>
+Use <emphasis>
+XkbGetCompatMap</emphasis>
+ to fetch any combination of the current compatibility map components from the
+server. When another client modifies the compatibility map, you are notified if
+you have selected for <emphasis>
+XkbCompatMapNotify</emphasis>
+ events (see section 17.5). <emphasis>
+XkbGetCompatMap</emphasis>
+ is particularly useful when you receive an event of this type, as it allows
+you to update your program’s version of the compatibility map to match the
+modified version now in the server. If your program is dealing with multiple
+servers and needs to configure them all in a similar manner, the updated
+compatibility map may be used to reconfigure other servers.
+</para>
+
+<note><para>To make a complete matching configuration you must also update the
+explicit override components of the server state.</para></note>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetCompatMap</emphasis>
+(<emphasis>
+display, which, xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ display</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask of compatibility map components to fetch */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescRec * <emphasis>
+ xkb</emphasis>
+; /* keyboard description where results placed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetCompatMap</emphasis>
+ fetches the components of the compatibility map specified in <emphasis>
+which</emphasis>
+ from the server specified by <emphasis>
+display</emphasis>
+ and places them in the <emphasis>
+compat</emphasis>
+ structure of the keyboard description <emphasis>
+xkb</emphasis>
+. Valid values for <emphasis>
+which</emphasis>
+ are an inclusive OR of the values shown in Table 17.2.
+</para>
+
+<table frame='none'>
+<title>Compatibility Map Component Masks</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Value</entry>
+ <entry>Affecting</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry><emphasis>XkbSymInterpMask</emphasis></entry>
+ <entry>(1&lt;&lt;0)</entry>
+ <entry>Symbol interpretations</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbGroupCompatMask</emphasis></entry>
+ <entry>(1&lt;&lt;1)</entry>
+ <entry>Group maps</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbAllCompatMask</emphasis></entry>
+ <entry>(0x3)</entry>
+ <entry>All compatibility map components</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+If no compatibility map structure is allocated in <emphasis>
+xkb</emphasis>
+ upon entry, <emphasis>
+XkbGetCompatMap</emphasis>
+ allocates one. If one already exists, its contents are overwritten with the
+returned results.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetCompatMap</emphasis>
+ fetches compatibility map information for the device specified by the
+<emphasis>
+device_spec</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+. Unless you have specifically modified this field, it is the default keyboard
+device. <emphasis>
+XkbGetCompatMap</emphasis>
+ returns <emphasis>
+Success</emphasis>
+ if successful, <emphasis>
+BadAlloc</emphasis>
+ if it is unable to obtain necessary storage for either the return values or
+work space, <emphasis>
+BadMatch</emphasis>
+ if the <emphasis>
+dpy</emphasis>
+ field of the <emphasis>
+xkb</emphasis>
+ argument is non-<emphasis>
+NULL</emphasis>
+ and does not match the <emphasis>
+display</emphasis>
+ argument, and <emphasis>
+BadLength</emphasis>
+ under certain conditions caused by server or Xkb implementation errors.
+</para>
+
+
+</sect1>
+<sect1 id='using_the_compatibility_map'>
+<title>Using the Compatibility Map</title>
+
+<para>
+Xkb provides several functions that make it easier to apply the compatibility
+map to configure a client-side Xkb keyboard mapping, given a core protocol
+representation of part or all of a keyboard mapping. Obtain a core protocol
+representation of a keyboard mapping from an actual server (by using <emphasis>
+XGetKeyboardMapping</emphasis>
+, for example), a data file, or some other source.
+</para>
+
+<para>
+To update a local Xkb keyboard map to reflect the mapping expressed by a core
+format mapping by calling the function <emphasis>
+XkbUpdateMapFromCore</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbUpdateMapFromCore</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ first_key</emphasis>
+,<emphasis>
+ num_keys</emphasis>
+,<emphasis>
+ map_width</emphasis>
+,<emphasis>
+ core_keysyms</emphasis>
+,<emphasis>
+ changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description to update */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeyCode <emphasis>
+ first_key</emphasis>
+; /* keycode of first key description to update */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ num_keys</emphasis>
+; /* number of key descriptions to update */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+ map_width</emphasis>
+; /* width of core protocol keymap */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym *<emphasis>
+ core_keysyms</emphasis>
+; /* symbols in core protocol keymap */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbChangesPtr <emphasis>
+ changes</emphasis>
+; /* backfilled with changes made to Xkb */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbUpdateMapFromCore</emphasis>
+ interprets input argument information representing a keyboard map in core
+format to update the Xkb keyboard description passed in <emphasis>
+xkb</emphasis>
+. Only a portion of the Xkb map is updated — the portion corresponding to
+keys with keycodes in the range <emphasis>
+first_key</emphasis>
+ through <emphasis>
+first_key</emphasis>
+ + <emphasis>
+num_keys</emphasis>
+ - 1. If <emphasis>
+XkbUpdateMapFromCore</emphasis>
+ is being called in response to a<emphasis>
+ </emphasis>
+<emphasis>
+MappingNotify</emphasis>
+<emphasis>
+ </emphasis>
+event<emphasis>
+, first_key</emphasis>
+ and <emphasis>
+num_keys</emphasis>
+ are reported in the <emphasis>
+MappingNotify</emphasis>
+ event. <emphasis>
+core_keysyms</emphasis>
+ contains the keysyms corresponding to the keycode range being updated, in core
+keyboard description order. <emphasis>
+map_width</emphasis>
+ is the number of keysyms per key in <emphasis>
+core_keysyms</emphasis>
+. Thus, the first <emphasis>
+map_width</emphasis>
+ entries in <emphasis>
+core_keysyms</emphasis>
+ are for the key with keycode <emphasis>
+first_key</emphasis>
+, the next <emphasis>
+map_width</emphasis>
+ entries are for key <emphasis>
+first_key</emphasis>
+ + 1, and so on.
+</para>
+
+
+<para>
+In addition to modifying the Xkb keyboard mapping in <emphasis>
+xkb</emphasis>
+, <emphasis>
+XkbUpdateMapFromCore</emphasis>
+ backfills the changes structure whose address is passed in <emphasis>
+changes</emphasis>
+ to indicate the modifications that were made. You may then use <emphasis>
+changes</emphasis>
+ in subsequent calls such as <emphasis>
+XkbSetMap</emphasis>
+, to propagate the local modifications to a server.
+</para>
+
+
+<para>
+When dealing with core keyboard mappings or descriptions, it is sometimes
+necessary to determine the Xkb key types appropriate for the symbols bound to a
+key in a core keyboard mapping. Use <emphasis>
+XkbKeyTypesForCoreSymbols</emphasis>
+ for this purpose:
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+int <emphasis>
+XkbKeyTypesForCoreSymbols</emphasis>
+(<emphasis>
+map_width</emphasis>
+,<emphasis>
+ core_syms</emphasis>
+,<emphasis>
+ protected, types_inout, xkb_syms_rtrn</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr<emphasis>
+ xkb</emphasis>
+; /* keyboard description in which to place symbols*/
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int<emphasis>
+ map_width</emphasis>
+; /* width of core protocol keymap in <emphasis>
+xkb_syms_rtrn</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym *<emphasis>
+ core_syms</emphasis>
+; /* core protocol format array of KeySyms */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+protected</emphasis>
+; /* explicit key types */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int *<emphasis>
+ types_inout;</emphasis>
+ /* backfilled with the canonical types bound to groups one and two
+for the key */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+KeySym * <emphasis>
+xkb_syms_rtrn</emphasis>
+ ; /* backfilled with symbols bound to the key in the Xkb mapping */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbKeyTypesForCoreSymbols</emphasis>
+ expands the symbols in <emphasis>
+core_syms</emphasis>
+ and types in <emphasis>
+types_inout</emphasis>
+ according to the rules specified in section 12 of the core protocol, then
+chooses canonical key types (canonical key types are defined in section 15.2.1)
+for groups 1 and 2 using the rules specified by the Xkb protocol and places
+them in <emphasis>
+xkb_syms_rtrn</emphasis>
+, which will be non-<emphasis>
+NULL</emphasis>
+.
+</para>
+
+
+<para>
+A core keymap is a two-dimensional array of keysyms. It has <emphasis>
+map_width</emphasis>
+ columns and <emphasis>
+max_key_code</emphasis>
+ rows. <emphasis>
+XkbKeyTypesForCoreSymbols</emphasis>
+ takes a single row from a core keymap, determines the number of groups
+associated with it, the type of each group, and the symbols bound to each
+group. The return value is the number of groups, <emphasis>
+types_inout</emphasis>
+ has the types for each group, and <emphasis>
+xkb_syms_rtrn</emphasis>
+ has the symbols in Xkb order (that is, groups are contiguous, regardless of
+size).
+</para>
+
+
+<para>
+<emphasis>
+protected</emphasis>
+ contains the explicitly protected key types. There is one explicit override
+control associated with each of the four possible groups for each Xkb key,
+<emphasis>
+ExplicitKeyType1</emphasis>
+ through <emphasis>
+ExplicitKeyType4</emphasis>
+<emphasis>
+; protected </emphasis>
+is an inclusive OR of these controls. <emphasis>
+map_width</emphasis>
+ is the width of the core keymap and is not dependent on any Xkb definitions.
+<emphasis>
+types_inout</emphasis>
+ is an array of four type indices. On input, <emphasis>
+types_inout</emphasis>
+ contains the indices of any types already assigned to the key, in case they
+are explicitly protected from change.
+</para>
+
+
+<para>
+Upon return, <emphasis>
+types_inout</emphasis>
+ contains any automatically selected (that is, canonical) types plus any
+protected types. Canonical types are assigned to all four groups if there are
+enough symbols to do so. The four entries in <emphasis>
+types_inout</emphasis>
+ correspond to the four groups for the key in question.
+</para>
+
+
+<para>
+If the groups mapping does not change, but the symbols assigned to an Xkb
+keyboard compatibility map do change, the semantics of the key may be modified.
+To apply the new compatibility mapping to an individual key to get its
+semantics updated, use <emphasis>
+XkbApplyCompatMapToKey</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbApplyCompatMapToKey</emphasis>
+(<emphasis>
+xkb</emphasis>
+,<emphasis>
+ key</emphasis>
+,<emphasis>
+ changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+ XkbDescPtr<emphasis>
+ xkb; </emphasis>
+/* keyboard description to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+ KeyCode<emphasis>
+ key</emphasis>
+; /* key to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+ XkbChangesPtr<emphasis>
+ changes</emphasis>
+; /* notes changes to the Xkb keyboard description */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbApplyCompatMapToKey</emphasis>
+ essentially performs the operation described in section 17.1.2 to a specific
+key. This updates the behavior, actions, repeat status, and virtual modifier
+bindings of the key.
+</para>
+
+
+</sect1>
+<sect1 id='changing_the_servers_compatibility_map'>
+<title>Changing the Server’s Compatibility Map</title>
+
+<para>
+To modify the server’s compatibility map, first modify a local copy of the
+Xkb compatibility map, then call <emphasis>
+XkbSetCompatMap</emphasis>
+. You may allocate a new compatibility map for this purpose using <emphasis>
+XkbAllocCompatMap</emphasis>
+ (see section 17.6). You may also use a compatibility map from another server,
+although you need to adjust the <emphasis>
+device_spec</emphasis>
+ field in the <emphasis>
+XkbDescRec</emphasis>
+ accordingly. Note that symbol interpretations in a compatibility map
+(<emphasis>
+sym_interpret</emphasis>
+, the vector of <emphasis>
+XkbSymInterpretRec</emphasis>
+ structures) are also allocated using this same function.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetCompatMap</emphasis>
+(<emphasis>
+display, which, xkb, update_actions</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ display</emphasis>
+; /* connection to server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask of compat map components to set */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* source for compat map components */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ update_actions</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; apply to server’s keyboard map */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetCompatMap</emphasis>
+ copies compatibility map information from the keyboard description in
+<emphasis>
+xkb</emphasis>
+ to the server specified in <emphasis>
+display</emphasis>
+’s compatibility map for the device specified by the <emphasis>
+device_spec</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+. Unless you have specifically modified this field, it is the default keyboard
+device.<emphasis>
+ which</emphasis>
+ specifies the compatibility map components to be set, and is an inclusive OR
+of the bits shown in Table 17.2.
+</para>
+
+
+<para>
+After updating its compatibility map for the specified device, if <emphasis>
+update_actions</emphasis>
+ is <emphasis>
+True,</emphasis>
+ the server applies the new compatibility map to its entire keyboard for the
+device to generate a new set of key semantics, compatibility state, and a new
+core keyboard map. If <emphasis>
+update_actions</emphasis>
+ is <emphasis>
+False</emphasis>
+, the new compatibility map is not used to generate any modifications to the
+current device semantics, state, or core keyboard map. One reason for not
+applying the compatibility map immediately would be if one server was being
+configured to match another on a piecemeal basis; the map should not be applied
+until everything is updated. To force an update at a later time, use <emphasis>
+XkbSetCompatMap</emphasis>
+ specifying <emphasis>
+which</emphasis>
+ as zero and <emphasis>
+update_actions</emphasis>
+ as <emphasis>
+True</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbSetCompatMap</emphasis>
+ returns <emphasis>
+True</emphasis>
+ if successful and <emphasis>
+False</emphasis>
+ if unsuccessful. The server may report problems it encounters when processing
+the request subsequently via protocol errors.
+</para>
+
+
+<para>
+To add a symbol interpretation to the list of symbol interpretations in an
+<emphasis>
+XkbCompatRec</emphasis>
+, use <emphasis>
+XkbAddSymInterpret</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbSymInterpretPtr <emphasis>
+XkbAddSymInterpret</emphasis>
+(<emphasis>
+xkb, si, updateMap, changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr<emphasis>
+ xkb</emphasis>
+; /* keyboard description to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbSymInterpretPtr<emphasis>
+ si</emphasis>
+; /* symbol interpretation to be added */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool<emphasis>
+ updateMap</emphasis>
+; /* <emphasis>
+True</emphasis>
+=&gt;apply compatibility map to keys */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbChangesPtr<emphasis>
+ changes</emphasis>
+; /* changes are put here */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddSymInterpret</emphasis>
+ adds <emphasis>
+si</emphasis>
+ to the list of symbol interpretations in <emphasis>
+xkb</emphasis>
+. If <emphasis>
+updateMap</emphasis>
+ is <emphasis>
+True</emphasis>
+, it (re)applies the compatibility map to all of the keys on the keyboard. If
+<emphasis>
+changes</emphasis>
+ is non-<emphasis>
+NULL</emphasis>
+, it reports the parts of the keyboard that were affected (unless <emphasis>
+updateMap</emphasis>
+ is <emphasis>
+True</emphasis>
+, not much changes). <emphasis>
+XkbAddSymInterpret</emphasis>
+ returns a pointer to the actual new symbol interpretation in the list or
+<emphasis>
+NULL</emphasis>
+ if it failed.
+</para>
+
+
+</sect1>
+<sect1 id='tracking_changes_to_the_compatibility_map'>
+<title>Tracking Changes to the Compatibility Map</title>
+
+<para>
+The server automatically generates <emphasis>
+MappingNotify</emphasis>
+ events when the keyboard mapping changes. If you wish to be notified of
+changes to the compatibility map, you should select for <emphasis>
+XkbCompatMapNotify</emphasis>
+ events. If you select for <emphasis>
+XkbMapNotify</emphasis>
+ events, you no longer receive the automatically generated <emphasis>
+MappingNotify</emphasis>
+ events. If you subsequently deselect <emphasis>
+XkbMapNotifyEvent</emphasis>
+ delivery, you again receive <emphasis>
+MappingNotify</emphasis>
+ events.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbCompatMapNotify</emphasis>
+ events under all possible conditions, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) and pass <emphasis>
+XkbCompatMapNotifyMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbCompatMapNotify</emphasis>
+ events only under certain conditions, use <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbCompatMapNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying the desired map changes in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ using mask bits from Table 17.2.
+</para>
+
+
+<para>
+Note that you are notified of changes you make yourself, as well as changes
+made by other clients.
+</para>
+
+
+<para>
+The structure for the <emphasis>
+XkbCompatMapNotifyEvent</emphasis>
+ is:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis>True</emphasis> =&gt;
+ synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis>XkbCompatMapNotify</emphasis> */
+ int device; /* Xkb device ID, will not be
+ <emphasis>XkbUseCoreKbd</emphasis> */
+ unsigned int changed_groups;/* number of group maps changed */
+ int first_si; /* index to 1st changed symbol
+ interpretation */
+ int num_si; /* number of changed symbol
+ interpretations */
+ int num_total_si; /* total number of valid symbol
+ interpretations */
+} <emphasis>XkbCompatMapNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+<emphasis>
+changed_groups</emphasis>
+ is the number of group compatibility maps that have changed. If you are
+maintaining a corresponding copy of the compatibility map, or get a fresh copy
+from the server using <emphasis>
+XkbGetCompatMap</emphasis>
+, <emphasis>
+changed_groups</emphasis>
+ references <emphasis>
+groups</emphasis>
+[0..<emphasis>
+changed_groups</emphasis>
+-1] in the <emphasis>
+XkbCompatMapRec</emphasis>
+ structure.
+</para>
+
+
+<para>
+<emphasis>
+first_si</emphasis>
+ is the index of the first changed symbol interpretation, <emphasis>
+num_si</emphasis>
+ is the number of changed symbol interpretations, and <emphasis>
+num_total_si</emphasis>
+ is the total number of valid symbol interpretations. If you are maintaining a
+corresponding copy of the compatibility map, or get a fresh copy from the
+server using <emphasis>
+XkbGetCompatMap</emphasis>
+, <emphasis>
+first_si</emphasis>
+, <emphasis>
+num_si</emphasis>
+, and <emphasis>
+num_total_si</emphasis>
+ are appropriate for use with the <emphasis>
+compat.sym_interpret</emphasis>
+ vector in this structure.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_the_compatibility_map'>
+<title>Allocating and Freeing the Compatibility Map</title>
+
+<para>
+If you are modifying the compatibility map, you need to allocate a new
+compatibility map if you do not already have one available. To do so, use
+<emphasis>
+XkbAllocCompatMap</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocCompatMap</emphasis>
+(<emphasis>
+xkb, which, num_si</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description in which to allocate compat map */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask of compatibility map components to allocate */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ num_si</emphasis>
+; /* number of symbol interpretations to allocate */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+xkb</emphasis>
+ specifies the keyboard description for which compatibility maps are to be
+allocated. The compatibility map is the <emphasis>
+compat</emphasis>
+ field in this structure.
+</para>
+
+
+<para>
+<emphasis>
+which</emphasis>
+ specifies the compatibility map components to be allocated (see <emphasis>
+XkbGetCompatMap</emphasis>
+, in section 17.2). <emphasis>
+which</emphasis>
+ is an inclusive OR of the bits shown in Table 17.2.
+</para>
+
+
+<para>
+<emphasis>
+num_si</emphasis>
+ specifies the total number of entries to allocate in the symbol interpretation
+vector (<emphasis>
+xkb.compat.sym_interpret</emphasis>
+).
+</para>
+
+
+<para>
+Note that symbol interpretations in a compatibility map (the <emphasis>
+sym_interpret</emphasis>
+ vector of <emphasis>
+XkbSymInterpretRec</emphasis>
+ structures) are also allocated using this same function. To ensure that there
+is sufficient space in the symbol interpretation vector for entries to be
+added, use <emphasis>
+XkbAllocCompatMap</emphasis>
+ specifying <emphasis>
+which</emphasis>
+ as <emphasis>
+XkbSymInterpretMask</emphasis>
+ and the number of free symbol interpretations needed in <emphasis>
+num_si</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbAllocCompatMap</emphasis>
+ returns <emphasis>
+Success</emphasis>
+ if successful, <emphasis>
+BadMatch</emphasis>
+ if <emphasis>
+xkb</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, or <emphasis>
+BadAlloc</emphasis>
+ if errors are encountered when attempting to allocate storage.
+</para>
+
+
+<para>
+To free an entire compatibility map or selected portions of one, use <emphasis>
+XkbFreeCompatMap</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeCompatMap</emphasis>
+(<emphasis>
+xkb, which, free_map</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* Xkb description in which to free compatibility map */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask of compatibility map components to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+ free_map</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; free <emphasis>
+XkbCompatMap</emphasis>
+ structure itself */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+which</emphasis>
+ specifies the compatibility map components to be freed (see <emphasis>
+XkbGetCompatMap</emphasis>
+, in section 17.2). <emphasis>
+which</emphasis>
+ is an inclusive OR of the bits shown in Table 17.2
+</para>
+
+
+<para>
+<emphasis>
+free_map</emphasis>
+ indicates whether the <emphasis>
+XkbCompatMap</emphasis>
+ structure itself should be freed. If <emphasis>
+free_map</emphasis>
+ is <emphasis>
+True</emphasis>
+, <emphasis>
+which</emphasis>
+ is ignored, all non-<emphasis>
+NULL</emphasis>
+ compatibility map components are freed, and the <emphasis>
+compat</emphasis>
+ field in the <emphasis>
+XkbDescRec</emphasis>
+ referenced by <emphasis>
+xkb</emphasis>
+ is set to <emphasis>
+NULL</emphasis>
+.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch18.xml b/specs/XKB/ch18.xml
new file mode 100644
index 00000000..025d777f
--- /dev/null
+++ b/specs/XKB/ch18.xml
@@ -0,0 +1,1182 @@
+<chapter id='symbolic_names'>
+<title>Symbolic Names</title>
+
+<para>
+The core protocol does not provide any information to clients other than that
+actually used to interpret events. This makes it difficult to write an
+application that presents the keyboard to a user in an easy-to-understand way.
+Such applications have to examine the vendor string and keycodes to determine
+the type of keyboard connected to the server and then examine keysyms and
+modifier mappings to determine the effects of most modifiers (the <emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+ and <emphasis>
+Control</emphasis>
+ modifiers are defined by the core protocol but no semantics are implied for
+any other modifiers).
+</para>
+
+
+<para>
+To make it easier for applications to present a keyboard to the user, Xkb
+supports symbolic names for most components of the keyboard extension. Most of
+these symbolic names are grouped into the <emphasis>
+names</emphasis>
+ component of the keyboard description.
+</para>
+
+<sect1 id='the_xkbnamesrec_structure'>
+<title>The XkbNamesRec Structure</title>
+
+<para>
+The names component of the keyboard description is defined as follows:
+</para>
+
+<para><programlisting>
+#define XkbKeyNameLength 4
+#define XkbKeyNumVirtualMods 16
+#define XkbKeyNumIndicators 32
+#define XkbKeyNumKbdGroups 4
+#define XkbMaxRadioGroups 32
+</programlisting></para>
+
+<para><programlisting>
+typedef struct {
+ char name[XkbKeyNameLength]; /* symbolic key names */
+} <emphasis>XkbKeyNameRec</emphasis>,*XkbKeyNamePtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct {
+ char real[XkbKeyNameLength];
+ /* this key name must be in the keys array */
+ char alias[XkbKeyNameLength];
+ /* symbolic key name as alias for the key */
+} <emphasis>XkbKeyAliasRec</emphasis>,*XkbKeyAliasPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbNamesRec {
+ Atom keycodes; /* identifies range and meaning of keycodes */
+ Atom geometry; /* identifies physical location, size, and shape of keys */
+ Atom symbols; /* identifies the symbols logically bound to the keys */
+ Atom types; /* identifies the set of key types */
+ Atom compat; /* identifies actions for keys using core protocol */
+ Atom vmods[XkbNumVirtualMods]; /* symbolic names for virtual modifiers */
+ Atom indicators[XkbNumIndicators]; /* symbolic names for indicators */
+ Atom groups[XkbNumKbdGroups]; /* symbolic names for keyboard groups */
+ XkbKeyNamePtr keys; /* symbolic key name array */
+ XkbKeyAliasPtr key_aliases; /* real/alias symbolic name pairs array */
+ Atom * radio_groups; /* radio group name array */
+ Atom phys_symbols; /* identifies the symbols engraved on the keyboard */
+ unsigned char num_keys; /* number of keys in the <emphasis> keys</emphasis> array */
+ unsigned char num_key_aliases; /* number of keys in the
+ <emphasis> key_aliases</emphasis> array */
+ unsigned short num_rg; /* number of radio groups */
+} <emphasis>XkbNamesRec</emphasis>,*XkbNamesPtr; /*
+</programlisting></para>
+
+<para>
+The <emphasis>
+keycodes</emphasis>
+ name identifies the range and meaning of the keycodes returned by the keyboard
+in question. The <emphasis>
+geometry</emphasis>
+ name, on the other hand, identifies the physical location, size and shape of
+the various keys on the keyboard. As an example to distinguish between these
+two names, consider function keys on PC-compatible keyboards. Function keys are
+sometimes above the main keyboard and sometimes to the left of the main
+keyboard, but the same keycode is used for the key that is logically F1
+regardless of physical position. Thus, all PC-compatible keyboards share a
+similar keycodes name but may have different geometry names.
+</para>
+
+<note><para>The keycodes name is intended to be a very general description of
+the keycodes returned by a keyboard; a single keycodes name might cover
+keyboards with differing numbers of keys provided all keys have the same
+semantics when present. For example, 101 and 102 key PC keyboards might use the
+same name. In these cases, applications can use the keyboard <emphasis>
+geometry</emphasis>
+ name to determine which subset of the named keycodes is in use.</para></note>
+
+<para>
+The <emphasis>
+symbols</emphasis>
+ name identifies the symbols logically bound to the keys. The symbols name is a
+human or application-readable description of the intended locale or usage of
+the keyboard with these symbols. The <emphasis>
+phys_symbols</emphasis>
+ name, on the other hand, identifies the symbols actually engraved on the
+keyboard. Given this, the <emphasis>
+symbols</emphasis>
+ name and <emphasis>
+phys_symbols</emphasis>
+ names might be different. For example, the description for a keyboard that has
+English US engravings, but that is using Swiss German symbols might have a
+<emphasis>
+phys_symbols</emphasis>
+ name of "en_US" and a <emphasis>
+symbols</emphasis>
+ name of "de_CH."
+</para>
+
+
+<para>
+The <emphasis>
+types</emphasis>
+ name provides some information about the set of key types (see section 15.2)
+that can be associated with the keyboard. In addition, each key type can have a
+name, and each shift level of a type can have a name. Although these names are
+stored in the map description with each of the types, they are accessed using
+the same methods as the other symbolic names.
+</para>
+
+
+<para>
+The <emphasis>
+compat</emphasis>
+ name provides some information about the rules used to bind actions to keys
+that are changed using core protocol requests.
+</para>
+
+
+<para>
+Xkb provides symbolic names for each of the 4 keyboard groups, 16 virtual
+modifiers, 32 keyboard indicators, and 4 keyboard groups. These names are held
+in the <emphasis>
+vmods</emphasis>
+, <emphasis>
+indicators</emphasis>
+, and <emphasis>
+groups</emphasis>
+ fixed-length arrays.
+</para>
+
+
+<para>
+Each key has a four-byte symbolic name. All of the symbolic key names are held
+in the <emphasis>
+keys</emphasis>
+ array, and <emphasis>
+num_keys</emphasis>
+ reports the number of entries that are in the keys array. For each key, the
+key name links keys with similar functions or in similar positions on keyboards
+that report different keycodes. For example, the <emphasis>
+F1</emphasis>
+ key may emit keycode 23 on one keyboard and keycode 86 on another. By naming
+this key "FK01" on both keyboards, the keyboard layout designer can reuse parts
+of keyboard descriptions for different keyboards.
+</para>
+
+
+<para>
+Key aliases allow the keyboard layout designer to assign multiple key names to
+a single key. This allows the keyboard layout designer to refer to keys using
+either their position or their "function." For example, a keyboard layout
+designer may wish to refer to the left arrow key on a PC keyboard using the
+ISO9995-5 positional specification of A31 or using the functional specification
+of LEFT. The <emphasis>
+key_aliases</emphasis>
+ field holds a variable-length array of real and alias key name pairs, and the
+total number of entries in the <emphasis>
+key_aliases</emphasis>
+ array is held in <emphasis>
+num_key_aliases</emphasis>
+. For each real and alias key name pair, the <emphasis>
+real</emphasis>
+ field refers to the a name in the keys array, and the <emphasis>
+alias</emphasis>
+ field refers to the alias for that key. Using the previous example, the
+keyboard designer may use the name A31 in the keys array, but also define the
+name LEFT as an alias for A31 in the <emphasis>
+key_aliases</emphasis>
+ array.
+</para>
+
+<note><para>Key aliases defined in the geometry component of a keyboard mapping
+(see Chapter 13) override those defined in the keycodes component of the server
+database, which are stored in the <emphasis>
+XkbNamesRec</emphasis>
+ (<emphasis>
+xkb-&gt;names</emphasis>
+). Therefore, consider the key aliases defined by the geometry before
+considering key aliases supplied by the <emphasis>
+XkbNamesRec</emphasis>
+.</para></note>
+
+<para>
+A radio group is a set of keys whose behavior simulates a set of radio buttons.
+Once a key in a radio group is pressed, it stays logically depressed until
+another key in the group is pressed, at which point the previously depressed
+key is logically released. Consequently, at most one key in a radio group can
+be logically depressed at one time.
+</para>
+
+
+<para>
+Each radio group in the keyboard description can have a name. These names are
+held in the variable-length array <emphasis>
+radio_groups</emphasis>
+, and <emphasis>
+num_rg</emphasis>
+ tells how many elements are in the <emphasis>
+radio_groups</emphasis>
+ array.
+</para>
+
+
+</sect1>
+<sect1 id='symbolic_names_masks'>
+<title>Symbolic Names Masks</title>
+
+<para>
+Xkb provides several functions that work with symbolic names. Each of these
+functions uses a mask to specify individual fields of the structures described
+above. These masks and their relationships to the fields in a keyboard
+description are shown in Table 18.1.
+</para>
+
+<table frame='none'>
+<title>Symbolic Names Masks</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask Bit</entry>
+ <entry>Value</entry>
+ <entry>Keyboard Component</entry>
+ <entry>Field</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbKeycodesNameMask</entry>
+ <entry>(1&lt;&lt;0)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>keycodes</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbGeometryNameMask</entry>
+ <entry>(1&lt;&lt;1)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>geometry</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbSymbolsNameMask</entry>
+ <entry>(1&lt;&lt;2)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>symbols</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbPhysSymbolsNameMask</entry>
+ <entry>(1&lt;&lt;3)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>phys_symbols</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbTypesNameMask</entry>
+ <entry>(1&lt;&lt;4)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>type</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbCompatNameMask</entry>
+ <entry>(1&lt;&lt;5)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>compat</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKeyTypeNamesMask</entry>
+ <entry>(1&lt;&lt;6)</entry>
+ <entry>Xkb-&gt;map</entry>
+ <entry>type[*].name</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKTLevelNamesMask</entry>
+ <entry>(1&lt;&lt;7)</entry>
+ <entry>Xkb-&gt;map</entry>
+ <entry>type[*].lvl_names[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbIndicatorNamesMask</entry>
+ <entry>(1&lt;&lt;8)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>indicators[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKeyNamesMask</entry>
+ <entry>(1&lt;&lt;9)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>keys[*], num_keys</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKeyAliasesMask</entry>
+ <entry>(1&lt;&lt;10)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>key_aliases[*], num_key_aliases</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbVirtualModNamesMask</entry>
+ <entry>(1&lt;&lt;11)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>vmods[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbGroupNamesMask</entry>
+ <entry>(1&lt;&lt;12)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>groups[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbRGNamesMask</entry>
+ <entry>(1&lt;&lt;13)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>radio_groups[*], num_rg</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbComponentNamesMask</entry>
+ <entry>(0x3f)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>
+<para>keycodes,</para>
+<para>geometry,</para>
+<para>symbols,</para>
+<para>physical symbols,</para>
+<para>types, and</para>
+<para>compatibility map</para>
+ </entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbAllNamesMask</entry>
+ <entry>(0x3fff)</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>all name components</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+<sect1 id='getting_symbolic_names_from_the_server'>
+<title>Getting Symbolic Names From the Server</title>
+
+<para>
+To obtain symbolic names from the server, use <emphasis>
+XkbGetNames</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetNames</emphasis>
+(<emphasis>
+dpy, which, Xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of names or map components to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+ /* keyboard description to be updated */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetNames</emphasis>
+ retrieves symbolic names for the components of the keyboard extension from the
+X server. The <emphasis>
+which</emphasis>
+ parameter specifies the name components to be updated in the <emphasis>
+xkb</emphasis>
+ parameter, and is the bitwise inclusive OR of the valid names mask bits
+defined in Table 18.1.
+</para>
+
+
+<para>
+If the <emphasis>
+names</emphasis>
+ field of the keyboard description <emphasis>
+xkb</emphasis>
+ is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetNames</emphasis>
+ allocates and initializes the <emphasis>
+names</emphasis>
+ component of the keyboard description before obtaining the values specified by
+<emphasis>
+which</emphasis>
+. If the <emphasis>
+names</emphasis>
+ field of <emphasis>
+xkb</emphasis>
+ is not <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetNames</emphasis>
+ obtains the values specified by <emphasis>
+which</emphasis>
+ and copies them into the keyboard description <emphasis>
+Xkb</emphasis>
+.
+</para>
+
+
+<para>
+If the <emphasis>
+map</emphasis>
+ component of the <emphasis>
+xkb</emphasis>
+ parameter is <emphasis>
+NULL</emphasis>
+, <emphasis>
+XkbGetNames</emphasis>
+ does not retrieve type or shift level names, even if <emphasis>
+XkbKeyTypeNamesMask</emphasis>
+ or <emphasis>
+XkbKTLevelNamesMask</emphasis>
+ are set in <emphasis>
+which</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetNames</emphasis>
+ can return <emphasis>
+Success</emphasis>
+, or <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadLength</emphasis>
+, <emphasis>
+BadMatch</emphasis>
+, and <emphasis>
+BadImplementation</emphasis>
+ errors.
+</para>
+
+
+<para>
+To free symbolic names, use <emphasis>
+XkbFreeNames</emphasis>
+ (see section 18.6)
+</para>
+
+
+</sect1>
+<sect1 id='changing_symbolic_names_on_the_server'>
+<title>Changing Symbolic Names on the Server</title>
+
+<para>
+To change the symbolic names in the server, first modify a local copy of the
+keyboard description and then use either <emphasis>
+XkbSetNames,</emphasis>
+ or, to save network traffic, use a <emphasis>
+XkbNameChangesRec</emphasis>
+structure and call <emphasis>
+XkbChangeNames</emphasis>
+ to download the changes to the server. <emphasis>
+XkbSetNames</emphasis>
+ and <emphasis>
+XkbChangeNames</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadAtom</emphasis>
+, <emphasis>
+BadLength</emphasis>
+, <emphasis>
+BadMatch,</emphasis>
+ and <emphasis>
+BadImplementation</emphasis>
+ errors.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetNames</emphasis>
+(<emphasis>
+dpy, which, first_type, num_types, xkb</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of names or map components to be changed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+first_type</emphasis>
+ ; /* first type whose name is to be changed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+num_types</emphasis>
+; /* number of types for which names are to be changed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description from which names are to be taken */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+Use<emphasis>
+ XkbSetNames</emphasis>
+ to change many names at the same time. For each bit set in <emphasis>
+which</emphasis>
+, <emphasis>
+XkbSetNames</emphasis>
+ takes the corresponding value (or values in the case of arrays) from the
+keyboard description <emphasis>
+xkb</emphasis>
+ and sends it to the server.
+</para>
+
+
+<para>
+The <emphasis>
+first_type</emphasis>
+ and <emphasis>
+num_types</emphasis>
+ arguments are used only if <emphasis>
+XkbKeyTypeNamesMask</emphasis>
+ or <emphasis>
+XkbKTLevelNamesMask</emphasis>
+ is set in <emphasis>
+which</emphasis>
+ and specify a subset of the types for which the corresponding names are to be
+changed. If either or both of these mask bits are set but the specified types
+are illegal, <emphasis>
+XkbSetNames</emphasis>
+ returns <emphasis>
+False</emphasis>
+ and does not update any of the names specified in <emphasis>
+which</emphasis>
+. The specified types are illegal if <emphasis>
+xkb</emphasis>
+ does not include a map component or if <emphasis>
+first_type</emphasis>
+ and <emphasis>
+num_types</emphasis>
+ specify types that are not defined in the keyboard description.
+</para>
+
+
+<sect2>
+<title/>
+
+<sect3 id='the_xkbnamechangesrec_structure'>
+<title>The XkbNameChangesRec Structure</title>
+
+<para>
+The <emphasis>
+XkbNameChangesRec</emphasis>
+ allows applications to identify small modifications to the symbolic names and
+effectively reduces the amount of traffic sent to the server:
+</para>
+
+<para><programlisting>
+typedef struct _XkbNameChanges {
+ unsigned int changed; /* name components that have
+ changed */
+ unsigned char first_type; /* first key type with a new
+ name */
+ unsigned char num_types; /* number of types with new
+ names */
+ unsigned char first_lvl; /* first key type with new level
+ names */
+ unsigned char num_lvls; /* number of key types with new
+ level names */
+ unsigned char num_aliases; /* if key aliases changed,
+ total number of key aliases */
+ unsigned char num_rg; /* if radio groups changed, total
+ number of radio groups */
+ unsigned char first_key; /* first key with a new name */
+ unsigned char num_keys; /* number of keys with new names
+ */
+ unsigned short changed_vmods; /* mask of virtual
+ modifiers for which names have changed */
+ unsigned long changed_indicators; /* mask of indicators
+ for which names were changed */
+ unsigned char changed_groups; /* mask of groups for
+ which names were changed */
+} <emphasis>XkbNameChangesRec</emphasis>, *XkbNameChangesPtr
+</programlisting></para>
+
+<para>
+The <emphasis>
+changed</emphasis>
+ field specifies the name components that have changed and is the bitwise
+inclusive OR of the valid names mask bits defined in Table 18.1. The rest of
+the fields in the structure specify the ranges that have changed for the
+various kinds of symbolic names, as shown in Table 18.2.
+</para>
+
+<table frame='none'>
+<title>XkbNameChanges Fields</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Mask</entry>
+ <entry>Fields</entry>
+ <entry>Component</entry>
+ <entry>Field</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbKeyTypeNamesMask</entry>
+ <entry>
+<para>first_type,</para>
+<para>num_types</para>
+ </entry>
+ <entry>Xkb-&gt;map</entry>
+ <entry>type[*].name</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKTLevelNamesMask</entry>
+ <entry>
+<para>first_lvl,</para>
+<para>num_lvls</para>
+ </entry>
+ <entry>Xkb-&gt;map</entry>
+ <entry>type[*].lvl_names[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKeyAliasesMask</entry>
+ <entry>num_aliases</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>key_aliases[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbRGNamesMask</entry>
+ <entry>num_rg</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>radio_groups[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbKeyNamesMask</entry>
+ <entry>
+<para>first_key,</para>
+<para>num_keys</para>
+ </entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>keys[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbVirtualModNamesMask</entry>
+ <entry>changed_vmods</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>vmods[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbIndicatorNamesMask</entry>
+ <entry>changed_indicators</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>indicators[*]</entry>
+</row>
+<row rowsep='0'>
+ <entry>XkbGroupNamesMask</entry>
+ <entry>changed_groups</entry>
+ <entry>Xkb-&gt;names</entry>
+ <entry>groups[*]</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+<emphasis>
+XkbChangeNames</emphasis>
+ provides a more flexible method for changing symbolic names than <emphasis>
+XkbSetNames</emphasis>
+ and requires the use of an <emphasis>
+XkbNameChangesRec</emphasis>
+ structure.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbChangeNames</emphasis>
+(<emphasis>
+dpy, xkb, changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+ xkb</emphasis>
+; /* keyboard description from which names are to be taken */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbNameChangesPtr <emphasis>
+ changes</emphasis>
+; /* names map components to be updated on the server */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbChangeNames</emphasis>
+ copies any names specified by <emphasis>
+changes</emphasis>
+ from the keyboard description, <emphasis>
+xkb</emphasis>
+, to the X server specified by <emphasis>
+dpy</emphasis>
+.<emphasis>
+ XkbChangeNames</emphasis>
+ aborts and returns <emphasis>
+False</emphasis>
+ if any illegal type names or type shift level names are specified by <emphasis>
+changes</emphasis>
+.
+</para>
+
+</sect3>
+</sect2>
+</sect1>
+<sect1 id='tracking_name_changes'>
+<title>Tracking Name Changes</title>
+
+<para>
+Whenever a symbolic name changes in the server’s keyboard description, the
+server sends a <emphasis>
+XkbNamesNotify</emphasis>
+ event to all interested clients. To receive name notify events, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) with <emphasis>
+XkbNamesNotifyMask</emphasis>
+ in both the <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ parameters.
+</para>
+
+
+<para>
+To receive events for only specific names, use <emphasis>
+XkbSelectEventDetails</emphasis>
+. Set the <emphasis>
+event_type</emphasis>
+ parameter to <emphasis>
+XkbNamesNotify</emphasis>
+, and set both the <emphasis>
+bits_to_change </emphasis>
+and<emphasis>
+ values_for_bits</emphasis>
+ detail parameter to a mask composed of a bitwise OR of masks in Table 18.1.
+</para>
+
+
+<para>
+The structure for the <emphasis>
+XkbNamesNotify</emphasis>
+ event is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for
+ event */
+ Bool send_event; /* <emphasis>True</emphasis>
+ =&gt; synthetically generated */
+ Display * display; /* server connection where event
+ generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis>XkbNamesNotify</emphasis> */
+ int device; /* Xkb device ID, will not be
+ <emphasis>XkbUseCoreKbd</emphasis> */
+ unsigned int changed; /* mask of name components
+that have changed */
+ int first_type; /* first key type with a new name */
+ int num_types; /* number of types with new names */
+ int first_lvl; /* first key type with new level names */
+ int num_lvls; /* number of key types with new level names */
+ int num_aliases; /* if key aliases changed, total number
+ of key aliases */
+ int num_radio_groups; /* if radio groups changed,
+ total number of radio groups */
+ unsigned int changed_vmods; /* mask of virtual modifiers for
+ which names have changed */
+ unsigned int changed_groups; /* mask of groups for
+ which names were changed */
+ unsigned int changed_indicators; /* mask of indicators for which
+ names were changed */
+ int first_key; /* first key with a new name */
+ int num_keys; /* number of keys with new names */
+} <emphasis>XkbNamesNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+changed</emphasis>
+ field specifies the name components that have changed and is the bitwise
+inclusive OR of the valid names mask bits defined in Table 18.1. The other
+fields in this event are interpreted as the like-named fields in an <emphasis>
+XkbNameChangesRec</emphasis> , as previously defined.
+</para>
+
+
+<para>
+When your application receives a X<emphasis>
+kbNamesNotify</emphasis>
+ event, you can note the changed names in a changes structure using <emphasis>
+XkbNoteNameChanges</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbNoteNameChanges</emphasis>
+(<emphasis>
+old</emphasis>
+,<emphasis>
+ new</emphasis>
+,<emphasis>
+ wanted</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbNameChangesPtr <emphasis>
+old</emphasis>
+; /* <emphasis>
+XkbNameChanges</emphasis>
+ structure to be updated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbNamesNotifyEvent * <emphasis>
+new</emphasis>
+; /* event from which changes are to be copied */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+wanted</emphasis>
+; /* types of names for which changes are to be noted */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+wanted</emphasis>
+ parameter is the bitwise inclusive OR of the valid names mask bits shown in
+Table 18.1. <emphasis>
+XkbNoteNameChanges</emphasis>
+ copies any changes that are reported in <emphasis>
+new</emphasis>
+ and specified in <emphasis>
+wanted</emphasis>
+ into the changes record specified by <emphasis>
+old</emphasis>
+.
+</para>
+
+
+<para>
+To update the local copy of the keyboard description with the actual values,
+pass to <emphasis>
+XkbGetNameChanges</emphasis>
+ the results of one or more calls to <emphasis>
+XkbNoteNameChanges</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetNameChanges</emphasis>
+(<emphasis>
+dpy</emphasis>
+,<emphasis>
+ xkb</emphasis>
+,<emphasis>
+ changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to the X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description to which names are copied */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbNameChangesPtr <emphasis>
+changes</emphasis>
+; /* names components to be obtained from the server */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetNameChanges</emphasis>
+ examines the <emphasis>
+changes</emphasis>
+ parameter, retrieves the necessary information from the server, and places the
+results into the <emphasis>
+xkb</emphasis>
+ keyboard description.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetNamesChanges</emphasis>
+ can generate <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadImplementation,</emphasis>
+ and <emphasis>
+BadMatch</emphasis>
+ errors.
+</para>
+
+
+</sect1>
+<sect1 id='allocating_and_freeing_symbolic_names'>
+<title>Allocating and Freeing Symbolic Names</title>
+
+<para>
+Most applications do not need to directly allocate symbolic names structures.
+Do not allocate a names structure directly using <emphasis>
+malloc</emphasis>
+ or <emphasis>
+Xmalloc</emphasis>
+ if your application changes the number of key aliases or radio groups or
+constructs a symbolic names structure without loading the necessary components
+from the X server. Instead use <emphasis>
+XkbAllocNames</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocNames</emphasis>
+(<emphasis>
+xkb, which, num_rg, num_key_aliases)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb;</emphasis>
+ /* keyboard description for which names are to be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which;</emphasis>
+ /* mask of names to be allocated */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+num_rg;</emphasis>
+ /* total number of radio group names needed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+num_key_aliases;</emphasis>
+ /* total number of key aliases needed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocNames</emphasis>
+ can return <emphasis>
+BadAlloc</emphasis>
+, <emphasis>
+BadMatch,</emphasis>
+ and <emphasis>
+BadValue</emphasis>
+ errors.<emphasis>
+ </emphasis>
+The <emphasis>
+which</emphasis>
+ parameter is the bitwise inclusive OR of the valid names mask bits defined in
+Table 18.1.
+</para>
+
+
+<para>
+Do not free symbolic names structures directly using <emphasis>
+free</emphasis>
+ or <emphasis>
+XFree</emphasis>
+. Use <emphasis>
+XkbFreeNames</emphasis>
+ instead.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeNames</emphasis>
+(<emphasis>
+xkb, which, free_map)</emphasis>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDescPtr <emphasis>
+xkb</emphasis>
+; /* keyboard description for which names are to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of names components to be freed */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+free_map</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; XkbNamesRec structure itself should be freed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The <emphasis>
+which</emphasis>
+ parameter is the bitwise inclusive OR of the valid names mask bits defined in
+Table 18.1.
+</para>
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch19.xml b/specs/XKB/ch19.xml
new file mode 100644
index 00000000..9e675b35
--- /dev/null
+++ b/specs/XKB/ch19.xml
@@ -0,0 +1,328 @@
+<chapter id='replacing_a_keyboard_on_the_fly'>
+<title>Replacing a Keyboard "On the Fly"</title>
+
+<para>
+Some operating system and X server implementations allow "hot plugging" of
+input devices. When using these implementations, input devices can be unplugged
+and new ones plugged in without restarting the software that is using those
+devices. There is no provision in the standard X server for notification of
+client programs if input devices are unplugged and/or new ones plugged in. In
+the case of the X keyboard, this could result in the X server having a keymap
+that does not match the new keyboard.
+</para>
+
+
+<para>
+If the X server implementation supports the X input device extension, a client
+program may also change the X keyboard programmatically. The
+XChangeKeyboardDevice input extension request allows a client to designate an
+input extension keyboard device as the X keyboard, in which case the old X
+keyboard device becomes inaccessible except via the input device extension. In
+this case, core protocol <emphasis>
+XMappingNotify</emphasis>
+ and input extension <emphasis>
+XChangeDeviceNotify</emphasis>
+ events are generated to notify all clients that a new keyboard with a new
+keymap has been designated.
+</para>
+
+
+<para>
+When a client opens a connection to the X server, the server reports the
+minimum and maximum keycodes. The server keeps track of the minimum and maximum
+keycodes last reported to each client. When delivering events to a particular
+client, the server filters out any events that fall outside of the valid range
+for the client.
+</para>
+
+
+<para>
+Xkb provides an <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event that reports a change in keyboard geometry and/or the range of supported
+keycodes. The server can generate an <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event when it detects a new keyboard or in response to an <emphasis>
+XkbGetKeyboardByName</emphasis>
+ request that loads a new keyboard description. Selecting for <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events allows Xkb-aware clients to be notified whenever a keyboard change
+occurs that may affect the keymap.
+</para>
+
+
+<para>
+When a client requests <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events, the server compares the range of keycodes for the current keyboard to
+the range of keycodes that are valid for the client. If they are not the same,
+the server immediately sends the client an <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event. Even if the "new" keyboard is not new to the server, it is new to this
+particular client.
+</para>
+
+
+<para>
+When the server sends an <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event to a client to inform it of a new keycode range, it resets the stored
+range of legal keycodes for the client to the keycode range reported in the
+event; it does not reset this range for the client if it does not sent an
+<emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event to a client. Because Xkb-unaware clients and Xkb-aware clients that do
+not request <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events are never sent these events, the server’s notion of the legal keycode
+range never changes, and these clients never receive events from keys that fall
+outside of their notion of the legal keycode range.
+</para>
+
+
+<para>
+Clients that have not selected to receive <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events do, however, receive the <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event when a keyboard change occurs. Clients that have not selected to receive
+this event also receive numerous other events detailing the individual changes
+that occur when a keyboard change occurs.
+</para>
+
+
+<para>
+Clients wishing to track changes in <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ must watch for both <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ and <emphasis>
+XkbMapNotify</emphasis>
+ events, because a simple mapping change causes an <emphasis>
+XkbMapNotify</emphasis>
+ event and may change the range of valid keycodes, but does not cause an
+<emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event. If a client does not select for <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ events, the server restricts the range of keycodes reported to the client.
+</para>
+
+
+<para>
+In addition to filtering out-of-range key events, Xkb:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Adjusts core protocol <emphasis>
+MappingNotify</emphasis>
+ events to refer only to keys that match the stored legal range.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Reports keyboard mappings for keys that match the stored legal range to clients
+that issue a core protocol <emphasis>
+GetKeyboardMapping</emphasis>
+ request.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Reports modifier mappings only for keys that match the stored legal range to
+clients that issue a core protocol <emphasis>
+GetModifierMapping</emphasis>
+ request.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Restricts the core protocol <emphasis>
+ChangeKeyboardMapping</emphasis>
+ and <emphasis>
+SetModifierMapping</emphasis>
+ requests to keys that fall inside the stored legal range.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+In short, Xkb does everything possible to hide from Xkb-unaware clients the
+fact that the range of legal keycodes has changed, because such clients cannot
+be expected to deal with them. Xkb events and requests are not modified in this
+manner; all Xkb events report the full range of legal keycodes. No requested
+Xkb events are discarded, and no Xkb requests have their keycode range clamped.
+</para>
+
+
+<para>
+The structure for the <emphasis>
+XkbNewKeyboardNotify</emphasis>
+ event is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct _XkbNewKeyboardNotify {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event*/
+ Bool send_event; /* <emphasis>True</emphasis>
+ =&gt; synthetically generated */
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis>XkbNewKeyboardNotify</emphasis> */
+ int device; /* device ID of new keyboard */
+ int old_device; /* device ID of old keyboard */
+ int min_key_code; /* min keycode of new keyboard */
+ int max_key_code; /* max keycode of new keyboard */
+ int old_min_key_code; /* min keycode of old keyboard */
+ int old_max_key_code; /* max keycode of old keyboard */
+ unsigned int changed; /* changed aspects - see masks below */
+ char req_major; /* major request that caused change */
+ char req_minor; /* minor request that caused change */
+} <emphasis>XkbNewKeyboardNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+To receive name notify events, use <emphasis>
+XkbSelectEvents</emphasis>
+ (see section 4.3) with <emphasis>
+XkbNewKeyboardNotifyMask</emphasis>
+ in both the <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+ parameters. To receive events for only specific names, use <emphasis>
+XkbSelectEventDetails</emphasis>
+. Set the <emphasis>
+event_type</emphasis>
+ parameter to <emphasis>
+XkbNewKeyboardNotify</emphasis>
+, and set both the <emphasis>
+bits_to_change </emphasis>
+and<emphasis>
+ values_for_bits</emphasis>
+ detail parameter to a mask composed of a bitwise OR of masks in Table 19.1.
+</para>
+
+<table frame='none'>
+<title>XkbNewKeyboardNotifyEvent Details</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='1'>
+ <entry>XkbNewKeyboardNotify Event Details</entry>
+ <entry>Value</entry>
+ <entry>Circumstances</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='1'>
+ <entry><emphasis>XkbNKN_KeycodesMask</emphasis></entry>
+ <entry>(1L&lt;&lt;0)</entry>
+ <entry>Notification of keycode range changes wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbNKN_GeometryMask</emphasis></entry>
+ <entry>(1L&lt;&lt;1)</entry>
+ <entry>Notification of geometry changes wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbNKN_DeviceIDMask</entry>
+ <entry>(1L&lt;&lt;2)</entry>
+ <entry>Notification of device ID changes wanted</entry>
+ </row>
+ <row rowsep='0'>
+ <entry><emphasis>XkbNKN_AllChangesMask</emphasis></entry>
+ <entry>(0x7)</entry>
+ <entry>Includes all of the above masks</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+req_major</emphasis>
+ and <emphasis>
+req_minor</emphasis>
+ fields indicate what type of keyboard change has occurred.
+</para>
+
+
+<para>
+If <emphasis>
+req_major</emphasis>
+ and <emphasis>
+req_minor</emphasis>
+ are zero, the device change was not caused by a software request to the server
+— a spontaneous change has occurred, such as hot-plugging a new device. In
+this case, <emphasis>
+device</emphasis>
+ is the device identifier for the new, current X keyboard device, but no
+implementation-independent guarantee can be made about <emphasis>
+old_device</emphasis>
+. <emphasis>
+old_device</emphasis>
+ may be identical to <emphasis>
+device</emphasis>
+ (an implementor is permitted to reuse the device specifier when the device
+changes); or it may be different. Note that <emphasis>
+req_major</emphasis>
+ and <emphasis>
+req_minor</emphasis>
+ being zero do not necessarily mean that the physical keyboard device has
+changed; rather, they only imply a spontaneous change outside of software
+control (some systems have keyboards that can change personality at the press
+of a key).
+</para>
+
+
+<para>
+If the keyboard change is the result of an X Input Extension <emphasis>
+ChangeKeyboardDevice</emphasis>
+ request, <emphasis>
+req_major</emphasis>
+ contains the input extension major opcode, and <emphasis>
+req_minor</emphasis>
+ contains the input extension request number for <emphasis>
+X_ChangeKeyboardDevice</emphasis>
+. In this case, <emphasis>
+device</emphasis>
+ and <emphasis>
+old_device</emphasis>
+ are different, with <emphasis>
+device</emphasis>
+ being the identifier for the new, current X keyboard device, and <emphasis>
+old_device</emphasis>
+ being the identifier for the former device.
+</para>
+
+
+<para>
+If the keyboard change is the result of an <emphasis>
+XkbGetKeyboardByName</emphasis>
+ function call, which generates an <emphasis>
+X_kbGetKbdByName</emphasis>
+ request, <emphasis>
+req_major</emphasis>
+ contains the Xkb extension base event code (see section 2.4), and <emphasis>
+req_minor</emphasis>
+ contains the event code for the Xkb extension request <emphasis>
+X_kbGetKbdByName</emphasis>
+. <emphasis>
+device</emphasis>
+ contains the device identifier for the new device, but nothing definitive can
+be said for <emphasis>
+old_device</emphasis>
+; it may be identical to <emphasis>
+device</emphasis>
+, or it may be different, depending on the implementation.
+</para>
+
+</chapter>
diff --git a/specs/XKB/ch20.xml b/specs/XKB/ch20.xml
new file mode 100644
index 00000000..9eba2f98
--- /dev/null
+++ b/specs/XKB/ch20.xml
@@ -0,0 +1,1188 @@
+<chapter id='server_database_of_keyboard_components'>
+<title>Server Database of Keyboard Components</title>
+
+<para>
+The X server maintains a database of keyboard components, identified by
+component type. The database contains all the information necessary to build a
+complete keyboard description for a particular device, as well as to assemble
+partial descriptions. Table 20.1 identifies the component types and the type of
+information they contain.
+</para>
+
+<table frame='none'>
+<title>Server Database Keyboard Components</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Component Type</entry>
+ <entry>Component Primary Contents</entry>
+ <entry>May also contain</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>Keymap</entry>
+ <entry>
+<para>Complete keyboard description</para>
+<para>Normally assembled using a complete component from each of the other types</para>
+ </entry>
+ <entry></entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Keycodes</entry>
+ <entry>
+<para>Symbolic name for each key</para>
+<para>Minimum and maximum legal keycodes</para>
+ </entry>
+ <entry>
+<para>Aliases for some keys</para>
+<para>Symbolic names for indicators</para>
+<para>Description of indicators physically present</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Types</entry>
+ <entry>Key types</entry>
+ <entry>
+Real modifier bindings and symbolic names for some virtual modifiers
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Compatibility</entry>
+ <entry>Rules used to assign actions to keysyms</entry>
+ <entry>
+<para>Maps for some indicators</para>
+<para>Real modifier bindings and symbolic names for some virtual modifiers</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Symbols</entry>
+ <entry>
+<para>Symbol mapping for keyboard keys</para>
+<para>Modifier mapping</para>
+<para>Symbolic names for groups</para>
+ </entry>
+ <entry>
+<para>Explicit actions and behaviors for some keys</para>
+<para>Real modifier bindings and symbolic names for some virtual modifiers</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>Geometry</entry>
+ <entry>Layout of the keyboard</entry>
+ <entry>
+<para>Aliases for some keys; overrides keycodes component aliases</para>
+<para>Symbolic names for some indicators</para>
+<para>Description of indicators physically present</para>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+While a keymap is a database entry for a complete keyboard description, and
+therefore logically different from the individual component database entries,
+the rules for processing keymap entries are identical to those for the
+individual components. In the discussion that follows, the term component is
+used to refer to either individual components or a keymap.
+</para>
+
+<para>
+There may be multiple entries for each of the component types. An entry may be
+either <emphasis>
+complete</emphasis>
+ or <emphasis>
+partial</emphasis>
+. Partial entries describe only a piece of the corresponding keyboard component
+and are designed to be combined with other entries of the same type to form a
+complete entry.
+</para>
+
+<para>
+For example, a partial symbols map might describe the differences between a
+common ASCII keyboard and some national layout. Such a partial map is not
+useful on its own because it does not include those symbols that are the same
+on both the ASCII and national layouts (such as function keys). On the other
+hand, this partial map can be used to configure <emphasis>
+any</emphasis>
+ ASCII keyboard to use a national layout.
+</para>
+
+<para>
+When a keyboard description is built, the components are processed in the order
+in which they appear in Table 20.1; later definitions override earlier ones.
+</para>
+
+<sect1 id='component_names'>
+<title>Component Names</title>
+
+<para>
+Component names have the form "<emphasis>
+class(member)</emphasis>
+" where <emphasis>
+class</emphasis>
+ describes a subset of the available components for a particular type and the
+optional <emphasis>
+member</emphasis>
+ identifies a specific component from that subset. For example, the name
+"atlantis(acme)" for a symbols component might specify the symbols used for the
+atlantis national keyboard layout by the vendor "acme." Each class has an
+optional <emphasis>
+default</emphasis>
+ member — references that specify a class but not a member refer to the
+default member of the class, if one exists. Xkb places no constraints on the
+interpretation of the class and member names used in component names.
+</para>
+
+<para>
+The <emphasis>
+class</emphasis>
+ and <emphasis>
+member</emphasis>
+ names are both specified using characters from the Latin-1 character set. Xkb
+implementations must accept all alphanumeric characters, minus (‘-’) and
+underscore (‘_’) in class or member names, and must not accept parentheses,
+plus, vertical bar, percent sign, asterisk, question mark, or white space. The
+use of other characters is implementation-dependent.
+</para>
+
+</sect1>
+<sect1 id='listing_the_known_keyboard_components'>
+<title>Listing the Known Keyboard Components</title>
+
+<para>
+You may ask the server for a list of components for one or more component
+types. The request takes the form of a set of patterns, one pattern for each of
+the component types, including a pattern for the complete keyboard description.
+To obtain this list, use <emphasis>
+XkbListComponents</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbComponentListPtr<emphasis>
+ XkbListComponents</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+device_spec</emphasis>
+, <emphasis>
+ptrns</emphasis>
+, <emphasis>
+max_inout</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbComponentNamesPtr <emphasis>
+ptrns</emphasis>
+; /* namelist for components of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int * <emphasis>
+max_inout</emphasis>
+; /* max # returned names, # left over */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbListComponents</emphasis>
+ queries the server for a list of component names matching the patterns
+specified in <emphasis>
+ptrns</emphasis>
+. It waits for a reply and returns the matching component names in an <emphasis>
+XkbComponentListRec</emphasis>
+ structure. When you are done using the structure, you should free it using
+<emphasis>
+XkbFreeComponentList</emphasis>
+. <emphasis>
+device_spec</emphasis>
+ indicates a particular device in which the caller is interested. A server is
+allowed (but not required) to restrict its reply to portions of the database
+that are relevant for that particular device.
+</para>
+
+
+<para>
+<emphasis>
+ptrns</emphasis>
+ is a pointer to an <emphasis>
+XkbComponentNamesRec</emphasis>
+, described below. Each of the fields in <emphasis>
+ptrns</emphasis>
+ contains a pattern naming the components of interest. Each of the patterns is
+composed of characters from the ISO <emphasis>
+Latin1</emphasis>
+ encoding, but can contain only parentheses, the wildcard characters
+‘<emphasis>
+?</emphasis>
+’ and ‘<emphasis>
+*</emphasis>
+’, and characters permitted in a component class or member name (see section
+20.1). A pattern may be <emphasis>
+NULL</emphasis>
+, in which case no components for that type is returned. Pattern matches with
+component names are case sensitive. The ‘<emphasis>
+?</emphasis>
+’ wildcard matches any single character, except a left or right parenthesis;
+the ‘<emphasis>
+*</emphasis>
+’ wildcard matches any number of characters, except a left or right
+parenthesis. If an implementation allows additional characters in a component
+class or member name other than those required by the Xkb extension (see
+section 20.1), the result of comparing one of the additional characters to
+either of the wildcard characters is implementation-dependent.
+</para>
+
+
+<para>
+If a pattern contains illegal characters, the illegal characters are ignored.
+The matching process is carried out as if the illegal characters were omitted
+from the pattern.
+</para>
+
+
+<para>
+<emphasis>
+max_inout</emphasis>
+ is used to throttle the amount of data passed to and from the server. On
+input, it specifies the maximum number of names to be returned (the total
+number of names in all component categories). Upon return from <emphasis>
+XkbListComponents</emphasis>
+, <emphasis>
+max_inout</emphasis>
+ contains the number of names that matched the request but were not returned
+because of the limit.
+</para>
+
+
+<para>
+The component name patterns used to describe the request are passed to
+<emphasis>
+XkbListComponents</emphasis>
+ using an <emphasis>
+XkbComponentNamesRec</emphasis>
+ structure. This structure has no special allocation constraints or
+interrelationships with other structures; allocate and free this structure
+using standard <emphasis>
+malloc</emphasis>
+ and <emphasis>
+free</emphasis>
+ calls or their equivalent:
+</para>
+
+<para><programlisting>
+typedef struct _XkbComponentNames {
+ char * keymap; /* keymap names */
+ char * keycodes; /* keycode names */
+ char * types; /* type names */
+ char * compat; /* compatibility map names */
+ char * symbols; /* symbol names */
+ char * geometry; /* geometry names */
+} <emphasis>XkbComponentNamesRec</emphasis>, *XkbComponentNamesPtr;
+</programlisting></para>
+
+<para>
+<emphasis>
+XkbListComponents</emphasis>
+ returns a pointer to an <emphasis>
+XkbComponentListRec</emphasis>
+:
+</para>
+
+<para><programlisting>
+typedef struct _XkbComponentList {
+ int num_keymaps; /* number of entries in keymap */
+ int num_keycodes; /* number of entries in keycodes */
+ int num_types; /* number of entries in types */
+ int num_compat; /* number of entries in compat */
+ int num_symbols; /* number of entries in symbols */
+ int num_geometry; /* number of entries in geometry;
+ XkbComponentNamePtr keymap; /* keymap names */
+ XkbComponentNamePtr keycodes; /* keycode names */
+ XkbComponentNamePtr types; /* type names */
+ XkbComponentNamePtr compat; /* compatibility map names */
+ XkbComponentNamePtr symbols; /* symbol names */
+ XkbComponentNamePtr geometry; /* geometry names */
+} <emphasis>XkbComponentListRec</emphasis>, *XkbComponentListPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbComponentName {
+ unsigned short flags; /* hints regarding component name */
+ char * name; /* name of component */
+} <emphasis>XkbComponentNameRec</emphasis>, *XkbComponentNamePtr;
+</programlisting></para>
+
+<para>
+Note that the structure used to specify patterns on input is an <emphasis>
+XkbComponentNamesRec</emphasis>
+, and that used to hold the individual component names upon return is an
+<emphasis>
+XkbComponentNameRec</emphasis>
+ (no trailing ‘s’ in Name).
+</para>
+
+
+<para>
+When you are done using the structure returned by <emphasis>
+XkbListComponents</emphasis>
+, free it using <emphasis>
+XkbFreeComponentList</emphasis>
+.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeComponentList</emphasis>
+(list)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbComponentListPtr list; /* pointer to <emphasis>
+XkbComponentListRec</emphasis>
+ to free */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+
+</sect1>
+<sect1 id='component_hints'>
+<title>Component Hints</title>
+
+<para>
+A set of flags is associated with each component; these flags provide
+additional hints about the component’s use. These hints are designated by bit
+masks in the flags field of the <emphasis>
+XkbComponentNameRec</emphasis>
+ structures contained in the <emphasis>
+XkbComponentListRec</emphasis>
+ returned from <emphasis>
+XkbListComponents</emphasis>
+. The least significant byte of the flags field has the same meaning for all
+types of keyboard components; the interpretation of the most significant byte
+is dependent on the type of component. The flags bits are defined in Table
+20.2. The symbols hints in Table 20.2 apply only to partial symbols components
+(those with <emphasis>
+XkbLC_Partial</emphasis>
+ also set); full symbols components are assumed to specify all of the pieces.
+</para>
+
+
+<para>
+The alphanumeric, modifier, keypad or function keys symbols hints should
+describe the primary intent of the component designer and should not be simply
+an exhaustive list of the kinds of keys that are affected. For example,
+national keyboard layouts affect primarily alphanumeric keys, but many affect a
+few modifier keys as well; such mappings should set only the <emphasis>
+XkbLC_AlphanumericKeys</emphasis>
+ hint. In general, symbols components should set only one of the four flags
+(<emphasis>
+XkbLC_AlternateGroup</emphasis>
+ may be combined with any of the other flags).
+</para>
+
+<table frame='none'>
+<title>XkbComponentNameRec Flags Bits</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Component Type</entry>
+ <entry>Component Hints (flags)</entry>
+ <entry>Meaning</entry>
+ <entry>Value</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>All Components</entry>
+ <entry><para><emphasis>XkbLC_Hidden</emphasis></para></entry>
+ <entry>Do not present to user</entry>
+ <entry>(1L&lt;&lt;0)</entry>
+</row>
+<row rowsep='0'>
+ <entry></entry>
+ <entry><emphasis>XkbLC_Default</emphasis></entry>
+ <entry>Default member of class</entry>
+ <entry>(1L&lt;&lt;1)</entry>
+</row>
+<row rowsep='0'>
+ <entry></entry>
+ <entry><emphasis>XkbLC_Partial</emphasis></entry>
+ <entry>Partial component</entry>
+ <entry>(1L&lt;&lt;2)</entry>
+</row>
+<row rowsep='0'>
+ <entry>Keymap</entry>
+ <entry>none</entry>
+ <entry></entry>
+ <entry></entry>
+</row>
+<row rowsep='0'>
+ <entry>Keycodes</entry>
+ <entry>none</entry>
+ <entry></entry>
+ <entry></entry>
+</row>
+<row rowsep='0'>
+ <entry>Types</entry>
+ <entry>none</entry>
+ <entry></entry>
+ <entry></entry>
+</row>
+<row rowsep='0'>
+ <entry>Compatibility</entry>
+ <entry>none</entry>
+ <entry></entry>
+ <entry></entry>
+</row>
+<row rowsep='0'>
+ <entry>Symbols</entry>
+ <entry><emphasis>XkbLC_AlphanumericKeys</emphasis></entry>
+ <entry>Bindings primarily for alphanumeric keyboard section</entry>
+ <entry>(1L&lt;&lt;8)</entry>
+</row>
+<row rowsep='0'>
+ <entry></entry>
+ <entry><emphasis>XkbLC_ModifierKeys</emphasis></entry>
+ <entry>Bindings primarily for modifier keys</entry>
+ <entry>(1L&lt;&lt;9)</entry>
+</row>
+<row rowsep='0'>
+ <entry></entry>
+ <entry><emphasis>XkbLC_KeypadKeys</emphasis></entry>
+ <entry>Bindings primarily for numeric keypad keys</entry>
+ <entry>(1L&lt;&lt;10)</entry>
+</row>
+<row rowsep='0'>
+ <entry></entry>
+ <entry><emphasis>XkbLC_FunctionKeys</emphasis></entry>
+ <entry>Bindings primarily for function keys</entry>
+ <entry>(1L&lt;&lt;11)</entry>
+</row>
+<row rowsep='0'>
+ <entry></entry>
+ <entry><emphasis>XkbLC_AlternateGroup</emphasis></entry>
+ <entry>Bindings for an alternate group</entry>
+ <entry>(1L&lt;&lt;12)</entry>
+</row>
+<row rowsep='0'>
+ <entry>Geometry</entry>
+ <entry>none</entry>
+ <entry></entry>
+ <entry></entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+</sect1>
+<sect1 id='building_a_keyboard_description_using_the_server_database'>
+<title>Building a Keyboard Description Using the Server Database</title>
+
+<para>
+A client may request that the server fetch one or more components from its
+database and use those components to build a new server keyboard description.
+The new keyboard description may be built from scratch, or it may be built
+starting with the current keyboard description for a particular device. Once
+the keyboard description is built, all or part of it may be returned to the
+client. The parts returned to the client need not include all of the parts used
+to build the description. At the time it requests the server to build a new
+keyboard description, a client may also request that the server use the new
+description internally to replace the current keyboard description for a
+specific device, in which case the behavior of the device changes accordingly.
+</para>
+
+
+<para>
+To build a new keyboard description from a set of named components, and to
+optionally have the server use the resulting description to replace an active
+one, use <emphasis>
+XkbGetKeyboardByName</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDescPtr <emphasis>
+XkbGetKeyboardByName</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+device_spec</emphasis>
+, <emphasis>
+names</emphasis>
+, <emphasis>
+want</emphasis>
+, <emphasis>
+need</emphasis>
+, <emphasis>
+load</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbComponentNamesPtr <emphasis>
+names</emphasis>
+; /* names of components to fetch */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+want</emphasis>
+; /* desired structures in returned record */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+need</emphasis>
+; /* mandatory structures in returned record */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+load</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; load into <emphasis>
+device_spec</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+names</emphasis>
+ contains a set of expressions describing the keyboard components the server
+should use to build the new keyboard description. <emphasis>
+want</emphasis>
+ and <emphasis>
+need</emphasis>
+ are bit fields describing the parts of the resulting keyboard description that
+should be present in the returned <emphasis>
+XkbDescRec</emphasis>
+.
+</para>
+
+
+<para>
+The individual fields in <emphasis>
+names</emphasis>
+ are <emphasis>
+component expressions</emphasis>
+ composed of keyboard component names (no wildcarding as may be used in
+<emphasis>
+XkbListComponents</emphasis>
+), the special component name symbol ‘%’, and the special operator
+characters ‘<emphasis>
++</emphasis>
+’ and ‘<emphasis>
+|</emphasis>
+’. A component expression is parsed left to right, as follows:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+The special component name "<emphasis>
+computed</emphasis>
+" may be used in <emphasis>
+keycodes</emphasis>
+ component expressions and refers to a component consisting of a set of
+keycodes computed automatically by the server as needed.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The special component name "<emphasis>
+canonical</emphasis>
+" may be used in <emphasis>
+types</emphasis>
+ component expressions and refers to a partial component defining the four
+standard key types: <emphasis>
+ALPHABETIC</emphasis>
+, <emphasis>
+ONE_LEVEL</emphasis>
+, <emphasis>
+TWO_LEVEL</emphasis>
+, and <emphasis>
+KEYPAD</emphasis>
+.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The special component name ‘<emphasis>
+%</emphasis>
+’ refers to the keyboard description for the device specified in <emphasis>
+device_spec</emphasis>
+ or the keymap names component. If a keymap names component is specified that
+does not begin with ‘+’ or ‘|’ and does not contain ‘<emphasis>
+%</emphasis>
+’, then ‘<emphasis>
+%</emphasis>
+’ refers to the description generated by the keymap names component.
+Otherwise, it refers to the keyboard description for <emphasis>
+device_spec</emphasis>
+.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The ‘<emphasis>
++</emphasis>
+’ operator specifies that the following component should <emphasis>
+override</emphasis>
+ the currently assembled description; any definitions that are present in both
+components are taken from the second.
+ </para>
+</listitem>
+<listitem>
+ <para>
+The ‘<emphasis>
+|</emphasis>
+’ operator specifies that the next specified component should <emphasis>
+augment</emphasis>
+ the currently assembled description; any definitions that are present in both
+components are taken from the first.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If the component expression begins with an operator, a leading ‘<emphasis>
+%</emphasis>
+’ is implied.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If any unknown or illegal characters appear anywhere in the expression, the
+entire expression is invalid and is ignored.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+For example, if <emphasis>
+names-&gt;symbols</emphasis>
+ contained the expression "+de", it specifies that the default member of the
+"de" class of symbols should be applied to the current keyboard mapping,
+overriding any existing definitions (it could also be written "+de(default)").
+</para>
+
+
+<para>
+Here is a slightly more involved example: the expression
+"acme(ascii)+de(basic)|iso9995-3" constructs a German (de) mapping for the
+ASCII keyboard supplied by the "acme" vendor. The new definition begins with
+the symbols for the ASCII keyboard for Acme (<emphasis>
+acme(ascii)</emphasis>
+), overrides them with definitions for the basic German keyboard (<emphasis>
+de(basic)</emphasis>
+), and then applies the definitions from the default iso9995-3 keyboard
+(<emphasis>
+iso9995-3</emphasis>
+) to any undefined keys or groups of keys (part three of the iso9995 standard
+defines a common set of bindings for the secondary group, but allows national
+layouts to override those definitions where necessary).
+</para>
+
+<note><para>The interpretation of the above expression components (acme, ascii,
+de, basic, iso9995-3) is not defined by Xkb; only the operations and their
+ordering are.</para></note>
+
+<para>
+Note that the presence of a keymap <emphasis>
+names</emphasis>
+ component that does not contain ‘<emphasis>
+%</emphasis>
+’ (either explicit or implied by virtue of an expression starting with an
+operator) indicates a description that is independent of the keyboard
+description for the device specified in <emphasis>
+device_spec</emphasis>
+. The same is true of requests in which the keymap names component is empty and
+all five other names components contain expressions void of references to
+‘<emphasis>
+%</emphasis>
+’. Requests of this form allow you to deal with keyboard definitions
+independent of any actual device.
+</para>
+
+
+<para>
+The server parses all non-<emphasis>
+NULL</emphasis>
+ fields in <emphasis>
+names</emphasis>
+ and uses them to build a keyboard description. However, before parsing the
+expressions in <emphasis>
+names</emphasis>
+, the server ORs the bits in <emphasis>
+want</emphasis>
+ and <emphasis>
+need</emphasis>
+ together and examines the result in relationship to the expressions in
+<emphasis>
+names</emphasis>
+. Table 20.3 identifies the components that are required for each of the
+possible bits in <emphasis>
+want</emphasis>
+ or <emphasis>
+need</emphasis>
+. If a required component has not been specified in the <emphasis>
+names</emphasis>
+ structure (the corresponding field is <emphasis>
+NULL</emphasis>
+), the server substitutes the expression "<emphasis>
+%</emphasis>
+", resulting in the component values being taken from <emphasis>
+device_spec</emphasis>
+. In addition, if <emphasis>
+load</emphasis>
+ is <emphasis>
+True</emphasis>
+, the server modifies <emphasis>
+names</emphasis>
+ if necessary (again using a "<emphasis>
+%</emphasis>
+" entry) to ensure all of the following fields are non-<emphasis>
+NULL</emphasis>
+: <emphasis>
+types</emphasis>
+, <emphasis>
+keycodes</emphasis>
+, <emphasis>
+symbols</emphasis>
+, and <emphasis>
+compat</emphasis>
+.<emphasis>
+</emphasis>
+</para>
+
+<table frame='none'>
+<title>Want and Need Mask Bits and Required Names Components</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>want or need mask bit</entry>
+ <entry>Required names Components</entry>
+ <entry>value</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbGBN_TypesMask</entry>
+ <entry>Types</entry>
+ <entry>(1L&lt;&lt;0)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_CompatMapMask</entry>
+ <entry>Compat</entry>
+ <entry>(1L&lt;&lt;1)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_ClientSymbolsMask</entry>
+ <entry>Types + Symbols + Keycodes</entry>
+ <entry>(1L&lt;&lt;2)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_ServerSymbolsMask</entry>
+ <entry>Types + Symbols + Keycodes</entry>
+ <entry>(1L&lt;&lt;3)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_SymbolsMask</entry>
+ <entry>Symbols</entry>
+ <entry>(1L&lt;&lt;1)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_IndicatorMapMask</entry>
+ <entry>Compat</entry>
+ <entry>(1L&lt;&lt;4)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_KeyNamesMask</entry>
+ <entry>Keycodes</entry>
+ <entry>(1L&lt;&lt;5)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_GeometryMask</entry>
+ <entry>Geometry</entry>
+ <entry>(1L&lt;&lt;6)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_OtherNamesMask</entry>
+ <entry>Types + Symbols + Keycodes + Compat + Geometry</entry>
+ <entry>(1L&lt;&lt;7)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_AllComponentsMask</entry>
+ <entry></entry>
+ <entry>(0xff)</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+<emphasis>
+need</emphasis>
+ specifies a set of keyboard components that the server must be able to resolve
+in order for <emphasis>
+XkbGetKeyboardByName</emphasis>
+ to succeed; if any of the components specified in <emphasis>
+need</emphasis>
+ cannot be successfully resolved, <emphasis>
+XkbGetKeyboardByName</emphasis>
+ fails.
+</para>
+
+
+<para>
+<emphasis>
+want</emphasis>
+ specifies a set of keyboard components that the server should attempt to
+resolve, but that are not mandatory. If the server is unable to resolve any of
+these components, <emphasis>
+XkbGetKeyboardByName</emphasis>
+ still succeeds. Bits specified in <emphasis>
+want</emphasis>
+ that are also specified in <emphasis>
+need</emphasis>
+ have no effect in the context of <emphasis>
+want</emphasis>
+.
+</para>
+
+
+<para>
+If <emphasis>
+load</emphasis>
+ is <emphasis>
+True</emphasis>
+, the server updates its keyboard description for <emphasis>
+device_spec</emphasis>
+ to match the result of the keyboard description just built. If load is
+<emphasis>
+False</emphasis>
+, the server’s description for device <emphasis>
+device_spec</emphasis>
+ is not updated. In all cases, the parts specified by <emphasis>
+want</emphasis>
+ and <emphasis>
+need</emphasis>
+ from the just-built keyboard description are returned.
+</para>
+
+
+<para>
+The <emphasis>
+names</emphasis>
+ structure in an <emphasis>
+XkbDescRec</emphasis>
+ keyboard description record (see Chapter 18) contains one field for each of
+the five component types used to build a keyboard description. When a keyboard
+description is built from a set of database components, the corresponding
+fields in this <emphasis>
+names</emphasis>
+ structure are set to match the expressions used to build the component.
+</para>
+
+
+<para>
+The entire process of building a new keyboard description from the server
+database of components and returning all or part of it is diagrammed in Figure
+20.1:
+</para>
+
+<mediaobject>
+ <imageobject> <imagedata fileref="XKBlib-21.gif"/>
+ </imageobject>
+ <caption>Building a New Keyboard Description from the Server Database</caption>
+</mediaobject>
+
+<para>
+The information returned to the client in the <emphasis>
+XkbDescRec</emphasis>
+ is essentially the result of a series of calls to extract information from a
+fictitious device whose description matches the one just built. The calls
+corresponding to each of the mask bits are summarized in Table 20.4, together
+with the <emphasis>
+XkbDescRec</emphasis>
+ components that are filled in.
+</para>
+
+<table frame='none'>
+<title>XkbDescRec Components Returned for Values of Want &amp; Needs</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Request (want+need)</entry>
+ <entry>Fills in Xkb components</entry>
+ <entry>Equivalent Function Call</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbGBN_TypesMask</entry>
+ <entry>map.types</entry>
+ <entry>XkbGetUpdatedMap(dpy, XkbTypesMask, Xkb)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_ServerSymbolsMask</entry>
+ <entry>server</entry>
+ <entry>XkbGetUpdatedMap(dpy, XkbAllClientInfoMask, Xkb)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_ClientSymbolsMask</entry>
+ <entry>map, including map.types</entry>
+ <entry>XkbGetUpdatedMap(dpy, XkbAllServerInfoMask, Xkb)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_IndicatorMaps</entry>
+ <entry>indicators</entry>
+ <entry>XkbGetIndicatorMap(dpy, XkbAllIndicators, Xkb)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_CompatMapMask</entry>
+ <entry>compat</entry>
+ <entry>XkbGetCompatMap(dpy, XkbAllCompatMask, Xkb)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_GeometryMask</entry>
+ <entry>geom</entry>
+ <entry>XkbGetGeometry(dpy, Xkb)</entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_KeyNamesMask</entry>
+ <entry>
+<para>names.keys</para>
+<para>names.key_aliases</para>
+ </entry>
+ <entry>
+XkbGetNames(dpy, XkbKeyNamesMask | XkbKeyAliasesMask, Xkb)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbGBN_OtherNamesMask</entry>
+ <entry>
+<para>names.keycodes</para>
+<para>names.geometry</para>
+<para>names.symbols</para>
+<para>names.types</para>
+<para>map.types[*].lvl_names[*]</para>
+<para>names.compat</para>
+<para>names.vmods</para>
+<para>names.indicators</para>
+<para>names.groups</para>
+<para>names.radio_groups</para>
+<para>names.phys_symbols</para>
+ </entry>
+ <entry>
+<para>XkbGetNames(dpy, XkbAllNamesMask &amp;</para>
+<para>~(XkbKeyNamesMask | XkbKeyAliasesMask),</para>
+<para>Xkb)</para>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+There is no way to determine which components specified in <emphasis>
+want</emphasis>
+ (but not in <emphasis>
+need</emphasis>
+) were actually fetched, other than breaking the call into successive calls to
+<emphasis>
+XkbGetKeyboardByName</emphasis>
+ and specifying individual components.
+</para>
+
+
+<para>
+<emphasis>
+XkbGetKeyboardByName</emphasis>
+ always sets <emphasis>
+min_key_code</emphasis>
+ and <emphasis>
+max_key_code</emphasis>
+ in the returned <emphasis>
+XkbDescRec</emphasis>
+ structure.
+</para>
+
+
+<para>
+<emphasis>XkbGetKeyboardByName</emphasis>
+is synchronous; it sends the request to the server to build a new keyboard
+description and waits for the reply. If successful, the return value is
+non-<emphasis>NULL</emphasis>.
+<emphasis>XkbGetKeyboardByName</emphasis>
+generates a <emphasis>BadMatch</emphasis>
+protocol error if errors are encountered when building the keyboard
+description.
+</para>
+
+
+<para>
+If you simply want to obtain information about the current keyboard device,
+rather than generating a new keyboard description from elements in the server
+database, use <emphasis>
+XkbGetKeyboard</emphasis>
+ (see section 6.2).
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDescPtr <emphasis>
+XkbGetKeyboard</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+which</emphasis>
+, <emphasis>
+device_spec</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int<emphasis>
+ which</emphasis>
+; /* mask of components of <emphasis>
+XkbDescRec</emphasis>
+ of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ device_spec</emphasis>
+; /* device ID */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetKeyboard</emphasis>
+ is used to read the current description for one or more components of a
+keyboard device. It calls <emphasis>
+XkbGetKeyboardByName</emphasis>
+ as follows:
+</para>
+
+
+<para>
+<emphasis>
+XkbGetKeyboardByName</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+device_spec</emphasis>
+, <emphasis>
+NULL</emphasis>
+, <emphasis>
+which</emphasis>
+, <emphasis>
+which</emphasis>
+, <emphasis>
+False</emphasis>
+).
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch21.xml b/specs/XKB/ch21.xml
new file mode 100644
index 00000000..aef8378f
--- /dev/null
+++ b/specs/XKB/ch21.xml
@@ -0,0 +1,2043 @@
+<chapter id='attaching_xkb_actions_to_x_input_extension_devices'>
+<title>Attaching Xkb Actions to X Input Extension Devices</title>
+
+<para>
+The X input extension allows an X server to support multiple keyboards, as well
+as other input devices, in addition to the core X keyboard and pointer. The
+input extension categorizes devices by grouping them into classes. Keyboards
+and other input devices with keys are classified as KeyClass devices by the
+input extension. Other types of devices supported by the input extension
+include, but are not limited to: mice, tablets, touchscreens, barcode readers,
+button boxes, trackballs, identifier devices, data gloves, and eye trackers.
+Xkb provides additional control over all X input extension devices, whether
+they are <emphasis>KeyClass</emphasis>
+ devices or not, as well as the core keyboard and pointer.
+</para>
+
+
+<para>
+If an X server implements support for both the input extension and Xkb, the
+server implementor determines whether interaction between Xkb and the input
+extension is allowed. Implementors are free to restrict the effects of Xkb to
+only the core X keyboard device or allow interaction between Xkb and the input
+extension.
+</para>
+
+
+<para>
+Several types of interaction between Xkb and the input extension are defined by
+Xkb. Some or all may be allowed by the X server implementation.
+</para>
+
+
+<para>
+Regardless of whether the server allows interaction between Xkb and the input
+extension, the following access is provided:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Xkb functionality for the core X keyboard device and its mapping is accessed
+via the functions described in the other chapters of this specification.
+ </para>
+</listitem>
+<listitem>
+ <para>
+Xkb functionality for the core X pointer device is accessed via the
+XkbGetDeviceInfo and XkbSetDeviceInfo functions described in this chapter.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+If all types of interaction are allowed between Xkb and the input extension,
+the following additional access is provided:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+If allowed, Xkb functionality for additional <emphasis>
+KeyClass</emphasis>
+ devices supported by the input extension is accessed via those same functions.
+ </para>
+</listitem>
+<listitem>
+ <para>
+If allowed, Xkb functionality for non-<emphasis>
+KeyClass</emphasis>
+ devices supported by the input extension is also accessed via the
+XkbGetDeviceInfo and XkbSetDeviceInfo functions described in this chapter.
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+Each device has an X Input Extension device ID. Each device may have several
+classes of feedback. For example, there are two types of feedbacks that can
+generate bells: bell feedback and keyboard feedback (<emphasis>
+BellFeedbackClass</emphasis>
+ and <emphasis>
+KbdFeedbackClass</emphasis>
+). A device can have more than one feedback of each type; the feedback ID
+identifies the particular feedback within its class.
+</para>
+
+
+<para>
+A keyboard feedback has:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Auto-repeat status (global and per key)
+ </para>
+</listitem>
+<listitem>
+ <para>
+32 LEDs
+ </para>
+</listitem>
+<listitem>
+ <para>
+A bell
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+An indicator feedback has:
+</para>
+
+<itemizedlist>
+<listitem>
+ <para>
+Up to 32 LEDs
+ </para>
+</listitem>
+</itemizedlist>
+
+<para>
+If the input extension is present and the server allows interaction between the
+input extension and Xkb, then the core keyboard, the core keyboard indicators,
+and the core keyboard bells may each be addressed using an appropriate device
+spec, class, and ID. The constant <emphasis>
+XkbXIDfltID</emphasis>
+ may be used as the device ID to specify the core keyboard indicators for the
+core indicator feedback. The particular device ID corresponding to the core
+keyboard feedback and the core indicator feedback may be obtained by calling
+<emphasis>
+XkbGetDeviceInfo</emphasis>
+ and specifying <emphasis>
+XkbUseCoreKbd</emphasis>
+ as the <emphasis>
+device_spec</emphasis>
+; the values will be returned in <emphasis>
+dflt_kbd_id</emphasis>
+ and <emphasis>
+dflt_led_id</emphasis>
+.
+</para>
+
+
+<para>
+If the server does not allow Xkb access to input extension <emphasis>
+KeyClass</emphasis>
+ devices, attempts to use Xkb requests with those devices fail with a
+Bad<emphasis>
+Keyboard</emphasis>
+ error. Attempts to access non-<emphasis>
+KeyClass</emphasis>
+ input extension devices via XkbGetDeviceInfo and XkbSetDeviceInfo fail
+silently if Xkb access to those devices is not supported by the X server.
+</para>
+
+<sect1 id='xkbdeviceinforec'>
+<title>XkbDeviceInfoRec</title>
+
+<para>
+Information about X Input Extension devices is transferred between a client
+program and the Xkb extension in an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure:
+</para>
+
+<para><programlisting>
+typedef struct {
+ char * name; /* name for device */
+ Atom type; /* name for class of devices */
+ unsigned short device_spec; /* device of interest */
+ Bool has_own_state; /* <emphasis> True</emphasis> =&gt;this
+ device has its own state */
+ unsigned short supported; /* bits indicating supported capabilities */
+ unsigned short unsupported; /* bits indicating unsupported capabilities */
+ unsigned short num_btns; /* number of entries in <emphasis> btn_acts</emphasis> */
+ XkbAction * btn_acts; /* button actions */
+ unsigned short sz_leds; /* total number of entries in LEDs vector */
+ unsigned short num_leds; /* number of valid entries in LEDs vector */
+ unsigned short dflt_kbd_fb; /* input extension ID of default (core kbd) indicator */
+ unsigned short dflt_led_fb; /* input extension ID of default indicator feedback */
+ XkbDeviceLedInfoPtr leds; /* LED descriptions */
+} <emphasis>XkbDeviceInfoRec</emphasis>, *XkbDeviceInfoPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct {
+ unsigned short led_class; /* class for this LED device*/
+ unsigned short led_id; /* ID for this LED device */
+ unsigned int phys_indicators; /* bits for which LEDs physically
+ present */
+ unsigned int maps_present; /* bits for which LEDs have maps in
+ <emphasis>maps</emphasis> */
+ unsigned int names_present; /* bits for which LEDs are in
+ <emphasis> names</emphasis> */
+ unsigned int state; /* 1 bit =&gt; corresponding LED is on */
+ Atom names[XkbNumIndicators]; /* names for LEDs */
+ XkbIndicatorMapRec maps; /* indicator maps for each LED */
+} <emphasis>XkbDeviceLedInfoRec</emphasis>, *XkbDeviceLedInfoPtr;
+</programlisting></para>
+
+<para>
+The <emphasis>
+type</emphasis>
+ field is a registered symbolic name for a class of devices (for example,
+"TABLET"). If a device is a keyboard (that is, is a member of <emphasis>
+KeyClass</emphasis>
+), it has its own state, and <emphasis>
+has_own_state</emphasis>
+ is <emphasis>
+True</emphasis>
+. If <emphasis>
+has_own_state</emphasis>
+ is <emphasis>
+False</emphasis>
+, the state of the core keyboard is used. The <emphasis>
+supported</emphasis>
+ and <emphasis>
+unsupported</emphasis>
+ fields are masks where each bit indicates a capability. The meaning of the
+mask bits is listed in Table 21.1, together with the fields in the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure that are associated with the capability represented by each bit. The
+same bits are used to indicate the specific information desired in many of the
+functions described subsequently in this section.
+</para>
+
+<table frame='none'>
+<title>XkbDeviceInfoRec Mask Bits</title>
+<tgroup cols='4'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+ <row rowsep='0'>
+ <entry>Name</entry>
+ <entry>XkbDeviceInfoRec Fields Effected</entry>
+ <entry>Value</entry>
+ <entry>Capability If Set</entry>
+ </row>
+</thead>
+<tbody>
+ <row rowsep='0'>
+ <entry>XkbXI_KeyboardsMask</entry>
+ <entry></entry>
+ <entry>(1L &lt;&lt; 0)</entry>
+ <entry>
+Clients can use all Xkb requests and events with
+<emphasis>KeyClass</emphasis>
+devices supported by the input device extension.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_ButtonActionsMask</entry>
+ <entry>
+<para>num_btns</para>
+<para>btn_acts</para>
+ </entry>
+ <entry>(1L &lt;&lt;1)</entry>
+ <entry>
+Clients can assign key actions to buttons on non-<emphasis>
+KeyClass</emphasis>
+input extension devices.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_IndicatorNamesMask</entry>
+ <entry>leds-&gt;names</entry>
+ <entry>(1L &lt;&lt;2)</entry>
+ <entry>
+Clients can assign names to indicators on non-<emphasis>
+KeyClass</emphasis>
+ input extension devices.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_IndicatorMapsMask</entry>
+ <entry>leds-&gt;maps</entry>
+ <entry>(1L &lt;&lt;3)</entry>
+ <entry>
+Clients can assign indicator maps to indicators on non-<emphasis>
+KeyClass</emphasis>
+ input extension devices.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_IndicatorStateMask</entry>
+ <entry>leds-&gt;state</entry>
+ <entry>(1L &lt;&lt;4)</entry>
+ <entry>
+Clients can request the status of indicators on non-<emphasis>
+KeyClass</emphasis>
+ input extension devices.
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_IndicatorsMask</entry>
+ <entry>
+<para>sz_leds</para>
+<para>num_leds</para>
+<para>leds-&gt;*</para>
+ </entry>
+ <entry>(0x1c)</entry>
+ <entry>
+<para>XkbXI_IndicatorNamesMask |</para>
+<para>XkbXI_IndicatorMapsMask |</para>
+<para>XkbXI_IndicatorStateMask</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_UnsupportedFeaturesMask</entry>
+ <entry>unsupported</entry>
+ <entry>(1L &lt;&lt;15)</entry>
+ <entry></entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_AllDeviceFeaturesMask</entry>
+ <entry>Those selected by Value column masks</entry>
+ <entry>(0x1e)</entry>
+ <entry>
+<para>XkbXI_IndicatorsMask | </para>
+<para>XkbSI_ButtonActionsMask</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_AllFeaturesMask</entry>
+ <entry>Those selected by Value column masks</entry>
+ <entry>(0x1f)</entry>
+ <entry>
+<para>XkbSI_AllDeviceFeaturesMask |</para>
+<para>XkbSI_KeyboardsMask</para>
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry>XkbXI_AllDetailsMask</entry>
+ <entry>Those selected by Value column masks</entry>
+ <entry>(0x801f)</entry>
+ <entry>
+<para>XkbXI_AllFeaturesMask | </para>
+<para>XkbXI_UnsupportedFeaturesMask</para>
+ </entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+The <emphasis>
+name</emphasis>
+, <emphasis>
+type</emphasis>
+, <emphasis>
+has_own_state</emphasis>
+, <emphasis>
+supported</emphasis>
+, and <emphasis>
+unsupported</emphasis>
+ fields are always filled in when a valid reply is returned from the server
+involving an <emphasis>
+XkbDeviceInfoRec</emphasis>
+. All of the other fields are modified only if the particular function asks for
+them.
+</para>
+
+</sect1>
+<sect1 id='querying_xkb_features_for_non_keyclass_input_extension_devices'>
+<title>Querying Xkb Features for Non-KeyClass Input Extension Devices</title>
+
+<para>
+To determine whether the X server allows Xkb access to particular capabilities
+of input devices other than the core X keyboard, or to determine the status of
+indicator maps, indicator names or button actions on a non-<emphasis>
+KeyClass</emphasis>
+ extension device, use XkbGetDeviceInfo.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDeviceInfoPtr <emphasis>
+XkbGetDeviceInfo</emphasis>
+(<emphasis>
+dpy</emphasis>
+, which, device_spec, ind_class, ind_id)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int which; /* mask indicating information to
+return */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+device_spec</emphasis>
+; /* device ID, or <emphasis>
+XkbUseCoreKbd</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ind_class</emphasis>
+; /* feedback class for indicator requests */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ind_id</emphasis>
+; /* feedback ID for indicator requests */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetDeviceInfo</emphasis>
+ returns information about the input device specified by <emphasis>
+device_spec</emphasis>
+. Unlike the <emphasis>
+device_spec</emphasis>
+ parameter of most Xkb functions, <emphasis>
+device_spec</emphasis>
+ does not need to be a keyboard device. It must, however, indicate either the
+core keyboard or a valid X Input Extension device.
+</para>
+
+
+<para>
+The <emphasis>
+which </emphasis>
+parameter<emphasis>
+ </emphasis>
+is a mask specifying optional information to be returned. It is an inclusive OR
+of one or more of the values from Table 21.1 and causes the returned <emphasis>
+XkbDeviceInfoRec</emphasis>
+ to contain values for the corresponding fields specified in the table.
+</para>
+
+
+<para>
+The <emphasis>
+XkbDeviceInfoRec</emphasis>
+ returned by <emphasis>
+XkbGetDeviceInfo</emphasis>
+ always has values for <emphasis>
+name</emphasis>
+ (may be a null string, ""), <emphasis>
+type</emphasis>
+, <emphasis>
+supported</emphasis>
+, <emphasis>
+unsupported</emphasis>
+, <emphasis>
+has_own_state</emphasis>
+, <emphasis>
+dflt_kbd_fd</emphasis>
+, and <emphasis>
+dflt_kbd_fb</emphasis>
+. Other fields are filled in as specified by <emphasis>
+which</emphasis>
+.
+</para>
+
+
+<para>
+Upon return, the <emphasis>
+supported</emphasis>
+ field will be set to the inclusive OR of zero or more bits from Table 21.1;
+each bit set indicates an optional Xkb extension device feature supported by
+the server implementation, and a client may modify the associated behavior.
+</para>
+
+
+<para>
+If the <emphasis>
+XkbButtonActionsMask</emphasis>
+ bit is set in <emphasis>
+which</emphasis>
+, the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ returned will have the button actions (<emphasis>
+btn_acts</emphasis>
+ field) filled in for all buttons.
+</para>
+
+
+<para>
+If <emphasis>
+which</emphasis>
+ includes one of the bits in XkbXI_IndicatorsMask, the feedback class of the
+indicators must be specified in ind_class, and the feedback ID of the
+indicators must be specified in ind_id. If the request does not include any of
+the bits in XkbXI_IndicatorsMask, the ind_class and ind_id parameters are
+ignored. The class and ID can be obtained via the input device extension
+XListInputDevices request.
+</para>
+
+
+<para>
+If any of the <emphasis>
+XkbXI_IndicatorsMask</emphasis>
+ bits are set in <emphasis>
+which</emphasis>
+, the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ returned will have filled in the portions of the <emphasis>
+leds</emphasis>
+ structure corresponding to the indicator feedback identified by <emphasis>
+ind_class</emphasis>
+ and <emphasis>
+ind_id</emphasis>
+. The <emphasis>
+leds</emphasis>
+ vector of the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ is allocated if necessary and <emphasis>
+sz_leds</emphasis>
+ and <emphasis>
+num_leds</emphasis>
+ filled in. The <emphasis>
+led_class</emphasis>
+, <emphasis>
+led_id</emphasis>
+ and <emphasis>
+phys_indicators</emphasis>
+ fields of the <emphasis>
+leds</emphasis>
+ entry corresponding to <emphasis>
+ind_class</emphasis>
+ and <emphasis>
+ind_id</emphasis>
+ are always filled in. If <emphasis>
+which</emphasis>
+ contains <emphasis>
+XkbXI_IndicatorNamesMask</emphasis>
+, the <emphasis>
+names_present</emphasis>
+ and <emphasis>
+names</emphasis>
+ fields of the <emphasis>
+leds</emphasis>
+ structure corresponding to <emphasis>
+ind_class</emphasis>
+ and <emphasis>
+ind_id</emphasis>
+ are returned.<emphasis>
+ </emphasis>
+If <emphasis>
+which</emphasis>
+ contains <emphasis>
+XkbXI_IndicatorStateMask</emphasis>
+<emphasis>
+,</emphasis>
+ the corresponding <emphasis>
+state</emphasis>
+ field is updated. If <emphasis>
+which</emphasis>
+ contains <emphasis>
+XkbXI_IndicatorMapsMask</emphasis>
+, the <emphasis>
+maps_present</emphasis>
+ and <emphasis>
+maps</emphasis>
+ fields are updated.
+</para>
+
+
+<para>
+Xkb provides convenience functions to request subsets of the information
+available via <emphasis>
+XkbGetDeviceInfo</emphasis>
+. These convenience functions mirror some of the mask bits. The functions all
+take an <emphasis>
+XkbDeviceInfoPtr</emphasis>
+ as an input argument and operate on the X Input Extension device specified by
+the <emphasis>
+device_spec</emphasis>
+ field of the structure. Only the parts of the structure indicated in the
+function description are updated. The <emphasis>
+XkbDeviceInfo</emphasis>
+Rec structure used in the function call can be obtained by calling
+XkbGetDeviceInfo or can be allocated by calling XkbAllocDeviceInfo (see section
+21.3).
+</para>
+
+
+<para>
+These convenience functions are described as follows.
+</para>
+
+
+<para>
+To query the button actions associated with an X Input Extension device, use
+XkbGetDeviceButtonActions.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetDeviceButtonActions</emphasis>
+(<emphasis>
+dpy, device_info, all_buttons, first_button, num_buttons</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure to update with
+results */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+all_buttons</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; get information for all buttons */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int first_button; /* number of first button for
+which info is desired */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int num_buttons; /* number of buttons for which
+info is desired */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetDeviceButtonActions</emphasis>
+ queries the server for the desired button information for the device indicated
+by the <emphasis>
+device_spec</emphasis>
+ field of <emphasis>
+device_info</emphasis>
+ and waits for a reply. If successful,<emphasis>
+ XkbGetDeviceButtonActions</emphasis>
+ backfills the button actions (<emphasis>
+btn_acts</emphasis>
+ field of <emphasis>
+device_info</emphasis>
+) for only the requested buttons, updates the <emphasis>
+name</emphasis>
+, <emphasis>
+type</emphasis>
+, <emphasis>
+supported</emphasis>
+, and <emphasis>
+unsupported</emphasis>
+ fields, and returns <emphasis>
+Success</emphasis>
+.
+</para>
+
+
+<para>
+<emphasis>
+all_buttons</emphasis>
+, <emphasis>
+first_button</emphasis>
+ and <emphasis>
+num_buttons</emphasis>
+ specify the device buttons for which actions should be returned. Setting
+<emphasis>
+all_buttons</emphasis>
+ to <emphasis>
+True</emphasis>
+ requests actions for all device buttons; if <emphasis>
+all_buttons</emphasis>
+ is <emphasis>
+False</emphasis>
+, <emphasis>
+first_button</emphasis>
+ and <emphasis>
+num_buttons</emphasis>
+ specify a range of buttons for which actions are requested.
+</para>
+
+
+<para>
+If a compatible version of Xkb is not available in the server or the Xkb
+extension has not been properly initialized, XkbGetDeviceButtonActions returns
+<emphasis>
+BadAccess</emphasis>
+. If allocation errors occur, a <emphasis>
+BadAlloc</emphasis>
+ status is returned. If the specified device (<emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+device_spec</emphasis>
+) is invalid, a BadKeyboard status is returned. If the device has no buttons, a
+Bad<emphasis>
+Match</emphasis>
+ status is returned. If <emphasis>
+first_button</emphasis>
+ and <emphasis>
+num_buttons</emphasis>
+ specify illegal buttons, a Bad<emphasis>
+Value</emphasis>
+ status is returned.
+</para>
+
+
+<para>
+To query the indicator names, maps, and state associated with an LED feedback
+of an input extension device, use XkbGetDeviceLedInfo.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetDeviceLedInfo</emphasis>
+(<emphasis>
+dpy, device_i</emphasis>
+nfo, led_class, led_id, which)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure to update with
+results */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+led_class</emphasis>
+; /* LED feedback class assigned by input extension */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int led_id; /* LED feedback ID assigned by input
+extension */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int which; /* mask indicating desired
+information */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbGetDeviceLedInfo</emphasis>
+ queries the server for the desired LED information for the feedback specified
+by <emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+ for the X input extension device indicated by <emphasis>
+device_spec</emphasis>
+-&gt;<emphasis>
+device_info</emphasis>
+ and waits for a reply. If successful, <emphasis>
+XkbGetDeviceLedInfo</emphasis>
+ backfills the relevant fields of <emphasis>
+device_info</emphasis>
+ as determined by <emphasis>
+which</emphasis>
+ with the results and returns <emphasis>
+Success</emphasis>
+. Valid values for <emphasis>
+which</emphasis>
+ are the inclusive OR of any of <emphasis>
+XkbXI_IndicatorNamesMask</emphasis>
+, <emphasis>
+XkbXI_IndicatorMapsMask</emphasis>
+, and <emphasis>
+XkbXI_IndicatorStateMask</emphasis>
+.
+</para>
+
+
+<para>
+The fields of <emphasis>
+device_info</emphasis>
+ that are filled in when this request succeeds are <emphasis>
+name, type, supported</emphasis>
+, and <emphasis>
+unsupported</emphasis>
+, and portions of the <emphasis>
+leds</emphasis>
+ structure corresponding to <emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+ as indicated by the bits set in <emphasis>
+which</emphasis>
+. The <emphasis>
+device_info-&gt;leds</emphasis>
+ vector is allocated if necessary and <emphasis>
+sz_leds</emphasis>
+ and <emphasis>
+num_leds</emphasis>
+ filled in. The <emphasis>
+led_class</emphasis>
+, <emphasis>
+led_id</emphasis>
+ and <emphasis>
+phys_indicators</emphasis>
+ fields of the <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+ entry corresponding to <emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+ are always filled in.
+</para>
+
+
+<para>
+If <emphasis>
+which</emphasis>
+ contains <emphasis>
+XkbXI_IndicatorNamesMask</emphasis>
+, the <emphasis>
+names_present</emphasis>
+ and <emphasis>
+names</emphasis>
+ fields of the <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+ structure corresponding to <emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+ are updated, if <emphasis>
+which</emphasis>
+ contains <emphasis>
+XkbXI_IndicatorStateMask</emphasis>
+<emphasis>
+,</emphasis>
+ the corresponding <emphasis>
+state</emphasis>
+ field is updated, and if <emphasis>
+which</emphasis>
+ contains <emphasis>
+XkbXI_IndicatorMapsMask</emphasis>
+, the <emphasis>
+maps_present</emphasis>
+ and <emphasis>
+maps</emphasis>
+ fields are updated.
+</para>
+
+
+<para>
+If a compatible version of Xkb is not available in the server or the Xkb
+extension has not been properly initialized, <emphasis>
+XkbGetDeviceLedInfo</emphasis>
+ returns <emphasis>
+BadAccess</emphasis>
+. If allocation errors occur, a BadAlloc status is returned. If the device has
+no indicators, a BadMatch error is returned. If <emphasis>
+ledClass</emphasis>
+ or <emphasis>
+ledID</emphasis>
+ have illegal values, a Bad<emphasis>
+Value</emphasis>
+ error is returned. If they have legal values but do not specify a feedback
+that contains LEDs and is associated with the specified device, a Bad<emphasis>
+Match</emphasis>
+ error is returned.
+</para>
+
+
+</sect1>
+<sect1
+id='allocating_initializing_and_freeing_the_xkbdeviceinforec_structure'>
+<title>Allocating, Initializing, and Freeing the XkbDeviceInfoRec
+Structure</title>
+
+<para>
+To obtain an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure, use XkbGetDeviceInfo or XkbAllocDeviceInfo.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDeviceInfoPtr <emphasis>
+XkbAllocDeviceInfo</emphasis>
+(device_spec, n_buttons, sz_leds)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int device_spec; /* device ID with which
+structure will be used */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+n_buttons</emphasis>
+; /* number of button actions to allocate space for*/
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+sz_leds</emphasis>
+; /* number of LED feedbacks to allocate space for */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocDeviceInfo</emphasis>
+ allocates space for an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure and initializes that structure’s <emphasis>
+device_spec</emphasis>
+ field with the device ID specified by device_spec. If <emphasis>
+n_buttons</emphasis>
+ is nonzero, <emphasis>
+n_buttons</emphasis>
+ <emphasis>
+XkbActions</emphasis>
+ are linked into the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure and initialized to zero. If sz_leds is nonzero, <emphasis>
+sz_leds</emphasis>
+ <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structures are also allocated and linked into the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure. If you request <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structures be allocated using this request, you must initialize them
+explicitly.
+</para>
+
+
+<para>
+To obtain an <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structure, use XkbAllocDeviceLedInfo.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbAllocDeviceLedInfo</emphasis>
+(devi, num_needed)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr <emphasis>
+device_info</emphasis>
+; /* structure in which to allocate LED space */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+int <emphasis>
+num_needed</emphasis>
+; /* number of indicators to allocate space for */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAllocDeviceLedInfo</emphasis>
+ allocates space for an <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ and places it in <emphasis>
+device_info</emphasis>
+. If num_needed is nonzero, <emphasis>
+num_needed</emphasis>
+ <emphasis>
+XkbIndicatorMapRec</emphasis>
+ structures are also allocated and linked into the <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structure. If you request <emphasis>
+XkbIndicatorMapRec</emphasis>
+ structures be allocated using this request, you must initialize them
+explicitly. All other fields are initialized to zero.
+</para>
+
+
+<para>
+To initialize an <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structure, use XkbAddDeviceLedInfo.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+XkbDeviceLedInfoPtr <emphasis>
+XkbAddDeviceLedInfo</emphasis>
+(device_info, led_class, led_id)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure in which to
+add LED info */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+led_class</emphasis>
+; /* input extension class for LED device of interest */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+led_id</emphasis>
+; /* input extension ID for LED device of interest */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbAddDeviceLedInfo</emphasis>
+ first checks to see whether an entry matching <emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+ already exists in the <emphasis>
+device_info-&gt;leds</emphasis>
+ array. If it finds a matching entry, it returns a pointer to that entry.
+Otherwise, it checks to be sure there is at least one empty entry in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+ and extends it if there is not enough room. It then increments <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+num_leds</emphasis>
+ and fills in the next available entry in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+ with <emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+.
+</para>
+
+
+<para>
+If successful, <emphasis>
+XkbAddDeviceLedInfo</emphasis>
+ returns a pointer to the <emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structure that was initialized. If unable to allocate sufficient storage, or
+if <emphasis>
+device_info</emphasis>
+ points to an invalid <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure, or if <emphasis>
+led_class</emphasis>
+ or <emphasis>
+led_id</emphasis>
+ are inappropriate, <emphasis>
+XkbAddDeviceLedInfo</emphasis>
+ returns <emphasis>
+NULL</emphasis>
+.
+</para>
+
+
+<para>
+To allocate additional space for button actions in an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure, use XkbResizeDeviceButtonActions.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbResizeDeviceButtonActions</emphasis>
+(device_info, new_total)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure in which to
+allocate button actions */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+new_total</emphasis>
+; /* new total number of button actions needed */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbResizeDeviceButton</emphasis>
+ reallocates space, if necessary, to make sure there is room for a total of
+<emphasis>
+new_total</emphasis>
+ button actions in the <emphasis>
+device_info</emphasis>
+ structure. Any new entries allocated are zeroed. If successful, <emphasis>
+XkbResizeDeviceButton</emphasis>
+ returns Success. If new_total is zero, all button actions are deleted,
+<emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+num_btns</emphasis>
+ is set to zero, and <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+btn_acts</emphasis>
+ is set to <emphasis>
+NULL</emphasis>
+. If device_info is invalid or new_total is greater than 255, BadValue is
+returned. If a memory allocation failure occurs, a <emphasis>
+BadAlloc</emphasis>
+ is returned.
+</para>
+
+
+<para>
+To free an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure, use XkbFreeDeviceInfo.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbFreeDeviceInfo</emphasis>
+(device_info, which, free_all)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* pointer to <emphasis>
+XkbDeviceInfoRec</emphasis>
+ in which to free items */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask of components of <emphasis>
+device_info</emphasis>
+ to free */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Bool <emphasis>
+free_all</emphasis>
+; /* <emphasis>
+True</emphasis>
+ =&gt; free everything, including device_info */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+If free_all is <emphasis>
+True</emphasis>
+, the <emphasis>
+XkbFreeDeviceInfo</emphasis>
+ frees all components of <emphasis>
+device_info</emphasis>
+ and the <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure pointed to by <emphasis>
+device_info</emphasis>
+ itself. If free_all is <emphasis>
+False</emphasis>
+, the value of which determines which subcomponents are freed. <emphasis>
+which </emphasis>
+is an inclusive OR of one or more of the values from Table 21.1. If which
+contains XkbXI_ButtonActionsMask, all button actions associated with <emphasis>
+device_info</emphasis>
+ are freed, <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+btn_acts</emphasis>
+ is set to <emphasis>
+NULL</emphasis>
+, and <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+num_btns</emphasis>
+ is set to zero. If which contains all bits in XkbXI_IndicatorsMask, all
+<emphasis>
+XkbDeviceLedInfoRec</emphasis>
+ structures associated with <emphasis>
+device_info</emphasis>
+ are freed, <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+ is set to <emphasis>
+NULL</emphasis>
+, and <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+sz_leds</emphasis>
+ and <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+num_leds</emphasis>
+ are set to zero. If which contains XkbXI_IndicatorMapsMask, all indicator maps
+associated with <emphasis>
+device_info</emphasis>
+ are cleared, but the number of LEDs and the leds structures themselves are
+preserved. If which contains XkbXI_IndicatorNamesMask, all indicator names
+associated with device_info are cleared, but the number of LEDs and the leds
+structures themselves are preserved. If which contains
+XkbXI_IndicatorStateMask, the indicator state associated with the <emphasis>
+device_info</emphasis>
+ leds are set to zeros but the number of LEDs and the leds structures
+themselves are preserved.
+</para>
+
+
+</sect1>
+<sect1 id='setting_xkb_features_for_non_keyclass_input_extension_devices_'>
+<title>Setting Xkb Features for Non-KeyClass Input Extension Devices </title>
+
+<para>
+The Xkb extension allows clients to assign any key action to either core
+pointer or input extension device buttons. This makes it possible to control
+the keyboard or generate keyboard key events from extension devices or from the
+core pointer.
+</para>
+
+
+<para>
+Key actions assigned to core X pointer buttons or input extension device
+buttons cause key events to be generated as if they had originated from the
+core X keyboard.
+</para>
+
+
+<para>
+Xkb implementations are required to support key actions for the buttons of the
+core pointer device, but support for actions on extension devices is optional.
+Implementations that do not support button actions for extension devices must
+not set the <emphasis>
+XkbXI_ButtonActionsMask</emphasis>
+ bit in the <emphasis>
+supported</emphasis>
+ field of an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure.
+</para>
+
+
+<para>
+If a client attempts to modify valid characteristics of a device using an
+implementation that does not support modification of those characteristics, no
+protocol error is generated. Instead, the server reports a failure for the
+request; it also sends an <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ event to the client that issued the request if the client has selected to
+receive these events.
+</para>
+
+
+<para>
+To change characteristics of an X Input Extension device in the server, first
+modify a local copy of the device structure and then use either <emphasis>
+XkbSetDeviceInfo,</emphasis>
+ or, to save network traffic, use an <emphasis>
+XkbDeviceChangesRec</emphasis>
+ structure (see section 21.6) and call <emphasis>
+XkbChangeDeviceInfo</emphasis>
+ to download the changes to the server.
+</para>
+
+
+<para>
+To modify some or all of the characteristics of an X Input Extension device,
+use XkbSetDeviceInfo.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetDeviceInfo</emphasis>
+(<emphasis>
+dpy</emphasis>
+, which, device_info)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+which</emphasis>
+; /* mask indicating characteristics to modify */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure defining the
+device and modifications */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetDeviceInfo</emphasis>
+ sends a request to the server to modify the characteristics of the device
+specified in the <emphasis>
+device_info</emphasis>
+ structure. The particular characteristics modified are identified by the bits
+set in <emphasis>
+which</emphasis>
+ and take their values from the relevant fields in <emphasis>
+device_info</emphasis>
+ (see Table 21.1). <emphasis>
+XkbSetDeviceInfo</emphasis>
+ returns <emphasis>
+True</emphasis>
+ if the request was successfully sent to the server. If the X server
+implementation does not allow interaction between the X input extension and the
+Xkb Extension, the function does nothing and returns <emphasis>
+False</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+which</emphasis>
+ parameter specifies which aspects of the device should be changed and is a
+bitmask composed of an inclusive OR or one or more of the following bits:
+<emphasis>
+XkbXI_ButtonActionsMask</emphasis>
+, <emphasis>
+XkbXI_IndicatorNamesMask</emphasis>
+, <emphasis>
+XkbXI_IndicatorMapsMask</emphasis>
+. If the features requested to be manipulated in <emphasis>
+which</emphasis>
+ are valid for the device, but the server does not support assignment of one or
+more of them, that particular portion of the request is ignored.
+</para>
+
+
+<para>
+If the device specified in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+device_spec</emphasis>
+ does not contain buttons and a request affecting buttons is made, or the
+device does not contain indicators and a request affecting indicators is made,
+a <emphasis>
+BadMatch</emphasis>
+ protocol error results.
+</para>
+
+
+<para>
+If the <emphasis>
+XkbXI_ButtonActionsMask</emphasis>
+ bit is set in the supported mask returned by XkbGetDeviceInfo, the Xkb
+extension allows applications to assign key actions to buttons on input
+extension devices other than the core keyboard device. If the <emphasis>
+XkbXI_ButtonActionsMask</emphasis>
+ is set in <emphasis>
+which</emphasis>
+, the actions for all buttons specified in device_info are set to the <emphasis>
+XkbAction</emphasis>
+s specified in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+btn_acts</emphasis>
+. If the number of buttons requested to be updated is not valid for the device,
+<emphasis>
+XkbSetDeviceInfo</emphasis>
+ returns <emphasis>
+False</emphasis>
+ and a <emphasis>
+BadValue</emphasis>
+ protocol error results.
+</para>
+
+
+<para>
+If the <emphasis>
+XkbXI_IndicatorMaps</emphasis>
+ and / or <emphasis>
+XkbXI_IndicatorNamesMask</emphasis>
+ bit is set in the supported mask returned by XkbGetDeviceInfo, the Xkb
+extension allows applications to assign maps and / or names to the indicators
+of nonkeyboard extension devices. If supported, maps and / or names can be
+assigned to all extension device indicators, whether they are part of a
+keyboard feedback or part of an indicator feedback.
+</para>
+
+
+<para>
+If the <emphasis>
+XkbXI_IndicatorMapsMask</emphasis>
+ and / or <emphasis>
+XkbXI_IndicatorNamesMask</emphasis>
+ flag is set in <emphasis>
+which</emphasis>
+, the indicator maps and / or names for all <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+num_leds</emphasis>
+ indicator devices specified in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+ are set to the maps and / or names specified in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+. <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+-&gt;<emphasis>
+led_class</emphasis>
+ and <emphasis>
+led_id</emphasis>
+ specify the input extension class and device ID for each indicator device to
+modify; if they have invalid values, a <emphasis>
+BadValue</emphasis>
+ protocol error results and <emphasis>
+XkbSetDeviceInfo</emphasis>
+ returns <emphasis>
+False</emphasis>
+. If they have legal values but do not specify a keyboard or indicator class
+feedback for the device in question, a <emphasis>
+BadMatch</emphasis>
+ error results. If any of the values in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+leds</emphasis>
+<emphasis>
+-&gt;</emphasis>
+<emphasis>
+names</emphasis>
+ are not a valid Atom or <emphasis>
+None</emphasis>
+, a <emphasis>
+BadAtom</emphasis>
+ protocol error results.
+</para>
+
+
+<para>
+Xkb provides convenience functions to modify subsets of the information
+accessible via <emphasis>
+XkbSetDeviceInfo</emphasis>
+. Only the parts of the structure indicated in the function description are
+modified. These convenience functions are described as follows.
+</para>
+
+
+<para>
+To change only the button actions for an input extension device, use
+XkbSetDeviceButtonActions.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetDeviceButtonActions</emphasis>
+(<emphasis>
+dpy</emphasis>
+, device, first_button, num_buttons, actions)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure defining the
+device and modifications */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int first_button; /* number of first button to
+update, 0 relative */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int num_buttons; /* number of buttons to update
+*/
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetDeviceButtonActions</emphasis>
+ assigns actions to the buttons of the device specified in
+device_info-&gt;<emphasis>
+device_spec</emphasis>
+. Actions are assigned to <emphasis>
+num_buttons</emphasis>
+ buttons beginning with <emphasis>
+first_button</emphasis>
+ and are taken from the actions specified in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+btn_acts</emphasis>
+.
+</para>
+
+
+<para>
+If the server does not support assignment of Xkb actions to extension device
+buttons, <emphasis>
+XkbSetDeviceButtonActions</emphasis>
+ has no effect and returns <emphasis>
+False</emphasis>
+. If the device has no buttons or if <emphasis>
+first_button</emphasis>
+ or <emphasis>
+num_buttons</emphasis>
+ specify buttons outside of the valid range as determined by <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+num_btns</emphasis>
+, the function has no effect and returns <emphasis>
+False</emphasis>
+. Otherwise, <emphasis>
+XkbSetDeviceButtonActions</emphasis>
+ sends a request to the server to change the actions for the specified buttons
+and returns <emphasis>
+True</emphasis>
+.
+</para>
+
+
+<para>
+If the actual request sent to the server involved illegal button numbers, a
+<emphasis>
+BadValue</emphasis>
+ protocol error is generated. If an invalid device identifier is specified in
+device_info-&gt;<emphasis>
+device_spec</emphasis>
+, a BadKeyboard protocol error results. If the actual device specified in
+<emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+device_spec</emphasis>
+ does not contain buttons and a request affecting buttons is made, a <emphasis>
+BadMatch</emphasis>
+ protocol error is generated.
+</para>
+
+
+</sect1>
+<sect1 id='xkbextensiondevicenotify_event'>
+<title>XkbExtensionDeviceNotify Event</title>
+
+<para>
+The Xkb extension generates <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ events when the status of an input extension device changes or when an attempt
+is made to use an Xkb feature that is not supported by a particular device.
+</para>
+
+<note><para>Events indicating an attempt to use an unsupported feature are
+delivered only to the client requesting the event.</para></note>
+
+<para>
+To track changes to the status of input extension devices or attempts to use
+unsupported features of a device, select to receive <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ events by calling either <emphasis>
+XkbSelectEvents</emphasis>
+ or <emphasis>
+XkbSelectEventDetails</emphasis>
+ (see section 4.3).
+</para>
+
+
+<para>
+To receive <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ events under all possible conditions, call <emphasis>
+XkbSelectEvents</emphasis>
+ and pass <emphasis>
+XkbExtensionDeviceNotifyMask</emphasis>
+ in both <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits</emphasis>
+.
+</para>
+
+
+<para>
+The <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ event has no event details. However, you can call <emphasis>
+XkbSelectEventDetails</emphasis>
+ using <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ as the <emphasis>
+event_type</emphasis>
+ and specifying <emphasis>
+XkbAllExtensionDeviceMask</emphasis>
+ in <emphasis>
+bits_to_change</emphasis>
+ and <emphasis>
+values_for_bits.</emphasis>
+ This has the same effect as a call to <emphasis>
+XkbSelectEvents</emphasis>
+.
+</para>
+
+
+<para>
+The structure for <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ events is:
+</para>
+
+<para><programlisting>
+typedef struct {
+ int type; /* Xkb extension base event code */
+ unsigned long serial; /* X server serial number for event */
+ Bool send_event; /* <emphasis>True</emphasis>
+ =&gt; synthetically generated*/
+ Display * display; /* server connection where event generated */
+ Time time; /* server time when event generated */
+ int xkb_type; /* <emphasis>XkbExtensionDeviceNotifyEvent</emphasis> */
+ int device; /* Xkb device ID, will not be
+ <emphasis>XkbUseCoreKbd</emphasis> */
+ unsigned int reason; /* reason for the event */
+ unsigned int supported; /* mask of supported features */
+ unsigned int unsupported; /* unsupported features this client
+ attempted to use */
+ int first_btn; /* first button that changed */
+ int num_btns; /* number of buttons that changed */
+ unsigned int leds_defined; /* indicators with names or maps */
+ unsigned int led_state; /* current state of the indicators */
+ int led_class; /* feedback class for LED changes */
+ int led_id; /* feedback ID for LED changes */
+} <emphasis>XkbExtensionDeviceNotifyEvent</emphasis>;
+</programlisting></para>
+
+<para>
+The <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ event has fields enabling it to report changes in the state (on/off) of all of
+the buttons for a device, but only for one LED feedback associated with a
+device. You will get multiple events when more than one LED feedback changes
+state or configuration.
+</para>
+
+
+</sect1>
+<sect1 id='tracking_changes_to_extension_devices'>
+<title>Tracking Changes to Extension Devices</title>
+
+<para>
+Changes to an Xkb extension device may be tracked by listening to <emphasis>
+XkbDeviceExtensionNotify</emphasis>
+ events and accumulating the changes in an <emphasis>
+XkbDeviceChangesRec</emphasis>
+ structure. The changes noted in the structure may then be used in subsequent
+operations to update either a server configuration or a local copy of an Xkb
+extension device configuration. The changes structure is defined as follows:
+</para>
+
+<para><programlisting>
+typedef struct _XkbDeviceChanges {
+ unsigned int changed; /* bits indicating what has changed */
+ unsigned short first_btn; /* number of first button which changed,
+ if any */
+ unsigned short num_btns; /* number of buttons that have changed */
+ XkbDeviceLedChangesRec leds;
+} <emphasis>XkbDeviceChangesRec</emphasis>,*XkbDeviceChangesPtr;
+</programlisting></para>
+
+<para><programlisting>
+typedef struct _XkbDeviceLedChanges {
+ unsigned short led_class; /* class of this indicator feedback bundle */
+ unsigned short led_id; /* ID of this indicator feedback bundle */
+ unsigned int names; /* bits indicating which names have changed */
+ unsigned int maps; /* bits indicating which maps have changed */
+ struct _XkbDeviceLedChanges *next; /* link to indicator change record
+ for next set */
+} <emphasis>XkbDeviceLedChangesRec</emphasis>,*XkbDeviceLedChangesPtr;
+</programlisting></para>
+
+<para>
+A local description of the configuration and state of a device may be kept in
+an <emphasis>
+XkbDeviceInfoRec</emphasis>
+ structure. The actual state or configuration of the device may change because
+of XkbSetDeviceInfo and XkbSetButtonActions requests made by clients or by user
+interaction with the device. The X server sends an XkbExtensionDeviceNotify
+event to all interested clients when the state of any buttons or indicators or
+the configuration of the buttons or indicators on the core keyboard or any
+input extension device changes. The event reports the state of indicators for a
+single indicator feedback, and the state of up to 128 buttons. If more than 128
+buttons or more than one indicator feedback are changed, the additional buttons
+and indicator feedbacks are reported in subsequent events. Xkb provides
+functions with which you can track changes to input extension devices by noting
+the changes that were made and then requesting the changed information from the
+server.
+</para>
+
+
+<para>
+To note device changes reported in an <emphasis>
+XkbExtensionDeviceNotify</emphasis>
+ event, use XkbNoteDeviceChanges.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+void <emphasis>
+XkbNoteDeviceChanges</emphasis>
+ (<emphasis>
+old, new, wanted</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceChangesPtr <emphasis>
+old</emphasis>
+; /* structure tracking state changes */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbExtensionDeviceNotifyEvent * <emphasis>
+new</emphasis>
+; /* event indicating state changes */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+wanted</emphasis>
+; /* mask indicating changes to note */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The wanted field specifies the changes that should be noted in <emphasis>
+old</emphasis>
+, and is composed of the bitwise inclusive OR of one or more of the masks from
+Table 21.1<emphasis>
+.</emphasis>
+ The <emphasis>
+reason</emphasis>
+ field of the event in <emphasis>
+new</emphasis>
+ indicates the types of changes the event is reporting. <emphasis>
+XkbNoteDeviceChanges</emphasis>
+ updates the <emphasis>
+XkbDeviceChangesRec</emphasis>
+ specified by <emphasis>
+old</emphasis>
+ with the changes that are both specified in <emphasis>
+wanted</emphasis>
+ and contained in <emphasis>
+new</emphasis>
+-&gt;<emphasis>
+reason</emphasis>
+.
+</para>
+
+
+<para>
+To update a local copy of the state and configuration of an X input extension
+device with the changes previously noted in an <emphasis>
+XkbDeviceChangesRec</emphasis>
+ structure, use XkbGetDeviceInfoChanges.
+</para>
+
+
+<para>
+To query the changes that have occurred in the button actions or indicator
+names and indicator maps associated with an input extension device, use
+XkbGetDeviceInfoChanges.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Status <emphasis>
+XkbGetDeviceInfoChanges</emphasis>
+(<emphasis>
+dpy</emphasis>
+, <emphasis>
+device_info</emphasis>
+, changes)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr device_info; /* structure to update with
+results */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceChangesPtr <emphasis>
+changes</emphasis>
+; /* contains notes of changes that have occurred */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+The changes-&gt;changed field indicates which attributes of the device
+specified in <emphasis>
+changes</emphasis>
+-&gt;<emphasis>
+device</emphasis>
+ have changed. The parameters describing the changes are contained in the other
+fields of <emphasis>
+changes</emphasis>
+. <emphasis>
+XkbGetDeviceInfoChanges</emphasis>
+ uses that information to call XkbGetDeviceInfo to obtain the current status of
+those attributes that have changed. It then updates the local description of
+the device in <emphasis>
+device_info</emphasis>
+ with the new information.
+</para>
+
+
+<para>
+To update the server’s description of a device with the changes noted in an
+XkbDeviceChangesRec, use XkbChangeDeviceInfo.
+</para>
+
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbChangeDeviceInfo</emphasis>
+ (<emphasis>
+dpy, device_info, changes</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+dpy</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceInfoPtr <emphasis>
+device_info</emphasis>
+; /* local copy of device state and configuration */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+XkbDeviceChangesPtr <emphasis>
+changes</emphasis>
+; /* note specifying changes in <emphasis>
+device_info</emphasis>
+ */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbChangeDeviceInfo</emphasis>
+ updates the server’s description of the device specified in <emphasis>
+device_info</emphasis>
+-&gt;<emphasis>
+device_spec</emphasis>
+ with the changes specified in <emphasis>
+changes</emphasis>
+ and contained in <emphasis>
+device_info</emphasis>
+. The update is made by an XkbSetDeviceInfo request.
+</para>
+
+</sect1>
+</chapter>
diff --git a/specs/XKB/ch22.xml b/specs/XKB/ch22.xml
new file mode 100644
index 00000000..ba16bffb
--- /dev/null
+++ b/specs/XKB/ch22.xml
@@ -0,0 +1,216 @@
+<chapter id='debugging_aids'>
+<title>Debugging Aids</title>
+
+<para>
+The debugging aids are intended for use primarily by Xkb implementors and are
+optional in any implementation.
+</para>
+
+
+<para>
+There are two bitmasks that may be used to control debugging. One bitmask
+controls the output of debugging information, and the other controls behavior.
+Both bitmasks are initially all zeros.
+</para>
+
+
+<para>
+To change the values of any of the debug controls, use <emphasis>
+XkbSetDebuggingFlags</emphasis>
+.
+</para>
+
+<informaltable frame='none'>
+<tgroup cols='1'>
+<colspec colsep='0'/>
+<tbody>
+ <row rowsep='0'>
+ <entry role='functiondecl'>
+Bool <emphasis>
+XkbSetDebuggingFlags</emphasis>
+(<emphasis>
+display, mask, flags, msg, ctrls_mask, ctrls, ret_flags, ret_ctrls</emphasis>
+)
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+Display * <emphasis>
+ display</emphasis>
+; /* connection to X server */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ mask</emphasis>
+; /* mask selecting debug output flags to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ flags</emphasis>
+; /* values for debug output flags selected by <emphasis>
+mask</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+char * <emphasis>
+ msg</emphasis>
+; /* message to print right now */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ctrls_mask</emphasis>
+; /* mask selecting debug controls to change */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int <emphasis>
+ctrls</emphasis>
+; /* values for debug controls selected by <emphasis>
+ctrls_mask</emphasis>
+ */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+ ret_flags</emphasis>
+; /* resulting state of all debug output flags */
+ </entry>
+ </row>
+ <row rowsep='0'>
+ <entry role='functionargdecl'>
+unsigned int * <emphasis>
+ret_ctrls</emphasis>
+; /* resulting state of all debug controls */
+ </entry>
+</row>
+</tbody>
+</tgroup>
+</informaltable>
+
+<para>
+<emphasis>
+XkbSetDebuggingFlags</emphasis>
+ modifies the debug output flags as specified by <emphasis>
+mask</emphasis>
+ and <emphasis>
+flags</emphasis>
+, modifies the debug controls flags as specified by <emphasis>
+ctrls_mask</emphasis>
+ and <emphasis>
+ctrls</emphasis>
+, prints the message <emphasis>
+msg</emphasis>
+, and backfills <emphasis>
+ret_flags</emphasis>
+ and <emphasis>
+ret_ctrls</emphasis>
+ with the resulting debug output and debug controls flags.
+</para>
+
+
+<para>
+When bits are set in the debug output masks, <emphasis>
+mask</emphasis>
+ and <emphasis>
+flags</emphasis>
+, Xkb prints debug information corresponding to each bit at appropriate points
+during its processing. The device to which the output is written is
+implementation-dependent, but is normally the same device to which X server
+error messages are directed; thus the bits that can be set in <emphasis>
+mask</emphasis>
+ and <emphasis>
+flags</emphasis>
+ is implementation-specific. To turn on a debug output selection, set the bit
+for the output in the <emphasis>
+mask</emphasis>
+ parameter and set the corresponding bit in the <emphasis>
+flags</emphasis>
+ parameter. To turn off event selection for an event, set the bit for the
+output in the <emphasis>
+mask</emphasis>
+ parameter and do not set the corresponding bit in the <emphasis>
+flags</emphasis>
+ parameter.
+</para>
+
+
+<para>
+When bits are set in the debug controls masks, <emphasis>
+ctrls_mask</emphasis>
+ and <emphasis>
+ctrls</emphasis>
+, Xkb modifies its behavior according to each controls bit. <emphasis>
+ctrls_mask</emphasis>
+ and <emphasis>
+ctrls</emphasis>
+ are related in the same way that <emphasis>
+mask</emphasis>
+ and <emphasis>
+flags</emphasis>
+ are. The valid controls bits are defined in Table 22.1.
+</para>
+
+<table frame='none'>
+<title>Debug Control Masks</title>
+<tgroup cols='3'>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<colspec colsep='0'/>
+<thead>
+<row rowsep='0'>
+ <entry>Debug Control Mask</entry>
+ <entry>Value</entry>
+ <entry>Meaning</entry>
+</row>
+</thead>
+<tbody>
+<row rowsep='0'>
+ <entry>XkbDF_DisableLocks</entry>
+ <entry>(1 &lt;&lt; 0)</entry>
+ <entry>Disable actions that lock modifiers</entry>
+ </row>
+</tbody>
+</tgroup>
+</table>
+
+<para>
+<emphasis>
+XkbSetDebuggingFlags</emphasis>
+ returns <emphasis>
+True</emphasis>
+ if successful and <emphasis>
+False</emphasis>
+ otherwise. The only protocol error it may generate is <emphasis>
+BadAlloc</emphasis>
+, if for some reason it is unable to allocate storage.
+</para>
+
+
+<para>
+<emphasis>
+XkbSetDebuggingFlags</emphasis>
+ is intended for developer use and may be disabled in production X servers. If
+it is disabled, <emphasis>
+XkbSetDebuggingFlags</emphasis>
+ has no effect and does not generate any protocol errors.
+</para>
+
+
+<para>
+The message in <emphasis>
+msg</emphasis>
+ is written immediately. The device to which it is written is implementation
+dependent but is normally the same device where X server error messages are
+directed.
+</para>
+</chapter>
diff --git a/specs/XKB/glossary.xml b/specs/XKB/glossary.xml
new file mode 100644
index 00000000..0cccf0f8
--- /dev/null
+++ b/specs/XKB/glossary.xml
@@ -0,0 +1,1016 @@
+<glossary id='glossary'>
+<title>Glossary</title>
+<glossentry>
+ <glossterm>Allocator</glossterm>
+ <glossdef>
+ <para>
+Xkb provides functions, known as allocators, to create and initialize Xkb data
+structures.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Audible Bell</glossterm>
+ <glossdef>
+ <para>
+An audible bell is the sound generated by whatever bell is associated with the
+keyboard or input extension device, as opposed to any other audible sound
+generated elsewhere in the system.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Autoreset Controls</glossterm>
+ <glossdef>
+ <para>
+The autoreset controls configure the boolean controls to automatically be
+enabled or disabled at the time a program exits.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Base Group</glossterm>
+ <glossdef>
+ <para>
+The group in effect as a result of all actions other than a previous lock or
+latch request; the base group is transient. For example, the user pressing and
+holding a group shift key that shifts to Group2 would result in the base group
+being group 2 at that point in time. Initially, base group is always Group1.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Base Modifiers</glossterm>
+ <glossdef>
+ <para>
+Modifiers that are turned on as a result of some actions other than previous
+lock or latch requests; base modifiers are transient. For example, the user
+pressing and holding a key bound to the Shift modifier would result in Shift
+being a base modifier at that point in time.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Base Event Code</glossterm>
+ <glossdef>
+ <para>
+A number assigned by the X server at run time that is assigned to the extension
+to identify events from that extension.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Base State</glossterm>
+ <glossdef>
+ <para>
+The base group and base modifiers represent keys that are physically or
+logically down; these constitute the base state.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Boolean Controls</glossterm>
+ <glossdef>
+ <para>
+Global keyboard controls that may be selectively enabled and disabled under
+program control and that may be automatically set to an on or off condition
+upon client program exit.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Canonical Key Types</glossterm>
+ <glossdef>
+ <para>
+The canonical key types are predefined key types that describe the types of
+keys available on most keyboards. The definitions for the canonical key types
+are held in the first <emphasis>
+XkbNumRequiredTypes</emphasis>
+ entries of the <emphasis>
+types</emphasis>
+ field of the client map and are indexed using the following constants:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+<emphasis>XkbOneLevelIndex</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+<emphasis>XkbTwoLevelIndex</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+<emphasis>XkbAlphabeticIndex</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+<emphasis>XkbKeypadIndex</emphasis>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </glossdef>
+</glossentry>
+
+<glossentry>
+ <glossterm>Client Map</glossterm>
+ <glossdef>
+ <para>
+The key mapping information needed to convert arbitrary keycodes to symbols.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Compat Name</glossterm>
+ <glossdef>
+ <para>
+The <emphasis>
+compat</emphasis>
+ name is a string that provides some information about the rules used to bind
+actions to keys that are changed using core protocol requests.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Compatibility State</glossterm>
+ <glossdef>
+ <para>
+When an Xkb-extended X server connects to an Xkb-unaware client, the
+compatibility state remaps the keyboard group into a core modifier whenever
+possible.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Compatibility Grab State</glossterm>
+ <glossdef>
+ <para>
+The grab state that results from applying the compatibility map to the Xkb grab
+state.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Compatibility Map</glossterm>
+ <glossdef>
+ <para>
+The definition of how to map core protocol keyboard state to Xkb keyboard state.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Component Expression</glossterm>
+ <glossdef>
+ <para>
+An expression used to describe server keyboard database components to be
+loaded. It describes the order in which the components should be loaded and the
+rules by which duplicate attributes should be resolved.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Compose Processing</glossterm>
+ <glossdef>
+ <para>
+The process of mapping a series of keysyms to a string is known as compose
+processing.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Consumed Modifier</glossterm>
+ <glossdef>
+ <para>
+Xkb normally consumes modifiers in determining the appropriate symbol for an
+event, that is, the modifiers are not considered during any of the later stages
+of event processing. For those rare occasions when a modifier <emphasis>
+should</emphasis>
+ be considered despite having been used to look up a symbol, key types include
+an optional <emphasis>
+preserve</emphasis>
+ field.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Core Event</glossterm>
+ <glossdef>
+ <para>
+An event created from the core X server.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Detectable Auto-Repeat</glossterm>
+ <glossdef>
+ <para>
+Detectable auto-repeat allows a client to detect an auto-repeating key. If a
+client requests and the server supports detectable auto-repeat, Xkb generates
+<emphasis>
+KeyRelease</emphasis>
+ events only when the key is physically released. Thus the client receives a
+number of <emphasis>
+KeyPress</emphasis>
+ events for that key without intervening <emphasis>
+KeyRelease</emphasis>
+ events until the key is finally released, when a <emphasis>
+KeyRelease</emphasis>
+ event is received.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Effective Group</glossterm>
+ <glossdef>
+ <para>
+The effective group is the arithmetic sum of the locked, latched, and base
+groups. The effective keyboard group is always brought back into range
+depending on the value of the <emphasis>
+GroupsWrap</emphasis>
+ control for the keyboard. If an event occurs with an effective group that is
+legal for the keyboard as a whole, but not for the key in question, the group
+<emphasis>
+for that event only</emphasis>
+ is normalized using the algorithm specified by the <emphasis>
+group_info</emphasis>
+ member of the key symbol map (<emphasis>
+XkbSymMapRec</emphasis>
+).
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Effective Mask</glossterm>
+ <glossdef>
+ <para>
+An Xkb modifier definition consists of a set of bit masks corresponding to the
+eight real modifiers; a similar set of bitmasks corresponding to the 16 named
+virtual modifiers; and an effective mask. The effective mask represents the set
+of all real modifiers that can logically be set either by setting any of the
+real modifiers or by setting any of the virtual modifiers in the definition.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Effective Modifier</glossterm>
+ <glossdef>
+ <para>
+The effective modifiers are the bitwise union of the base, latched and locked
+modifiers.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Extension Device</glossterm>
+ <glossdef>
+ <para>
+Any keyboard or other input device recognized by the X input extension.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Global Keyboard Controls</glossterm>
+ <glossdef>
+ <para>
+Controls that affect the way Xkb generates key events. The controls affect all
+keys, as opposed to per-key controls that are for a single key. Global controls
+include
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>RepeatKeys Control</para>
+ </listitem>
+ <listitem>
+ <para>DetectableAuto-repeat</para>
+ </listitem>
+ <listitem>
+ <para>SlowKeys</para>
+ </listitem>
+ <listitem>
+ <para>BounceKeys</para>
+ </listitem>
+ <listitem>
+ <para>StickyKeys</para>
+ </listitem>
+ <listitem>
+ <para>MouseKeys</para>
+ </listitem>
+ <listitem>
+ <para>MouseKeysAccel</para>
+ </listitem>
+ <listitem>
+ <para>AccessXKeys</para>
+ </listitem>
+ <listitem>
+ <para>AccessXTimeout</para>
+ </listitem>
+ <listitem>
+ <para>AccessXFeedback</para>
+ </listitem>
+ <listitem>
+ <para>Overlay1</para>
+ </listitem>
+ <listitem>
+ <para>Overlay2</para>
+ </listitem>
+ <listitem>
+ <para>EnabledControls</para>
+ </listitem>
+ </itemizedlist>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Grab State</glossterm>
+ <glossdef>
+ <para>
+The grab state is the state used when matching events to passive grabs. It
+consists of the grab group and the grab modifiers.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Group</glossterm>
+ <glossdef>
+ <para>See Keysym Group</para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Group Index</glossterm>
+ <glossdef>
+ <para>
+A number used as the internal representation for a group number. Group1 through
+Group 4 have indices of 0 through 3.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Groups Wrap Control</glossterm>
+ <glossdef>
+ <para>
+If a group index exceeds the maximum number of groups permitted for the
+specified keyboard, it is wrapped or truncated back into range as specified by
+the global <emphasis>GroupsWrap</emphasis> control. <emphasis>
+GroupsWrap</emphasis> can have the following values:
+ </para>
+ <literallayout>
+ <emphasis>WrapIntoRange</emphasis>
+ <emphasis>ClampIntoRange</emphasis>
+ <emphasis>RedirectIntoRange</emphasis>
+ </literallayout>
+ </glossdef>
+</glossentry>
+
+<glossentry>
+ <glossterm>Key Type</glossterm>
+ <glossdef>
+ <para>
+An attribute of a key that identifies which modifiers affect the shift level of
+a key and the number of groups on the key.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Key Width</glossterm>
+ <glossdef>
+ <para>
+The maximum number of shift levels in any group for the key type associated
+with a key.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keysym Group</glossterm>
+ <glossdef>
+ <para>
+A keysym group is a logical state of the keyboard providing access to a
+collection of characters. A group usually contains a set of characters that
+logically belong together and that may be arranged on several shift levels
+within that group. For example, Group1 could be the English alphabet, and
+Group2 could be Greek. Xkb supports up to four different groups for an input
+device or keyboard. Groups are in the range 1-4 (Group1 - Group4), and are
+often referred to as G1 - G4 and indexed as 0 - 3.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Indicator</glossterm>
+ <glossdef>
+ <para>
+An indicator is a feedback mechanism such as an LED on an input device. Using
+Xkb, a client application can determine the names of the various indicators,
+determine and control the way that the individual indicators should be updated
+to reflect keyboard changes, and determine which of the 32 keyboard indicators
+reported by the protocol are actually present on the keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Indicator Feedback</glossterm>
+ <glossdef>
+ <para>
+An indicator feedback describes the state of a bank of up to 32 lights. It has
+a mask where each bit corresponds to a light and an associated value mask that
+specifies which lights are on or off.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Indicator Map</glossterm>
+ <glossdef>
+ <para>
+An indicator has its own set of attributes that specify whether clients can
+explicitly set its state and whether it tracks the keyboard state. The
+indicator map is the collection of these attributes for each indicator and is
+held in the <emphasis>
+maps</emphasis>
+ array, which is an array of <emphasis>
+XkbIndicatorRec</emphasis>
+ structures.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Input Extension</glossterm>
+ <glossdef>
+ <para>
+An extension to the core X protocol that allows an X server to support multiple
+keyboards, as well as other input devices, in addition to the core X keyboard
+and pointer. Other types of devices supported by the input extension include,
+but are not limited to: mice, tablets, touchscreens, barcode readers, button
+boxes, trackballs, identifier devices, data gloves, and eye trackers.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Key Action</glossterm>
+ <glossdef>
+ <para>
+A key action consists of an operator and some optional data. Once the server
+has applied the global controls and per-key behavior and has decided to process
+a key event, it applies key actions to determine the effects of the key on the
+internal state of the server. Xkb supports actions that do the following:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+Change base, latched, or locked modifiers or group
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Move the core pointer or simulate core pointer button events
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Change most aspects of keyboard behavior
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Terminate or suspend the server
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Send a message to interested clients
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+Simulate events on other keys
+ </para>
+ </listitem>
+ </itemizedlist>
+ </glossdef>
+</glossentry>
+
+<glossentry>
+ <glossterm>Key Alias</glossterm>
+ <glossdef>
+ <para>
+A key alias is a symbolic name for a specific physical key. Key aliases allow
+the keyboard layout designer to assign multiple key names to a single key. This
+allows the keyboard layout designer to refer to keys using either their
+position or their "function." Key aliases can be specified both in the symbolic
+names component and in the keyboard geometry. Both sets of aliases are always
+valid, but key alias definitions in the keyboard geometry have priority; if
+both symbolic names and geometry include aliases, you should consider the
+definitions from the geometry before considering the definitions from the
+symbolic names section.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Key Behavior</glossterm>
+ <glossdef>
+ <para>
+The <emphasis>
+behaviors</emphasis>
+ field of the server map is an array of <emphasis>
+XkbBehavior</emphasis>
+, indexed by keycode, and contains the behavior for each key. The X server uses
+key behavior to determine whether to process or filter out any given key event;
+key behavior is independent of keyboard modifier or group state. Each key has
+exactly one behavior.
+ </para>
+ <para>Key behaviors include:</para>
+ <itemizedlist>
+ <listitem>
+ <para>XkbKB_Default</para>
+ </listitem>
+ <listitem>
+ <para>XkbKB_Lock</para>
+ </listitem>
+ <listitem>
+ <para>XkbKB_RadioGroup</para>
+ </listitem>
+ <listitem>
+ <para>XkbKB_Overlay1</para>
+ </listitem>
+ <listitem>
+ <para>XkbKB_Overlay2</para>
+ </listitem>
+ </itemizedlist>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Key Symbol Map</glossterm>
+ <glossdef>
+ <para>
+A key symbol map describes the symbols bound to a key and the rules to be used
+to interpret those symbols. It is an array of <emphasis>
+XkbSymMapRec</emphasis>
+ structures indexed by keycode.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Key Type</glossterm>
+ <glossdef>
+ <para>
+Key types are used to determine the shift level of a key given the current
+state of the keyboard. There is one key type for each group for a key. Key
+types are defined using the <emphasis>
+XkbKeyTypeRec</emphasis>
+ and <emphasis>
+XkbKTMapEntryRec</emphasis>
+ structures. Xkb allows up to <emphasis>
+XkbMaxKeyTypes</emphasis>
+ (255) key types to be defined, but requires at least <emphasis>
+XkbNumRequiredTypes</emphasis>
+ (4) predefined types to be in a key map.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keyboard Bells</glossterm>
+ <glossdef>
+ <para>
+The sound the default bell makes when rung is the system bell or the default
+keyboard bell. Some input devices may have more than one bell, identified by
+<emphasis>bell_class</emphasis> and <emphasis>bell_id</emphasis>.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keyboard Components</glossterm>
+ <glossdef>
+ <para>
+There are five types of components stored in the X server database of keyboard
+components. They correspond to the <emphasis>
+symbols, geometry, keycodes, compat, </emphasis>
+and<emphasis>
+ types</emphasis>
+ symbolic names associated with a keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keyboard Feedback</glossterm>
+ <glossdef>
+ <para>
+A keyboard feedback includes the following:
+ </para>
+<literallayout>
+ Keyclick volume
+ Bell volume
+ Bell pitch
+ Bell duration
+ Global auto-repeat
+ Per key auto-repeat
+ 32 LEDs
+</literallayout>
+ </glossdef>
+</glossentry>
+
+<glossentry>
+ <glossterm>Key Width, Key Type Width</glossterm>
+ <glossdef>
+ <para>
+The maximum number of shift levels for a type is referred to as the width of a
+key type.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keyboard Geometry</glossterm>
+ <glossdef>
+ <para>
+Keyboard geometry describes the physical appearance of the keyboard, including
+the shape, location, and color of all keyboard keys or other visible keyboard
+components such as indicators and is stored in a <emphasis>
+XkbGeometryRec</emphasis>
+ structure. The information contained in a keyboard geometry is sufficient to
+allow a client program to draw an accurate two-dimensional image of the
+keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keyboard Geometry Name</glossterm>
+ <glossdef>
+ <para>
+The keyboard geometry name describes the physical location, size, and shape of
+the various keys on the keyboard and is part of the <emphasis>
+XkbNamesRec</emphasis>
+ structure.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keyboard State</glossterm>
+ <glossdef>
+ <para>
+Keyboard state encompasses all of the transitory information necessary to map a
+physical key press or release to an appropriate event.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keycode</glossterm>
+ <glossdef>
+ <para>
+A numeric value returned to the X server when a key on a keyboard is pressed or
+released, indicating which key is being modulated. Keycode numbers are in the
+range 1 &lt;= keycode &lt;= max, where max is the number of physical keys on
+the device.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Keycode Name</glossterm>
+ <glossdef>
+ <para>
+The keycode name describes the range and meaning of the keycodes returned by
+the keyboard and is part of the <emphasis>
+XkbNamesRec</emphasis>
+ structure.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Latched Group</glossterm>
+ <glossdef>
+ <para>
+A latched group is a group index that is combined with the base and locked
+group to form the effective group. It applies only to the next key event that
+does not change the keyboard state. The latched group can be changed by
+keyboard activity or via Xkb extension library functions.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Latched Modifier</glossterm>
+ <glossdef>
+ <para>
+Latched modifiers are the set of modifiers that are combined with the base
+modifiers and the locked modifiers to form the effective modifiers. It applies
+only to the next key event that does not change the keyboard state.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>LED</glossterm>
+ <glossdef>
+ <para>
+A light emitting diode. However, for the purposes of the X keyboard extension
+specification, a LED is any form of visual two-state indicator that is either
+on or off.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Locked Group</glossterm>
+ <glossdef>
+ <para>
+A locked group is a group index that is combined with the base and latched
+group to form the effective group. When a group is locked, it supersedes any
+previous locked group and remains the locked group for all future key events,
+until a new group is locked. The locked group can be changed by keyboard
+activity or via Xkb extension library functions.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Locked Modifiers</glossterm>
+ <glossdef>
+ <para>
+Locked modifiers are the set of modifiers that are combined with the base
+modifiers and the latched modifiers to form the effective modifiers. A locked
+modifier applies to all future key events until it is explicitly unlocked.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Lookup State </glossterm>
+ <glossdef>
+ <para>
+The lookup state is composed of the lookup group and the lookup modifiers, and
+it is the state an Xkb-capable or Xkb-aware client should use to map a keycode
+to a keysym.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Modifier</glossterm>
+ <glossdef>
+ <para>
+A modifier is a logical condition that is either set or unset. The modifiers
+control the Shift Level selected when a key event occurs. Xkb supports the core
+protocol eight modifiers (<emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+, <emphasis>
+Control</emphasis>
+, and <emphasis>
+Mod1</emphasis>
+ through <emphasis>
+Mod5</emphasis>
+), called the <emphasis>
+real</emphasis>
+ modifiers. In addition, Xkb extends modifier flexibility by providing a set of
+sixteen named virtual modifiers, each of which can be bound to any set of the
+eight real modifiers.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Modifier Key</glossterm>
+ <glossdef>
+ <para>
+A modifier key is a key whose operation has no immediate effect, but that, for
+as long as it is held down, modifies the effect of other keys. A modifier key
+may be, for example, a shift key or a control key.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Modifier Definition</glossterm>
+ <glossdef>
+ <para>
+An Xkb modifier definition, held in an <emphasis>
+XkbModsRec</emphasis>
+, consists of a set of real modifiers, a set of virtual modifiers, and an
+effective mask. The mask is the union of the real modifiers and the set of real
+modifiers to which the virtual modifiers map; the mask cannot be explicitly
+changed.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Nonkeyboard Extension Device </glossterm>
+ <glossdef>
+ <para>
+An input extension device that is not a keyboard. Other types of devices
+supported by the input extension include, but are not limited to: mice,
+tablets, touchscreens, barcode readers, button boxes, trackballs, identifier
+devices, data gloves, and eye trackers.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Outlines</glossterm>
+ <glossdef>
+ <para>
+An outline is a list of one or more points that describes a single closed
+polygon, used in the geometry specification for a keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Physical Indicator Mask</glossterm>
+ <glossdef>
+ <para>
+The physical indicator mask is a field in the <emphasis>
+XkbIndicatorRec</emphasis>
+ that indicates which indicators are bound to physical LEDs on the keyboard; if
+a bit is set in <emphasis>
+phys_indicators</emphasis>
+, then the associated indicator has a physical LED associated with it. This
+field is necessary because some indicators may not have corresponding physical
+LEDs on the keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Physical Symbol Keyboard Name</glossterm>
+ <glossdef>
+ <para>
+The <emphasis>
+symbols</emphasis>
+ keyboard name identifies the symbols logically bound to the keys. The symbols
+name is a human or application-readable description of the intended locale or
+usage of the keyboard with these symbols. The <emphasis>
+phys_symbols</emphasis>
+ keyboard name, on the other hand, identifies the symbols actually engraved on
+the keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Preserved Modifier</glossterm>
+ <glossdef>
+ <para>
+Xkb normally consumes modifiers in determining the appropriate symbol for an
+event, that is, the modifiers are not considered during any of the later stages
+of event processing. For those rare occasions when a modifier <emphasis>
+should</emphasis>
+ be considered despite having been used to look up a symbol, key types include
+an optional <emphasis>
+preserve</emphasis>
+ field. If a modifier is present in the <emphasis>
+preserve</emphasis>
+ list, it is a preserved modifier.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Radio Group</glossterm>
+ <glossdef>
+ <para>
+A radio group is a set of keys whose behavior simulates a set of radio buttons.
+Once a key in a radio group is pressed, it stays logically depressed until
+another key in the group is pressed, at which point the previously depressed
+key is logically released. Consequently, at most one key in a radio group can
+be logically depressed at one time.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Real Modifier</glossterm>
+ <glossdef>
+ <para>
+Xkb supports the eight core protocol modifiers (<emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+, <emphasis>
+Control</emphasis>
+, and <emphasis>
+Mod1</emphasis>
+ through <emphasis>
+Mod5</emphasis>
+); these are called the <emphasis>
+real</emphasis>
+ modifiers, as opposed to the set of sixteen named virtual modifiers that can
+be bound to any set of the eight real modifiers.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Server Internal Modifiers</glossterm>
+ <glossdef>
+ <para>
+Modifiers that the server uses to determine the appropriate symbol for an
+event; internal modifiers are normally consumed by the server.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Shift Level</glossterm>
+ <glossdef>
+ <para>
+One of several states (normally 2 or 3) governing which graphic character is
+produced when a key is actuated.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Symbol Keyboard Name</glossterm>
+ <glossdef>
+ <para>
+The <emphasis>
+symbols</emphasis>
+ keyboard name identifies the symbols logically bound to the keys. The symbols
+name is a human or application-readable description of the intended locale or
+usage of the keyboard with these symbols. The <emphasis>
+phys_symbols</emphasis>
+ keyboard name, on the other hand, identifies the symbols actually engraved on
+the keyboard.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Symbolic Name</glossterm>
+ <glossdef>
+ <para>
+Xkb supports symbolic names for most components of the keyboard extension. Most
+of these symbolic names are grouped into the <emphasis>
+names</emphasis>
+ component of the keyboard description.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>State Field</glossterm>
+ <glossdef>
+ <para>
+The portion of a client-side core protocol event that holds the modifier,
+group, and button state information pertaining to the event.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Types Name</glossterm>
+ <glossdef>
+ <para>
+The <emphasis>
+types</emphasis>
+ name provides some information about the set of key types that can be
+associated with the keyboard. In addition, each key type can have a name, and
+each shift level of a type can have a name.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Valuator</glossterm>
+ <glossdef>
+ <para>
+A valuator reports a range of values for some entity, like a mouse axis, a
+slider, or a dial.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Virtual Modifier</glossterm>
+ <glossdef>
+ <para>
+Xkb provides a set of sixteen named virtual modifiers that can be bound to any
+set of the eight real modifiers. Each virtual modifier can be bound to any set
+of the real modifiers (<emphasis>
+Shift</emphasis>
+, <emphasis>
+Lock</emphasis>
+, <emphasis>
+Control,</emphasis>
+ and <emphasis>
+Mod1</emphasis>
+-<emphasis>
+Mod5</emphasis>
+).
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Virtual Modifier Mapping</glossterm>
+ <glossdef>
+ <para>
+Xkb maintains a virtual modifier mapping, which lists the virtual modifiers
+associated with each key.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Xkb-aware Client</glossterm>
+ <glossdef>
+ <para>
+A client application that initializes Xkb extension and is consequently bound
+to an Xlib that includes the Xkb extension.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Xkb-capable Client</glossterm>
+ <glossdef>
+ <para>
+A client application that makes no Xkb extension Xlib calls but is bound to an
+Xlib that includes the Xkb extension.
+ </para>
+ </glossdef>
+</glossentry>
+<glossentry>
+ <glossterm>Xkb-unaware Client</glossterm>
+ <glossdef>
+ <para>
+A client application that makes no Xkb extension Xlib calls and is bound to an
+Xlib that does not include the Xkb extension.
+ </para>
+ </glossdef>
+</glossentry>
+
+</glossary>
diff --git a/specs/XKB/xkblib.xml b/specs/XKB/xkblib.xml
new file mode 100644
index 00000000..95bf6640
--- /dev/null
+++ b/specs/XKB/xkblib.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book
+ PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+
+<book id="xkblib">
+
+<bookinfo>
+ <title>The X Keyboard Extension:</title>
+ <subtitle>Library Specification</subtitle>
+ <authorgroup>
+ <author>
+ <firstname>Amber</firstname>
+ <othername>J.</othername>
+ <surname>Benson</surname>
+ </author>
+ <author>
+ <firstname>Gary</firstname>
+ <surname>Aitken</surname>
+ </author>
+ <author>
+ <firstname>Erik</firstname>
+ <surname>Fortune</surname>
+ <affiliation><orgname>Silicon Graphics, Inc</orgname></affiliation>
+ </author>
+ <author>
+ <firstname>Donna</firstname>
+ <surname>Converse</surname>
+ <affiliation><orgname>X Consortium, Inc</orgname></affiliation>
+ </author>
+ <author>
+ <firstname>George</firstname>
+ <surname>Sachs</surname>
+ <affiliation><orgname>Hewlett-Packard Company</orgname></affiliation>
+ </author>
+ <author>
+ <firstname>Will</firstname>
+ <surname>Walker</surname>
+ <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
+ </author>
+ </authorgroup>
+ <releaseinfo>X Version 11, Release 6.4</releaseinfo>
+
+<legalnotice>
+<para>Copyright © 1995, 1996 X Consortium Inc.</para>
+<para>Copyright © 1995, 1996 Silicon Graphics Inc.</para>
+<para>Copyright © 1995, 1996 Hewlett-Packard Company</para>
+<para>Copyright © 1995, 1996 Digital Equipment Corporation</para>
+<para>
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the “Software”),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+</para>
+<para>
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+</para>
+<para>
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+</para>
+<para>
+Except as contained in this notice, the names of the X Consortium, Silicon
+Graphics Inc., Hewlett-Packard Company, and Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization.
+</para>
+</legalnotice>
+
+</bookinfo>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="acknowledgement.xml"/>
+<!-- Document font conventions pg goes here -->
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch01.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch02.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch03.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch04.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch05.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch06.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch07.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch08.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch09.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch10.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch11.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch12.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch13.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch14.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch15.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch16.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch17.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch18.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch19.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch20.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch21.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="ch22.xml"/>
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glossary.xml"/>
+</book>