1 <chapter id='Complete_Keyboard_Description'>
2 <title>Complete Keyboard Description</title>
5 The complete Xkb description for a keyboard device is accessed using a single
6 structure containing pointers to major Xkb components. This chapter describes
7 this single structure and provides references to other sections of this
8 document that discuss the major Xkb components in detail.
11 <sect1 id='The_XkbDescRec_Structure'>
12 <title>The XkbDescRec Structure</title>
15 The complete description of an Xkb keyboard is given by an <emphasis>
17 . The component structures in the <emphasis>
19 represent the major Xkb components outlined in Figure 1.1. <!-- xref -->
22 <para><programlisting>
24 struct _XDisplay * display; /* connection to
26 unsigned short flags; /* private to Xkb, do
28 unsigned short device_spec; /* device of
30 KeyCode min_key_code; /* minimum keycode for
32 KeyCode max_key_code; /* maximum keycode for
34 XkbControlsPtr ctrls; /* controls */
35 XkbServerMapPtr server; /* server keymap */
36 XkbClientMapPtr map; /* client keymap */
37 XkbIndicatorPtr indicators; /* indicator map
39 XkbNamesPtr names; /* names for all
41 XkbCompatMapPtr compat; /* compatibility map
43 XkbGeometryPtr geom; /* physical geometry of
48 </programlisting></para>
53 field points to an X display structure. The <emphasis>
55 field is private to the library: modifying <emphasis>
57 may yield unpredictable results. The <emphasis>
58 device_spec</emphasis>
59 field specifies the device identifier of the keyboard input device, or
61 XkbUseCoreKeyboard</emphasis>
62 , which specifies the core keyboard device. The <emphasis>
63 min_key_code</emphasis>
65 max_key_code</emphasis>
66 fields specify the least and greatest keycode that can be returned by the
72 The other fields specify structure components of the keyboard description and
73 are described in detail in other sections of this document. Table 6.1
74 identifies the subsequent sections of this document that discuss the individual
75 components of the <emphasis>
80 <table frame='topbot'>
81 <title>XkbDescRec Component References</title>
82 <?dbfo keep-together="always" ?>
83 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
84 <colspec colname='c1' colwidth='1.0*'/>
85 <colspec colname='c2' colwidth='2.0*'/>
88 <entry>XkbDescRec Field</entry>
89 <entry>For more info</entry>
95 <entry>Chapter 10</entry>
99 <entry>Chapter 16</entry>
103 <entry>Chapter 15</entry>
106 <entry>indicators</entry>
107 <entry>Chapter 8</entry>
111 <entry>Chapter 18</entry>
114 <entry>compat</entry>
115 <entry>Chapter 17</entry>
119 <entry>Chapter 13</entry>
126 Each structure component has a corresponding mask bit that is used in function
127 calls to indicate that the structure should be manipulated in some manner, such
128 as allocating it or freeing it. These masks and their relationships to the
129 fields in the <emphasis>
130 XkbDescRec</emphasis>
131 are shown in Table 6.2. <!-- xref -->
134 <table frame='topbot'>
135 <title>Mask Bits for XkbDescRec</title>
136 <?dbfo keep-together="always" ?>
137 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
138 <colspec colname='c1' colwidth='1.0*'/>
139 <colspec colname='c2' colwidth='1.0*'/>
140 <colspec colname='c3' colwidth='1.0*'/>
143 <entry>Mask Bit</entry>
144 <entry>XkbDescRec Field</entry>
150 <entry>XkbControlsMask</entry>
152 <entry>(1L<<0)</entry>
155 <entry>XkbServerMapMask</entry>
156 <entry>server</entry>
157 <entry>(1L<<1)</entry>
160 <entry>XkbIClientMapMask</entry>
162 <entry>(1L<<2)</entry>
165 <entry>XkbIndicatorMapMask</entry>
166 <entry>indicators</entry>
167 <entry>(1L<<3)</entry>
170 <entry>XkbNamesMask</entry>
172 <entry>(1L<<4)</entry>
175 <entry>XkbCompatMapMask</entry>
176 <entry>compat</entry>
177 <entry>(1L<<5)</entry>
180 <entry>XkbGeometryMask</entry>
182 <entry>(1L<<6)</entry>
185 <entry>XkbAllComponentsMask</entry>
186 <entry>All Fields</entry>
187 <entry>(0x7f)</entry>
194 <sect1 id='Obtaining_a_Keyboard_Description_from_the_Server'>
195 <title>Obtaining a Keyboard Description from the Server</title>
198 To retrieve one or more components of a keyboard device description, use
200 XkbGetKeyboard</emphasis>
202 XkbGetKeyboardbyName</emphasis>
206 <informaltable frame='none'>
207 <?dbfo keep-together="always" ?>
208 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
209 <colspec colname='c1' colwidth='1.0*'/>
212 <entry role='functiondecl'>
213 XkbDescPtr <emphasis>
214 XkbGetKeyboard</emphasis>
216 display, which, device_spec</emphasis>
221 <entry role='functionargdecl'>
224 ; /* connection to X server */
228 <entry role='functionargdecl'>
229 unsigned int <emphasis>
231 ; /* mask indicating components to return */
235 <entry role='functionargdecl'>
236 unsigned int<emphasis>
237 device_spec</emphasis>
238 ; /* device for which to fetch description, or <emphasis>
239 XkbUseCoreKbd</emphasis>
249 XkbGetKeyboard </emphasis>
250 allocates and returns a pointer to a keyboard description. It queries the
251 server for those components specified in the <emphasis>
253 parameter for device <emphasis>
254 device_spec</emphasis>
255 and copies the results to the <emphasis>
256 XkbDescRec</emphasis>
257 it allocated. The remaining fields in the keyboard description are set to
260 . The valid masks for <emphasis>
262 are those listed in Table 6.2. <!-- xref -->
268 XkbGetKeyboard</emphasis>
269 can generate <emphasis>
276 To free the returned keyboard description, use <emphasis>
277 XkbFreeKeyboard</emphasis>
278 (see section 6.4). <!-- xref -->
283 <sect1 id='Tracking_Changes_to_the_Keyboard_Description_in_the_Server'>
284 <title>Tracking Changes to the Keyboard Description in the Server</title>
287 The server can generate events whenever its copy of the keyboard description
288 for a device changes. Refer to section 14.4 for detailed information on <!-- xref -->
289 tracking changes to the keyboard description.
294 <sect1 id='Allocating_and_Freeing_a_Keyboard_Description'>
295 <title>Allocating and Freeing a Keyboard Description</title>
298 Applications seldom need to directly allocate a keyboard description; calling
300 XkbGetKeyboard</emphasis>
301 usually suffices. In the event you need to create a keyboard description from
302 scratch, however, use <emphasis>
303 XkbAllocKeyboard</emphasis>
304 rather than directly calling <emphasis>
311 <informaltable frame='none'>
312 <?dbfo keep-together="always" ?>
313 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
314 <colspec colname='c1' colwidth='1.0*'/>
317 <entry role='functiondecl'>
318 XkbDescRec * <emphasis>
319 XkbAllocKeyboard</emphasis>
329 XkbAllocKeyboard</emphasis>
330 fails to allocate the keyboard description, it returns <emphasis>
332 . Otherwise, it returns a pointer to an empty keyboard description structure.
334 device_spec</emphasis>
335 field will have been initialized to <emphasis>
336 XkbUseCoreKbd</emphasis>
337 . You may then either fill in the structure components or use Xkb functions to
338 obtain values for the structure components from a keyboard device.
343 To destroy either an entire an <emphasis>
344 XkbDescRec</emphasis>
345 or just some of its members, use <emphasis>
346 XkbFreeKeyboard.</emphasis>
350 <informaltable frame='none'>
351 <?dbfo keep-together="always" ?>
352 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
353 <colspec colname='c1' colwidth='1.0*'/>
356 <entry role='functiondecl'>
358 XkbFreeKeyboard</emphasis>
360 (xkb, which, free_all</emphasis>
365 <entry role='functionargdecl'>
366 XkbDescPtr <emphasis>
368 ; /* keyboard description with components to free */
372 <entry role='functionargdecl'>
373 unsigned int <emphasis>
375 ; /* mask selecting components to free */
379 <entry role='functionargdecl'>
384 => free all components and <emphasis>
395 XkbFreeKeyboard</emphasis>
396 frees the components of <emphasis>
398 specified by <emphasis>
400 and sets the corresponding values to <emphasis>
407 XkbFreeKeyboard</emphasis>
408 frees every non-<emphasis>
410 component of <emphasis>
412 and then frees the <emphasis>