1 <chapter id='Indicators'>
2 <title>Indicators</title>
5 Although the core X implementation supports up to 32 LEDs on an input device,
6 it does not provide any linkage between the state of the LEDs and the logical
7 state of the input device. For example, most keyboards have a <emphasis>
9 LED, but X does not provide a mechanism to make the LED automatically follow
10 the logical state of the <emphasis>
17 Furthermore, the core X implementation does not provide clients with the
18 ability to determine what bits in the <emphasis>
20 field of the <emphasis>
21 XKeyboardState</emphasis>
22 map to the particular LEDs on the keyboard. For example, X does not provide a
23 method for a client to determine what bit to set in the <emphasis>
25 field to turn on the <emphasis>
26 Scroll Lock </emphasis>
27 LED or whether the keyboard even has a <emphasis>
28 Scroll Lock</emphasis>
34 Xkb provides indicator names and programmable indicators to help solve these
35 problems. Using Xkb, clients can determine the names of the various indicators,
36 determine and control the way that the individual indicators should be updated
37 to reflect keyboard changes, and determine which of the 32 keyboard indicators
38 reported by the protocol are actually present on the keyboard. Clients may also
39 request immediate notification of changes to the state of any subset of the
40 keyboard indicators, which makes it straightforward to provide an on-screen
41 "virtual" LED panel. This chapter describes Xkb indicators and the functions
42 used for manipulating them.
45 <sect1 id='Indicator_Names'>
46 <title>Indicator Names</title>
49 Xkb provides the capability of symbolically naming indicators. Xkb itself
50 doesn’t use these symbolic names for anything; they are there only to help
51 make the keyboard description comprehensible to humans. To set the names of
52 specific indicators, use <emphasis>
53 XkbSetNames</emphasis>
54 as discussed in Chapter 18. Then set the map using <emphasis> <!-- xref -->
56 (see section 14.3) or <emphasis> <!-- xref -->
57 XkbSetNamedIndicator</emphasis>
58 (below). To retrieve indicator names, use <emphasis>
59 XkbGetNames</emphasis>
60 (Chapter 18). <!-- xref -->
65 <sect1 id='Indicator_Data_Structures'>
66 <title>Indicator Data Structures</title>
69 Use the indicator description record, <emphasis>
70 XkbIndicatorRec</emphasis>
71 , and its indicator map, <emphasis>
72 XkbIndicatorMapRec</emphasis>
73 , to inquire about and control most indicator properties and behaviors.
77 <sect2 id='XkbIndicatorRec'>
78 <title>XkbIndicatorRec</title>
81 The description for all the Xkb indicators is held in the <emphasis>
83 field of the complete keyboard description (see Chapter 6), which is defined <!-- xref -->
87 <para><programlisting>
88 #define XkbNumIndicators 32
89 </programlisting></para>
90 <para><programlisting>
92 unsigned long phys_indicators; /* LEDs existence */
93 XkbIndicatorMapRec maps[XkbNumIndicators]; /* indicator maps */
94 } <emphasis>XkbIndicatorRec</emphasis>,*XkbIndicatorPtr;
95 </programlisting></para>
98 This structure contains the <emphasis>
99 phys_indicators</emphasis>
100 field, which relates some information about the correspondence between
101 indicators and physical LEDs on the keyboard, and an array of indicator
104 , one map per indicator.
109 phys_indicators</emphasis>
110 field indicates which indicators are bound to physical LEDs on the keyboard;
111 if a bit is set in <emphasis>
112 phys_indicators</emphasis>
113 , then the associated indicator has a physical LED associated with it. This
114 field is necessary because some indicators may not have corresponding physical
115 LEDs on the keyboard. For example, most keyboards have an LED for indicating
116 the state of <emphasis>
118 , but most keyboards do not have an LED that indicates the current group.
120 phys_indicators</emphasis>
121 describes a physical characteristic of the keyboard, you cannot directly
122 change it under program control. However, if a client program loads a
123 completely new keyboard description via <emphasis>
124 XkbGetKeyboardByName</emphasis>
125 , or if a new keyboard is attached and the X implementation notices, <emphasis>
126 phys_indicators</emphasis>
127 changes if the indicators for the new keyboard are different.
132 <sect2 id='XkbIndicatorMapRec'>
133 <title>XkbIndicatorMapRec</title>
136 Each indicator has its own set of attributes that specify whether clients can
137 explicitly set its state and whether it tracks the keyboard state. The
138 attributes of each indicator are held in the <emphasis>
140 array, which is an array of <emphasis>
141 XkbIndicatorRec</emphasis>
145 <para><programlisting>
147 unsigned char flags; /* how the indicator can be changed */
148 unsigned char which_groups; /* match criteria for groups */
149 unsigned char groups; /* which keyboard groups the indicator watches */
150 unsigned char which_mods; /* match criteria for modifiers */
151 XkbModsRec mods; /* which modifiers the indicator watches */
152 unsigned int ctrls; /* which controls the indicator watches */
153 } <emphasis>XkbIndicatorMapRec</emphasis>, *XkbIndicatorMapPtr;
154 </programlisting></para>
157 This indicator map specifies for each indicator:
163 The conditions under which the keyboard modifier state affects the indicator
168 The conditions under which the keyboard group state affects the indicator
173 The conditions under which the state of the boolean controls affects the
179 The effect (if any) of attempts to explicitly change the state of the indicator
180 using the functions <emphasis>
181 XkbSetControls</emphasis>
183 XChangeKeyboardControl</emphasis>
190 For more information on the effects of explicit changes to indicators and the
191 relationship to the indicator map, see section 8.4.1. <!-- xref -->
194 <sect3 id='XkbIndicatorMapRec_flags_field'>
195 <title>XkbIndicatorMapRec flags field</title>
200 field specifies the conditions under which the indicator can be changed and
201 the effects of changing the indicator. The valid values for <emphasis>
203 and their effects are shown in Table 8.1. <!-- xref -->
206 <table frame='topbot'>
207 <title>XkbIndicatorMapRec flags Field</title>
208 <?dbfo keep-together="always" ?>
209 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
210 <colspec colname='c1' colwidth='2.0*'/>
211 <colspec colname='c2' colwidth='1.0*'/>
212 <colspec colname='c3' colwidth='3.0*'/>
217 <entry>Effect</entry>
222 <entry>XkbIM_NoExplicit</entry>
223 <entry>(1L<<7)</entry>
224 <entry>Client applications cannot change the state of the indicator.</entry>
227 <entry>XkbIM_NoAutomatic</entry>
228 <entry>(1L<<6)</entry>
229 <entry>Xkb does not automatically change the value of the indicator based
230 upon a change in the keyboard state, regardless of the values for the other
231 fields of the indicator map.</entry>
234 <entry>XkbIM_LEDDrivesKB</entry>
235 <entry>(1L<<5)</entry>
236 <entry>A client application changing the state of the indicator causes the
237 state of the keyboard to change.</entry>
244 Note that if <emphasis>
245 XkbIM_NoAutomatic</emphasis>
246 is not set, by default the indicator follows the keyboard state.
252 XkbIM_LEDDrivesKB</emphasis>
253 is set and <emphasis>
254 XkbIM_NoExplicit</emphasis>
255 is not, and if you call a function which updates the server’s image of the
256 indicator map (such as <emphasis>
257 XkbSetIndicatorMap</emphasis>
259 XkbSetNamedIndicator</emphasis>
260 ), Xkb changes the keyboard state and controls to reflect the other fields of
261 the indicator map, as described in the remainder of this section. If you
262 attempt to explicitly change the value of an indicator for which <emphasis>
263 XkbIM_LEDDrivesKB</emphasis>
264 is absent or for which <emphasis>
265 XkbIM_NoExplicit</emphasis>
266 is present, keyboard state or controls are unaffected.
271 For example, a keyboard designer may want to make the <emphasis>
273 LED controllable only by the server, but allow the <emphasis>
274 Scroll Lock</emphasis>
275 LED to be controlled by client applications. To do so, the keyboard designer
276 could set the <emphasis>
277 XkbIM_NoExplicit</emphasis>
278 flag for the <emphasis>
282 LED, but not set it for the <emphasis>
283 Scroll Lock</emphasis>
284 LED. Or the keyboard designer may wish to allow the <emphasis>
286 LED to be controlled by both the server and client applications and also have
287 the server to automatically change the <emphasis>
291 modifier state whenever a client application changes the <emphasis>
293 LED. To do so, the keyboard designer would not set the <emphasis>
294 XkbIM_NoExplicit</emphasis>
295 flag, but would instead set the <emphasis>
296 XkbIM_LEDDrivesKB</emphasis>
301 The remaining fields in the indicator map specify the conditions under which
302 Xkb automatically turns an indicator on or off (only if <emphasis>
303 XkbIM_NoAutomatic</emphasis>
304 is not set). If these conditions match the keyboard state, Xkb turns the
305 indicator on. If the conditions do not match, Xkb turns the indicator off.
310 <sect3 id='XkbIndicatorMapRec_which_groups_and_groups_fields'>
311 <title>XkbIndicatorMapRec which_groups and groups fields</title>
315 which_groups</emphasis>
318 fields of an indicator map determine how the keyboard group state affects the
319 corresponding indicator. The <emphasis>
320 which_groups</emphasis>
321 field controls the interpretation of <emphasis>
323 and may contain any one of the following values:
326 <para><programlisting>
327 #define XkbIM_UseNone 0
328 #define XkbIM_UseBase (1L << 0)
329 #define XkbIM_UseLatched (1L << 1)
330 #define XkbIM_UseLocked (1L << 2)
331 #define XkbIM_UseEffective (1L << 3)
332 #define XkbIM_UseAnyGroup XkbIM_UseLatched | XkbIM_UseLocked |
334 </programlisting></para>
339 field specifies what keyboard groups an indicator watches and is the bitwise
340 inclusive OR of the following valid values:
343 <para><programlisting>
344 #define XkbGroup1Mask (1<<0)
345 #define XkbGroup2Mask (1<<1)
346 #define XkbGroup3Mask (1<<2)
347 #define XkbGroup4Mask (1<<3)
348 #define XkbAnyGroupMask (1<<7)
349 #define XkbAllGroupsMask (0xf)
350 </programlisting></para>
354 XkbIM_NoAutomatic</emphasis>
355 is not set (the keyboard drives the indicator), the effect of <emphasis>
356 which_groups</emphasis>
359 is shown in Table 8.2. <!-- xref -->
362 <table frame='topbot'>
363 <title>XkbIndicatorMapRec which_groups and groups, Keyboard Drives
365 <?dbfo keep-together="always" ?>
366 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
367 <colspec colname='c1' colwidth='1.0*'/>
368 <colspec colname='c2' colwidth='2.0*'/>
371 <entry>which_groups</entry>
372 <entry>Effect</entry>
377 <entry>XkbIM_UseNone</entry>
381 field and the current keyboard group state are ignored.
385 <entry>XkbIM_UseBase</entry>
389 is nonzero, the indicator is lit whenever the base keyboard group is nonzero.
392 is zero, the indicator is lit whenever the base keyboard group is zero.
396 <entry>XkbIM_UseLatched</entry>
400 is nonzero, the indicator is lit whenever the latched keyboard group is
401 nonzero. If <emphasis>
403 is zero, the indicator is lit whenever the latched keyboard group is zero.
407 <entry>XkbIM_UseLocked</entry>
411 field is interpreted as a mask. The indicator is lit when the current locked
412 keyboard group matches one of the bits that are set in <emphasis>
417 <entry>XkbIM_UseEffective</entry>
421 field is interpreted as a mask. The indicator is lit when the current
422 effective keyboard group matches one of the bits that are set in <emphasis>
432 The effect of <emphasis>
433 which_groups</emphasis>
436 when you change an indicator for which <emphasis>
437 XkbIM_LEDDrivesKB</emphasis>
438 is set (the indicator drives the keyboard) is shown in Table 8.3. The "New
439 State" column refers to the new state to which you set the indicator.
442 <table frame='topbot'>
443 <title>XkbIndicatorMapRec which_groups and groups, Indicator Drives
445 <?dbfo keep-together="always" ?>
446 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
447 <colspec colname='c1' colwidth='2.0*'/>
448 <colspec colname='c2' colwidth='1.0*'/>
449 <colspec colname='c3' colwidth='3.0*'/>
452 <entry>which_groups</entry>
453 <entry>New State</entry>
454 <entry>Effect on Keyboard Group State</entry>
459 <entry>XkbIM_UseNone </entry>
460 <entry>On or Off</entry>
461 <entry>No effect</entry>
464 <entry>XkbIM_UseBase</entry>
465 <entry>On or Off</entry>
466 <entry>No effect</entry>
469 <entry>XkbIM_UseLatched</entry>
474 field is treated as a group mask. The keyboard group latch is changed to the
475 lowest numbered group specified in <emphasis>
479 is empty, the keyboard group latch is changed to zero.
483 <entry>XkbIM_UseLatched</entry>
488 field is treated as a group mask. If the indicator is explicitly extinguished,
489 keyboard group latch is changed to the lowest numbered group not specified in
494 is zero, the keyboard group latch is set to the index of the highest legal
499 <entry>XkbIM_UseLocked or XkbIM_UseEffective</entry>
504 mask is empty, group is not changed; otherwise, the locked keyboard group is
505 changed to the lowest numbered group specified in <emphasis>
510 <entry>XkbIM_UseLocked or XkbIM_UseEffective</entry>
513 Locked keyboard group is changed to the lowest numbered group that is not
514 specified in the <emphasis>
516 mask, or to <emphasis>
520 mask contains all keyboard groups.
528 <sect3 id='XkbIndicatorMapRec_which_mods_and_mods_fields'>
529 <title>XkbIndicatorMapRec which_mods and mods fields</title>
534 field specifies what modifiers an indicator watches. The <emphasis>
536 field is an Xkb modifier definition, <emphasis>
537 XkbModsRec</emphasis>
538 , as described in section 7.2, which can specify both real and virtual <!-- xref -->
539 modifiers. The <emphasis>
541 field takes effect even if some or all of the virtual indicators specified in
544 are unbound. To specify the mods field, in general, assign the modifiers of
545 interest to <emphasis>
546 mods.real_mods</emphasis>
547 and the virtual modifiers of interest to <emphasis>
548 mods.vmods</emphasis>
549 . You can disregard the <emphasis>
551 field unless your application needs to interpret the indicator map directly
552 (that is, to simulate automatic indicator behavior on its own). Relatively few
553 applications need to do so, but if you find it necessary, you can either read
554 the indicator map back from the server after you update it (the server
555 automatically updates the mask field whenever any of the real or virtual
556 modifiers are changed in the modifier definition) or you can use <emphasis>
557 XkbVirtualModsToReal</emphasis>
558 to determine the proper contents for the mask field, assuming that the
560 XkbDescRec</emphasis>
561 contains the virtual modifier definitions.
566 which_mods</emphasis>
567 specifies what criteria Xkb uses to determine a match with the corresponding
570 field by specifying one or more components of the Xkb keyboard state. If
572 XkbIM_NoAutomatic</emphasis>
573 is not set (the keyboard drives the indicator), the indicator is lit whenever
574 any of the modifiers specified in the <emphasis>
576 field of the<emphasis>
578 modifier definition are also set in any of the current keyboard state
579 components specified by <emphasis>
580 which_mods</emphasis>
581 . Remember that the <emphasis>
583 field is comprised of all of the real modifiers specified in the definition
584 plus any real modifiers that are bound to the virtual modifiers specified in
585 the definition. (See Chapter 5 for more information on the keyboard state and <!-- xref -->
586 Chapter 7 for more information on virtual modifiers.) Use a bitwise inclusive
587 OR of the following values to compose a value for <emphasis>
588 which_mods</emphasis>:
591 <para><programlisting>
592 #define XkbIM_UseNone 0
593 #define XkbIM_UseBase (1L << 0)
594 #define XkbIM_UseLatched (1L << 1)
595 #define XkbIM_UseLocked (1L << 2)
596 #define XkbIM_UseEffective (1L << 3)
597 #define XkbIM_UseCompat (1L << 4)
598 #define XkbIM_UseAnyMods XkbIM_UseBase | XkbIM_UseLatched |
599 XkbIM_UseLocked | XkbIM_UseEffective |
601 </programlisting></para>
605 XkbIM_NoAutomatic</emphasis>
606 is not set (the keyboard drives the indicator), the effect of <emphasis>
607 which_mods</emphasis>
610 is shown in Table 8.4 <!-- xref -->
613 <table frame='topbot'>
614 <title>XkbIndicatorMapRec which_mods and mods, Keyboard Drives Indicator</title>
615 <?dbfo keep-together="always" ?>
616 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
617 <colspec colname='c1' colwidth='1.0*'/>
618 <colspec colname='c2' colwidth='2.0*'/>
621 <entry>which_mods</entry>
622 <entry>Effect on Keyboard Modifiers</entry>
627 <entry>XkbIM_UseNone</entry>
628 <entry>The mods field and the current keyboard modifier state are
632 <entry>XkbIM_UseBase</entry>
634 The indicator is lit when any of the modifiers specified in the <emphasis>
638 are on in the keyboard base state. If both <emphasis>
639 mods.real_mods</emphasis>
641 mods.vmods</emphasis>
642 are zero, the indicator is lit when the base keyboard state contains no
647 <entry>XkbIM_UseLatched</entry>
649 The indicator is lit when any of the modifiers specified in the <emphasis>
653 are latched. If both <emphasis>
654 mods.real_mods</emphasis>
656 mods.vmods</emphasis>
657 are zero, the indicator is lit when none of the modifier keys are latched.
661 <entry>XkbIM_UseLocked</entry>
663 The indicator is lit when any of the modifiers specified in the <emphasis>
667 are locked. If both <emphasis>
668 mods.real_mods</emphasis>
670 mods.vmods</emphasis>
671 are zero, the indicator is lit when none of the modifier keys are locked.
675 <entry>XkbIM_UseEffective</entry>
677 The indicator is lit when any of the modifiers specified in the <emphasis>
681 are in the effective keyboard state. If both <emphasis>
682 mods.real_mods</emphasis>
684 mods.vmods</emphasis>
685 are zero, the indicator is lit when the effective keyboard state contains no
690 <entry>XkbIM_UseCompat</entry>
692 The indicator is lit when any of the modifiers specified in the <emphasis>
696 are in the keyboard compatibility state. If both <emphasis>
697 mods.real_mods</emphasis>
699 mods.vmods</emphasis>
700 are zero, the indicator is lit when the keyboard compatibility state contains
709 The effect on the keyboard modifiers of <emphasis>
710 which_mods</emphasis>
713 when you change an indicator for which <emphasis>
714 XkbIM_LEDDrivesKB</emphasis>
715 is set (the indicator drives the keyboard) is shown in Table 8.5. The "New
716 State" column refers to the new state to which you set the indicator.
717 </para> <!-- xref -->
719 <table frame='topbot'>
720 <title>XkbIndicatorMapRec which_mods and mods, Indicator Drives Keyboard</title>
721 <?dbfo keep-together="always" ?>
722 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
723 <colspec colname='c1' colwidth='2.0*'/>
724 <colspec colname='c2' colwidth='1.0*'/>
725 <colspec colname='c3' colwidth='3.0*'/>
728 <entry>which_mods</entry>
729 <entry>New State</entry>
730 <entry>Effect on Keyboard Modifiers</entry>
735 <entry>XkbIM_UseNone or XkbIM_UseBase</entry>
736 <entry>On or Off</entry>
737 <entry>No Effect</entry>
740 <entry>XkbIM_UseLatched</entry>
743 Any modifiers specified in the <emphasis>
747 are added to the latched modifiers.
751 <entry>XkbIM_UseLatched</entry>
754 Any modifiers specified in the <emphasis>
758 are removed from the latched modifiers.
762 <entry>XkbIM_UseLocked, XkbIM_UseCompat, or XkbIM_UseEffective</entry>
765 Any modifiers specified in the <emphasis>
769 are added to the locked modifiers.
773 <entry>XkbIM_UseLocked</entry>
776 Any modifiers specified in the <emphasis>
780 are removed from the locked modifiers.
784 <entry>XkbIM_UseCompat or XkbIM_UseEffective</entry>
787 Any modifiers specified in the <emphasis>
791 are removed from both the locked and latched modifiers.
799 <sect3 id='XkbIndicatorMapRec_ctrls_field'>
800 <title>XkbIndicatorMapRec ctrls field</title>
805 field specifies what controls (see Chapter 10) the indicator watches and is
806 composed using the bitwise inclusive OR of the following values:
807 </para> <!-- xref -->
809 <para><programlisting>
810 #define XkbRepeatKeysMask (1L << 0)
811 #define XkbSlowKeysMask (1L << 1)
812 #define XkbBounceKeysMask (1L << 2)
813 #define XkbStickyKeysMask (1L << 3)
814 #define XkbMouseKeysMask (1L << 4)
815 #define XkbMouseKeysAccelMask (1L << 5)
816 #define XkbAccessXKeysMask (1L << 6)
817 #define XkbAccessXTimeoutMask (1L << 7)
818 #define XkbAccessXFeedbackMask (1L << 8)
819 #define XkbAudibleBellMask (1L << 9)
820 #define XkbOverlay1Mask (1L << 10)
821 #define XkbOverlay2Mask (1L << 11)
822 #define XkbAllBooleanCtrlsMask (0x00001FFF)
823 </programlisting></para>
826 Xkb lights the indicator whenever any of the boolean controls specified in
836 <sect1 id='Getting_Information_About_Indicators'>
837 <title>Getting Information About Indicators</title>
840 Xkb allows applications to obtain information about indicators using two
841 different methods. The first method, which is similar to the core X
842 implementation, uses a mask to specify the indicators. The second method, which
843 is more suitable for applications concerned with interoperability, uses
844 indicator names. The correspondence between the indicator name and the bit
845 position in masks is as follows: one of the parameters returned from <emphasis>
846 XkbGetNamedIndicators</emphasis>
847 is an index that is the bit position to use in any function call that requires
848 a mask of indicator bits, as well as the indicator’s index into the <emphasis>
849 XkbIndicatorRec</emphasis>
850 array of indicator maps.
854 <sect2 id='Getting_Indicator_State'>
855 <title>Getting Indicator State</title>
858 Because the state of the indicators is relatively volatile, the keyboard
859 description does not hold the current state of the indicators. To obtain the
860 current state of the keyboard indicators, use <emphasis>
861 XkbGetIndicatorState</emphasis>.
864 <informaltable frame='none'>
865 <?dbfo keep-together="always" ?>
866 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
867 <colspec colname='c1' colwidth='1.0*'/>
870 <entry role='functiondecl'>
872 XkbGetIndicatorState</emphasis>
876 device_spec</emphasis>
878 state_return</emphasis>
883 <entry role='functionargdecl'>
886 ; /* connection to the X server */
890 <entry role='functionargdecl'>
891 unsigned int <emphasis>
892 device_spec</emphasis>
893 ; /* device ID, or <emphasis>
894 XkbUseCoreKbd</emphasis>
899 <entry role='functionargdecl'>
900 unsigned int * <emphasis>
901 state_return</emphasis>
902 ; /* backfilled with a mask of the indicator state */
911 XkbGetIndicatorState</emphasis>
912 queries the <emphasis>
914 for the state of the indicators on the device specified by the <emphasis>
915 device_spec</emphasis>
916 . For each indicator that is "turned on" on the device, the associated bit is
918 state_return</emphasis>
919 . If a compatible version of the Xkb extension is not available in the server,
921 XkbGetIndicatorState</emphasis>
924 error. Otherwise, it sends the request to the X server, places the state of
925 the indicators into <emphasis>
926 state_return,</emphasis>
927 and returns <emphasis>
929 . Thus the value reported by <emphasis>
930 XkbGetIndicatorState</emphasis>
931 is identical to the value reported by the core protocol.
936 <sect2 id='Getting_Indicator_Information_by_Index'>
937 <title>Getting Indicator Information by Index</title>
940 To get the map for one or more indicators, using a mask to specify the
941 indicators, use <emphasis>
942 XkbGetIndicatorMap</emphasis>.
945 <informaltable frame='none'>
946 <?dbfo keep-together="always" ?>
947 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
948 <colspec colname='c1' colwidth='1.0*'/>
951 <entry role='functiondecl'>
953 XkbGetIndicatorMap</emphasis>
964 <entry role='functionargdecl'>
967 ; /* connection to the X server */
971 <entry role='functionargdecl'>
972 unsigned int <emphasis>
974 ; /* mask of indicators for which maps should be returned */
978 <entry role='functionargdecl'>
979 XkbDescPtr <emphasis>
981 ; /* keyboard description to be updated */
990 XkbGetIndicatorMap</emphasis>
991 obtains the maps from the server for only those indicators specified by the
994 mask and copies the values into the keyboard description specified by
998 indicators</emphasis>
999 field of the <emphasis>
1001 parameter is <emphasis>
1004 XkbGetIndicatorMap</emphasis>
1005 allocates and initializes it.
1011 XkbGetIndicatorMap</emphasis>
1012 can generate <emphasis>
1015 BadLength</emphasis>
1019 BadImplementation</emphasis>
1025 To free the indicator maps, use <emphasis>
1026 XkbFreeIndicatorMaps</emphasis>
1032 <sect2 id='Getting_Indicator_Information_by_Name'>
1033 <title>Getting Indicator Information by Name</title>
1036 Xkb also allows applications to refer to indicators by name. Use <emphasis>
1037 XkbGetNames</emphasis>
1038 to get the indicator names (see Chapter 18). Using names eliminates the need
1039 for hard-coding bitmask values for particular keyboards. For example, instead
1040 of using vendor-specific constants such as <emphasis>
1041 WSKBLed_ScrollLock</emphasis>
1042 mask on Digital workstations or <emphasis>
1043 XLED_SCROLL_LOCK</emphasis>
1044 on Sun workstations, you can instead use <emphasis>
1045 XkbGetNamedIndicator</emphasis>
1046 to look up information on the indicator named "Scroll Lock."
1051 XkbGetNamedIndicator</emphasis>
1052 to look up the indicator map and other information for an indicator by name.
1055 <informaltable frame='none'>
1056 <?dbfo keep-together="always" ?>
1057 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1058 <colspec colname='c1' colwidth='1.0*'/>
1061 <entry role='functiondecl'>
1063 XkbGetNamedIndicator</emphasis>
1073 state_rtrn</emphasis>
1077 real_rtrn</emphasis>
1082 <entry role='functionargdecl'>
1083 Display * <emphasis>
1085 ; /* connection to the X server */
1089 <entry role='functionargdecl'>
1090 unsigned int <emphasis>
1091 device_spec</emphasis>
1092 ; /* keyboard device ID, or <emphasis>
1093 XkbUseCoreKbd</emphasis>
1098 <entry role='functionargdecl'>
1101 ; /* name of the indicator to be retrieved */
1105 <entry role='functionargdecl'>
1108 ; /* backfilled with the index of the retrieved indicator */
1112 <entry role='functionargdecl'>
1114 state_rtrn</emphasis>
1115 ; /* backfilled with the current state of the retrieved indicator */
1119 <entry role='functionargdecl'>
1120 XkbIndicatorMapPtr <emphasis>
1122 ; /* backfilled with the mapping for the retrieved indicator */
1126 <entry role='functionargdecl'>
1128 real_rtrn</emphasis>
1129 ; /* backfilled with <emphasis>
1131 if the named indicator is real (physical) */
1139 If the device specified by <emphasis>
1140 device_spec</emphasis>
1141 has an indicator named <emphasis>
1144 XkbGetNamedIndicator</emphasis>
1147 and populates the rest of the parameters with information about the indicator.
1148 Otherwise, <emphasis>
1149 XkbGetNamedIndicator</emphasis>
1159 field returns the zero-based index of the named indicator. This index is the
1160 bit position to use in any function call that requires a mask of indicator
1161 bits, as well as the indicator’s index into the <emphasis>
1162 XkbIndicatorRec</emphasis>
1163 array of indicator maps. <emphasis>
1164 state_rtrn</emphasis>
1165 returns the current state of the named indicator (<emphasis>
1171 returns the indicator map for the named indicator. In addition, if the
1172 indicator is mapped to a physical LED, the <emphasis>
1173 real_rtrn</emphasis>
1174 parameter is set to <emphasis>
1181 Each of the "<emphasis>
1183 " arguments is optional; you can pass <emphasis>
1185 for any unneeded "<emphasis>
1193 XkbGetNamedIndicator</emphasis>
1194 can generate <emphasis>
1197 BadImplementation</emphasis>
1204 <sect1 id='Changing_Indicator_Maps_and_State'>
1205 <title>Changing Indicator Maps and State</title>
1208 Just as you can get the indicator map using a mask or using an indicator name,
1209 so you can change it using a mask or a name.
1212 <note><para>You cannot change the <emphasis>
1213 phys_indicators</emphasis>
1214 field of the indicators structure. The only way to change the <emphasis>
1215 phys_indicators</emphasis>
1216 field is to change the keyboard map.</para></note>
1219 There are two ways to make changes to indicator maps and state: either change a
1220 local copy of the indicator maps and use <emphasis>
1221 XkbSetIndicatorMap</emphasis>
1223 XkbSetNamedIndicator</emphasis>
1224 , or, to reduce network traffic, use an<emphasis>
1225 XkbIndicatorChangesRec</emphasis>
1226 structure and use <emphasis>
1227 XkbChangeIndicators</emphasis>.
1231 <sect2 id='Effects_of_Explicit_Changes_on_Indicators'>
1232 <title>Effects of Explicit Changes on Indicators</title>
1235 This section discusses the effects of explicitly changing indicators depending
1236 upon different settings in the indicator map. See Tables 8.3 and Table 8.5 for
1237 information on the effects of the indicator map fields when explicit changes
1244 XkbIM_LEDDrivesKB</emphasis>
1245 is set and <emphasis>
1246 XkbIM_NoExplicit</emphasis>
1247 is not, and if you call a function that updates the server’s image of the
1248 indicator map (such as <emphasis>
1249 XkbSetIndicatorMap</emphasis>
1251 XkbSetNamedIndicator</emphasis>
1252 ), Xkb changes the keyboard state and controls to reflect the other fields of
1253 the indicator map. If you attempt to explicitly change the value of an
1254 indicator for which <emphasis>
1255 XkbIM_LEDDrivesKB</emphasis>
1256 is absent or for which <emphasis>
1257 XkbIM_NoExplicit</emphasis>
1258 is present, keyboard state or controls are unaffected.
1263 If neither <emphasis>
1264 XkbIM_NoAutomatic</emphasis>
1266 XkbIM_NoExplicit</emphasis>
1267 is set in an indicator map, Xkb honors any request to change the state of the
1268 indicator, but the new state might be immediately superseded by automatic
1269 changes to the indicator state if the keyboard state or controls change.
1274 The effects of changing an indicator that drives the keyboard are cumulative;
1275 it is possible for a single change to affect keyboard group, modifiers, and
1276 controls simultaneously.
1281 If you change an indicator for which both the <emphasis>
1282 XkbIM_LEDDrivesKB</emphasis>
1284 XkbIM_NoAutomatic</emphasis>
1285 flags are specified, Xkb applies the keyboard changes specified in the other
1286 indicator map fields and changes the indicator to reflect the state that was
1287 explicitly requested. The indicator remains in the new state until it is
1288 explicitly changed again.
1294 XkbIM_NoAutomatic</emphasis>
1295 flag is not set and <emphasis>
1296 XkbIM_LEDDrivesKB</emphasis>
1297 is set, Xkb applies the changes specified in the other indicator map fields
1298 and sets the state of the indicator to the values specified by the indicator
1299 map. Note that it is possible in this case for the indicator to end up in a
1300 different state than the one that was explicitly requested. For example, Xkb
1301 does not extinguish an indicator with <emphasis>
1302 which_mods</emphasis>
1304 XkbIM_UseBase</emphasis>
1309 if, at the time Xkb processes the request to extinguish the indicator, one of
1312 keys is physically depressed.
1317 If you explicitly light an indicator for which <emphasis>
1318 XkbIM_LEDDrivesKB</emphasis>
1319 is set, Xkb enables all of the boolean controls specified in the <emphasis>
1321 field of its indicator map. Explicitly extinguishing such an indicator causes
1322 Xkb to disable all of the boolean controls specified in <emphasis>
1329 <sect2 id='Changing_Indicator_Maps_by_Index'>
1330 <title>Changing Indicator Maps by Index</title>
1333 To update the maps for one or more indicators, first modify a local copy of the
1334 keyboard description, then use <emphasis>
1335 XkbSetIndicatorMap</emphasis>
1336 to download the changes to the server:
1339 <informaltable frame='none'>
1340 <?dbfo keep-together="always" ?>
1341 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1342 <colspec colname='c1' colwidth='1.0*'/>
1345 <entry role='functiondecl'>
1347 XkbSetIndicatorMap</emphasis>
1358 <entry role='functionargdecl'>
1359 Display * <emphasis>
1361 ; /* connection to the X server */
1365 <entry role='functionargdecl'>
1366 unsigned int <emphasis>
1368 ; /* mask of indicators to change */
1372 <entry role='functionargdecl'>
1373 XkbDescPtr <emphasis>
1375 ; /* keyboard description from which the maps are taken */
1385 bit set in the <emphasis>
1387 parameter,<emphasis>
1388 XkbSetIndicatorMap</emphasis>
1389 sends the corresponding indicator map from the <emphasis>
1391 parameter to the server.
1396 <sect2 id='Changing_Indicator_Maps_by_Name'>
1397 <title>Changing Indicator Maps by Name</title>
1401 XkbSetNamedIndicator</emphasis>
1402 can do several related things:
1408 Name an indicator if it is not already named
1413 Toggle the state of the indicator
1418 Set the indicator to a specified state
1423 Set the indicator map for the indicator
1428 <informaltable frame='none'>
1429 <?dbfo keep-together="always" ?>
1430 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1431 <colspec colname='c1' colwidth='1.0*'/>
1434 <entry role='functiondecl'>
1436 XkbSetNamedIndicator</emphasis>
1440 device_spec</emphasis>
1444 change_state, state</emphasis>
1446 create_new</emphasis>
1453 <entry role='functionargdecl'>
1454 Display * <emphasis>
1456 ; /* connection to the X server */
1460 <entry role='functionargdecl'>
1461 unsigned int <emphasis>
1462 device_spec</emphasis>
1463 ; /* device ID, or <emphasis>
1464 XkbUseCoreKbd</emphasis>
1469 <entry role='functionargdecl'>
1472 ; /* name of the indicator to change */
1476 <entry role='functionargdecl'>
1478 change_state</emphasis>
1479 ; /* whether to change the indicator state or not */
1483 <entry role='functionargdecl'>
1486 ; /* desired new state for the indicator */
1490 <entry role='functionargdecl'>
1492 create_new</emphasis>
1493 ; /* whether a new indicator with the specified name should be
1494 created when necessary */
1498 <entry role='functionargdecl'>
1499 XkbIndicatorMapPtr <emphasis>
1501 ; /* new map for the indicator */
1509 If a compatible version of the Xkb extension is not available in the server,
1511 XkbSetNamedIndicator</emphasis>
1514 . Otherwise, it sends a request to the X server to change the indicator
1515 specified by <emphasis>
1517 and returns <emphasis>
1524 change_state</emphasis>
1527 , and the optional parameter, <emphasis>
1532 XkbSetNamedIndicator</emphasis>
1533 tells the server to change the state of the named indicator to the value
1534 specified by <emphasis>
1540 If an indicator with the name specified by <emphasis>
1542 does not already exist, the <emphasis>
1543 create_new</emphasis>
1544 parameter tells the server whether it should create a new named indicator. If
1546 create_new</emphasis>
1549 , the server finds the first indicator that doesn’t have a name and gives it
1550 the name specified by <emphasis>
1556 If the optional parameter, <emphasis>
1561 XkbSetNamedIndicator</emphasis>
1562 tells the server to change the indicator’s map to the values specified
1563 in <emphasis>map</emphasis>.
1568 XkbSetNamedIndicator</emphasis>
1569 can generate <emphasis>
1572 BadImplementation</emphasis>
1573 errors. In addition, it can also generate <emphasis>
1574 XkbIndicatorStateNotify</emphasis>
1575 (see section 8.5), <emphasis> <!-- xref -->
1576 XkbIndicatorMapNotify</emphasis>
1578 XkbNamesNotify</emphasis>
1579 events (see section 18.5). <!-- xref -->
1584 <sect2 id='The_XkbIndicatorChangesRec_Structure'>
1585 <title>The XkbIndicatorChangesRec Structure</title>
1589 XkbIndicatorChangesRec</emphasis>
1590 identifies small modifications to the indicator map. Use it with the function
1592 XkbChangeIndicators</emphasis>
1593 to reduce the amount of traffic sent to the server.
1596 <para><programlisting>
1597 typedef struct _XkbIndicatorChanges {
1598 unsigned int state_changes;
1599 unsigned int map_changes;
1601 XkbIndicatorChangesRec</emphasis>,*XkbIndicatorChangesPtr;
1602 </programlisting></para>
1606 state_changes</emphasis>
1607 field is a mask that specifies the indicators that have changed state, and
1609 map_changes</emphasis>
1610 is a mask that specifies the indicators whose maps have changed.
1615 To change indicator maps or state without passing the entire keyboard
1616 description, use <emphasis>
1617 XkbChangeIndicators</emphasis>
1621 <informaltable frame='none'>
1622 <?dbfo keep-together="always" ?>
1623 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1624 <colspec colname='c1' colwidth='1.0*'/>
1627 <entry role='functiondecl'>
1629 XkbChangeIndicators</emphasis>
1631 dpy, xkb, changes, state</emphasis>
1636 <entry role='functionargdecl'>
1637 Display * <emphasis>
1639 ; /* connection to the X server */
1643 <entry role='functionargdecl'>
1644 XkbDescPtr <emphasis>
1646 ; /* keyboard description from which names are to be
1650 <entry role='functionargdecl'>
1655 <entry role='functionargdecl'>
1656 XkbIndicatorChangesPtr <emphasis>
1658 ; /* indicators to be updated on the server */
1662 <entry role='functionargdecl'>
1663 unsigned int <emphasis>
1665 ; /* new state of indicators listed in
1669 <entry role='functionargdecl'>
1673 state_changes</emphasis>
1683 XkbChangeIndicators</emphasis>
1684 copies any maps specified by <emphasis>
1686 from the keyboard description, <emphasis>
1688 , to the server specified by <emphasis>
1690 . If any bits are set in the <emphasis>
1691 state_changes</emphasis>
1695 XkbChangeIndicators</emphasis>
1696 also sets the state of those indicators to the values specified in the
1699 mask. A 1 bit in <emphasis>
1701 turns the corresponding indicator on, a 0 bit turns it off.
1707 XkbChangeIndicator</emphasis>
1708 s can generate <emphasis>
1711 BadImplementation</emphasis>
1712 errors. In addition, it can also generate <emphasis>
1713 XkbIndicatorStateNotify</emphasis>
1715 XkbIndicatorMapNotify</emphasis>
1716 events (see section 8.5). <!-- xref -->
1722 <sect1 id='Tracking_Changes_to_Indicator_State_or_Map'>
1723 <title>Tracking Changes to Indicator State or Map</title>
1726 Whenever an indicator changes state, the server sends <emphasis>
1727 XkbIndicatorStateNotify</emphasis>
1728 events to all interested clients. Similarly, whenever an indicator’s map
1729 changes, the server sends <emphasis>
1730 XkbIndicatorMapNotify</emphasis>
1731 events to all interested clients.
1736 To receive <emphasis>
1737 XkbIndicatorStateNotify</emphasis>
1738 events, use <emphasis>
1739 XkbSelectEvents</emphasis>
1740 (see section 4.3) with both the <emphasis> <!-- xref -->
1741 bits_to_change </emphasis>
1743 values_for_bits</emphasis>
1744 parameters containing <emphasis>
1745 XkbIndicatorStateNotifyMask</emphasis>
1746 . To receive <emphasis>
1747 XkbIndicatorMapNotify</emphasis>
1748 events, use <emphasis>
1749 XkbSelectEvents</emphasis>
1751 XkbIndicatorMapNotifyMask</emphasis>
1757 To receive events for only specific indicators, use <emphasis>
1758 XkbSelectEventDetails</emphasis>
1759 . Set the <emphasis>
1760 event_type</emphasis>
1762 to XkbIndicatorStateNotify</emphasis>
1764 XkbIndicatorMapNotify</emphasis>
1765 , and set both the <emphasis>
1766 bits_to_change </emphasis>
1768 values_for_bits</emphasis>
1769 detail parameters to a mask where each bit specifies one indicator, turning on
1770 those bits that specify the indicators for which you want to receive events.
1775 Both types of indicator events use the same structure:
1778 <para><programlisting>
1779 typedef struct _XkbIndicatorNotify {
1780 int type; /* Xkb extension base event code */
1781 unsigned long serial; /* X server serial number for event */
1782 Bool send_event; /* <emphasis> True</emphasis> => synthetically generated */
1783 Display * display; /* server connection where event generated */
1784 Time time; /* server time when event generated */
1785 int xkb_type; /* specifies state or map notify */
1786 int device; /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
1787 unsigned int changed; /* mask of indicators with new state or map */
1788 unsigned int state; /* current state of all indicators */
1789 } <emphasis>XkbIndicatorNotifyEvent</emphasis>;
1790 </programlisting></para>
1795 is either <emphasis>
1796 XkbIndicatorStateNotify</emphasis>
1798 XkbIndicatorMapNotify</emphasis>
1799 , depending on whether the event is a <emphasis>
1800 kbIndicatorStateNotify</emphasis>
1802 kbIndicatorMapNotify</emphasis>
1809 parameter is a mask that is the bitwise inclusive OR of the indicators that
1810 have changed. If the event is of type <emphasis>
1811 XkbIndicatorMapNotify</emphasis>
1814 reports the maps that changed. If the event is of type <emphasis>
1815 XkbIndicatorStateNotify</emphasis>
1818 reports the indicators that have changed state. <emphasis>
1820 is a mask that specifies the current state of all indicators, whether they
1821 have changed or not, for both <emphasis>
1822 XkbIndicatorStateNotify</emphasis>
1823 and <emphasis>IndicatorMapNotify</emphasis> events.
1827 When your client application receives either a <emphasis>
1828 XkbIndicatorStateNotify</emphasis>
1830 XkbIndicatorMapNotify</emphasis>
1831 event, you can note the changes in a changes structure by calling <emphasis>
1832 XkbNoteIndicatorChanges</emphasis>.
1835 <informaltable frame='none'>
1836 <?dbfo keep-together="always" ?>
1837 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1838 <colspec colname='c1' colwidth='1.0*'/>
1841 <entry role='functiondecl'>
1843 XkbNoteIndicatorChanges</emphasis>
1854 <entry role='functionargdecl'>
1855 XkbIndicatorChangesPtr <emphasis>
1857 ; /* XkbIndicatorChanges structure to be updated */
1861 <entry role='functionargdecl'>
1862 XkbIndicatorNotifyEvent * <emphasis>
1864 ; /* event from which changes are to be copied */
1868 <entry role='functionargdecl'>
1869 unsigned int <emphasis>
1871 ; /* which changes are to be noted */
1881 parameter is the bitwise inclusive OR of <emphasis>
1882 XkbIndicatorMapMask</emphasis>
1884 XkbIndicatorStateMask</emphasis>
1886 XkbNoteIndicatorChanges</emphasis>
1887 copies any changes reported in <emphasis>
1889 and specified in <emphasis>
1891 into the changes record specified by <emphasis>
1897 To update a local copy of the keyboard description with the actual values, pass
1898 the results of one or more calls to <emphasis>
1899 XkbNoteIndicatorChanges</emphasis>
1901 XkbGetIndicatorChanges</emphasis>:
1905 <informaltable frame='none'>
1906 <?dbfo keep-together="always" ?>
1907 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
1908 <colspec colname='c1' colwidth='1.0*'/>
1911 <entry role='functiondecl'>
1913 XkbGetIndicatorChanges</emphasis>
1926 <entry role='functionargdecl'>
1927 Display * <emphasis>
1929 ; /* connection to the X server */
1933 <entry role='functionargdecl'>
1934 XkbDescPtr <emphasis>
1936 ; /* keyboard description to hold the new values */
1940 <entry role='functionargdecl'>
1941 XkbIndicatorChangesPtr <emphasis>
1943 ; /* indicator maps/state to be obtained from the server */
1947 <entry role='functionargdecl'>
1948 unsigned int * <emphasis>
1950 ; /* backfilled with the state of the indicators */
1959 XkbGetIndicatorChanges</emphasis>
1960 examines the <emphasis>
1962 parameter, pulls over the necessary information from the server, and copies
1963 the results into the <emphasis>
1965 keyboard description. If any bits are set in the <emphasis>
1966 state_changes</emphasis>
1970 XkbGetIndicatorChanges</emphasis>
1971 also places the state of those indicators in <emphasis>
1974 indicators</emphasis>
1980 XkbGetIndicatorChanges</emphasis>
1981 allocates and initializes it. To free the <emphasis>
1982 indicators</emphasis>
1983 field, use <emphasis>
1984 XkbFreeIndicators</emphasis>
1985 (see section 8.6). <!-- xref -->
1991 XkbGetIndicatorChanges</emphasis>
1992 can generate <emphasis>
1995 BadImplementation,</emphasis>
2003 <sect1 id='Allocating_and_Freeing_Indicator_Maps'>
2004 <title>Allocating and Freeing Indicator Maps</title>
2007 Most applications do not need to directly allocate the <emphasis>
2008 indicators</emphasis>
2009 member of the keyboard description record (the keyboard description record is
2010 described in Chapter 6). If the need arises, however, use <emphasis>
2011 XkbAllocIndicatorMaps.</emphasis>
2014 <informaltable frame='none'>
2015 <?dbfo keep-together="always" ?>
2016 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
2017 <colspec colname='c1' colwidth='1.0*'/>
2020 <entry role='functiondecl'>
2022 XkbAllocIndicatorMaps</emphasis>
2029 <entry role='functionargdecl'>
2030 XkbDescPtr <emphasis>
2032 ; /* keyboard description structure */
2042 parameter must point to a valid keyboard description. If it doesn’t,
2044 XkbAllocIndicatorMaps</emphasis>
2045 returns a <emphasis>
2047 error. Otherwise, <emphasis>
2048 XkbAllocIndicatorMaps</emphasis>
2049 allocates and initializes the <emphasis>
2050 indicators</emphasis>
2051 member of the keyboard description record and returns <emphasis>
2054 XkbAllocIndicatorMaps</emphasis>
2055 was unable to allocate the indicators record, it reports a Bad<emphasis>
2061 To free memory used by the <emphasis>
2062 indicators</emphasis>
2063 member of an <emphasis>
2064 XkbDescRec</emphasis>
2065 structure, use <emphasis>
2066 XkbFreeIndicatorMaps.</emphasis>
2069 <informaltable frame='none'>
2070 <?dbfo keep-together="always" ?>
2071 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
2072 <colspec colname='c1' colwidth='1.0*'/>
2075 <entry role='functiondecl'>
2077 XkbFreeIndicatorMaps</emphasis>
2084 <entry role='functionargdecl'>
2085 XkbDescPtr <emphasis>
2087 ; /* keyboard description structure */
2095 If the <emphasis>indicators</emphasis>
2096 member of the keyboard description record
2097 pointed to by <emphasis>xkb</emphasis>
2098 is not <emphasis>NULL</emphasis>
2099 , <emphasis>XkbFreeIndicatorMaps</emphasis>
2100 frees the memory associated with
2101 the <emphasis>indicators</emphasis>
2102 member of <emphasis>xkb</emphasis>.