1 <chapter id='Keyboard_Indicators'>
2 <title>Keyboard Indicators</title>
5 Although the core X protocol supports thirty-two LEDs on a keyboard, it does
6 not provide any way to link the state of the LEDs and the logical state of the
7 keyboard. For example, most keyboards have a "Caps Lock" LED, but X does not
8 provide any standard way to make the LED automatically follow the logical state
9 of the modifier bound to the <emphasis>
16 The core protocol also gives no way to determine which bits in the <emphasis>
18 field of the keyboard state map to the particular LEDs on the keyboard. For
19 example, X does not provide a method for a client to determine which bit to set
22 to turn on the "Scroll Lock" LED, or even if the keyboard has a "Scroll Lock"
28 Most X servers implement some kind of automatic behavior for one or more of the
29 keyboard LEDs, but the details of that automatic behavior are
30 implementation-specific and can be difficult or impossible to control.
35 XKB provides indicator names and programmable indicators to help solve these
36 problems. Using XKB, clients can determine the names of the various indicators,
37 determine and control the way that the individual indicators should be updated
38 to reflect keyboard changes, and determine which of the 32 keyboard indicators
39 reported by the protocol are actually present on the keyboard. Clients may also
40 request immediate notification of changes to the state of any subset of the
41 keyboard indicators, which makes it straightforward to provide an on-screen
45 <sect1 id='Global_Information_About_Indicators'>
46 <title>Global Information About Indicators</title>
49 XKB provides only two pieces of information about the indicators as a group.
55 physical indicators</emphasis>
56 mask reports which of the 32 logical keyboard indicators supported by the core
57 protocol and XKB corresponds to some actual indicator on the keyboard itself.
58 Because the physical indicators mask describes a physical characteristic of the
59 keyboard, it cannot be directly changed under program control. It is possible,
60 however, for the set of physical indicators to be change if a new keyboard is
61 attached or if a completely new keyboard description is loaded by the <emphasis>
62 XkbGetKeyboardByName</emphasis>
63 request (see <link linkend='Using_the_Servers_Database_of_Keyboard_Components'>Using the Server’s
64 Database of Keyboard Components</link>).
70 indicator state</emphasis>
71 mask reports the current state of the 32 logical keyboard indicators. This
72 field and the core protocol indicator state (as reported by the <emphasis>
74 field of the core protocol <emphasis>
75 GetKeyboardControl</emphasis>
76 request) are always identical.
81 <sect1 id='Per_Indicator_Information'>
82 <title>Per-Indicator Information</title>
85 Each of the thirty-two keyboard indicators has a symbolic name, of type ATOM.
87 XkbGetNames</emphasis>
88 request reports the symbolic names for all keyboard components, including the
89 indicators. Use the <emphasis>
90 XkbSetNames</emphasis>
91 request to change symbolic names. Both requests are described in <link linkend='Querying_and_Changing_Symbolic_Names'>Querying and Changing Symbolic
96 <sect2 id='Indicator_Maps'>
97 <title>Indicator Maps</title>
100 XKB also provides an <emphasis>
101 indicator map</emphasis>
102 for each of the thirty-two keyboard indicators; an indicator map specifies:
107 <para>The conditions under which the keyboard modifier state affects the
112 <para>The conditions under which the keyboard group state affects the
117 <para>The conditions under which the state of the boolean controls affects
122 <para>The effect (if any) of attempts to explicitly change the state of the
123 indicator using the core protocol <emphasis>
124 SetKeyboardControl</emphasis>
132 IM_NoAutomatic</emphasis>
133 is set in the <emphasis>
135 field of an indicator map, that indicator never changes in response to changes
136 in keyboard state or controls, regardless of the values for the other fields of
137 the indicator map. If <emphasis>
138 IM_NoAutomatic</emphasis>
139 is not set in <emphasis>
141 , the other fields of the indicator map specify the automatic changes to the
142 indicator in response to changes in the keyboard state or controls.
148 which_groups</emphasis>
151 fields of an indicator map determine how the keyboard group state affects the
152 corresponding indicator. The <emphasis>
153 which_groups</emphasis>
154 field controls the interpretation of <emphasis>
156 and may contain any one of the following values:
159 <informaltable frame='topbot'>
160 <?dbfo keep-together="always" ?>
161 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
162 <colspec colname='c1' colwidth='1.0*'/>
163 <colspec colname='c2' colwidth='3.0*'/>
167 <entry>Interpretation of the Groups Field</entry>
173 IM_UseNone</emphasis>
175 <entry>The <emphasis>
177 field and the current keyboard group state are ignored.</entry>
181 IM_UseBase</emphasis>
185 is non-zero, the indicator is lit whenever the base keyboard group is
186 non-zero. If <emphasis>
188 is zero, the indicator is lit whenever the base keyboard group is zero.</entry>
192 IM_UseLatched</emphasis>
196 is non-zero, the indicator is lit whenever the latched keyboard group is
197 non-zero. If <emphasis>
199 is zero, the indicator is lit whenever the latched keyboard group is
204 IM_UseLocked</emphasis>
206 <entry>The <emphasis>
208 field is interpreted as a mask. The indicator is lit when the current locked
209 keyboard group matches one of the bits that are set in <emphasis>
215 IM_UseEffective</emphasis>
217 <entry>The <emphasis>
219 field is interpreted as a mask. The indicator is lit when the current
220 effective keyboard group matches one of the bits that are set in <emphasis>
230 which_mods</emphasis>
233 fields of an indicator map determine how the state of the keyboard modifiers
234 affect the corresponding indicator. The <emphasis>
236 field is an XKB modifier definition, as described in <link linkend='Modifier_Definitions'>Modifier Definitions</link>, which can
237 specify both real and virtual modifiers. The mods field takes effect even if
238 some or all of the virtual indicators specified in <emphasis>
246 which_mods</emphasis>
247 field can specify one or more components of the XKB keyboard state. The
248 corresponding indicator is lit whenever any of the real modifiers specified in
251 field of the <emphasis>
253 modifier definition are also set in any of the current keyboard state
254 components specified by the <emphasis>
255 which_mods</emphasis>
257 which_mods</emphasis>
258 field may have any combination of the following values:
261 <informaltable frame='topbot'>
262 <?dbfo keep-together="always" ?>
263 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
264 <colspec colname='c1' colwidth='1.0*'/>
265 <colspec colname='c2' colwidth='3.0*'/>
269 <entry>Keyboard State Component To Be Considered</entry>
275 IM_UseBase</emphasis>
277 <entry>Base modifier state</entry>
281 IM_UseLatched</emphasis>
283 <entry>Latched modifier state</entry>
287 IM_UseLocked</emphasis>
289 <entry>Locked modifier state</entry>
293 IM_UseEffective</emphasis>
295 <entry>Effective modifier state</entry>
299 IM_UseCompat</emphasis>
301 <entry>Modifier compatibility state</entry>
310 field specifies a subset of the boolean keyboard controls (see <link linkend='Boolean_Controls_and_The_EnabledControls_Control'>"Boolean" Controls and The
311 EnabledControls Control</link>). The indicator is lit whenever any of the
312 boolean controls specified in <emphasis>
319 An indicator is lit whenever any of the conditions specified by its indicator
320 map are met, unless overridden by the <emphasis>
321 IM_NoAutomatic</emphasis>
322 flag (described above) or an explicit indicator change (described below).
326 <sect3 id='Effects_of_Explicit_Changes_on_Indicators'>
327 <title>Effects of Explicit Changes on Indicators</title>
331 IM_NoExplicit</emphasis>
332 flag is set in an indicator map, attempts to change the state of the indicator
339 IM_NoExplicit</emphasis>
341 IM_NoAutomatic</emphasis>
342 are both absent from an indicator map, requests to change the state of the
343 indicator are honored but might be immediately superseded by automatic changes
344 to the indicator state which reflect changes to keyboard state or controls.
350 IM_LEDDrivesKB</emphasis>
351 flag is set and the <emphasis>
352 IM_NoExplicit</emphasis>
353 flag is not, the keyboard state and controls are changed to reflect the other
354 fields of the indicator map, as described in the remainder of this section.
355 Attempts to explicitly change the value of an indicator for which <emphasis>
356 IM_LEDDrivesKB</emphasis>
357 is absent or for which <emphasis>
358 IM_NoExplicit</emphasis>
359 is present do not affect keyboard state or controls.
364 The effect on group state of changing an explicit indicator which drives the
365 keyboard is determined by the value of <emphasis>
366 which_groups</emphasis>
372 <informaltable frame='topbot'>
373 <?dbfo keep-together="always" ?>
374 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
375 <colspec colname='c1' colwidth='2.0*'/>
376 <colspec colname='c2' colwidth='1.0*'/>
377 <colspec colname='c3' colwidth='2.0*'/>
380 <entry> which_groups</entry>
381 <entry>New State</entry>
382 <entry>Effect on Keyboard Group State</entry>
388 IM_UseNone</emphasis>
390 IM_UseBase</emphasis>
392 <entry>On or Off</entry>
393 <entry>No Effect</entry>
397 IM_UseLatched</emphasis>
400 <entry>The <emphasis>
402 field is treated as a group mask. The keyboard group latch is changed to the
403 lowest numbered group specified in <emphasis>
407 is empty, the keyboard group latch is changed to zero.</entry>
410 <entry>IM_UseLatched</entry>
412 <entry>The <emphasis>
414 field is treated as a group mask. If the indicator is explicitly extinguished,
415 keyboard group latch is changed to the lowest numbered group not specified in
420 is zero, the keyboard group latch is set to the index of the highest legal
421 keyboard group.</entry>
425 IM_UseLocked</emphasis>
427 IM_UseEffective</emphasis>
430 <entry>If the <emphasis>
432 mask is empty, group is not changed, otherwise the locked keyboard group is
433 changed to the lowest numbered group specified in <emphasis>
439 IM_UseLocked</emphasis>
441 IM_UseEffective</emphasis>
444 <entry>Locked keyboard group is changed to the lowest numbered group that
445 is not specified in the <emphasis>
447 mask, or to <emphasis>
451 mask contains all keyboard groups.</entry>
458 The effect on the keyboard modifiers of changing an explicit indicator which
459 drives the keyboard is determined by the values that are set in of <emphasis>
460 which_mods</emphasis>
466 <informaltable frame='topbot'>
467 <?dbfo keep-together="always" ?>
468 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
469 <colspec colname='c1' colwidth='1.0*'/>
470 <colspec colname='c2' colwidth='1.0*'/>
471 <colspec colname='c3' colwidth='3.0*'/>
474 <entry>Set in which_mods</entry>
475 <entry>New State</entry>
476 <entry>Effect on Keyboard Modifiers</entry>
482 IM_UseBase</emphasis>
484 <entry>On or Off</entry>
485 <entry>No Effect</entry>
489 IM_UseLatched</emphasis>
492 <entry>Any modifiers specified in the <emphasis>
496 are added to the latched modifiers.</entry>
500 IM_UseLatched</emphasis>
503 <entry>Any modifiers specified in the <emphasis>
507 are removed from the latched modifiers.</entry>
511 IM_UseLocked</emphasis>
513 IM_UseCompat</emphasis>
515 IM_UseEffective</emphasis>
518 <entry>Any modifiers specified in the <emphasis>
522 are added to the locked modifiers.</entry>
526 IM_UseLocked</emphasis>
529 <entry>Any modifiers specified in the <emphasis>
533 are removed from the locked modifiers.</entry>
537 IM_UseCompat</emphasis>
539 IM_UseEffective</emphasis>
542 <entry>Any modifiers specified in the <emphasis>
546 are removed from both the locked and latched modifiers.</entry>
553 Lighting an explicit indicator which drives the keyboard also enables all of
554 the boolean controls specified in the <emphasis>
556 field of its indicator map. Explicitly extinguishing such an indicator
557 disables all of the boolean controls specified in <emphasis>
564 The effects of changing an indicator which drives the keyboard are cumulative;
565 it is possible for a single change to affect keyboard group, modifiers and
566 controls simultaneously.
571 If an indicator for which both the <emphasis>
572 IM_LEDDrivesKB</emphasis>
574 IM_NoAutomatic</emphasis>
575 flags are specified is changed, the keyboard changes specified above are
576 applied and the indicator is changed to reflect the state that was explicitly
577 requested. The indicator will remain in the new state until it is explicitly
584 IM_NoAutomatic</emphasis>
585 flag is not set for an indicator which drives the keyboard, the changes
586 specified above are applied and the state of the indicator is set to the values
587 specified by the indicator map. Note that it is possible in this case for the
588 indicator to end up in a different state than the one that was explicitly
589 requested. For example, an indicator with <emphasis>
590 which_mods</emphasis>
592 IM_UseBase</emphasis>
597 is not extinguished if one of the <emphasis>
599 keys is physically depressed when the request to extinguish the indicator is