ch08.xml revision 3233502e
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3	  "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
4<chapter id='Indicators'>
5<title>Indicators</title>
6
7<indexterm significance="preferred" zone="Indicators">
8<primary>indicators</primary></indexterm>
9
10<para>
11Although the core X implementation supports up to 32 LEDs on an input device,
12it does not provide any linkage between the state of the LEDs and the logical
13state of the input device. For example, most keyboards have a
14<guilabel>CapsLock</guilabel>
15LED, but X does not provide a mechanism to make the LED automatically follow
16the logical state of the
17<keycap>CapsLock</keycap>
18key.
19</para>
20
21
22<para>
23Furthermore, the core X implementation does not provide clients with the
24ability to determine what bits in the
25<structfield>led_mask</structfield>
26field of the
27<structname>XKeyboardState</structname>
28map to the particular LEDs on the keyboard. For example, X does not provide a
29method for a client to determine what bit to set in the
30<structfield>led_mask</structfield>
31field to turn on the
32<guilabel>Scroll Lock</guilabel>
33LED or whether the keyboard even has a
34<guilabel>Scroll Lock</guilabel>
35LED.
36</para>
37
38
39<para>
40Xkb provides indicator names and programmable indicators to help solve these
41problems. Using Xkb, clients can determine the names of the various indicators,
42determine and control the way that the individual indicators should be updated
43to reflect keyboard changes, and determine which of the 32 keyboard indicators
44reported by the protocol are actually present on the keyboard. Clients may also
45request immediate notification of changes to the state of any subset of the
46keyboard indicators, which makes it straightforward to provide an on-screen
47<quote>virtual</quote> LED panel.
48This chapter describes Xkb indicators and the functions
49used for manipulating them.
50</para>
51
52<sect1 id='Indicator_Names'>
53<title>Indicator Names</title>
54
55<para>
56Xkb provides the capability of symbolically naming indicators. Xkb itself
57doesn’t use these symbolic names for anything; they are there only to help
58make the keyboard description comprehensible to humans. To set the names of
59specific indicators, use
60<function>XkbSetNames</function>
61as discussed in <xref linkend="Symbolic_Names" />. Then set the map using
62<function>XkbSetMap</function>
63(see <link linkend="Changing_Map_Components_in_the_Server">section 14.3</link>)
64or
65<function>XkbSetNamedDeviceIndicator</function>
66(below). To retrieve indicator names, use
67<function>XkbGetNames</function>
68(<xref linkend="Symbolic_Names" />).
69</para>
70
71
72</sect1>
73<sect1 id='Indicator_Data_Structures'>
74<title>Indicator Data Structures</title>
75
76<para>
77Use the indicator description record,
78<structname>XkbIndicatorRec</structname>,
79and its indicator map,
80<structname>XkbIndicatorMapRec</structname>,
81to inquire about and control most indicator properties and behaviors.
82</para>
83
84
85<sect2 id='XkbIndicatorRec'>
86<title>XkbIndicatorRec</title>
87
88<indexterm significance="preferred" zone="XkbIndicatorRec">
89<primary><structname>XkbIndicatorRec</structname></primary></indexterm>
90
91<para>
92The description for all the Xkb indicators is held in the
93<structfield>indicators</structfield>
94field of the complete keyboard description (see <xref linkend="Complete_Keyboard_Description" />), which is defined
95as follows:
96
97<programlisting>
98#define      XkbNumIndicators      32
99
100typedef struct {
101    unsigned long           phys_indicators;            /* LEDs existence */
102    XkbIndicatorMapRec      maps[XkbNumIndicators];     /* indicator maps */
103} <structname>XkbIndicatorRec</structname>, *XkbIndicatorPtr;
104</programlisting></para>
105
106<para>
107This structure contains the
108<structfield>phys_indicators</structfield>
109field, which relates some information about the correspondence between
110indicators and physical LEDs on the keyboard, and an array of indicator
111<structfield>maps</structfield>,
112one map per indicator.
113</para>
114
115<para>
116The
117<structfield>phys_indicators</structfield>
118field indicates which indicators are bound to physical LEDs on the keyboard;
119if a bit is set in
120<structfield>phys_indicators</structfield>,
121then the associated indicator has a physical LED associated with it. This
122field is necessary because some indicators may not have corresponding physical
123LEDs on the keyboard. For example, most keyboards have an LED for indicating
124the state of
125<keycap>CapsLock</keycap>,
126but most keyboards do not have an LED that indicates the current group.
127Because
128<structfield>phys_indicators</structfield>
129describes a physical characteristic of the keyboard, you cannot directly
130change it under program control. However, if a client program loads a
131completely new keyboard description via
132<function>XkbGetKeyboardByName</function>,
133or if a new keyboard is attached and the X implementation notices,
134<structfield>phys_indicators</structfield>
135changes if the indicators for the new keyboard are different.
136</para>
137
138
139</sect2>
140<sect2 id='XkbIndicatorMapRec'>
141<title>XkbIndicatorMapRec</title>
142
143<indexterm significance="preferred" zone="XkbIndicatorMapRec">
144<primary><structname>XkbIndicatorMapRec</structname></primary></indexterm>
145
146<para>
147Each indicator has its own set of attributes that specify whether clients can
148explicitly set its state and whether it tracks the keyboard state. The
149attributes of each indicator are held in the
150<structfield>maps</structfield>
151array, which is an array of
152<structname>XkbIndicatorRec</structname>
153structures:
154
155<programlisting>
156typedef struct {
157    unsigned char  flags;         /* how the indicator can be changed */
158    unsigned char  which_groups;  /* match criteria for groups */
159    unsigned char  groups;        /* which keyboard groups the indicator watches */
160    unsigned char  which_mods;    /* match criteria for modifiers */
161    XkbModsRec     mods;          /* which modifiers the indicator watches */
162    unsigned int   ctrls;         /* which controls the indicator watches */
163} <structname>XkbIndicatorMapRec</structname>, *XkbIndicatorMapPtr;
164</programlisting></para>
165
166<para>
167This indicator map specifies for each indicator:
168</para>
169
170<itemizedlist>
171<listitem>
172  <para>
173The conditions under which the keyboard modifier state affects the indicator
174  </para>
175</listitem>
176<listitem>
177  <para>
178The conditions under which the keyboard group state affects the indicator
179  </para>
180</listitem>
181<listitem>
182  <para>
183The conditions under which the state of the boolean controls affects the
184indicator
185  </para>
186</listitem>
187<listitem>
188  <para>
189The effect (if any) of attempts to explicitly change the state of the indicator
190using the functions
191<function>XkbSetControls</function>
192or
193<function>XChangeKeyboardControl</function>
194
195  </para>
196</listitem>
197</itemizedlist>
198
199<para>
200For more information on the effects of explicit changes to indicators and the
201relationship to the indicator map, see <link linkend="Effects_of_Explicit_Changes_on_Indicators">section 8.4.1</link>.
202</para>
203
204<sect3 id='XkbIndicatorMapRec_flags_field'>
205<title>XkbIndicatorMapRec flags field</title>
206
207<para>
208The
209<structfield>flags</structfield>
210field specifies the conditions under which the indicator can be changed and
211the effects of changing the indicator. The valid values for
212<structfield>flags</structfield>
213and their effects are shown in <link linkend="table8.1">Table 8.1</link>.
214</para>
215
216<table id='table8.1' frame='topbot'>
217<title>XkbIndicatorMapRec flags Field</title>
218<?dbfo keep-together="always" ?>
219<tgroup cols='3' align='left' colsep='0' rowsep='0'>
220<colspec colname='c1' colwidth='2.0*'/>
221<colspec colname='c2' colwidth='1.0*'/>
222<colspec colname='c3' colwidth='3.0*'/>
223<thead>
224<row rowsep='1'>
225  <entry>Value</entry>
226  <entry></entry>
227  <entry>Effect</entry>
228  </row>
229</thead>
230<tbody>
231  <row>
232    <entry><symbol>XkbIM_NoExplicit</symbol></entry>
233    <entry>(1L&lt;&lt;7)</entry>
234    <entry>Client applications cannot change the state of the indicator.</entry>
235  </row>
236  <row>
237    <entry><symbol>XkbIM_NoAutomatic</symbol></entry>
238    <entry>(1L&lt;&lt;6)</entry>
239    <entry>Xkb does not automatically change the value of the indicator based
240upon a change in the keyboard state, regardless of the values for the other
241fields of the indicator map.</entry>
242  </row>
243  <row>
244    <entry><symbol>XkbIM_LEDDrivesKB</symbol></entry>
245    <entry>(1L&lt;&lt;5)</entry>
246    <entry>A client application changing the state of the indicator causes the
247state of the keyboard to change.</entry>
248  </row>
249</tbody>
250</tgroup>
251</table>
252
253<para>
254Note that if
255<symbol>XkbIM_NoAutomatic</symbol>
256is not set, by default the indicator follows the keyboard state.
257</para>
258
259
260<para>
261If
262<symbol>XkbIM_LEDDrivesKB</symbol>
263is set and
264<symbol>XkbIM_NoExplicit</symbol>
265is not, and if you call a function which updates the server’s image of the
266indicator map (such as
267<function>XkbSetIndicatorMap</function>
268or
269<function>XkbSetNamedDeviceIndicator</function>),
270Xkb changes the keyboard state and controls to reflect the other fields of
271the indicator map, as described in the remainder of this section. If you
272attempt to explicitly change the value of an indicator for which
273<symbol>XkbIM_LEDDrivesKB</symbol>
274is absent or for which
275<symbol>XkbIM_NoExplicit</symbol>
276is present, keyboard state or controls are unaffected.
277</para>
278
279
280<para>
281For example, a keyboard designer may want to make the
282<guilabel>CapsLock</guilabel>
283LED controllable only by the server, but allow the
284<guilabel>Scroll Lock</guilabel>
285LED to be controlled by client applications. To do so, the keyboard designer
286could set the
287<symbol>XkbIM_NoExplicit</symbol>
288flag for the
289<guilabel>CapsLock</guilabel>
290LED, but not set it for the
291<guilabel>Scroll Lock</guilabel>
292LED. Or the keyboard designer may wish to allow the
293<guilabel>CapsLock</guilabel>
294LED to be controlled by both the server and client applications and also have
295the server to automatically change the
296<emphasis>CapsLock</emphasis>
297
298modifier state whenever a client application changes the
299<guilabel>CapsLock</guilabel>
300LED. To do so, the keyboard designer would not set the
301<symbol>XkbIM_NoExplicit</symbol>
302flag, but would instead set the
303<symbol>XkbIM_LEDDrivesKB</symbol>
304flag.
305</para>
306
307<para>
308The remaining fields in the indicator map specify the conditions under which
309Xkb automatically turns an indicator on or off (only if
310<symbol>XkbIM_NoAutomatic</symbol>
311is not set). If these conditions match the keyboard state, Xkb turns the
312indicator on. If the conditions do not match, Xkb turns the indicator off.
313</para>
314
315</sect3>
316
317<sect3 id='XkbIndicatorMapRec_which_groups_and_groups_fields'>
318<title>XkbIndicatorMapRec which_groups and groups fields</title>
319
320<para>
321The
322<structfield>which_groups</structfield>
323and the
324<structfield>groups</structfield>
325fields of an indicator map determine how the keyboard group state affects the
326corresponding indicator. The
327<structfield>which_groups</structfield>
328field controls the interpretation of
329<structfield>groups</structfield>
330and may contain any one of the following values:
331
332<programlisting>
333#define XkbIM_UseNone             0
334#define XkbIM_UseBase             (1L &lt;&lt; 0)
335#define XkbIM_UseLatched          (1L &lt;&lt; 1)
336#define XkbIM_UseLocked           (1L &lt;&lt; 2)
337#define XkbIM_UseEffective        (1L &lt;&lt; 3)
338#define XkbIM_UseAnyGroup         XkbIM_UseLatched | XkbIM_UseLocked |
339                                  XkbIM_UseEffective
340</programlisting></para>
341
342<para>
343The
344<structfield>groups</structfield>
345field specifies what keyboard groups an indicator watches and is the bitwise
346inclusive OR of the following valid values:
347
348<programlisting>
349#define XkbGroup1Mask            (1&lt;&lt;0)
350#define XkbGroup2Mask            (1&lt;&lt;1)
351#define XkbGroup3Mask            (1&lt;&lt;2)
352#define XkbGroup4Mask            (1&lt;&lt;3)
353#define XkbAnyGroupMask          (1&lt;&lt;7)
354#define XkbAllGroupsMask         (0xf)
355</programlisting></para>
356
357<para>
358If
359<symbol>XkbIM_NoAutomatic</symbol>
360is not set (the keyboard drives the indicator), the effect of
361<structfield>which_groups</structfield>
362and
363<structfield>groups</structfield>
364is shown in <link linkend="table8.2">Table 8.2</link>.
365</para>
366
367<table id='table8.2' frame='topbot'>
368<title>XkbIndicatorMapRec which_groups and groups, Keyboard Drives
369Indicator</title>
370<?dbfo keep-together="always" ?>
371<tgroup cols='2' align='left' colsep='0' rowsep='0'>
372<colspec colname='c1' colwidth='1.0*'/>
373<colspec colname='c2' colwidth='2.0*'/>
374<thead>
375<row rowsep='1'>
376  <entry>which_groups</entry>
377  <entry>Effect</entry>
378  </row>
379</thead>
380<tbody>
381  <row>
382    <entry><symbol>XkbIM_UseNone</symbol></entry>
383    <entry>
384The
385<structfield>groups</structfield>
386field and the current keyboard group state are ignored.
387    </entry>
388  </row>
389  <row>
390    <entry><symbol>XkbIM_UseBase</symbol></entry>
391    <entry>
392If
393<structfield>groups</structfield>
394is nonzero, the indicator is lit whenever the base keyboard group is nonzero.
395If
396<structfield>groups</structfield>
397is zero, the indicator is lit whenever the base keyboard group is zero.
398    </entry>
399  </row>
400  <row>
401    <entry><symbol>XkbIM_UseLatched</symbol></entry>
402    <entry>
403If
404<structfield>groups</structfield>
405is nonzero, the indicator is lit whenever the latched keyboard group is
406nonzero. If
407<structfield>groups</structfield>
408is zero, the indicator is lit whenever the latched keyboard group is zero.
409    </entry>
410  </row>
411  <row>
412    <entry><symbol>XkbIM_UseLocked</symbol></entry>
413    <entry>
414The
415<structfield>groups</structfield>
416field is interpreted as a mask. The indicator is lit when the current locked
417keyboard group matches one of the bits that are set in
418<structfield>groups</structfield>.
419    </entry>
420  </row>
421  <row>
422    <entry><symbol>XkbIM_UseEffective</symbol></entry>
423    <entry>
424The
425<structfield>groups</structfield>
426field is interpreted as a mask. The indicator is lit when the current
427effective keyboard group matches one of the bits that are set in
428<structfield>groups</structfield>.
429</entry>
430  </row>
431</tbody>
432</tgroup>
433</table>
434
435<para>
436The effect of
437<structfield>which_groups</structfield>
438and
439<structfield>groups</structfield>
440when you change an indicator for which
441<symbol>XkbIM_LEDDrivesKB</symbol>
442is set (the indicator drives the keyboard) is shown in
443<link linkend="table8.3">Table 8.3</link>. The <quote>New State</quote>
444column refers to the new state to which you set the indicator.
445</para>
446
447<table id='table8.3' frame='topbot'>
448<title>XkbIndicatorMapRec which_groups and groups, Indicator Drives
449Keyboard</title>
450<?dbfo keep-together="always" ?>
451<tgroup cols='3' align='left' colsep='0' rowsep='0'>
452<colspec colname='c1' colwidth='2.0*'/>
453<colspec colname='c2' colwidth='1.0*'/>
454<colspec colname='c3' colwidth='3.0*'/>
455<thead>
456<row rowsep='1'>
457  <entry>which_groups</entry>
458  <entry>New State</entry>
459  <entry>Effect on Keyboard Group State</entry>
460  </row>
461</thead>
462<tbody>
463  <row>
464    <entry><symbol>XkbIM_UseNone</symbol></entry>
465    <entry>On or Off</entry>
466    <entry>No effect</entry>
467  </row>
468  <row>
469    <entry><symbol>XkbIM_UseBase</symbol></entry>
470    <entry>On or Off</entry>
471    <entry>No effect</entry>
472  </row>
473  <row>
474    <entry><symbol>XkbIM_UseLatched</symbol></entry>
475    <entry>On</entry>
476    <entry>
477The
478<structfield>groups</structfield>
479field is treated as a group mask. The keyboard group latch is changed to the
480lowest numbered group specified in
481<structfield>groups</structfield>;
482if
483<structfield>groups</structfield>
484is empty, the keyboard group latch is changed to zero.
485    </entry>
486  </row>
487  <row>
488    <entry><symbol>XkbIM_UseLatched</symbol></entry>
489    <entry>Off</entry>
490    <entry>
491The
492<structfield>groups</structfield>
493field is treated as a group mask. If the indicator is explicitly extinguished,
494keyboard group latch is changed to the lowest numbered group not specified in
495<structfield>groups</structfield>;
496if
497<structfield>groups</structfield>
498is zero, the keyboard group latch is set to the index of the highest legal
499keyboard group.
500    </entry>
501  </row>
502  <row>
503    <entry>XkbIM_UseLocked or XkbIM_UseEffective</entry>
504    <entry>On</entry>
505    <entry>
506If the
507<structfield>groups</structfield>
508mask is empty, group is not changed; otherwise, the locked keyboard group is
509changed to the lowest numbered group specified in
510<structfield>groups</structfield>.
511    </entry>
512  </row>
513  <row>
514    <entry>XkbIM_UseLocked or XkbIM_UseEffective</entry>
515    <entry>Off</entry>
516    <entry>
517Locked keyboard group is changed to the lowest numbered group that is not
518specified in the
519<structfield>groups</structfield>
520mask, or to
521<emphasis>Group1</emphasis>
522if the
523<structfield>groups</structfield>
524mask contains all keyboard groups.
525    </entry>
526  </row>
527</tbody>
528</tgroup>
529</table>
530
531</sect3>
532<sect3 id='XkbIndicatorMapRec_which_mods_and_mods_fields'>
533<title>XkbIndicatorMapRec which_mods and mods fields</title>
534
535<para>
536The
537<structfield>mods</structfield>
538field specifies what modifiers an indicator watches. The
539<structfield>mods</structfield>
540field is an Xkb modifier definition,
541<structname>XkbModsRec</structname>,
542as described in <link linkend="Modifier_Definitions">section 7.2</link>, which can specify both real and virtual
543modifiers. The
544<structfield>mods</structfield>
545field takes effect even if some or all of the virtual indicators specified in
546<structfield>mods</structfield>
547are unbound. To specify the mods field, in general, assign the modifiers of
548interest to
549<structfield>mods.real_mods</structfield>
550and the virtual modifiers of interest to
551<structfield>mods.vmods</structfield>.
552You can disregard the
553<structfield>mods.mask</structfield>
554field unless your application needs to interpret the indicator map directly
555(that is, to simulate automatic indicator behavior on its own). Relatively few
556applications need to do so, but if you find it necessary, you can either read
557the indicator map back from the server after you update it (the server
558automatically updates the mask field whenever any of the real or virtual
559modifiers are changed in the modifier definition) or you can use
560<function>XkbVirtualModsToReal</function>
561to determine the proper contents for the mask field, assuming that the
562<structname>XkbDescRec</structname>
563contains the virtual modifier definitions.
564</para>
565
566<para>
567<structfield>which_mods</structfield>
568specifies what criteria Xkb uses to determine a match with the corresponding
569<structfield>mods</structfield>
570field by specifying one or more components of the Xkb keyboard state. If
571<symbol>XkbIM_NoAutomatic</symbol>
572is not set (the keyboard drives the indicator), the indicator is lit whenever
573any of the modifiers specified in the
574<structfield>mask</structfield>
575field of the
576<structfield>mods</structfield>
577modifier definition are also set in any of the current keyboard state
578components specified by
579<structfield>which_mods</structfield>.
580Remember that the
581<structfield>mask</structfield>
582field is comprised of all of the real modifiers specified in the definition
583plus any real modifiers that are bound to the virtual modifiers specified in
584the definition. (See <xref linkend="Keyboard_State" /> for more information on the keyboard state and
585<xref linkend="Virtual_Modifiers" /> for more information on virtual modifiers.) Use a bitwise inclusive
586OR of the following values to compose a value for
587<structfield>which_mods</structfield>:
588
589<programlisting>
590#define XkbIM_UseNone             0
591#define XkbIM_UseBase             (1L &lt;&lt; 0)
592#define XkbIM_UseLatched          (1L &lt;&lt; 1)
593#define XkbIM_UseLocked           (1L &lt;&lt; 2)
594#define XkbIM_UseEffective        (1L &lt;&lt; 3)
595#define XkbIM_UseCompat           (1L &lt;&lt; 4)
596#define XkbIM_UseAnyMods          XkbIM_UseBase | XkbIM_UseLatched |
597                                  XkbIM_UseLocked | XkbIM_UseEffective |
598                                  XkbIM_UseCompat
599</programlisting></para>
600
601<para>
602If
603<symbol>XkbIM_NoAutomatic</symbol>
604is not set (the keyboard drives the indicator), the effect of
605<structfield>which_mods</structfield>
606and
607<structfield>mods</structfield>
608is shown in <link linkend="table8.4">Table 8.4</link>
609</para>
610
611<table id='table8.4' frame='topbot'>
612<title>XkbIndicatorMapRec which_mods and mods, Keyboard Drives Indicator</title>
613<?dbfo keep-together="always" ?>
614<tgroup cols='2' align='left' colsep='0' rowsep='0'>
615<colspec colname='c1' colwidth='1.0*'/>
616<colspec colname='c2' colwidth='2.0*'/>
617<thead>
618<row rowsep='1'>
619  <entry>which_mods</entry>
620  <entry>Effect on Keyboard Modifiers</entry>
621  </row>
622</thead>
623<tbody>
624  <row>
625    <entry><symbol>XkbIM_UseNone</symbol></entry>
626    <entry>The mods field and the current keyboard modifier state are
627ignored.</entry>
628  </row>
629  <row>
630    <entry><symbol>XkbIM_UseBase</symbol></entry>
631    <entry>
632The indicator is lit when any of the modifiers specified in the
633<structfield>mask</structfield>
634field of
635<structfield>mods</structfield>
636are on in the keyboard base state. If both
637<structfield>mods.real_mods</structfield>
638and
639<structfield>mods.vmods</structfield>
640are zero, the indicator is lit when the base keyboard state contains no
641modifiers.
642    </entry>
643  </row>
644  <row>
645    <entry><symbol>XkbIM_UseLatched</symbol></entry>
646    <entry>
647The indicator is lit when any of the modifiers specified in the
648<structfield>mask</structfield>
649field of
650<structfield>mods</structfield>
651are latched. If both
652<structfield>mods.real_mods</structfield>
653and
654<structfield>mods.vmods</structfield>
655are zero, the indicator is lit when none of the modifier keys are latched.
656    </entry>
657  </row>
658  <row>
659    <entry><symbol>XkbIM_UseLocked</symbol></entry>
660    <entry>
661The indicator is lit when any of the modifiers specified in the
662<structfield>mask</structfield>
663field of
664<structfield>mods</structfield>
665are locked. If both
666<structfield>mods.real_mods</structfield>
667and
668<structfield>mods.vmods</structfield>
669are zero, the indicator is lit when none of the modifier keys are locked.
670    </entry>
671  </row>
672  <row>
673    <entry><symbol>XkbIM_UseEffective</symbol></entry>
674    <entry>
675The indicator is lit when any of the modifiers specified in the
676<structfield>mask</structfield>
677field of
678<structfield>mods</structfield>
679are in the effective keyboard state. If both
680<structfield>mods.real_mods</structfield>
681and
682<structfield>mods.vmods</structfield>
683are zero, the indicator is lit when the effective keyboard state contains no
684modifiers.
685    </entry>
686  </row>
687  <row>
688    <entry><symbol>XkbIM_UseCompat</symbol></entry>
689    <entry>
690The indicator is lit when any of the modifiers specified in the
691<structfield>mask</structfield>
692field of
693<structfield>mods</structfield>
694are in the keyboard compatibility state. If both
695<structfield>mods.real_mods</structfield>
696and
697<structfield>mods.vmods</structfield>
698are zero, the indicator is lit when the keyboard compatibility state contains
699no modifiers.
700    </entry>
701  </row>
702</tbody>
703</tgroup>
704</table>
705
706<para>
707The effect on the keyboard modifiers of
708<structfield>which_mods</structfield>
709and
710<structfield>mods</structfield>
711when you change an indicator for which
712<symbol>XkbIM_LEDDrivesKB</symbol>
713is set (the indicator drives the keyboard) is shown in
714<link linkend="table8.5">Table 8.5</link>. The <quote>New State</quote>
715column refers to the new state to which you set the indicator.
716</para>
717
718<table id='table8.5' frame='topbot'>
719<title>XkbIndicatorMapRec which_mods and mods, Indicator Drives Keyboard</title>
720<?dbfo keep-together="always" ?>
721<tgroup cols='3' align='left' colsep='0' rowsep='0'>
722<colspec colname='c1' colwidth='2.0*'/>
723<colspec colname='c2' colwidth='1.0*'/>
724<colspec colname='c3' colwidth='3.0*'/>
725<thead>
726<row rowsep='1'>
727  <entry>which_mods</entry>
728  <entry>New State</entry>
729  <entry>Effect on Keyboard Modifiers</entry>
730  </row>
731</thead>
732<tbody>
733  <row>
734    <entry>XkbIM_UseNone or XkbIM_UseBase</entry>
735    <entry>On or Off</entry>
736    <entry>No Effect</entry>
737  </row>
738  <row>
739    <entry><symbol>XkbIM_UseLatched</symbol></entry>
740    <entry>On</entry>
741    <entry>
742Any modifiers specified in the
743<structfield>mask</structfield>
744field of
745<structfield>mods</structfield>
746are added to the latched modifiers.
747    </entry>
748  </row>
749  <row>
750    <entry><symbol>XkbIM_UseLatched</symbol></entry>
751    <entry>Off</entry>
752    <entry>
753Any modifiers specified in the
754<structfield>mask</structfield>
755field of
756<structfield>mods</structfield>
757are removed from the latched modifiers.
758    </entry>
759  </row>
760  <row>
761    <entry>XkbIM_UseLocked, XkbIM_UseCompat, or XkbIM_UseEffective</entry>
762    <entry>On</entry>
763    <entry>
764Any modifiers specified in the
765<structfield>mask</structfield>
766field of
767<structfield>mods</structfield>
768are added to the locked modifiers.
769    </entry>
770  </row>
771  <row>
772    <entry><symbol>XkbIM_UseLocked</symbol></entry>
773    <entry>Off</entry>
774    <entry>
775Any modifiers specified in the
776<structfield>mask</structfield>
777field of
778<structfield>mods</structfield>
779are removed from the locked modifiers.
780    </entry>
781  </row>
782  <row>
783    <entry>XkbIM_UseCompat or XkbIM_UseEffective</entry>
784    <entry>Off</entry>
785    <entry>
786Any modifiers specified in the
787<structfield>mask</structfield>
788field of
789<structfield>mods</structfield>
790are removed from both the locked and latched modifiers.
791    </entry>
792  </row>
793</tbody>
794</tgroup>
795</table>
796
797</sect3>
798<sect3 id='XkbIndicatorMapRec_ctrls_field'>
799<title>XkbIndicatorMapRec ctrls field</title>
800
801<para>
802The
803<structfield>ctrls</structfield>
804field specifies what controls (see <xref linkend="Keyboard_Controls" />) the indicator watches and is
805composed using the bitwise inclusive OR of the following values:
806
807<programlisting>
808#define XkbRepeatKeysMask           (1L &lt;&lt; 0)
809#define XkbSlowKeysMask             (1L &lt;&lt; 1)
810#define XkbBounceKeysMask           (1L &lt;&lt; 2)
811#define XkbStickyKeysMask           (1L &lt;&lt; 3)
812#define XkbMouseKeysMask            (1L &lt;&lt; 4)
813#define XkbMouseKeysAccelMask       (1L &lt;&lt; 5)
814#define XkbAccessXKeysMask          (1L &lt;&lt; 6)
815#define XkbAccessXTimeoutMask       (1L &lt;&lt; 7)
816#define XkbAccessXFeedbackMask      (1L &lt;&lt; 8)
817#define XkbAudibleBellMask          (1L &lt;&lt; 9)
818#define XkbOverlay1Mask             (1L &lt;&lt; 10)
819#define XkbOverlay2Mask             (1L &lt;&lt; 11)
820#define XkbAllBooleanCtrlsMask      (0x00001FFF)
821</programlisting></para>
822
823<para>
824Xkb lights the indicator whenever any of the boolean controls specified in
825<structfield>ctrls</structfield>
826is enabled.
827</para>
828
829
830</sect3>
831</sect2>
832</sect1>
833<sect1 id='Getting_Information_About_Indicators'>
834<title>Getting Information About Indicators</title>
835
836<para>
837Xkb allows applications to obtain information about indicators using two
838different methods. The first method, which is similar to the core X
839implementation, uses a mask to specify the indicators. The second method, which
840is more suitable for applications concerned with interoperability, uses
841indicator names. The correspondence between the indicator name and the bit
842position in masks is as follows: one of the parameters returned from
843<function>XkbGetNamedDeviceIndicator</function>
844is an index that is the bit position to use in any function call that requires
845a mask of indicator bits, as well as the indicator’s index into the
846<structname>XkbIndicatorRec</structname>
847array of indicator maps.
848</para>
849
850
851<sect2 id='Getting_Indicator_State'>
852<title>Getting Indicator State</title>
853
854<para>
855Because the state of the indicators is relatively volatile, the keyboard
856description does not hold the current state of the indicators. To obtain the
857current state of the keyboard indicators, use
858<function>XkbGetIndicatorState</function>.
859</para>
860
861<indexterm significance="preferred" zone="XkbGetIndicatorState"><primary><function>XkbGetIndicatorState</function></primary></indexterm>
862<funcsynopsis id="XkbGetIndicatorState">
863  <funcprototype>
864    <funcdef>Status <function>XkbGetIndicatorState</function></funcdef>
865<!-- (
866<parameter>display</parameter>,
867<parameter>device_spec</parameter>,
868<parameter>state_return</parameter>
869) -->
870
871    <paramdef>Display *<parameter>display</parameter></paramdef>
872    <paramdef>unsigned int <parameter>device_spec</parameter></paramdef>
873    <paramdef>unsigned int *<parameter>state_return</parameter></paramdef>
874  </funcprototype>
875</funcsynopsis>
876<variablelist>
877  <varlistentry>
878    <term>
879      <parameter>display</parameter>
880    </term>
881    <listitem>
882      <para>
883        connection to the X server
884      </para>
885    </listitem>
886  </varlistentry>
887  <varlistentry>
888    <term>
889      <parameter>device_spec</parameter>
890    </term>
891    <listitem>
892      <para>
893        device ID, or <symbol>XkbUseCoreKbd</symbol>
894      </para>
895    </listitem>
896  </varlistentry>
897  <varlistentry>
898    <term>
899      <parameter>state_return</parameter>
900    </term>
901    <listitem>
902      <para>
903        backfilled with a mask of the indicator state
904      </para>
905    </listitem>
906  </varlistentry>
907</variablelist>
908
909<para>
910<function>XkbGetIndicatorState</function>
911queries the
912<parameter>display</parameter>
913for the state of the indicators on the device specified by the
914<parameter>device_spec</parameter>.
915For each indicator that is <quote>turned on</quote> on the device,
916the associated bit is set in
917<parameter>state_return</parameter>.
918If a compatible version of the Xkb extension is not available in the server,
919<function>XkbGetIndicatorState</function>
920returns a
921<errorname>BadMatch</errorname>
922error. Otherwise, it sends the request to the X server, places the state of
923the indicators into
924<parameter>state_return</parameter>,
925and returns
926<symbol>Success</symbol>.
927Thus the value reported by
928<function>XkbGetIndicatorState</function>
929is identical to the value reported by the core protocol.
930</para>
931
932
933</sect2>
934<sect2 id='Getting_Indicator_Information_by_Index'>
935<title>Getting Indicator Information by Index</title>
936
937<para>
938To get the map for one or more indicators, using a mask to specify the
939indicators, use
940<function>XkbGetIndicatorMap</function>.
941</para>
942
943<indexterm significance="preferred" zone="XkbGetIndicatorMap"><primary><function>XkbGetIndicatorMap</function></primary></indexterm>
944<funcsynopsis id="XkbGetIndicatorMap">
945  <funcprototype>
946    <funcdef>Status <function>XkbGetIndicatorMap</function></funcdef>
947<!-- (
948<parameter>dpy</parameter>,
949<parameter>which</parameter>,
950<parameter>desc</parameter>
951) -->
952
953    <paramdef>Display *<parameter>dpy</parameter></paramdef>
954    <paramdef>unsigned int <parameter>which</parameter></paramdef>
955    <paramdef>XkbDescPtr <parameter>desc</parameter></paramdef>
956  </funcprototype>
957</funcsynopsis>
958<variablelist>
959  <varlistentry>
960    <term>
961      <parameter>dpy</parameter>
962    </term>
963    <listitem>
964      <para>
965        connection to the X server
966      </para>
967    </listitem>
968  </varlistentry>
969  <varlistentry>
970    <term>
971      <parameter>which</parameter>
972    </term>
973    <listitem>
974      <para>
975        mask of indicators for which maps should be returned
976      </para>
977    </listitem>
978  </varlistentry>
979  <varlistentry>
980    <term>
981      <parameter>desc</parameter>
982    </term>
983    <listitem>
984      <para>
985        keyboard description to be updated
986      </para>
987    </listitem>
988  </varlistentry>
989</variablelist>
990
991<para>
992<function>XkbGetIndicatorMap</function>
993obtains the maps from the server for only those indicators specified by the
994<parameter>which</parameter>
995mask and copies the values into the keyboard description specified by
996<parameter>desc</parameter>.
997If the
998<structfield>indicators</structfield>
999field of the
1000<parameter>desc</parameter>
1001parameter is
1002<symbol>NULL</symbol>,
1003<function>XkbGetIndicatorMap</function>
1004allocates and initializes it.
1005</para>
1006
1007
1008<para>
1009<function>XkbGetIndicatorMap</function>
1010can generate
1011<errorname>BadAlloc</errorname>,
1012<errorname>BadLength</errorname>,
1013<errorname>BadMatch</errorname>,
1014and
1015<errorname>BadImplementation</errorname>
1016errors.
1017</para>
1018
1019
1020<para>
1021To free the indicator maps, use
1022<function>XkbFreeIndicatorMaps</function>
1023(see <link linkend="Allocating_and_Freeing_Indicator_Maps">section 8.6</link>).
1024</para>
1025
1026
1027</sect2>
1028<sect2 id='Getting_Indicator_Information_by_Name'>
1029<title>Getting Indicator Information by Name</title>
1030
1031<para>
1032Xkb also allows applications to refer to indicators by name. Use
1033<function>XkbGetNames</function>
1034to get the indicator names (see <xref linkend="Symbolic_Names" />). Using names eliminates the need
1035for hard-coding bitmask values for particular keyboards. For example, instead
1036of using vendor-specific constants such as
1037<symbol>WSKBLed_ScrollLock</symbol>
1038mask on Digital workstations or
1039<symbol>XLED_SCROLL_LOCK</symbol>
1040on Sun workstations, you can instead use
1041<function>XkbGetNamedDeviceIndicator</function> or
1042<function>XkbGetNamedIndicator</function>
1043to look up information on the indicator named <quote>Scroll Lock.</quote>
1044</para>
1045
1046<para>
1047Use
1048<function>XkbGetNamedDeviceIndicator</function>
1049to look up the indicator map and other information for an indicator by name
1050on a specific device.
1051</para>
1052
1053<indexterm significance="preferred" zone="XkbGetNamedDeviceIndicator"><primary><function>XkbGetNamedDeviceIndicator</function></primary></indexterm>
1054<funcsynopsis id="XkbGetNamedDeviceIndicator">
1055  <funcprototype>
1056    <funcdef>Bool <function>XkbGetNamedDeviceIndicator</function></funcdef>
1057<!-- (
1058<parameter>dpy</parameter>,
1059<parameter>dev_spec</parameter>,
1060<parameter>name</parameter>,
1061<parameter>ndx_rtrn</parameter>,
1062<parameter>state_rtrn</parameter>,
1063<parameter>map_rtrn</parameter>,
1064<parameter>real_rtrn</parameter>
1065) -->
1066
1067    <paramdef>Display *<parameter>dpy</parameter></paramdef>
1068    <paramdef>unsigned int <parameter>device_spec</parameter></paramdef>
1069    <paramdef>unsigned int <parameter>led_class</parameter></paramdef>
1070    <paramdef>unsigned int <parameter>led_id</parameter></paramdef>
1071    <paramdef>Atom <parameter>name</parameter></paramdef>
1072    <paramdef>int *<parameter>ndx_rtrn</parameter></paramdef>
1073    <paramdef>Bool *<parameter>state_rtrn</parameter></paramdef>
1074    <paramdef>XkbIndicatorMapPtr <parameter>map_rtrn</parameter></paramdef>
1075    <paramdef>Bool *<parameter>real_rtrn</parameter></paramdef>
1076  </funcprototype>
1077</funcsynopsis>
1078<variablelist>
1079  <varlistentry>
1080    <term>
1081      <parameter>dpy</parameter>
1082    </term>
1083    <listitem>
1084      <para>
1085        connection to the X server
1086      </para>
1087    </listitem>
1088  </varlistentry>
1089  <varlistentry>
1090    <term>
1091      <parameter>device_spec</parameter>
1092    </term>
1093    <listitem>
1094      <para>
1095        keyboard device ID, or <symbol>XkbUseCoreKbd</symbol>
1096      </para>
1097    </listitem>
1098  </varlistentry>
1099  <varlistentry>
1100    <term>
1101      <parameter>led_class</parameter>
1102    </term>
1103    <listitem>
1104      <para>
1105        feedback class, or <symbol>XkbDfltXIClass</symbol>
1106      </para>
1107    </listitem>
1108  </varlistentry>
1109  <varlistentry>
1110    <term>
1111      <parameter>led_id</parameter>
1112    </term>
1113    <listitem>
1114      <para>
1115        feedback ID, or <symbol>XkbDfltXIId</symbol>
1116      </para>
1117    </listitem>
1118  </varlistentry>
1119  <varlistentry>
1120    <term>
1121      <parameter>name</parameter>
1122    </term>
1123    <listitem>
1124      <para>
1125        name of the indicator to be retrieved
1126      </para>
1127    </listitem>
1128  </varlistentry>
1129  <varlistentry>
1130    <term>
1131      <parameter>ndx_rtrn</parameter>
1132    </term>
1133    <listitem>
1134      <para>
1135        backfilled with the index of the retrieved indicator
1136      </para>
1137    </listitem>
1138  </varlistentry>
1139  <varlistentry>
1140    <term>
1141      <parameter>state_rtrn</parameter>
1142    </term>
1143    <listitem>
1144      <para>
1145        backfilled with the current state of the retrieved indicator
1146      </para>
1147    </listitem>
1148  </varlistentry>
1149  <varlistentry>
1150    <term>
1151      <parameter>map_rtrn</parameter>
1152    </term>
1153    <listitem>
1154      <para>
1155        backfilled with the mapping for the retrieved indicator
1156      </para>
1157    </listitem>
1158  </varlistentry>
1159  <varlistentry>
1160    <term>
1161      <parameter>real_rtrn</parameter>
1162    </term>
1163    <listitem>
1164      <para>
1165        backfilled with <symbol>True</symbol>
1166         if the named indicator is real (physical)
1167      </para>
1168    </listitem>
1169  </varlistentry>
1170</variablelist>
1171
1172<para>
1173If the device specified by
1174<parameter>device_spec</parameter>
1175with feedback specified by
1176<parameter>led_class</parameter> and <parameter>led_id</parameter>
1177has an indicator named
1178<parameter>name</parameter>,
1179<function>XkbGetNamedDeviceIndicator</function>
1180returns
1181<symbol>True</symbol>
1182and populates the rest of the parameters with information about the indicator.
1183Otherwise,
1184<function>XkbGetNamedDeviceIndicator</function>
1185returns
1186<symbol>False</symbol>.
1187</para>
1188
1189
1190<para>
1191The
1192<parameter>ndx_rtrn</parameter>
1193field returns the zero-based index of the named indicator. This index is the
1194bit position to use in any function call that requires a mask of indicator
1195bits, as well as the indicator’s index into the
1196<structname>XkbIndicatorRec</structname>
1197array of indicator maps.
1198<parameter>state_rtrn</parameter>
1199returns the current state of the named indicator
1200(<symbol>True</symbol>
1201= on,
1202<symbol>False</symbol>
1203= off).
1204<parameter>map_rtrn</parameter>
1205returns the indicator map for the named indicator. In addition, if the
1206indicator is mapped to a physical LED, the
1207<parameter>real_rtrn</parameter>
1208parameter is set to
1209<symbol>True</symbol>.
1210</para>
1211
1212
1213<para>
1214Each of the "<parameter>_rtrn</parameter>" arguments is optional; you can pass
1215<symbol>NULL</symbol>
1216for any unneeded "<parameter>_rtrn</parameter>" arguments.
1217</para>
1218
1219
1220<para>
1221<function>XkbGetNamedDeviceIndicator</function>
1222can generate
1223<errorname>BadAtom</errorname>
1224and
1225<errorname>BadImplementation</errorname>
1226errors.
1227</para>
1228
1229<para>
1230As a convenience function, Xkb provides a function to get information about
1231indicators with the default class and identifier on the default device:
1232<function>XkbGetNamedIndicator</function>.
1233</para>
1234
1235
1236<indexterm significance="preferred" zone="XkbGetNamedIndicator"><primary><function>XkbGetNamedIndicator</function></primary></indexterm>
1237<funcsynopsis id="XkbGetNamedIndicator">
1238  <funcprototype>
1239    <funcdef>Bool <function>XkbGetNamedIndicator</function></funcdef>
1240    <paramdef>Display *<parameter>dpy</parameter></paramdef>
1241    <paramdef>Atom <parameter>name</parameter></paramdef>
1242    <paramdef>int *<parameter>ndx_rtrn</parameter></paramdef>
1243    <paramdef>Bool *<parameter>state_rtrn</parameter></paramdef>
1244    <paramdef>XkbIndicatorMapPtr <parameter>map_rtrn</parameter></paramdef>
1245    <paramdef>Bool *<parameter>real_rtrn</parameter></paramdef>
1246  </funcprototype>
1247</funcsynopsis>
1248<variablelist>
1249  <varlistentry>
1250    <term>
1251      <parameter>dpy</parameter>
1252    </term>
1253    <listitem>
1254      <para>
1255        connection to the X server
1256      </para>
1257    </listitem>
1258  </varlistentry>
1259  <varlistentry>
1260    <term>
1261      <parameter>name</parameter>
1262    </term>
1263    <listitem>
1264      <para>
1265        name of the indicator to be retrieved
1266      </para>
1267    </listitem>
1268  </varlistentry>
1269  <varlistentry>
1270    <term>
1271      <parameter>ndx_rtrn</parameter>
1272    </term>
1273    <listitem>
1274      <para>
1275        backfilled with the index of the retrieved indicator
1276      </para>
1277    </listitem>
1278  </varlistentry>
1279  <varlistentry>
1280    <term>
1281      <parameter>state_rtrn</parameter>
1282    </term>
1283    <listitem>
1284      <para>
1285        backfilled with the current state of the retrieved indicator
1286      </para>
1287    </listitem>
1288  </varlistentry>
1289  <varlistentry>
1290    <term>
1291      <parameter>map_rtrn</parameter>
1292    </term>
1293    <listitem>
1294      <para>
1295        backfilled with the mapping for the retrieved indicator
1296      </para>
1297    </listitem>
1298  </varlistentry>
1299  <varlistentry>
1300    <term>
1301      <parameter>real_rtrn</parameter>
1302    </term>
1303    <listitem>
1304      <para>
1305        backfilled with <symbol>True</symbol>
1306         if the named indicator is real (physical)
1307      </para>
1308    </listitem>
1309  </varlistentry>
1310</variablelist>
1311
1312<para>
1313<function>XkbGetNamedIndicator</function>
1314calls
1315<function>XkbGetNamedDeviceIndicator</function>
1316with the specified parameters, a
1317<structfield>device_spec</structfield>
1318of
1319<symbol>XkbUseCoreKbd</symbol>,
1320a
1321<structfield>led_class</structfield>
1322of
1323<symbol>XkbDfltXIClass</symbol>,
1324and a
1325<structfield>led_id</structfield>
1326of
1327<symbol>XkbDfltXIId</symbol>,
1328and returns the value which was returned by
1329<function>XkbGetNamedDeviceIndicator</function>.
1330</para>
1331
1332</sect2>
1333</sect1>
1334<sect1 id='Changing_Indicator_Maps_and_State'>
1335<title>Changing Indicator Maps and State</title>
1336
1337<para>
1338Just as you can get the indicator map using a mask or using an indicator name,
1339so you can change it using a mask or a name.
1340</para>
1341
1342<note><para>You cannot change the
1343<structfield>phys_indicators</structfield>
1344field of the indicators structure. The only way to change the
1345<structfield>phys_indicators</structfield>
1346field is to change the keyboard map.</para></note>
1347
1348<para>
1349There are two ways to make changes to indicator maps and state: either change a
1350local copy of the indicator maps and use
1351<function>XkbSetIndicatorMap</function>
1352or
1353<function>XkbSetNamedDeviceIndicator</function>,
1354or, to reduce network traffic, use an
1355<structname>XkbIndicatorChangesRec</structname>
1356structure and use
1357<function>XkbChangeIndicators</function>.
1358</para>
1359
1360
1361<sect2 id='Effects_of_Explicit_Changes_on_Indicators'>
1362<title>Effects of Explicit Changes on Indicators</title>
1363
1364<para>
1365This section discusses the effects of explicitly changing indicators depending
1366upon different settings in the indicator map. See
1367<link linkend="table8.3">Table 8.3</link> and
1368<link linkend="table8.5">Table 8.5</link> for
1369information on the effects of the indicator map fields when explicit changes
1370are made.
1371</para>
1372
1373
1374<para>
1375If
1376<symbol>XkbIM_LEDDrivesKB</symbol>
1377is set and
1378<symbol>XkbIM_NoExplicit</symbol>
1379is not, and if you call a function that updates the server’s image of the
1380indicator map (such as
1381<function>XkbSetIndicatorMap</function>
1382or
1383<function>XkbSetNamedDeviceIndicator</function>),
1384Xkb changes the keyboard state and controls to reflect the other fields of
1385the indicator map. If you attempt to explicitly change the value of an
1386indicator for which
1387<symbol>XkbIM_LEDDrivesKB</symbol>
1388is absent or for which
1389<symbol>XkbIM_NoExplicit</symbol>
1390is present, keyboard state or controls are unaffected.
1391</para>
1392
1393
1394<para>
1395If neither
1396<symbol>XkbIM_NoAutomatic</symbol>
1397nor
1398<symbol>XkbIM_NoExplicit</symbol>
1399is set in an indicator map, Xkb honors any request to change the state of the
1400indicator, but the new state might be immediately superseded by automatic
1401changes to the indicator state if the keyboard state or controls change.
1402</para>
1403
1404
1405<para>
1406The effects of changing an indicator that drives the keyboard are cumulative;
1407it is possible for a single change to affect keyboard group, modifiers, and
1408controls simultaneously.
1409</para>
1410
1411
1412<para>
1413If you change an indicator for which both the
1414<symbol>XkbIM_LEDDrivesKB</symbol>
1415and
1416<symbol>XkbIM_NoAutomatic</symbol>
1417flags are specified, Xkb applies the keyboard changes specified in the other
1418indicator map fields and changes the indicator to reflect the state that was
1419explicitly requested. The indicator remains in the new state until it is
1420explicitly changed again.
1421</para>
1422
1423
1424<para>
1425If the
1426<symbol>XkbIM_NoAutomatic</symbol>
1427flag is not set and
1428<symbol>XkbIM_LEDDrivesKB</symbol>
1429is set, Xkb applies the changes specified in the other indicator map fields
1430and sets the state of the indicator to the values specified by the indicator
1431map. Note that it is possible in this case for the indicator to end up in a
1432different state than the one that was explicitly requested. For example, Xkb
1433does not extinguish an indicator with
1434<structfield>which_mods</structfield>
1435of
1436<symbol>XkbIM_UseBase</symbol>
1437and
1438<structfield>mods</structfield>
1439of
1440<symbol>Shift</symbol>
1441if, at the time Xkb processes the request to extinguish the indicator, one of
1442the
1443<symbol>Shift</symbol>
1444keys is physically depressed.
1445</para>
1446
1447
1448<para>
1449If you explicitly light an indicator for which
1450<symbol>XkbIM_LEDDrivesKB</symbol>
1451is set, Xkb enables all of the boolean controls specified in the
1452<structfield>ctrls</structfield>
1453field of its indicator map. Explicitly extinguishing such an indicator causes
1454Xkb to disable all of the boolean controls specified in
1455<structfield>ctrls</structfield>.
1456</para>
1457
1458
1459</sect2>
1460<sect2 id='Changing_Indicator_Maps_by_Index'>
1461<title>Changing Indicator Maps by Index</title>
1462
1463<para>
1464To update the maps for one or more indicators, first modify a local copy of the
1465keyboard description, then use
1466<function>XkbSetIndicatorMap</function>
1467to download the changes to the server:
1468</para>
1469
1470<indexterm significance="preferred" zone="XkbSetIndicatorMap"><primary><function>XkbSetIndicatorMap</function></primary></indexterm>
1471<funcsynopsis id="XkbSetIndicatorMap">
1472  <funcprototype>
1473    <funcdef>Bool <function>XkbSetIndicatorMap</function></funcdef>
1474<!-- (
1475<parameter>dpy</parameter>,
1476<parameter>which</parameter>,
1477<parameter>desc</parameter>
1478) -->
1479
1480    <paramdef>Display *<parameter>dpy</parameter></paramdef>
1481    <paramdef>unsigned int <parameter>which</parameter></paramdef>
1482    <paramdef>XkbDescPtr <parameter>desc</parameter></paramdef>
1483  </funcprototype>
1484</funcsynopsis>
1485<variablelist>
1486  <varlistentry>
1487    <term>
1488      <parameter>dpy</parameter>
1489    </term>
1490    <listitem>
1491      <para>
1492        connection to the X server
1493      </para>
1494    </listitem>
1495  </varlistentry>
1496  <varlistentry>
1497    <term>
1498      <parameter>which</parameter>
1499    </term>
1500    <listitem>
1501      <para>
1502        mask of indicators to change
1503      </para>
1504    </listitem>
1505  </varlistentry>
1506  <varlistentry>
1507    <term>
1508      <parameter>desc</parameter>
1509    </term>
1510    <listitem>
1511      <para>
1512        keyboard description from which the maps are taken
1513      </para>
1514    </listitem>
1515  </varlistentry>
1516</variablelist>
1517
1518<para>
1519For each
1520bit set in the
1521<parameter>which</parameter>
1522parameter,
1523<function>XkbSetIndicatorMap</function>
1524sends the corresponding indicator map from the
1525<parameter>desc</parameter>
1526parameter to the server.
1527</para>
1528
1529
1530</sect2>
1531<sect2 id='Changing_Indicator_Maps_by_Name'>
1532<title>Changing Indicator Maps by Name</title>
1533
1534<para>
1535<function>XkbSetNamedDeviceIndicator</function> and
1536<function>XkbSetNamedIndicator</function>
1537can do several related things:
1538</para>
1539
1540<itemizedlist>
1541<listitem>
1542  <para>
1543Name an indicator if it is not already named
1544  </para>
1545</listitem>
1546<listitem>
1547  <para>
1548Toggle the state of the indicator
1549  </para>
1550</listitem>
1551<listitem>
1552  <para>
1553Set the indicator to a specified state
1554  </para>
1555</listitem>
1556<listitem>
1557  <para>
1558Set the indicator map for the indicator
1559  </para>
1560</listitem>
1561</itemizedlist>
1562
1563<indexterm significance="preferred" zone="XkbSetNamedDeviceIndicator"><primary><function>XkbSetNamedDeviceIndicator</function></primary></indexterm>
1564<funcsynopsis id="XkbSetNamedDeviceIndicator">
1565  <funcprototype>
1566    <funcdef>Bool<function>XkbSetNamedDeviceIndicator</function></funcdef>
1567<!-- (
1568<parameter>dpy</parameter>,
1569<parameter>device_spec</parameter>,
1570<parameter>name</parameter>,
1571<parameter>change_state, state</parameter>,
1572<parameter>create_new</parameter>,
1573<parameter>map</parameter>
1574) -->
1575
1576    <paramdef>Display *<parameter>dpy</parameter></paramdef>
1577    <paramdef>unsigned int <parameter>device_spec</parameter></paramdef>
1578    <paramdef>unsigned int <parameter>led_class</parameter></paramdef>
1579    <paramdef>unsigned int <parameter>led_id</parameter></paramdef>
1580    <paramdef>Atom <parameter>name</parameter></paramdef>
1581    <paramdef>Bool <parameter>change_state</parameter></paramdef>
1582    <paramdef>Bool <parameter>state</parameter></paramdef>
1583    <paramdef>Bool <parameter>create_new</parameter></paramdef>
1584    <paramdef>XkbIndicatorMapPtr <parameter>map</parameter></paramdef>
1585  </funcprototype>
1586</funcsynopsis>
1587<variablelist>
1588  <varlistentry>
1589    <term>
1590      <parameter>dpy</parameter>
1591    </term>
1592    <listitem>
1593      <para>
1594        connection to the X server
1595      </para>
1596    </listitem>
1597  </varlistentry>
1598  <varlistentry>
1599    <term>
1600      <parameter>device_spec</parameter>
1601    </term>
1602    <listitem>
1603      <para>
1604        device ID, or <symbol>XkbUseCoreKbd</symbol>
1605      </para>
1606    </listitem>
1607  </varlistentry>
1608  <varlistentry>
1609    <term>
1610      <parameter>led_class</parameter>
1611    </term>
1612    <listitem>
1613      <para>
1614        feedback class, or <symbol>XkbDfltXIClass</symbol>
1615      </para>
1616    </listitem>
1617  </varlistentry>
1618  <varlistentry>
1619    <term>
1620      <parameter>led_id</parameter>
1621    </term>
1622    <listitem>
1623      <para>
1624        feedback ID, or <symbol>XkbDfltXIId</symbol>
1625      </para>
1626    </listitem>
1627  </varlistentry>
1628  <varlistentry>
1629    <term>
1630      <parameter>name</parameter>
1631    </term>
1632    <listitem>
1633      <para>
1634        name of the indicator to change
1635      </para>
1636    </listitem>
1637  </varlistentry>
1638  <varlistentry>
1639    <term>
1640      <parameter>change_state</parameter>
1641    </term>
1642    <listitem>
1643      <para>
1644        whether to change the indicator state or not
1645      </para>
1646    </listitem>
1647  </varlistentry>
1648  <varlistentry>
1649    <term>
1650      <parameter>state</parameter>
1651    </term>
1652    <listitem>
1653      <para>
1654        desired new state for the indicator
1655      </para>
1656    </listitem>
1657  </varlistentry>
1658  <varlistentry>
1659    <term>
1660      <parameter>create_new</parameter>
1661    </term>
1662    <listitem>
1663      <para>
1664        whether a new indicator with the specified name should be
1665        created when necessary
1666      </para>
1667    </listitem>
1668  </varlistentry>
1669  <varlistentry>
1670    <term>
1671      <parameter>map</parameter>
1672    </term>
1673    <listitem>
1674      <para>
1675        new map for the indicator
1676      </para>
1677    </listitem>
1678  </varlistentry>
1679</variablelist>
1680
1681<para>
1682If a compatible version of the Xkb extension is not available in the server,
1683<function>XkbSetNamedDeviceIndicator</function>
1684returns
1685<symbol>False</symbol>.
1686Otherwise, it sends a request to the X server to change the indicator
1687specified by
1688<parameter>name</parameter>
1689and returns
1690<symbol>True</symbol>.
1691</para>
1692
1693
1694<para>
1695If
1696<parameter>change_state</parameter>
1697is
1698<symbol>True</symbol>,
1699<function>XkbSetNamedDeviceIndicator</function>
1700tells the server to change the state of the named indicator to the value
1701specified by
1702<parameter>state</parameter>.
1703If
1704<parameter>change_state</parameter>
1705is
1706<symbol>False</symbol>,
1707<parameter>state</parameter>
1708is not used.
1709</para>
1710
1711
1712<para>
1713If an indicator with the name specified by
1714<parameter>name</parameter>
1715does not already exist, the
1716<parameter>create_new</parameter>
1717parameter tells the server whether it should create a new named indicator. If
1718<parameter>create_new</parameter>
1719is
1720<symbol>True</symbol>,
1721the server finds the first indicator that doesn’t have a name and gives it
1722the name specified by
1723<parameter>name</parameter>.
1724</para>
1725
1726
1727<para>
1728If the optional parameter,
1729<parameter>map</parameter>,
1730is not
1731<symbol>NULL</symbol>,
1732<function>XkbSetNamedDeviceIndicator</function>
1733tells the server to change the indicator’s map to the values specified
1734in <parameter>map</parameter>.
1735</para>
1736
1737<para>
1738<function>XkbSetNamedDeviceIndicator</function>
1739can generate
1740<errorname>BadAtom</errorname>
1741and
1742<errorname>BadImplementation</errorname>
1743errors. In addition, it can also generate
1744<symbol>XkbIndicatorStateNotify</symbol>
1745(see <link linkend="Tracking_Changes_to_Indicator_State_or_Map">section 8.5</link>),
1746<symbol>XkbIndicatorMapNotify</symbol>,
1747and
1748<symbol>XkbNamesNotify</symbol>
1749events (see <link linkend="Tracking_Name_Changes">section 18.5</link>).
1750</para>
1751
1752<para>
1753As a convenience function, Xkb provides a function to set information about
1754indicators with the default class and identifier on the default device:
1755<function>XkbSetNamedIndicator</function>.
1756</para>
1757
1758<indexterm significance="preferred" zone="XkbSetNamedIndicator"><primary><function>XkbSetNamedIndicator</function></primary></indexterm>
1759<funcsynopsis id="XkbSetNamedIndicator">
1760  <funcprototype>
1761    <funcdef>Bool<function>XkbSetNamedIndicator</function></funcdef>
1762    <paramdef>Display *<parameter>dpy</parameter></paramdef>
1763    <paramdef>Atom <parameter>name</parameter></paramdef>
1764    <paramdef>Bool <parameter>change_state</parameter></paramdef>
1765    <paramdef>Bool <parameter>state</parameter></paramdef>
1766    <paramdef>Bool <parameter>create_new</parameter></paramdef>
1767    <paramdef>XkbIndicatorMapPtr <parameter>map</parameter></paramdef>
1768  </funcprototype>
1769</funcsynopsis>
1770<variablelist>
1771  <varlistentry>
1772    <term>
1773      <parameter>dpy</parameter>
1774    </term>
1775    <listitem>
1776      <para>
1777        connection to the X server
1778      </para>
1779    </listitem>
1780  </varlistentry>
1781  <varlistentry>
1782    <term>
1783      <parameter>name</parameter>
1784    </term>
1785    <listitem>
1786      <para>
1787        name of the indicator to change
1788      </para>
1789    </listitem>
1790  </varlistentry>
1791  <varlistentry>
1792    <term>
1793      <parameter>change_state</parameter>
1794    </term>
1795    <listitem>
1796      <para>
1797        whether to change the indicator state or not
1798      </para>
1799    </listitem>
1800  </varlistentry>
1801  <varlistentry>
1802    <term>
1803      <parameter>state</parameter>
1804    </term>
1805    <listitem>
1806      <para>
1807        desired new state for the indicator
1808      </para>
1809    </listitem>
1810  </varlistentry>
1811  <varlistentry>
1812    <term>
1813      <parameter>create_new</parameter>
1814    </term>
1815    <listitem>
1816      <para>
1817        whether a new indicator with the specified name should be
1818        created when necessary
1819      </para>
1820    </listitem>
1821  </varlistentry>
1822  <varlistentry>
1823    <term>
1824      <parameter>map</parameter>
1825    </term>
1826    <listitem>
1827      <para>
1828        new map for the indicator
1829      </para>
1830    </listitem>
1831  </varlistentry>
1832</variablelist>
1833
1834<para>
1835<function>XkbSetNamedIndicator</function>
1836calls
1837<function>XkbSetNamedDeviceIndicator</function>
1838with the specified parameters, a
1839<structfield>device_spec</structfield>
1840of
1841<symbol>XkbUseCoreKbd</symbol>,
1842a
1843<structfield>led_class</structfield>
1844of
1845<symbol>XkbDfltXIClass</symbol>,
1846and a
1847<structfield>led_id</structfield>
1848of
1849<symbol>XkbDfltXIId</symbol>,
1850and returns the value which was returned by
1851<function>XkbSetNamedDeviceIndicator</function>.
1852</para>
1853
1854</sect2>
1855<sect2 id='XkbIndicatorChangesRec'>
1856<title>The XkbIndicatorChangesRec Structure</title>
1857
1858<indexterm significance="preferred" zone="XkbIndicatorChangesRec">
1859<primary><structname>XkbIndicatorChangesRec</structname></primary></indexterm>
1860
1861<para>
1862The
1863<structname>XkbIndicatorChangesRec</structname>
1864identifies small modifications to the indicator map. Use it with the function
1865<function>XkbChangeIndicators</function>
1866to reduce the amount of traffic sent to the server.
1867</para>
1868
1869<para><programlisting>
1870typedef struct _XkbIndicatorChanges {
1871    unsigned int             state_changes;
1872    unsigned int             map_changes;
1873} <structname>XkbIndicatorChangesRec</structname>,*XkbIndicatorChangesPtr;
1874</programlisting></para>
1875
1876<para>
1877The
1878<structfield>state_changes</structfield>
1879field is a mask that specifies the indicators that have changed state, and
1880<structfield>map_changes</structfield>
1881is a mask that specifies the indicators whose maps have changed.
1882</para>
1883
1884
1885<para>
1886To change indicator maps or state without passing the entire keyboard
1887description, use
1888<function>XkbChangeIndicators</function>.
1889</para>
1890
1891<indexterm significance="preferred" zone="XkbChangeIndicators"><primary><function>XkbChangeIndicators</function></primary></indexterm>
1892<funcsynopsis id="XkbChangeIndicators">
1893  <funcprototype>
1894    <funcdef>Bool <function>XkbChangeIndicators</function></funcdef>
1895<!-- (
1896<parameter>dpy, xkb, changes, state</parameter>
1897) -->
1898
1899    <paramdef>Display *<parameter>dpy</parameter></paramdef>
1900    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
1901    <paramdef>XkbIndicatorChangesPtr <parameter>changes</parameter></paramdef>
1902    <paramdef>unsigned int <parameter>state</parameter></paramdef>
1903  </funcprototype>
1904</funcsynopsis>
1905<variablelist>
1906  <varlistentry>
1907    <term>
1908      <parameter>dpy</parameter>
1909    </term>
1910    <listitem>
1911      <para>
1912        connection to the X server
1913      </para>
1914    </listitem>
1915  </varlistentry>
1916  <varlistentry>
1917    <term>
1918      <parameter>xkb</parameter>
1919    </term>
1920    <listitem>
1921      <para>
1922        keyboard description from which names are to be  taken.
1923      </para>
1924    </listitem>
1925  </varlistentry>
1926  <varlistentry>
1927    <term>
1928      <parameter>changes</parameter>
1929    </term>
1930    <listitem>
1931      <para>
1932        indicators to be updated on the server
1933      </para>
1934    </listitem>
1935  </varlistentry>
1936  <varlistentry>
1937    <term>
1938      <parameter>state</parameter>
1939    </term>
1940    <listitem>
1941      <para>
1942        new state of indicators listed in <parameter>changes</parameter>-&gt;<structfield>state_changes</structfield>
1943      </para>
1944    </listitem>
1945  </varlistentry>
1946</variablelist>
1947
1948<para>
1949<function>XkbChangeIndicators</function>
1950copies any maps specified by
1951<parameter>changes</parameter>
1952from the keyboard description,
1953<parameter>xkb</parameter>,
1954to the server specified by
1955<parameter>dpy</parameter>.
1956If any bits are set in the
1957<structfield>state_changes</structfield>
1958field of
1959<parameter>changes</parameter>,
1960<function>XkbChangeIndicators</function>
1961also sets the state of those indicators to the values specified in the
1962<parameter>state</parameter>
1963mask. A 1 bit in
1964<parameter>state</parameter>
1965turns the corresponding indicator on, a 0 bit turns it off.
1966</para>
1967
1968
1969<para>
1970<function>XkbChangeIndicators</function>
1971can generate
1972<errorname>BadAtom</errorname>
1973and
1974<errorname>BadImplementation</errorname>
1975errors. In addition, it can also generate
1976<symbol>XkbIndicatorStateNotify</symbol>
1977and
1978<symbol>XkbIndicatorMapNotify</symbol>
1979events (see <link linkend="Tracking_Changes_to_Indicator_State_or_Map">section 8.5</link>).
1980</para>
1981
1982
1983</sect2>
1984</sect1>
1985<sect1 id='Tracking_Changes_to_Indicator_State_or_Map'>
1986<title>Tracking Changes to Indicator State or Map</title>
1987
1988<indexterm significance="preferred" zone="Tracking_Changes_to_Indicator_State_or_Map">
1989<primary>events</primary><secondary><symbol>XkbIndicatorStateNotify</symbol></secondary></indexterm>
1990<indexterm significance="preferred" zone="Tracking_Changes_to_Indicator_State_or_Map">
1991<primary><structname>XkbIndicatorStateNotifyEvent</structname></primary></indexterm>
1992
1993<indexterm significance="preferred" zone="Tracking_Changes_to_Indicator_State_or_Map">
1994<primary>events</primary><secondary><symbol>XkbIndicatorMapNotify</symbol></secondary></indexterm>
1995<indexterm significance="preferred" zone="Tracking_Changes_to_Indicator_State_or_Map">
1996<primary><structname>XkbIndicatorMapNotifyEvent</structname></primary></indexterm>
1997
1998<para>
1999Whenever an indicator changes state, the server sends
2000<symbol>XkbIndicatorStateNotify</symbol>
2001events to all interested clients. Similarly, whenever an indicator’s map
2002changes, the server sends
2003<symbol>XkbIndicatorMapNotify</symbol>
2004events to all interested clients.
2005</para>
2006
2007
2008<para>
2009To receive
2010<symbol>XkbIndicatorStateNotify</symbol>
2011events, use
2012<function>XkbSelectEvents</function>
2013(see <link linkend="Selecting_Xkb_Events">section 4.3</link>) with both the
2014<parameter>bits_to_change</parameter>
2015and
2016<parameter>values_for_bits</parameter>
2017parameters containing
2018<symbol>XkbIndicatorStateNotifyMask</symbol>.
2019To receive
2020<symbol>XkbIndicatorMapNotify</symbol>
2021events, use
2022<function>XkbSelectEvents</function>
2023with
2024<symbol>XkbIndicatorMapNotifyMask</symbol>.
2025</para>
2026
2027
2028<para>
2029To receive events for only specific indicators, use
2030<function>XkbSelectEventDetails</function>.
2031Set the
2032<structfield>event_type</structfield>
2033parameter to
2034<symbol>XkbIndicatorStateNotify</symbol>
2035or
2036<symbol>XkbIndicatorMapNotify</symbol>,
2037and set both the
2038<parameter>bits_to_change</parameter>
2039and
2040<parameter>values_for_bits</parameter>
2041detail parameters to a mask where each bit specifies one indicator, turning on
2042those bits that specify the indicators for which you want to receive events.
2043</para>
2044
2045
2046<para>
2047Both types of indicator events use the same structure:
2048
2049<programlisting>
2050typedef struct _XkbIndicatorNotify {
2051    int            type;        /* Xkb extension base event code */
2052    unsigned long  serial;      /* X server serial number for event */
2053    Bool           send_event;  /* <symbol>True</symbol> &rArr; synthetically generated */
2054    Display *      display;     /* server connection where event generated */
2055    Time           time;        /* server time when event generated */
2056    int            xkb_type;    /* specifies state or map notify */
2057    int            device;      /* Xkb device ID, will not be <symbol>XkbUseCoreKbd</symbol> */
2058    unsigned int   changed;     /* mask of indicators with new state or map */
2059    unsigned int   state;       /* current state of all indicators */
2060} <structname>XkbIndicatorNotifyEvent</structname>;
2061</programlisting></para>
2062
2063<para>
2064<structfield>xkb_type</structfield>
2065is either
2066<symbol>XkbIndicatorStateNotify</symbol>
2067or
2068<symbol>XkbIndicatorMapNotify</symbol>,
2069depending on whether the event is a
2070<symbol>XkbIndicatorStateNotify</symbol>
2071event or
2072<symbol>XkbIndicatorMapNotify</symbol>,
2073event.
2074</para>
2075
2076<para>
2077The
2078<structfield>changed</structfield>
2079parameter is a mask that is the bitwise inclusive OR of the indicators that
2080have changed. If the event is of type
2081<symbol>XkbIndicatorMapNotify</symbol>,
2082<structfield>changed</structfield>
2083reports the maps that changed. If the event is of type
2084<symbol>XkbIndicatorStateNotify</symbol>,
2085<structfield>changed</structfield>
2086reports the indicators that have changed state.
2087<parameter>state</parameter>
2088is a mask that specifies the current state of all indicators, whether they
2089have changed or not, for both
2090<symbol>XkbIndicatorStateNotify</symbol>
2091and <symbol>XkbIndicatorMapNotify</symbol> events.
2092</para>
2093
2094<para>
2095When your client application receives either a
2096<symbol>XkbIndicatorStateNotify</symbol>
2097event or
2098<symbol>XkbIndicatorMapNotify</symbol>
2099event, you can note the changes in a changes structure by calling
2100<function>XkbNoteIndicatorChanges</function>.
2101</para>
2102
2103<indexterm significance="preferred" zone="XkbNoteIndicatorChanges"><primary><function>XkbNoteIndicatorChanges</function></primary></indexterm>
2104<funcsynopsis id="XkbNoteIndicatorChanges">
2105  <funcprototype>
2106    <funcdef>void <function>XkbNoteIndicatorChanges</function></funcdef>
2107<!-- (
2108<parameter>old</parameter>,
2109<parameter>new</parameter>,
2110<parameter>wanted</parameter>
2111) -->
2112
2113    <paramdef>XkbIndicatorChangesPtr <parameter>old</parameter></paramdef>
2114    <paramdef>XkbIndicatorNotifyEvent *<parameter>new</parameter></paramdef>
2115    <paramdef>unsigned int <parameter>wanted</parameter></paramdef>
2116  </funcprototype>
2117</funcsynopsis>
2118<variablelist>
2119  <varlistentry>
2120    <term>
2121      <parameter>old</parameter>
2122    </term>
2123    <listitem>
2124      <para>
2125        XkbIndicatorChanges structure to be updated
2126      </para>
2127    </listitem>
2128  </varlistentry>
2129  <varlistentry>
2130    <term>
2131      <parameter>new</parameter>
2132    </term>
2133    <listitem>
2134      <para>
2135        event from which changes are to be copied
2136      </para>
2137    </listitem>
2138  </varlistentry>
2139  <varlistentry>
2140    <term>
2141      <parameter>wanted</parameter>
2142    </term>
2143    <listitem>
2144      <para>
2145        which changes are to be noted
2146      </para>
2147    </listitem>
2148  </varlistentry>
2149</variablelist>
2150
2151<para>
2152The
2153<parameter>wanted</parameter>
2154parameter is the bitwise inclusive OR of
2155<symbol>XkbIndicatorMapMask</symbol>
2156and
2157<emphasis>XkbIndicatorStateMask</emphasis>.
2158<function>XkbNoteIndicatorChanges</function>
2159copies any changes reported in
2160<parameter>new</parameter>
2161and specified in
2162<parameter>wanted</parameter>
2163into the changes record specified by
2164<parameter>old</parameter>.
2165</para>
2166
2167
2168<para>
2169To update a local copy of the keyboard description with the actual values, pass
2170the results of one or more calls to
2171<function>XkbNoteIndicatorChanges</function>
2172to
2173<function>XkbGetIndicatorChanges</function>:
2174</para>
2175
2176
2177<indexterm significance="preferred" zone="XkbGetIndicatorChanges"><primary><function>XkbGetIndicatorChanges</function></primary></indexterm>
2178<funcsynopsis id="XkbGetIndicatorChanges">
2179  <funcprototype>
2180    <funcdef>Status <function>XkbGetIndicatorChanges</function></funcdef>
2181<!-- (
2182<parameter>dpy</parameter>,
2183<parameter>xkb</parameter>,
2184<parameter>changes</parameter>,
2185<parameter>state</parameter>
2186) -->
2187
2188    <paramdef>Display *<parameter>dpy</parameter></paramdef>
2189    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
2190    <paramdef>XkbIndicatorChangesPtr <parameter>changes</parameter></paramdef>
2191    <paramdef>unsigned int *<parameter>state</parameter></paramdef>
2192  </funcprototype>
2193</funcsynopsis>
2194<variablelist>
2195  <varlistentry>
2196    <term>
2197      <parameter>dpy</parameter>
2198    </term>
2199    <listitem>
2200      <para>
2201        connection to the X server
2202      </para>
2203    </listitem>
2204  </varlistentry>
2205  <varlistentry>
2206    <term>
2207      <parameter>xkb</parameter>
2208    </term>
2209    <listitem>
2210      <para>
2211        keyboard description to hold the new values
2212      </para>
2213    </listitem>
2214  </varlistentry>
2215  <varlistentry>
2216    <term>
2217      <parameter>changes</parameter>
2218    </term>
2219    <listitem>
2220      <para>
2221        indicator maps/state to be obtained from the server
2222      </para>
2223    </listitem>
2224  </varlistentry>
2225  <varlistentry>
2226    <term>
2227      <parameter>state</parameter>
2228    </term>
2229    <listitem>
2230      <para>
2231        backfilled with the state of the indicators
2232      </para>
2233    </listitem>
2234  </varlistentry>
2235</variablelist>
2236
2237<para>
2238<function>XkbGetIndicatorChanges</function>
2239examines the
2240<parameter>changes</parameter>
2241parameter, pulls over the necessary information from the server, and copies
2242the results into the
2243<parameter>xkb</parameter>
2244keyboard description. If any bits are set in the
2245<structfield>state_changes</structfield>
2246field of
2247<parameter>changes</parameter>,
2248<function>XkbGetIndicatorChanges</function>
2249also places the state of those indicators in
2250<parameter>state</parameter>.
2251If the
2252<structfield>indicators</structfield>
2253field of
2254<parameter>xkb</parameter>
2255is
2256<symbol>NULL</symbol>,
2257<function>XkbGetIndicatorChanges</function>
2258allocates and initializes it. To free the
2259<structfield>indicators</structfield>
2260field, use
2261<function>XkbFreeIndicatorMaps</function>
2262(see <link linkend="Allocating_and_Freeing_Indicator_Maps">section 8.6</link>).
2263</para>
2264
2265
2266<para>
2267<function>XkbGetIndicatorChanges</function>
2268can generate
2269<errorname>BadAlloc</errorname>,
2270<errorname>BadImplementation</errorname>,
2271and
2272<errorname>BadMatch</errorname>
2273errors.
2274</para>
2275
2276
2277</sect1>
2278<sect1 id='Allocating_and_Freeing_Indicator_Maps'>
2279<title>Allocating and Freeing Indicator Maps</title>
2280
2281<para>
2282Most applications do not need to directly allocate the
2283<structfield>indicators</structfield>
2284member of the keyboard description record (the keyboard description record is
2285described in <xref linkend="Complete_Keyboard_Description" />). If the need arises, however, use
2286<function>XkbAllocIndicatorMaps</function>.
2287</para>
2288
2289<indexterm significance="preferred" zone="XkbAllocIndicatorMaps"><primary><function>XkbAllocIndicatorMaps</function></primary></indexterm>
2290<funcsynopsis id="XkbAllocIndicatorMaps">
2291  <funcprototype>
2292    <funcdef>Status <function>XkbAllocIndicatorMaps</function></funcdef>
2293<!-- (
2294<parameter>xkb</parameter>
2295) -->
2296
2297    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
2298  </funcprototype>
2299</funcsynopsis>
2300<variablelist>
2301  <varlistentry>
2302    <term>
2303      <parameter>xkb</parameter>
2304    </term>
2305    <listitem>
2306      <para>
2307        keyboard description structure
2308      </para>
2309    </listitem>
2310  </varlistentry>
2311</variablelist>
2312
2313<para>
2314The
2315<parameter>xkb</parameter>
2316parameter must point to a valid keyboard description. If it doesn’t,
2317<function>XkbAllocIndicatorMaps</function>
2318returns a
2319<errorname>BadMatch</errorname>
2320error. Otherwise,
2321<function>XkbAllocIndicatorMaps</function>
2322allocates and initializes the
2323<structfield>indicators</structfield>
2324member of the keyboard description record and returns
2325<symbol>Success</symbol>.
2326If
2327<function>XkbAllocIndicatorMaps</function>
2328was unable to allocate the indicators record, it reports a
2329<errorname>BadAlloc</errorname>
2330error.
2331</para>
2332
2333<para>
2334To free memory used by the
2335<structfield>indicators</structfield>
2336member of an
2337<structname>XkbDescRec</structname>
2338structure, use
2339<function>XkbFreeIndicatorMaps</function>.
2340</para>
2341
2342<indexterm significance="preferred" zone="XkbFreeIndicatorMaps"><primary><function>XkbFreeIndicatorMaps</function></primary></indexterm>
2343<funcsynopsis id="XkbFreeIndicatorMaps">
2344  <funcprototype>
2345    <funcdef>void <function>XkbFreeIndicatorMaps</function></funcdef>
2346<!-- (
2347<parameter>xkb</parameter>
2348) -->
2349
2350    <paramdef>XkbDescPtr <parameter>xkb</parameter></paramdef>
2351  </funcprototype>
2352</funcsynopsis>
2353<variablelist>
2354  <varlistentry>
2355    <term>
2356      <parameter>xkb</parameter>
2357    </term>
2358    <listitem>
2359      <para>
2360        keyboard description structure
2361      </para>
2362    </listitem>
2363  </varlistentry>
2364</variablelist>
2365
2366<para>
2367If the <structfield>indicators</structfield>
2368member of the keyboard description record
2369pointed to by <parameter>xkb</parameter>
2370is not <symbol>NULL</symbol>,
2371<function>XkbFreeIndicatorMaps</function>
2372frees the memory associated with
2373the <structfield>indicators</structfield>
2374member of <parameter>xkb</parameter>.
2375</para>
2376
2377</sect1>
2378</chapter>
2379