ch18.xml revision eb411b4b
1<chapter id='Symbolic_Names'>
2<title>Symbolic Names</title>
3
4<para>
5The core protocol does not provide any information to clients other than that
6actually used to interpret events. This makes it difficult to write an
7application that presents the keyboard to a user in an easy-to-understand way.
8Such applications have to examine the vendor string and keycodes to determine
9the type of keyboard connected to the server and then examine keysyms and
10modifier mappings to determine the effects of most modifiers (the <emphasis>
11Shift</emphasis>
12, <emphasis>
13Lock</emphasis>
14 and <emphasis>
15Control</emphasis>
16 modifiers are defined by the core protocol but no semantics are implied for
17any other modifiers).
18</para>
19
20
21<para>
22To make it easier for applications to present a keyboard to the user, Xkb
23supports symbolic names for most components of the keyboard extension. Most of
24these symbolic names are grouped into the <emphasis>
25names</emphasis>
26 component of the keyboard description.
27</para>
28
29<sect1 id='The_XkbNamesRec_Structure'>
30<title>The XkbNamesRec Structure</title>
31
32<para>
33The names component of the keyboard description is defined as follows:
34</para>
35
36<para><programlisting>
37#define      XkbKeyNameLength      4
38#define      XkbKeyNumVirtualMods  16
39#define      XkbKeyNumIndicators   32
40#define      XkbKeyNumKbdGroups    4
41#define      XkbMaxRadioGroups     32
42</programlisting></para>
43
44<para><programlisting>
45typedef struct {
46      char      name[XkbKeyNameLength];      /* symbolic key names */
47} <emphasis>XkbKeyNameRec</emphasis>,*XkbKeyNamePtr;
48</programlisting></para>
49
50<para><programlisting>
51typedef struct {
52      char      real[XkbKeyNameLength];
53                /* this key name must be in the keys array */
54      char      alias[XkbKeyNameLength];
55                /* symbolic key name as alias for the key */
56} <emphasis>XkbKeyAliasRec</emphasis>,*XkbKeyAliasPtr;
57</programlisting></para>
58
59<para><programlisting>
60typedef struct _XkbNamesRec {
61      Atom      keycodes;      /* identifies range and meaning of keycodes */
62      Atom      geometry;      /* identifies physical location, size, and shape of keys */
63      Atom      symbols;       /* identifies the symbols logically bound to the keys */
64      Atom      types;         /* identifies the set of key types */
65      Atom      compat;        /* identifies actions for keys using core protocol */
66      Atom      vmods[XkbNumVirtualMods]; /* symbolic names for virtual modifiers */
67      Atom      indicators[XkbNumIndicators];   /* symbolic names for indicators */
68      Atom      groups[XkbNumKbdGroups]; /* symbolic names for keyboard groups */
69      XkbKeyNamePtr      keys;         /* symbolic key name array */
70      XkbKeyAliasPtr     key_aliases;  /* real/alias symbolic name pairs array */
71      Atom *    radio_groups;      /* radio group name array */
72      Atom      phys_symbols;      /* identifies the symbols engraved on the keyboard */
73      unsigned char      num_keys; /* number of keys in the <emphasis> keys</emphasis> array */
74      unsigned char      num_key_aliases;  /* number of keys in the
75                                              <emphasis> key_aliases</emphasis> array */
76      unsigned short     num_rg;      /* number of radio groups */
77} <emphasis>XkbNamesRec</emphasis>,*XkbNamesPtr;      /*
78</programlisting></para>
79
80<para>
81The <emphasis>
82keycodes</emphasis>
83 name identifies the range and meaning of the keycodes returned by the keyboard
84in question. The <emphasis>
85geometry</emphasis>
86 name, on the other hand, identifies the physical location, size and shape of
87the various keys on the keyboard. As an example to distinguish between these
88two names, consider function keys on PC-compatible keyboards. Function keys are
89sometimes above the main keyboard and sometimes to the left of the main
90keyboard, but the same keycode is used for the key that is logically F1
91regardless of physical position. Thus, all PC-compatible keyboards share a
92similar keycodes name but may have different geometry names.
93</para>
94
95<note><para>The keycodes name is intended to be a very general description of
96the keycodes returned by a keyboard; a single keycodes name might cover
97keyboards with differing numbers of keys provided all keys have the same
98semantics when present. For example, 101 and 102 key PC keyboards might use the
99same name. In these cases, applications can use the keyboard <emphasis>
100geometry</emphasis>
101 name to determine which subset of the named keycodes is in use.</para></note>
102
103<para>
104The <emphasis>
105symbols</emphasis>
106 name identifies the symbols logically bound to the keys. The symbols name is a
107human or application-readable description of the intended locale or usage of
108the keyboard with these symbols. The <emphasis>
109phys_symbols</emphasis>
110 name, on the other hand, identifies the symbols actually engraved on the
111keyboard. Given this, the <emphasis>
112symbols</emphasis>
113 name and <emphasis>
114phys_symbols</emphasis>
115 names might be different. For example, the description for a keyboard that has
116English US engravings, but that is using Swiss German symbols might have a
117<emphasis>
118phys_symbols</emphasis>
119 name of "en_US" and a <emphasis>
120symbols</emphasis>
121 name of "de_CH."
122</para>
123
124
125<para>
126The <emphasis>
127types</emphasis>
128 name provides some information about the set of key types (see section 15.2)
129that can be associated with the keyboard. In addition, each key type can have a
130name, and each shift level of a type can have a name. Although these names are
131stored in the map description with each of the types, they are accessed using
132the same methods as the other symbolic names.
133</para>
134
135
136<para>
137The <emphasis>
138compat</emphasis>
139 name provides some information about the rules used to bind actions to keys
140that are changed using core protocol requests.
141</para>
142
143
144<para>
145Xkb provides symbolic names for each of the 4 keyboard groups, 16 virtual
146modifiers, 32 keyboard indicators, and 4 keyboard groups. These names are held
147in the <emphasis>
148vmods</emphasis>
149, <emphasis>
150indicators</emphasis>
151, and <emphasis>
152groups</emphasis>
153 fixed-length arrays.
154</para>
155
156
157<para>
158Each key has a four-byte symbolic name. All of the symbolic key names are held
159in the <emphasis>
160keys</emphasis>
161 array, and <emphasis>
162num_keys</emphasis>
163 reports the number of entries that are in the keys array. For each key, the
164key name links keys with similar functions or in similar positions on keyboards
165that report different keycodes. For example, the <emphasis>
166F1</emphasis>
167 key may emit keycode 23 on one keyboard and keycode 86 on another. By naming
168this key "FK01" on both keyboards, the keyboard layout designer can reuse parts
169of keyboard descriptions for different keyboards.
170</para>
171
172
173<para>
174Key aliases allow the keyboard layout designer to assign multiple key names to
175a single key. This allows the keyboard layout designer to refer to keys using
176either their position or their "function." For example, a keyboard layout
177designer may wish to refer to the left arrow key on a PC keyboard using the
178ISO9995-5 positional specification of A31 or using the functional specification
179of LEFT. The <emphasis>
180key_aliases</emphasis>
181 field holds a variable-length array of real and alias key name pairs, and the
182total number of entries in the <emphasis>
183key_aliases</emphasis>
184 array is held in <emphasis>
185num_key_aliases</emphasis>
186. For each real and alias key name pair, the <emphasis>
187real</emphasis>
188 field refers to the a name in the keys array, and the <emphasis>
189alias</emphasis>
190 field refers to the alias for that key. Using the previous example, the
191keyboard designer may use the name A31 in the keys array, but also define the
192name LEFT as an alias for A31 in the <emphasis>
193key_aliases</emphasis>
194 array.
195</para>
196
197<note><para>Key aliases defined in the geometry component of a keyboard mapping
198(see Chapter 13) override those defined in the keycodes component of the server
199database, which are stored in the <emphasis>
200XkbNamesRec</emphasis>
201 (<emphasis>
202xkb-&gt;names</emphasis>
203). Therefore, consider the key aliases defined by the geometry before
204considering key aliases supplied by the <emphasis>
205XkbNamesRec</emphasis>
206.</para></note>
207
208<para>
209A radio group is a set of keys whose behavior simulates a set of radio buttons.
210Once a key in a radio group is pressed, it stays logically depressed until
211another key in the group is pressed, at which point the previously depressed
212key is logically released. Consequently, at most one key in a radio group can
213be logically depressed at one time.
214</para>
215
216
217<para>
218Each radio group in the keyboard description can have a name. These names are
219held in the variable-length array <emphasis>
220radio_groups</emphasis>
221, and <emphasis>
222num_rg</emphasis>
223 tells how many elements are in the <emphasis>
224radio_groups</emphasis>
225 array.
226</para>
227
228
229</sect1>
230<sect1 id='Symbolic_Names_Masks'>
231<title>Symbolic Names Masks</title>
232
233<para>
234Xkb provides several functions that work with symbolic names. Each of these
235functions uses a mask to specify individual fields of the structures described
236above. These masks and their relationships to the fields in a keyboard
237description are shown in Table 18.1.
238</para>
239
240<table frame='topbot'>
241<title>Symbolic Names Masks</title>
242<?dbfo keep-together="always" ?>
243<tgroup cols='4' align='left' colsep='0' rowsep='0'>
244<colspec colname='c1' colwidth='3.0*'/>
245<colspec colname='c2' colwidth='1.0*'/>
246<colspec colname='c3' colwidth='1.5*'/>
247<colspec colname='c4' colwidth='2.0*'/>
248<thead>
249<row rowsep='1'>
250  <entry>Mask Bit</entry>
251  <entry>Value</entry>
252  <entry>Keyboard Component</entry>
253  <entry>Field</entry>
254</row>
255</thead>
256<tbody>
257<row>
258    <entry>XkbKeycodesNameMask</entry>
259    <entry>(1&lt;&lt;0)</entry>
260    <entry>Xkb-&gt;names</entry>
261    <entry>keycodes</entry>
262</row>
263<row>
264    <entry>XkbGeometryNameMask</entry>
265    <entry>(1&lt;&lt;1)</entry>
266    <entry>Xkb-&gt;names</entry>
267    <entry>geometry</entry>
268</row>
269<row>
270    <entry>XkbSymbolsNameMask</entry>
271    <entry>(1&lt;&lt;2)</entry>
272    <entry>Xkb-&gt;names</entry>
273    <entry>symbols</entry>
274</row>
275<row>
276    <entry>XkbPhysSymbolsNameMask</entry>
277    <entry>(1&lt;&lt;3)</entry>
278    <entry>Xkb-&gt;names</entry>
279    <entry>phys_symbols</entry>
280</row>
281<row>
282    <entry>XkbTypesNameMask</entry>
283    <entry>(1&lt;&lt;4)</entry>
284    <entry>Xkb-&gt;names</entry>
285    <entry>type</entry>
286</row>
287<row>
288    <entry>XkbCompatNameMask</entry>
289    <entry>(1&lt;&lt;5)</entry>
290    <entry>Xkb-&gt;names</entry>
291    <entry>compat</entry>
292</row>
293<row>
294    <entry>XkbKeyTypeNamesMask</entry>
295    <entry>(1&lt;&lt;6)</entry>
296    <entry>Xkb-&gt;map</entry>
297    <entry>type[*].name</entry>
298</row>
299<row>
300    <entry>XkbKTLevelNamesMask</entry>
301    <entry>(1&lt;&lt;7)</entry>
302    <entry>Xkb-&gt;map</entry>
303    <entry>type[*].lvl_names[*]</entry>
304</row>
305<row>
306    <entry>XkbIndicatorNamesMask</entry>
307    <entry>(1&lt;&lt;8)</entry>
308    <entry>Xkb-&gt;names</entry>
309    <entry>indicators[*]</entry>
310</row>
311<row>
312    <entry>XkbKeyNamesMask</entry>
313    <entry>(1&lt;&lt;9)</entry>
314    <entry>Xkb-&gt;names</entry>
315    <entry>keys[*], num_keys</entry>
316</row>
317<row>
318    <entry>XkbKeyAliasesMask</entry>
319    <entry>(1&lt;&lt;10)</entry>
320    <entry>Xkb-&gt;names</entry>
321    <entry>key_aliases[*], num_key_aliases</entry>
322</row>
323<row>
324    <entry>XkbVirtualModNamesMask</entry>
325    <entry>(1&lt;&lt;11)</entry>
326    <entry>Xkb-&gt;names</entry>
327    <entry>vmods[*]</entry>
328</row>
329<row>
330    <entry>XkbGroupNamesMask</entry>
331    <entry>(1&lt;&lt;12)</entry>
332    <entry>Xkb-&gt;names</entry>
333    <entry>groups[*]</entry>
334</row>
335<row>
336    <entry>XkbRGNamesMask</entry>
337    <entry>(1&lt;&lt;13)</entry>
338    <entry>Xkb-&gt;names</entry>
339    <entry>radio_groups[*], num_rg</entry>
340</row>
341<row>
342    <entry>XkbComponentNamesMask</entry>
343    <entry>(0x3f)</entry>
344    <entry>Xkb-&gt;names</entry>
345    <entry>
346<para>keycodes,</para>
347<para>geometry,</para>
348<para>symbols,</para>
349<para>physical symbols,</para>
350<para>types, and</para>
351<para>compatibility map</para>
352    </entry>
353</row>
354<row>
355    <entry>XkbAllNamesMask</entry>
356    <entry>(0x3fff)</entry>
357    <entry>Xkb-&gt;names</entry>
358    <entry>all name components</entry>
359  </row>
360</tbody>
361</tgroup>
362</table>
363
364</sect1>
365<sect1 id='Getting_Symbolic_Names_From_the_Server'>
366<title>Getting Symbolic Names From the Server</title>
367
368<para>
369To obtain symbolic names from the server, use <emphasis>
370XkbGetNames</emphasis>
371.
372</para>
373
374<informaltable frame='none'>
375<?dbfo keep-together="always" ?>
376<tgroup cols='1' align='left' colsep='0' rowsep='0'>
377<colspec colname='c1' colwidth='1.0*'/>
378<tbody>
379  <row>
380    <entry role='functiondecl'>
381Status <emphasis>
382XkbGetNames</emphasis>
383(<emphasis>
384dpy, which, Xkb</emphasis>
385)
386    </entry>
387  </row>
388  <row>
389    <entry role='functionargdecl'>
390Display *      <emphasis>
391dpy</emphasis>
392;      /* connection to the X server */
393    </entry>
394  </row>
395  <row>
396    <entry role='functionargdecl'>
397unsigned int      <emphasis>
398which</emphasis>
399;      /* mask of names or map components to be updated */
400    </entry>
401  </row>
402  <row>
403    <entry role='functionargdecl'>
404XkbDescPtr      <emphasis>
405xkb</emphasis>
406      /* keyboard description to be updated */
407    </entry>
408</row>
409</tbody>
410</tgroup>
411</informaltable>
412
413<para>
414<emphasis>
415XkbGetNames</emphasis>
416 retrieves symbolic names for the components of the keyboard extension from the
417X server. The <emphasis>
418which</emphasis>
419 parameter specifies the name components to be updated in the <emphasis>
420xkb</emphasis>
421 parameter, and is the bitwise inclusive OR of the valid names mask bits
422defined in Table 18.1.
423</para>
424
425
426<para>
427If the <emphasis>
428names</emphasis>
429 field of the keyboard description <emphasis>
430xkb</emphasis>
431 is <emphasis>
432NULL</emphasis>
433, <emphasis>
434XkbGetNames</emphasis>
435 allocates and initializes the <emphasis>
436names</emphasis>
437 component of the keyboard description before obtaining the values specified by
438<emphasis>
439which</emphasis>
440. If the <emphasis>
441names</emphasis>
442 field of <emphasis>
443xkb</emphasis>
444 is not <emphasis>
445NULL</emphasis>
446, <emphasis>
447XkbGetNames</emphasis>
448 obtains the values specified by <emphasis>
449which</emphasis>
450 and copies them into the keyboard description <emphasis>
451Xkb</emphasis>
452.
453</para>
454
455
456<para>
457If the <emphasis>
458map</emphasis>
459 component of the <emphasis>
460xkb</emphasis>
461 parameter is <emphasis>
462NULL</emphasis>
463, <emphasis>
464XkbGetNames</emphasis>
465 does not retrieve type or shift level names, even if <emphasis>
466XkbKeyTypeNamesMask</emphasis>
467 or <emphasis>
468XkbKTLevelNamesMask</emphasis>
469 are set in <emphasis>
470which</emphasis>
471.
472</para>
473
474
475<para>
476<emphasis>
477XkbGetNames</emphasis>
478 can return <emphasis>
479Success</emphasis>
480, or <emphasis>
481BadAlloc</emphasis>
482, <emphasis>
483BadLength</emphasis>
484, <emphasis>
485BadMatch</emphasis>
486, and <emphasis>
487BadImplementation</emphasis>
488 errors.
489</para>
490
491
492<para>
493To free symbolic names, use <emphasis>
494XkbFreeNames</emphasis>
495 (see section 18.6)
496</para>
497
498
499</sect1>
500<sect1 id='Changing_Symbolic_Names_on_the_Server'>
501<title>Changing Symbolic Names on the Server</title>
502
503<para>
504To change the symbolic names in the server, first modify a local copy of the
505keyboard description and then use either <emphasis>
506XkbSetNames,</emphasis>
507 or, to save network traffic, use a <emphasis>
508XkbNameChangesRec</emphasis>
509structure and call <emphasis>
510XkbChangeNames</emphasis>
511 to download the changes to the server. <emphasis>
512XkbSetNames</emphasis>
513 and <emphasis>
514XkbChangeNames</emphasis>
515 can generate <emphasis>
516BadAlloc</emphasis>
517, <emphasis>
518BadAtom</emphasis>
519, <emphasis>
520BadLength</emphasis>
521, <emphasis>
522BadMatch,</emphasis>
523 and <emphasis>
524BadImplementation</emphasis>
525 errors.
526</para>
527
528<informaltable frame='none'>
529<?dbfo keep-together="always" ?>
530<tgroup cols='1' align='left' colsep='0' rowsep='0'>
531<colspec colname='c1' colwidth='1.0*'/>
532<tbody>
533  <row>
534    <entry role='functiondecl'>
535Bool <emphasis>
536XkbSetNames</emphasis>
537(<emphasis>
538dpy, which, first_type, num_types, xkb</emphasis>
539)
540    </entry>
541  </row>
542  <row>
543    <entry role='functionargdecl'>
544Display *      <emphasis>
545dpy</emphasis>
546;            /* connection to the X server */
547    </entry>
548  </row>
549  <row>
550    <entry role='functionargdecl'>
551unsigned int      <emphasis>
552which</emphasis>
553;            /* mask of names or map components to be changed */
554    </entry>
555  </row>
556  <row>
557    <entry role='functionargdecl'>
558unsigned int      <emphasis>
559first_type</emphasis>
560      ;      /* first type whose name is to be changed */
561    </entry>
562  </row>
563  <row>
564    <entry role='functionargdecl'>
565unsigned int      <emphasis>
566num_types</emphasis>
567;            /* number of types for which names are to be changed */
568    </entry>
569  </row>
570  <row>
571    <entry role='functionargdecl'>
572XkbDescPtr      <emphasis>
573xkb</emphasis>
574;            /* keyboard description from which names are to be taken */
575    </entry>
576</row>
577</tbody>
578</tgroup>
579</informaltable>
580
581<para>
582Use<emphasis>
583 XkbSetNames</emphasis>
584 to change many names at the same time. For each bit set in <emphasis>
585which</emphasis>
586, <emphasis>
587XkbSetNames</emphasis>
588 takes the corresponding value (or values in the case of arrays) from the
589keyboard description <emphasis>
590xkb</emphasis>
591 and sends it to the server.
592</para>
593
594
595<para>
596The <emphasis>
597first_type</emphasis>
598 and <emphasis>
599num_types</emphasis>
600 arguments are used only if <emphasis>
601XkbKeyTypeNamesMask</emphasis>
602 or <emphasis>
603XkbKTLevelNamesMask</emphasis>
604 is set in <emphasis>
605which</emphasis>
606 and specify a subset of the types for which the corresponding names are to be
607changed. If either or both of these mask bits are set but the specified types
608are illegal, <emphasis>
609XkbSetNames</emphasis>
610 returns <emphasis>
611False</emphasis>
612 and does not update any of the names specified in <emphasis>
613which</emphasis>
614. The specified types are illegal if <emphasis>
615xkb</emphasis>
616 does not include a map component or if <emphasis>
617first_type</emphasis>
618 and <emphasis>
619num_types</emphasis>
620 specify types that are not defined in the keyboard description.
621</para>
622
623
624<sect2>
625<title/>
626
627<sect3 id='The_XkbNameChangesRec_Structure'>
628<title>The XkbNameChangesRec Structure</title>
629
630<para>
631The <emphasis>
632XkbNameChangesRec</emphasis>
633 allows applications to identify small modifications to the symbolic names and
634effectively reduces the amount of traffic sent to the server:
635</para>
636
637<para><programlisting>
638typedef struct _XkbNameChanges {
639      unsigned int      changed;            /* name components that have
640                                               changed */
641      unsigned char      first_type;        /* first key type with a new
642                                               name */
643      unsigned char      num_types;         /* number of types with new
644                                               names */
645      unsigned char      first_lvl;         /* first key type with new level
646                                               names */
647      unsigned char      num_lvls;          /* number of key types with new
648                                               level names */
649      unsigned char      num_aliases;       /* if key aliases changed,
650                                               total number of key aliases */
651      unsigned char      num_rg;            /* if radio groups changed, total
652                                               number of radio groups */
653      unsigned char      first_key;         /* first key with a new name */
654      unsigned char      num_keys;          /* number of keys with new names
655                                               */
656      unsigned short      changed_vmods;    /* mask of virtual
657                                               modifiers for which names have changed */
658      unsigned long      changed_indicators;  /* mask of indicators
659                                                 for which names were changed */
660      unsigned char       changed_groups;   /* mask of groups for
661                                               which names were changed */
662} <emphasis>XkbNameChangesRec</emphasis>, *XkbNameChangesPtr
663</programlisting></para>
664
665<para>
666The <emphasis>
667changed</emphasis>
668 field specifies the name components that have changed and is the bitwise
669inclusive OR of the valid names mask bits defined in Table 18.1. The rest of
670the fields in the structure specify the ranges that have changed for the
671various kinds of symbolic names, as shown in Table 18.2.
672</para>
673
674<table frame='topbot'>
675<title>XkbNameChanges Fields</title>
676<?dbfo keep-together="always" ?>
677<tgroup cols='4' align='left' colsep='0' rowsep='0'>
678<colspec colname='c1' colwidth='2.0*'/>
679<colspec colname='c2' colwidth='1.0*'/>
680<colspec colname='c3' colwidth='1.0*'/>
681<colspec colname='c4' colwidth='2.0*'/>
682<thead>
683<row rowsep='1'>
684  <entry>Mask</entry>
685  <entry>Fields</entry>
686  <entry>Component</entry>
687  <entry>Field</entry>
688</row>
689</thead>
690<tbody>
691<row>
692    <entry>XkbKeyTypeNamesMask</entry>
693    <entry>
694<para>first_type,</para>
695<para>num_types</para>
696    </entry>
697    <entry>Xkb-&gt;map</entry>
698    <entry>type[*].name</entry>
699</row>
700<row>
701    <entry>XkbKTLevelNamesMask</entry>
702    <entry>
703<para>first_lvl,</para>
704<para>num_lvls</para>
705    </entry>
706    <entry>Xkb-&gt;map</entry>
707    <entry>type[*].lvl_names[*]</entry>
708</row>
709<row>
710    <entry>XkbKeyAliasesMask</entry>
711    <entry>num_aliases</entry>
712    <entry>Xkb-&gt;names</entry>
713    <entry>key_aliases[*]</entry>
714</row>
715<row>
716    <entry>XkbRGNamesMask</entry>
717    <entry>num_rg</entry>
718    <entry>Xkb-&gt;names</entry>
719    <entry>radio_groups[*]</entry>
720</row>
721<row>
722    <entry>XkbKeyNamesMask</entry>
723    <entry>
724<para>first_key,</para>
725<para>num_keys</para>
726    </entry>
727    <entry>Xkb-&gt;names</entry>
728    <entry>keys[*]</entry>
729</row>
730<row>
731    <entry>XkbVirtualModNamesMask</entry>
732    <entry>changed_vmods</entry>
733    <entry>Xkb-&gt;names</entry>
734    <entry>vmods[*]</entry>
735</row>
736<row>
737    <entry>XkbIndicatorNamesMask</entry>
738    <entry>changed_indicators</entry>
739    <entry>Xkb-&gt;names</entry>
740    <entry>indicators[*]</entry>
741</row>
742<row>
743    <entry>XkbGroupNamesMask</entry>
744    <entry>changed_groups</entry>
745    <entry>Xkb-&gt;names</entry>
746    <entry>groups[*]</entry>
747  </row>
748</tbody>
749</tgroup>
750</table>
751
752<para>
753<emphasis>
754XkbChangeNames</emphasis>
755 provides a more flexible method for changing symbolic names than <emphasis>
756XkbSetNames</emphasis>
757 and requires the use of an <emphasis>
758XkbNameChangesRec</emphasis>
759 structure.
760</para>
761
762<informaltable frame='none'>
763<?dbfo keep-together="always" ?>
764<tgroup cols='1' align='left' colsep='0' rowsep='0'>
765<colspec colname='c1' colwidth='1.0*'/>
766<tbody>
767  <row>
768    <entry role='functiondecl'>
769Bool <emphasis>
770XkbChangeNames</emphasis>
771(<emphasis>
772dpy, xkb, changes</emphasis>
773)
774    </entry>
775  </row>
776  <row>
777    <entry role='functionargdecl'>
778Display *            <emphasis>
779dpy</emphasis>
780;            /* connection to the X server */
781    </entry>
782  </row>
783  <row>
784    <entry role='functionargdecl'>
785XkbDescPtr      <emphasis>
786      xkb</emphasis>
787;            /* keyboard description from which names are to be taken */
788    </entry>
789  </row>
790  <row>
791    <entry role='functionargdecl'>
792XkbNameChangesPtr      <emphasis>
793      changes</emphasis>
794;            /* names map components to be updated on the server */
795    </entry>
796</row>
797</tbody>
798</tgroup>
799</informaltable>
800
801<para>
802<emphasis>
803XkbChangeNames</emphasis>
804 copies any names specified by <emphasis>
805changes</emphasis>
806 from the keyboard description, <emphasis>
807xkb</emphasis>
808, to the X server specified by <emphasis>
809dpy</emphasis>
810.<emphasis>
811 XkbChangeNames</emphasis>
812 aborts and returns <emphasis>
813False</emphasis>
814 if any illegal type names or type shift level names are specified by <emphasis>
815changes</emphasis>
816.
817</para>
818
819</sect3>
820</sect2>
821</sect1>
822<sect1 id='Tracking_Name_Changes'>
823<title>Tracking Name Changes</title>
824
825<para>
826Whenever a symbolic name changes in the server’s keyboard description, the
827server sends a <emphasis>
828XkbNamesNotify</emphasis>
829 event to all interested clients. To receive name notify events, use <emphasis>
830XkbSelectEvents</emphasis>
831 (see section 4.3) with <emphasis>
832XkbNamesNotifyMask</emphasis>
833 in both the <emphasis>
834bits_to_change</emphasis>
835 and <emphasis>
836values_for_bits</emphasis>
837 parameters.
838</para>
839
840
841<para>
842To receive events for only specific names, use <emphasis>
843XkbSelectEventDetails</emphasis>
844. Set the <emphasis>
845event_type</emphasis>
846 parameter to <emphasis>
847XkbNamesNotify</emphasis>
848, and set both the <emphasis>
849bits_to_change </emphasis>
850and<emphasis>
851 values_for_bits</emphasis>
852 detail parameter to a mask composed of a bitwise OR of masks in Table 18.1.
853</para>
854
855
856<para>
857The structure for the <emphasis>
858XkbNamesNotify</emphasis>
859 event is defined as follows:
860</para>
861
862<para><programlisting>
863typedef struct {
864      int      type;                  /* Xkb extension base event code */
865      unsigned long      serial;      /* X server serial number for
866                                         event */
867      Bool      send_event;           /* <emphasis>True</emphasis>
868                                         =&gt; synthetically generated */
869      Display *      display;         /* server connection where event
870                                         generated */
871      Time      time;                 /* server time when event generated */
872      int      xkb_type;              /* <emphasis>XkbNamesNotify</emphasis> */
873      int      device;                /* Xkb device ID, will not be
874                                         <emphasis>XkbUseCoreKbd</emphasis> */
875      unsigned int      changed;      /* mask of name components
876that have changed */
877      int      first_type;            /* first key type with a new name */
878      int      num_types;             /* number of types with new names */
879      int      first_lvl;             /* first key type with new level names */
880      int      num_lvls;              /* number of key types with new level names */
881      int      num_aliases;           /* if key aliases changed, total number
882                                         of key aliases */
883      int      num_radio_groups;      /* if radio groups changed,
884                                         total number of radio groups */
885      unsigned int      changed_vmods;  /* mask of virtual modifiers for
886                                           which names have changed */
887      unsigned int      changed_groups; /* mask of groups for
888                                           which names were changed */
889      unsigned int      changed_indicators;  /* mask of indicators for which
890                                                names were changed */
891      int      first_key;             /* first key with a new name */
892      int      num_keys;              /* number of keys with new names */
893} <emphasis>XkbNamesNotifyEvent</emphasis>;
894</programlisting></para>
895
896<para>
897The <emphasis>
898changed</emphasis>
899 field specifies the name components that have changed and is the bitwise
900inclusive OR of the valid names mask bits defined in Table 18.1. The other
901fields in this event are interpreted as the like-named fields in an <emphasis>
902XkbNameChangesRec</emphasis> , as previously defined.
903</para>
904
905
906<para>
907When your application receives a X<emphasis>
908kbNamesNotify</emphasis>
909 event, you can note the changed names in a changes structure using <emphasis>
910XkbNoteNameChanges</emphasis>
911.
912</para>
913
914<informaltable frame='none'>
915<?dbfo keep-together="always" ?>
916<tgroup cols='1' align='left' colsep='0' rowsep='0'>
917<colspec colname='c1' colwidth='1.0*'/>
918<tbody>
919  <row>
920    <entry role='functiondecl'>
921void <emphasis>
922XkbNoteNameChanges</emphasis>
923(<emphasis>
924old</emphasis>
925,<emphasis>
926 new</emphasis>
927,<emphasis>
928 wanted</emphasis>
929)
930    </entry>
931  </row>
932  <row>
933    <entry role='functionargdecl'>
934XkbNameChangesPtr            <emphasis>
935old</emphasis>
936;            /* <emphasis>
937XkbNameChanges</emphasis>
938 structure to be updated */
939    </entry>
940  </row>
941  <row>
942    <entry role='functionargdecl'>
943XkbNamesNotifyEvent *            <emphasis>
944new</emphasis>
945;            /* event from which changes are to be copied */
946    </entry>
947  </row>
948  <row>
949    <entry role='functionargdecl'>
950unsigned int            <emphasis>
951wanted</emphasis>
952;            /* types of names for which changes are to be noted */
953    </entry>
954</row>
955</tbody>
956</tgroup>
957</informaltable>
958
959<para>
960The <emphasis>
961wanted</emphasis>
962 parameter is the bitwise inclusive OR of the valid names mask bits shown in
963Table 18.1. <emphasis>
964XkbNoteNameChanges</emphasis>
965 copies any changes that are reported in <emphasis>
966new</emphasis>
967 and specified in <emphasis>
968wanted</emphasis>
969 into the changes record specified by <emphasis>
970old</emphasis>
971.
972</para>
973
974
975<para>
976To update the local copy of the keyboard description with the actual values,
977pass to <emphasis>
978XkbGetNameChanges</emphasis>
979 the results of one or more calls to <emphasis>
980XkbNoteNameChanges</emphasis>
981.
982</para>
983
984
985<informaltable frame='none'>
986<?dbfo keep-together="always" ?>
987<tgroup cols='1' align='left' colsep='0' rowsep='0'>
988<colspec colname='c1' colwidth='1.0*'/>
989<tbody>
990  <row>
991    <entry role='functiondecl'>
992Status <emphasis>
993XkbGetNameChanges</emphasis>
994(<emphasis>
995dpy</emphasis>
996,<emphasis>
997 xkb</emphasis>
998,<emphasis>
999 changes</emphasis>
1000)
1001    </entry>
1002  </row>
1003  <row>
1004    <entry role='functionargdecl'>
1005Display *            <emphasis>
1006dpy</emphasis>
1007;            /* connection to the X server */
1008    </entry>
1009  </row>
1010  <row>
1011    <entry role='functionargdecl'>
1012XkbDescPtr            <emphasis>
1013xkb</emphasis>
1014;            /* keyboard description to which names are copied */
1015    </entry>
1016  </row>
1017  <row>
1018    <entry role='functionargdecl'>
1019XkbNameChangesPtr            <emphasis>
1020changes</emphasis>
1021;            /* names components to be obtained from the server */
1022    </entry>
1023</row>
1024</tbody>
1025</tgroup>
1026</informaltable>
1027
1028<para>
1029<emphasis>
1030XkbGetNameChanges</emphasis>
1031 examines the <emphasis>
1032changes</emphasis>
1033 parameter, retrieves the necessary information from the server, and places the
1034results into the <emphasis>
1035xkb</emphasis>
1036 keyboard description.
1037</para>
1038
1039
1040<para>
1041<emphasis>
1042XkbGetNamesChanges</emphasis>
1043 can generate <emphasis>
1044BadAlloc</emphasis>
1045, <emphasis>
1046BadImplementation,</emphasis>
1047 and <emphasis>
1048BadMatch</emphasis>
1049 errors.
1050</para>
1051
1052
1053</sect1>
1054<sect1 id='Allocating_and_Freeing_Symbolic_Names'>
1055<title>Allocating and Freeing Symbolic Names</title>
1056
1057<para>
1058Most applications do not need to directly allocate symbolic names structures.
1059Do not allocate a names structure directly using <emphasis>
1060malloc</emphasis>
1061 or <emphasis>
1062Xmalloc</emphasis>
1063 if your application changes the number of key aliases or radio groups or
1064constructs a symbolic names structure without loading the necessary components
1065from the X server. Instead use <emphasis>
1066XkbAllocNames</emphasis>
1067.
1068</para>
1069
1070<informaltable frame='none'>
1071<?dbfo keep-together="always" ?>
1072<tgroup cols='1' align='left' colsep='0' rowsep='0'>
1073<colspec colname='c1' colwidth='1.0*'/>
1074<tbody>
1075  <row>
1076    <entry role='functiondecl'>
1077Status <emphasis>
1078XkbAllocNames</emphasis>
1079(<emphasis>
1080xkb, which, num_rg, num_key_aliases)</emphasis>
1081    </entry>
1082  </row>
1083  <row>
1084    <entry role='functionargdecl'>
1085XkbDescPtr      <emphasis>
1086xkb;</emphasis>
1087      /* keyboard description for which names are to be allocated */
1088    </entry>
1089  </row>
1090  <row>
1091    <entry role='functionargdecl'>
1092unsigned int      <emphasis>
1093which;</emphasis>
1094      /* mask of names to be allocated */
1095    </entry>
1096  </row>
1097  <row>
1098    <entry role='functionargdecl'>
1099int      <emphasis>
1100num_rg;</emphasis>
1101      /* total number of radio group names needed */
1102    </entry>
1103  </row>
1104  <row>
1105    <entry role='functionargdecl'>
1106int      <emphasis>
1107num_key_aliases;</emphasis>
1108      /* total number of key aliases needed */
1109    </entry>
1110</row>
1111</tbody>
1112</tgroup>
1113</informaltable>
1114
1115<para>
1116<emphasis>
1117XkbAllocNames</emphasis>
1118 can return <emphasis>
1119BadAlloc</emphasis>
1120, <emphasis>
1121BadMatch,</emphasis>
1122 and <emphasis>
1123BadValue</emphasis>
1124 errors.<emphasis>
1125 </emphasis>
1126The <emphasis>
1127which</emphasis>
1128 parameter is the bitwise inclusive OR of the valid names mask bits defined in
1129Table 18.1.
1130</para>
1131
1132
1133<para>
1134Do not free symbolic names structures directly using <emphasis>
1135free</emphasis>
1136 or <emphasis>
1137XFree</emphasis>
1138. Use <emphasis>
1139XkbFreeNames</emphasis>
1140 instead.
1141</para>
1142
1143
1144<informaltable frame='none'>
1145<?dbfo keep-together="always" ?>
1146<tgroup cols='1' align='left' colsep='0' rowsep='0'>
1147<colspec colname='c1' colwidth='1.0*'/>
1148<tbody>
1149  <row>
1150    <entry role='functiondecl'>
1151void <emphasis>
1152XkbFreeNames</emphasis>
1153(<emphasis>
1154xkb, which, free_map)</emphasis>
1155    </entry>
1156  </row>
1157  <row>
1158    <entry role='functionargdecl'>
1159XkbDescPtr      <emphasis>
1160xkb</emphasis>
1161;      /* keyboard description for which names are to be freed */
1162    </entry>
1163  </row>
1164  <row>
1165    <entry role='functionargdecl'>
1166unsigned int      <emphasis>
1167which</emphasis>
1168;      /* mask of names components to be freed */
1169    </entry>
1170  </row>
1171  <row>
1172    <entry role='functionargdecl'>
1173Bool      <emphasis>
1174free_map</emphasis>
1175;      /* <emphasis>
1176True</emphasis>
1177 =&gt; XkbNamesRec structure itself should be freed */
1178    </entry>
1179</row>
1180</tbody>
1181</tgroup>
1182</informaltable>
1183
1184<para>
1185The <emphasis>
1186which</emphasis>
1187 parameter is the bitwise inclusive OR of the valid names mask bits defined in
1188Table 18.1.
1189</para>
1190</sect1>
1191</chapter>
1192