ch20.xml revision e9fcaa8a
1<chapter id='server_database_of_keyboard_components'>
2<title>Server Database of Keyboard Components</title>
3
4<para>
5The X server maintains a database of keyboard components, identified by
6component type. The database contains all the information necessary to build a
7complete keyboard description for a particular device, as well as to assemble
8partial descriptions. Table 20.1 identifies the component types and the type of
9information they contain.
10</para>
11
12<table frame='none'>
13<title>Server Database Keyboard Components</title>
14<tgroup cols='3'>
15<colspec colsep='0'/>
16<colspec colsep='0'/>
17<colspec colsep='0'/>
18<thead>
19<row rowsep='0'>
20  <entry>Component Type</entry>
21  <entry>Component Primary Contents</entry>
22  <entry>May also contain</entry>
23  </row>
24</thead>
25<tbody>
26  <row rowsep='0'>
27    <entry>Keymap</entry>
28    <entry>
29<para>Complete keyboard description</para>
30<para>Normally assembled using a complete component from each of the other types</para>
31    </entry>
32    <entry></entry>
33  </row>
34  <row rowsep='0'>
35    <entry>Keycodes</entry>
36    <entry>
37<para>Symbolic name for each key</para>
38<para>Minimum and maximum legal keycodes</para>
39    </entry>
40    <entry>
41<para>Aliases for some keys</para>
42<para>Symbolic names for indicators</para>
43<para>Description of indicators physically present</para>
44    </entry>
45  </row>
46  <row rowsep='0'>
47    <entry>Types</entry>
48    <entry>Key types</entry>
49    <entry>
50Real modifier bindings and symbolic names for some virtual modifiers
51    </entry>
52  </row>
53  <row rowsep='0'>
54    <entry>Compatibility</entry>
55    <entry>Rules used to assign actions to keysyms</entry>
56    <entry>
57<para>Maps for some indicators</para>
58<para>Real modifier bindings and symbolic names for some virtual modifiers</para>
59    </entry>
60  </row>
61  <row rowsep='0'>
62    <entry>Symbols</entry>
63    <entry>
64<para>Symbol mapping for keyboard keys</para>
65<para>Modifier mapping</para>
66<para>Symbolic names for groups</para>
67    </entry>
68    <entry>
69<para>Explicit actions and behaviors for some keys</para>
70<para>Real modifier bindings and symbolic names for some virtual modifiers</para>
71    </entry>
72  </row>
73  <row rowsep='0'>
74    <entry>Geometry</entry>
75    <entry>Layout of the keyboard</entry>
76    <entry>
77<para>Aliases for some keys; overrides keycodes component aliases</para>
78<para>Symbolic names for some indicators</para>
79<para>Description of indicators physically present</para>
80    </entry>
81  </row>
82</tbody>
83</tgroup>
84</table>
85
86<para>
87While a keymap is a database entry for a complete keyboard description, and
88therefore logically different from the individual component database entries,
89the rules for processing keymap entries are identical to those for the
90individual components. In the discussion that follows, the term component is
91used to refer to either individual components or a keymap.
92</para>
93
94<para>
95There may be multiple entries for each of the component types. An entry may be
96either <emphasis>
97complete</emphasis>
98 or <emphasis>
99partial</emphasis>
100. Partial entries describe only a piece of the corresponding keyboard component
101and are designed to be combined with other entries of the same type to form a
102complete entry.
103</para>
104
105<para>
106For example, a partial symbols map might describe the differences between a
107common ASCII keyboard and some national layout. Such a partial map is not
108useful on its own because it does not include those symbols that are the same
109on both the ASCII and national layouts (such as function keys). On the other
110hand, this partial map can be used to configure <emphasis>
111any</emphasis>
112 ASCII keyboard to use a national layout.
113</para>
114
115<para>
116When a keyboard description is built, the components are processed in the order
117in which they appear in Table 20.1; later definitions override earlier ones.
118</para>
119
120<sect1 id='component_names'>
121<title>Component Names</title>
122
123<para>
124Component names have the form "<emphasis>
125class(member)</emphasis>
126" where <emphasis>
127class</emphasis>
128 describes a subset of the available components for a particular type and the
129optional <emphasis>
130member</emphasis>
131 identifies a specific component from that subset. For example, the name
132"atlantis(acme)" for a symbols component might specify the symbols used for the
133atlantis national keyboard layout by the vendor "acme." Each class has an
134optional <emphasis>
135default</emphasis>
136 member — references that specify a class but not a member refer to the
137default member of the class, if one exists. Xkb places no constraints on the
138interpretation of the class and member names used in component names.
139</para>
140
141<para>
142The <emphasis>
143class</emphasis>
144 and <emphasis>
145member</emphasis>
146 names are both specified using characters from the Latin-1 character set. Xkb
147implementations must accept all alphanumeric characters, minus (‘-’) and
148underscore (‘_’) in class or member names, and must not accept parentheses,
149plus, vertical bar, percent sign, asterisk, question mark, or white space. The
150use of other characters is implementation-dependent.
151</para>
152
153</sect1>
154<sect1 id='listing_the_known_keyboard_components'>
155<title>Listing the Known Keyboard Components</title>
156
157<para>
158You may ask the server for a list of components for one or more component
159types. The request takes the form of a set of patterns, one pattern for each of
160the component types, including a pattern for the complete keyboard description.
161To obtain this list, use <emphasis>
162XkbListComponents</emphasis>
163.
164</para>
165
166<informaltable frame='none'>
167<tgroup cols='1'>
168<colspec colsep='0'/>
169<tbody>
170  <row rowsep='0'>
171    <entry role='functiondecl'>
172XkbComponentListPtr<emphasis>
173 XkbListComponents</emphasis>
174(<emphasis>
175dpy</emphasis>
176, <emphasis>
177device_spec</emphasis>
178, <emphasis>
179ptrns</emphasis>
180, <emphasis>
181max_inout</emphasis>
182)
183    </entry>
184  </row>
185  <row rowsep='0'>
186    <entry role='functionargdecl'>
187Display *      <emphasis>
188            dpy</emphasis>
189;            /* connection to X server */
190    </entry>
191  </row>
192  <row rowsep='0'>
193    <entry role='functionargdecl'>
194unsigned int                  <emphasis>
195device_spec</emphasis>
196;            /* device ID, or <emphasis>
197XkbUseCoreKbd</emphasis>
198 */
199    </entry>
200  </row>
201  <row rowsep='0'>
202    <entry role='functionargdecl'>
203XkbComponentNamesPtr                  <emphasis>
204ptrns</emphasis>
205;            /* namelist for components of interest */
206    </entry>
207  </row>
208  <row rowsep='0'>
209    <entry role='functionargdecl'>
210int *                  <emphasis>
211max_inout</emphasis>
212;            /* max # returned names, # left over */
213    </entry>
214</row>
215</tbody>
216</tgroup>
217</informaltable>
218
219<para>
220<emphasis>
221XkbListComponents</emphasis>
222 queries the server for a list of component names matching the patterns
223specified in <emphasis>
224ptrns</emphasis>
225. It waits for a reply and returns the matching component names in an <emphasis>
226XkbComponentListRec</emphasis>
227 structure. When you are done using the structure, you should free it using
228<emphasis>
229XkbFreeComponentList</emphasis>
230. <emphasis>
231device_spec</emphasis>
232 indicates a particular device in which the caller is interested. A server is
233allowed (but not required) to restrict its reply to portions of the database
234that are relevant for that particular device.
235</para>
236
237
238<para>
239<emphasis>
240ptrns</emphasis>
241 is a pointer to an <emphasis>
242XkbComponentNamesRec</emphasis>
243, described below. Each of the fields in <emphasis>
244ptrns</emphasis>
245 contains a pattern naming the components of interest. Each of the patterns is
246composed of characters from the ISO <emphasis>
247Latin1</emphasis>
248 encoding, but can contain only parentheses, the wildcard characters
249‘<emphasis>
250?</emphasis>
251’ and ‘<emphasis>
252*</emphasis>
253’, and characters permitted in a component class or member name (see section
25420.1). A pattern may be <emphasis>
255NULL</emphasis>
256, in which case no components for that type is returned. Pattern matches with
257component names are case sensitive. The ‘<emphasis>
258?</emphasis>
259’ wildcard matches any single character, except a left or right parenthesis;
260the ‘<emphasis>
261*</emphasis>
262’ wildcard matches any number of characters, except a left or right
263parenthesis. If an implementation allows additional characters in a component
264class or member name other than those required by the Xkb extension (see
265section 20.1), the result of comparing one of the additional characters to
266either of the wildcard characters is implementation-dependent.
267</para>
268
269
270<para>
271If a pattern contains illegal characters, the illegal characters are ignored.
272The matching process is carried out as if the illegal characters were omitted
273from the pattern.
274</para>
275
276
277<para>
278<emphasis>
279max_inout</emphasis>
280 is used to throttle the amount of data passed to and from the server. On
281input, it specifies the maximum number of names to be returned (the total
282number of names in all component categories). Upon return from <emphasis>
283XkbListComponents</emphasis>
284, <emphasis>
285max_inout</emphasis>
286 contains the number of names that matched the request but were not returned
287because of the limit.
288</para>
289
290
291<para>
292The component name patterns used to describe the request are passed to
293<emphasis>
294XkbListComponents</emphasis>
295 using an <emphasis>
296XkbComponentNamesRec</emphasis>
297 structure. This structure has no special allocation constraints or
298interrelationships with other structures; allocate and free this structure
299using standard <emphasis>
300malloc</emphasis>
301 and <emphasis>
302free</emphasis>
303 calls or their equivalent:
304</para>
305
306<para><programlisting>
307typedef struct _XkbComponentNames {
308      char *       keymap;    /* keymap names */
309      char *       keycodes;  /* keycode names */
310      char *       types;     /* type names */
311      char *       compat;    /* compatibility map names */
312      char *       symbols;   /* symbol names */
313      char *       geometry;  /* geometry names */
314} <emphasis>XkbComponentNamesRec</emphasis>, *XkbComponentNamesPtr;
315</programlisting></para>
316
317<para>
318<emphasis>
319XkbListComponents</emphasis>
320 returns a pointer to an <emphasis>
321XkbComponentListRec</emphasis>
322:
323</para>
324
325<para><programlisting>
326typedef struct _XkbComponentList {
327      int                  num_keymaps;     /* number of entries in keymap */
328      int                  num_keycodes;    /* number of entries in keycodes */
329      int                  num_types;       /* number of entries in types */
330      int                  num_compat;      /* number of entries in compat */
331      int                  num_symbols;     /* number of entries in symbols */
332      int                  num_geometry;    /* number of entries in geometry;
333      XkbComponentNamePtr  keymap;          /* keymap names */
334      XkbComponentNamePtr  keycodes;        /* keycode names */
335      XkbComponentNamePtr  types;           /* type names */
336      XkbComponentNamePtr  compat;          /* compatibility map names */
337      XkbComponentNamePtr  symbols;         /* symbol names */
338      XkbComponentNamePtr  geometry;        /* geometry names */
339} <emphasis>XkbComponentListRec</emphasis>, *XkbComponentListPtr;
340</programlisting></para>
341
342<para><programlisting>
343typedef struct _XkbComponentName {
344      unsigned short         flags;     /* hints regarding component name */
345      char *                 name;      /* name of component */
346} <emphasis>XkbComponentNameRec</emphasis>, *XkbComponentNamePtr;
347</programlisting></para>
348
349<para>
350Note that the structure used to specify patterns on input is an <emphasis>
351XkbComponentNamesRec</emphasis>
352, and that used to hold the individual component names upon return is an
353<emphasis>
354XkbComponentNameRec</emphasis>
355 (no trailing ‘s’ in Name).
356</para>
357
358
359<para>
360When you are done using the structure returned by <emphasis>
361XkbListComponents</emphasis>
362, free it using <emphasis>
363XkbFreeComponentList</emphasis>
364.
365</para>
366
367
368<informaltable frame='none'>
369<tgroup cols='1'>
370<colspec colsep='0'/>
371<tbody>
372  <row rowsep='0'>
373    <entry role='functiondecl'>
374void <emphasis>
375XkbFreeComponentList</emphasis>
376(list)
377    </entry>
378  </row>
379  <row rowsep='0'>
380    <entry role='functionargdecl'>
381XkbComponentListPtr                   list;      /* pointer to <emphasis>
382XkbComponentListRec</emphasis>
383 to free */
384    </entry>
385</row>
386</tbody>
387</tgroup>
388</informaltable>
389
390
391</sect1>
392<sect1 id='component_hints'>
393<title>Component Hints</title>
394
395<para>
396A set of flags is associated with each component; these flags provide
397additional hints about the component’s use. These hints are designated by bit
398masks in the flags field of the <emphasis>
399XkbComponentNameRec</emphasis>
400 structures contained in the <emphasis>
401XkbComponentListRec</emphasis>
402 returned from <emphasis>
403XkbListComponents</emphasis>
404. The least significant byte of the flags field has the same meaning for all
405types of keyboard components; the interpretation of the most significant byte
406is dependent on the type of component. The flags bits are defined in Table
40720.2. The symbols hints in Table 20.2 apply only to partial symbols components
408(those with <emphasis>
409XkbLC_Partial</emphasis>
410 also set); full symbols components are assumed to specify all of the pieces.
411</para>
412
413
414<para>
415The alphanumeric, modifier, keypad or function keys symbols hints should
416describe the primary intent of the component designer and should not be simply
417an exhaustive list of the kinds of keys that are affected. For example,
418national keyboard layouts affect primarily alphanumeric keys, but many affect a
419few modifier keys as well; such mappings should set only the <emphasis>
420XkbLC_AlphanumericKeys</emphasis>
421 hint. In general, symbols components should set only one of the four flags
422(<emphasis>
423XkbLC_AlternateGroup</emphasis>
424 may be combined with any of the other flags).
425</para>
426
427<table frame='none'>
428<title>XkbComponentNameRec Flags Bits</title>
429<tgroup cols='4'>
430<colspec colsep='0'/>
431<colspec colsep='0'/>
432<colspec colsep='0'/>
433<colspec colsep='0'/>
434<thead>
435<row rowsep='0'>
436  <entry>Component Type</entry>
437  <entry>Component Hints (flags)</entry>
438  <entry>Meaning</entry>
439  <entry>Value</entry>
440</row>
441</thead>
442<tbody>
443<row rowsep='0'>
444    <entry>All Components</entry>
445    <entry><para><emphasis>XkbLC_Hidden</emphasis></para></entry>
446    <entry>Do not present to user</entry>
447    <entry>(1L&lt;&lt;0)</entry>
448</row>
449<row rowsep='0'>
450    <entry></entry>
451    <entry><emphasis>XkbLC_Default</emphasis></entry>
452    <entry>Default member of class</entry>
453    <entry>(1L&lt;&lt;1)</entry>
454</row>
455<row rowsep='0'>
456    <entry></entry>
457    <entry><emphasis>XkbLC_Partial</emphasis></entry>
458    <entry>Partial component</entry>
459    <entry>(1L&lt;&lt;2)</entry>
460</row>
461<row rowsep='0'>
462    <entry>Keymap</entry>
463    <entry>none</entry>
464    <entry></entry>
465    <entry></entry>
466</row>
467<row rowsep='0'>
468    <entry>Keycodes</entry>
469    <entry>none</entry>
470    <entry></entry>
471    <entry></entry>
472</row>
473<row rowsep='0'>
474    <entry>Types</entry>
475    <entry>none</entry>
476    <entry></entry>
477    <entry></entry>
478</row>
479<row rowsep='0'>
480    <entry>Compatibility</entry>
481    <entry>none</entry>
482    <entry></entry>
483    <entry></entry>
484</row>
485<row rowsep='0'>
486    <entry>Symbols</entry>
487    <entry><emphasis>XkbLC_AlphanumericKeys</emphasis></entry>
488    <entry>Bindings primarily for alphanumeric keyboard section</entry>
489    <entry>(1L&lt;&lt;8)</entry>
490</row>
491<row rowsep='0'>
492    <entry></entry>
493    <entry><emphasis>XkbLC_ModifierKeys</emphasis></entry>
494    <entry>Bindings primarily for modifier keys</entry>
495    <entry>(1L&lt;&lt;9)</entry>
496</row>
497<row rowsep='0'>
498    <entry></entry>
499    <entry><emphasis>XkbLC_KeypadKeys</emphasis></entry>
500    <entry>Bindings primarily for numeric keypad keys</entry>
501    <entry>(1L&lt;&lt;10)</entry>
502</row>
503<row rowsep='0'>
504    <entry></entry>
505    <entry><emphasis>XkbLC_FunctionKeys</emphasis></entry>
506    <entry>Bindings primarily for function keys</entry>
507    <entry>(1L&lt;&lt;11)</entry>
508</row>
509<row rowsep='0'>
510    <entry></entry>
511    <entry><emphasis>XkbLC_AlternateGroup</emphasis></entry>
512    <entry>Bindings for an alternate group</entry>
513    <entry>(1L&lt;&lt;12)</entry>
514</row>
515<row rowsep='0'>
516    <entry>Geometry</entry>
517    <entry>none</entry>
518    <entry></entry>
519    <entry></entry>
520  </row>
521</tbody>
522</tgroup>
523</table>
524
525</sect1>
526<sect1 id='building_a_keyboard_description_using_the_server_database'>
527<title>Building a Keyboard Description Using the Server Database</title>
528
529<para>
530A client may request that the server fetch one or more components from its
531database and use those components to build a new server keyboard description.
532The new keyboard description may be built from scratch, or it may be built
533starting with the current keyboard description for a particular device. Once
534the keyboard description is built, all or part of it may be returned to the
535client. The parts returned to the client need not include all of the parts used
536to build the description. At the time it requests the server to build a new
537keyboard description, a client may also request that the server use the new
538description internally to replace the current keyboard description for a
539specific device, in which case the behavior of the device changes accordingly.
540</para>
541
542
543<para>
544To build a new keyboard description from a set of named components, and to
545optionally have the server use the resulting description to replace an active
546one, use <emphasis>
547XkbGetKeyboardByName</emphasis>
548.
549</para>
550
551<informaltable frame='none'>
552<tgroup cols='1'>
553<colspec colsep='0'/>
554<tbody>
555  <row rowsep='0'>
556    <entry role='functiondecl'>
557XkbDescPtr <emphasis>
558XkbGetKeyboardByName</emphasis>
559(<emphasis>
560dpy</emphasis>
561, <emphasis>
562device_spec</emphasis>
563, <emphasis>
564names</emphasis>
565, <emphasis>
566want</emphasis>
567, <emphasis>
568need</emphasis>
569, <emphasis>
570load</emphasis>
571)
572    </entry>
573  </row>
574  <row rowsep='0'>
575    <entry role='functionargdecl'>
576Display *      <emphasis>
577            dpy</emphasis>
578;            /* connection to X server */
579    </entry>
580  </row>
581  <row rowsep='0'>
582    <entry role='functionargdecl'>
583unsigned int                  <emphasis>
584device_spec</emphasis>
585;            /* device ID, or <emphasis>
586XkbUseCoreKbd</emphasis>
587 */
588    </entry>
589  </row>
590  <row rowsep='0'>
591    <entry role='functionargdecl'>
592XkbComponentNamesPtr                  <emphasis>
593names</emphasis>
594;            /* names of components to fetch */
595    </entry>
596  </row>
597  <row rowsep='0'>
598    <entry role='functionargdecl'>
599unsigned int                  <emphasis>
600want</emphasis>
601;            /* desired structures in returned record */
602    </entry>
603  </row>
604  <row rowsep='0'>
605    <entry role='functionargdecl'>
606unsigned int                  <emphasis>
607need</emphasis>
608;            /* mandatory structures in returned record */
609    </entry>
610  </row>
611  <row rowsep='0'>
612    <entry role='functionargdecl'>
613Bool                  <emphasis>
614load</emphasis>
615;            /* <emphasis>
616True</emphasis>
617 =&gt; load into <emphasis>
618device_spec</emphasis>
619 */
620    </entry>
621</row>
622</tbody>
623</tgroup>
624</informaltable>
625
626<para>
627<emphasis>
628names</emphasis>
629 contains a set of expressions describing the keyboard components the server
630should use to build the new keyboard description. <emphasis>
631want</emphasis>
632 and <emphasis>
633need</emphasis>
634 are bit fields describing the parts of the resulting keyboard description that
635should be present in the returned <emphasis>
636XkbDescRec</emphasis>
637.
638</para>
639
640
641<para>
642The individual fields in <emphasis>
643names</emphasis>
644 are <emphasis>
645component expressions</emphasis>
646 composed of keyboard component names (no wildcarding as may be used in
647<emphasis>
648XkbListComponents</emphasis>
649), the special component name symbol ‘%’, and the special operator
650characters ‘<emphasis>
651+</emphasis>
652’ and ‘<emphasis>
653|</emphasis>
654’. A component expression is parsed left to right, as follows:
655</para>
656
657<itemizedlist>
658<listitem>
659  <para>
660The special component name "<emphasis>
661computed</emphasis>
662" may be used in <emphasis>
663keycodes</emphasis>
664 component expressions and refers to a component consisting of a set of
665keycodes computed automatically by the server as needed.
666  </para>
667</listitem>
668<listitem>
669  <para>
670The special component name "<emphasis>
671canonical</emphasis>
672" may be used in <emphasis>
673types</emphasis>
674 component expressions and refers to a partial component defining the four
675standard key types: <emphasis>
676ALPHABETIC</emphasis>
677, <emphasis>
678ONE_LEVEL</emphasis>
679, <emphasis>
680TWO_LEVEL</emphasis>
681, and <emphasis>
682KEYPAD</emphasis>
683.
684  </para>
685</listitem>
686<listitem>
687  <para>
688The special component name ‘<emphasis>
689%</emphasis>
690’ refers to the keyboard description for the device specified in <emphasis>
691device_spec</emphasis>
692 or the keymap names component. If a keymap names component is specified that
693does not begin with ‘+’ or ‘|’ and does not contain ‘<emphasis>
694%</emphasis>
695’, then ‘<emphasis>
696%</emphasis>
697’ refers to the description generated by the keymap names component.
698Otherwise, it refers to the keyboard description for <emphasis>
699device_spec</emphasis>
700.
701  </para>
702</listitem>
703<listitem>
704  <para>
705The ‘<emphasis>
706+</emphasis>
707’ operator specifies that the following component should <emphasis>
708override</emphasis>
709 the currently assembled description; any definitions that are present in both
710components are taken from the second.
711  </para>
712</listitem>
713<listitem>
714  <para>
715The ‘<emphasis>
716|</emphasis>
717’ operator specifies that the next specified component should <emphasis>
718augment</emphasis>
719 the currently assembled description; any definitions that are present in both
720components are taken from the first.
721  </para>
722</listitem>
723<listitem>
724  <para>
725If the component expression begins with an operator, a leading ‘<emphasis>
726%</emphasis>
727’ is implied.
728  </para>
729</listitem>
730<listitem>
731  <para>
732If any unknown or illegal characters appear anywhere in the expression, the
733entire expression is invalid and is ignored.
734  </para>
735</listitem>
736</itemizedlist>
737
738<para>
739For example, if <emphasis>
740names-&gt;symbols</emphasis>
741 contained the expression "+de", it specifies that the default member of the
742"de" class of symbols should be applied to the current keyboard mapping,
743overriding any existing definitions (it could also be written "+de(default)").
744</para>
745
746
747<para>
748Here is a slightly more involved example: the expression
749"acme(ascii)+de(basic)|iso9995-3" constructs a German (de) mapping for the
750ASCII keyboard supplied by the "acme" vendor. The new definition begins with
751the symbols for the ASCII keyboard for Acme (<emphasis>
752acme(ascii)</emphasis>
753), overrides them with definitions for the basic German keyboard (<emphasis>
754de(basic)</emphasis>
755), and then applies the definitions from the default iso9995-3 keyboard
756(<emphasis>
757iso9995-3</emphasis>
758) to any undefined keys or groups of keys (part three of the iso9995 standard
759defines a common set of bindings for the secondary group, but allows national
760layouts to override those definitions where necessary).
761</para>
762
763<note><para>The interpretation of the above expression components (acme, ascii,
764de, basic, iso9995-3) is not defined by Xkb; only the operations and their
765ordering are.</para></note>
766
767<para>
768Note that the presence of a keymap <emphasis>
769names</emphasis>
770 component that does not contain ‘<emphasis>
771%</emphasis>
772’ (either explicit or implied by virtue of an expression starting with an
773operator) indicates a description that is independent of the keyboard
774description for the device specified in <emphasis>
775device_spec</emphasis>
776. The same is true of requests in which the keymap names component is empty and
777all five other names components contain expressions void of references to
778‘<emphasis>
779%</emphasis>
780’. Requests of this form allow you to deal with keyboard definitions
781independent of any actual device.
782</para>
783
784
785<para>
786The server parses all non-<emphasis>
787NULL</emphasis>
788 fields in <emphasis>
789names</emphasis>
790 and uses them to build a keyboard description. However, before parsing the
791expressions in <emphasis>
792names</emphasis>
793, the server ORs the bits in <emphasis>
794want</emphasis>
795 and <emphasis>
796need</emphasis>
797 together and examines the result in relationship to the expressions in
798<emphasis>
799names</emphasis>
800. Table 20.3 identifies the components that are required for each of the
801possible bits in <emphasis>
802want</emphasis>
803 or <emphasis>
804need</emphasis>
805. If a required component has not been specified in the <emphasis>
806names</emphasis>
807 structure (the corresponding field is <emphasis>
808NULL</emphasis>
809), the server substitutes the expression "<emphasis>
810%</emphasis>
811", resulting in the component values being taken from <emphasis>
812device_spec</emphasis>
813. In addition, if <emphasis>
814load</emphasis>
815 is <emphasis>
816True</emphasis>
817, the server modifies <emphasis>
818names</emphasis>
819 if necessary (again using a "<emphasis>
820%</emphasis>
821" entry) to ensure all of the following fields are non-<emphasis>
822NULL</emphasis>
823: <emphasis>
824types</emphasis>
825, <emphasis>
826keycodes</emphasis>
827, <emphasis>
828symbols</emphasis>
829, and <emphasis>
830compat</emphasis>
831.<emphasis>
832</emphasis>
833</para>
834
835<table frame='none'>
836<title>Want and Need Mask Bits and Required Names Components</title>
837<tgroup cols='3'>
838<colspec colsep='0'/>
839<colspec colsep='0'/>
840<colspec colsep='0'/>
841<thead>
842<row rowsep='0'>
843  <entry>want or need mask bit</entry>
844  <entry>Required names Components</entry>
845  <entry>value</entry>
846  </row>
847</thead>
848<tbody>
849  <row rowsep='0'>
850    <entry>XkbGBN_TypesMask</entry>
851    <entry>Types</entry>
852    <entry>(1L&lt;&lt;0)</entry>
853  </row>
854  <row rowsep='0'>
855    <entry>XkbGBN_CompatMapMask</entry>
856    <entry>Compat</entry>
857    <entry>(1L&lt;&lt;1)</entry>
858  </row>
859  <row rowsep='0'>
860    <entry>XkbGBN_ClientSymbolsMask</entry>
861    <entry>Types + Symbols + Keycodes</entry>
862    <entry>(1L&lt;&lt;2)</entry>
863  </row>
864  <row rowsep='0'>
865    <entry>XkbGBN_ServerSymbolsMask</entry>
866    <entry>Types + Symbols + Keycodes</entry>
867    <entry>(1L&lt;&lt;3)</entry>
868  </row>
869  <row rowsep='0'>
870    <entry>XkbGBN_SymbolsMask</entry>
871    <entry>Symbols</entry>
872    <entry>(1L&lt;&lt;1)</entry>
873  </row>
874  <row rowsep='0'>
875    <entry>XkbGBN_IndicatorMapMask</entry>
876    <entry>Compat</entry>
877    <entry>(1L&lt;&lt;4)</entry>
878  </row>
879  <row rowsep='0'>
880    <entry>XkbGBN_KeyNamesMask</entry>
881    <entry>Keycodes</entry>
882    <entry>(1L&lt;&lt;5)</entry>
883  </row>
884  <row rowsep='0'>
885    <entry>XkbGBN_GeometryMask</entry>
886    <entry>Geometry</entry>
887    <entry>(1L&lt;&lt;6)</entry>
888  </row>
889  <row rowsep='0'>
890    <entry>XkbGBN_OtherNamesMask</entry>
891    <entry>Types + Symbols + Keycodes + Compat + Geometry</entry>
892    <entry>(1L&lt;&lt;7)</entry>
893  </row>
894  <row rowsep='0'>
895    <entry>XkbGBN_AllComponentsMask</entry>
896    <entry></entry>
897    <entry>(0xff)</entry>
898  </row>
899</tbody>
900</tgroup>
901</table>
902
903<para>
904<emphasis>
905need</emphasis>
906 specifies a set of keyboard components that the server must be able to resolve
907in order for <emphasis>
908XkbGetKeyboardByName</emphasis>
909 to succeed; if any of the components specified in <emphasis>
910need</emphasis>
911 cannot be successfully resolved, <emphasis>
912XkbGetKeyboardByName</emphasis>
913 fails.
914</para>
915
916
917<para>
918<emphasis>
919want</emphasis>
920 specifies a set of keyboard components that the server should attempt to
921resolve, but that are not mandatory. If the server is unable to resolve any of
922these components, <emphasis>
923XkbGetKeyboardByName</emphasis>
924 still succeeds. Bits specified in <emphasis>
925want</emphasis>
926 that are also specified in <emphasis>
927need</emphasis>
928 have no effect in the context of <emphasis>
929want</emphasis>
930.
931</para>
932
933
934<para>
935If <emphasis>
936load</emphasis>
937 is <emphasis>
938True</emphasis>
939, the server updates its keyboard description for <emphasis>
940device_spec</emphasis>
941 to match the result of the keyboard description just built. If load is
942<emphasis>
943False</emphasis>
944, the server’s description for device <emphasis>
945device_spec</emphasis>
946 is not updated. In all cases, the parts specified by <emphasis>
947want</emphasis>
948 and <emphasis>
949need</emphasis>
950 from the just-built keyboard description are returned.
951</para>
952
953
954<para>
955The <emphasis>
956names</emphasis>
957 structure in an <emphasis>
958XkbDescRec</emphasis>
959 keyboard description record (see Chapter 18) contains one field for each of
960the five component types used to build a keyboard description. When a keyboard
961description is built from a set of database components, the corresponding
962fields in this <emphasis>
963names</emphasis>
964 structure are set to match the expressions used to build the component.
965</para>
966
967
968<para>
969The entire process of building a new keyboard description from the server
970database of components and returning all or part of it is diagrammed in Figure
97120.1:
972</para>
973
974<mediaobject>
975 <imageobject> <imagedata format="SVG" fileref="XKBlib-21.svg"/>
976 </imageobject>
977 <caption>Building a New Keyboard Description from the Server Database</caption>
978</mediaobject>
979
980<para>
981The information returned to the client in the <emphasis>
982XkbDescRec</emphasis>
983 is essentially the result of a series of calls to extract information from a
984fictitious device whose description matches the one just built. The calls
985corresponding to each of the mask bits are summarized in Table 20.4, together
986with the <emphasis>
987XkbDescRec</emphasis>
988 components that are filled in.
989</para>
990
991<table frame='none'>
992<title>XkbDescRec Components Returned for Values of Want &amp; Needs</title>
993<tgroup cols='3'>
994<colspec colsep='0'/>
995<colspec colsep='0'/>
996<colspec colsep='0'/>
997<thead>
998<row rowsep='0'>
999  <entry>Request (want+need)</entry>
1000  <entry>Fills in Xkb components</entry>
1001  <entry>Equivalent Function Call</entry>
1002  </row>
1003</thead>
1004<tbody>
1005  <row rowsep='0'>
1006    <entry>XkbGBN_TypesMask</entry>
1007    <entry>map.types</entry>
1008    <entry>XkbGetUpdatedMap(dpy, XkbTypesMask, Xkb)</entry>
1009  </row>
1010  <row rowsep='0'>
1011    <entry>XkbGBN_ServerSymbolsMask</entry>
1012    <entry>server</entry>
1013    <entry>XkbGetUpdatedMap(dpy, XkbAllClientInfoMask, Xkb)</entry>
1014  </row>
1015  <row rowsep='0'>
1016    <entry>XkbGBN_ClientSymbolsMask</entry>
1017    <entry>map, including map.types</entry>
1018    <entry>XkbGetUpdatedMap(dpy, XkbAllServerInfoMask, Xkb)</entry>
1019  </row>
1020  <row rowsep='0'>
1021    <entry>XkbGBN_IndicatorMaps</entry>
1022    <entry>indicators</entry>
1023    <entry>XkbGetIndicatorMap(dpy, XkbAllIndicators, Xkb)</entry>
1024  </row>
1025  <row rowsep='0'>
1026    <entry>XkbGBN_CompatMapMask</entry>
1027    <entry>compat</entry>
1028    <entry>XkbGetCompatMap(dpy, XkbAllCompatMask, Xkb)</entry>
1029  </row>
1030  <row rowsep='0'>
1031    <entry>XkbGBN_GeometryMask</entry>
1032    <entry>geom</entry>
1033    <entry>XkbGetGeometry(dpy, Xkb)</entry>
1034  </row>
1035  <row rowsep='0'>
1036    <entry>XkbGBN_KeyNamesMask</entry>
1037    <entry>
1038<para>names.keys</para>
1039<para>names.key_aliases</para>
1040    </entry>
1041    <entry>
1042XkbGetNames(dpy, XkbKeyNamesMask | XkbKeyAliasesMask, Xkb)
1043    </entry>
1044  </row>
1045  <row rowsep='0'>
1046    <entry>XkbGBN_OtherNamesMask</entry>
1047    <entry>
1048<para>names.keycodes</para>
1049<para>names.geometry</para>
1050<para>names.symbols</para>
1051<para>names.types</para>
1052<para>map.types[*].lvl_names[*]</para>
1053<para>names.compat</para>
1054<para>names.vmods</para>
1055<para>names.indicators</para>
1056<para>names.groups</para>
1057<para>names.radio_groups</para>
1058<para>names.phys_symbols</para>
1059    </entry>
1060    <entry>
1061<para>XkbGetNames(dpy, XkbAllNamesMask &amp;</para>
1062<para>~(XkbKeyNamesMask | XkbKeyAliasesMask),</para>
1063<para>Xkb)</para>
1064    </entry>
1065  </row>
1066</tbody>
1067</tgroup>
1068</table>
1069
1070<para>
1071There is no way to determine which components specified in <emphasis>
1072want</emphasis>
1073 (but not in <emphasis>
1074need</emphasis>
1075) were actually fetched, other than breaking the call into successive calls to
1076<emphasis>
1077XkbGetKeyboardByName</emphasis>
1078 and specifying individual components.
1079</para>
1080
1081
1082<para>
1083<emphasis>
1084XkbGetKeyboardByName</emphasis>
1085 always sets <emphasis>
1086min_key_code</emphasis>
1087 and <emphasis>
1088max_key_code</emphasis>
1089 in the returned <emphasis>
1090XkbDescRec</emphasis>
1091 structure.
1092</para>
1093
1094
1095<para>
1096<emphasis>XkbGetKeyboardByName</emphasis>
1097is synchronous; it sends the request to the server to build a new keyboard
1098description and waits for the reply. If successful, the return value is
1099non-<emphasis>NULL</emphasis>.
1100<emphasis>XkbGetKeyboardByName</emphasis>
1101generates a <emphasis>BadMatch</emphasis>
1102protocol error if errors are encountered when building the keyboard
1103description.
1104</para>
1105
1106
1107<para>
1108If you simply want to obtain information about the current keyboard device,
1109rather than generating a new keyboard description from elements in the server
1110database, use <emphasis>
1111XkbGetKeyboard</emphasis>
1112 (see section 6.2).
1113</para>
1114
1115<informaltable frame='none'>
1116<tgroup cols='1'>
1117<colspec colsep='0'/>
1118<tbody>
1119  <row rowsep='0'>
1120    <entry role='functiondecl'>
1121XkbDescPtr <emphasis>
1122XkbGetKeyboard</emphasis>
1123(<emphasis>
1124dpy</emphasis>
1125, <emphasis>
1126which</emphasis>
1127, <emphasis>
1128device_spec</emphasis>
1129)
1130    </entry>
1131  </row>
1132  <row rowsep='0'>
1133    <entry role='functionargdecl'>
1134Display *      <emphasis>
1135      dpy</emphasis>
1136;            /* connection to X server */
1137    </entry>
1138  </row>
1139  <row rowsep='0'>
1140    <entry role='functionargdecl'>
1141unsigned int<emphasis>
1142            which</emphasis>
1143;            /* mask of components of <emphasis>
1144XkbDescRec</emphasis>
1145 of interest */
1146    </entry>
1147  </row>
1148  <row rowsep='0'>
1149    <entry role='functionargdecl'>
1150unsigned int      <emphasis>
1151      device_spec</emphasis>
1152;            /* device ID */
1153    </entry>
1154</row>
1155</tbody>
1156</tgroup>
1157</informaltable>
1158
1159<para>
1160<emphasis>
1161XkbGetKeyboard</emphasis>
1162 is used to read the current description for one or more components of a
1163keyboard device. It calls <emphasis>
1164XkbGetKeyboardByName</emphasis>
1165 as follows:
1166</para>
1167
1168
1169<para>
1170<emphasis>
1171XkbGetKeyboardByName</emphasis>
1172(<emphasis>
1173dpy</emphasis>
1174, <emphasis>
1175device_spec</emphasis>
1176, <emphasis>
1177NULL</emphasis>
1178, <emphasis>
1179which</emphasis>
1180, <emphasis>
1181which</emphasis>
1182, <emphasis>
1183False</emphasis>
1184).
1185</para>
1186
1187</sect1>
1188</chapter>
1189