1 <chapter id='X_Library_Controls'>
2 <title>X Library Controls</title>
5 The Xkb extension is composed of two parts: a server extension, and a
6 client-side X library extension. Chapter 10 discusses functions used to modify
7 controls affecting the behavior of the server portion of the Xkb extension.
8 This chapter discusses functions used to modify controls that affect only the
9 behavior of the client portion of the extension; these controls are known as
15 All of the Library Controls are boolean flags that may be enabled and disabled.
16 The controls can be divided into several categories:
22 Controls affecting general string lookups
27 Controls affecting compose processing
32 Controls affecting event delivery
38 There are two types of string lookups performed by <emphasis>
39 XLookupString</emphasis>
40 . The first type involves translating a single keycode into a string; the
41 controls in the first category affect this type of lookup. The second type
42 involves translating a series of keysyms into a string; the controls in the
43 second category affect this type of lookup.
48 An Xkb implementation is required to support the programming interface for all
49 of the controls. However, an implementation may choose not to support the
50 semantics associated with the controls that deal with compose processing. In
51 this case, a program that accesses these controls should still function
52 normally; however, the feedback that would normally occur with the controls
53 enabled may be missing.
56 <sect1 id='Controls_Affecting_Keycode_to_String_Translation'>
57 <title>Controls Affecting Keycode-to-String Translation</title>
60 The first type of string lookups, which are here called <emphasis>
61 simple string lookups</emphasis>
62 , involves translating a single keycode into a string. Because these simple
63 lookups involve only a single keycode, all of the information needed to do the
64 translation is contained in the keyboard state in a single event. The controls
65 affecting simple string lookups are:
68 <para><programlisting>
69 <emphasis>ForceLatin1Lookup</emphasis>
70 <emphasis>ConsumeLookupMods</emphasis>
71 <emphasis>LevelOneUsesShiftAndLock</emphasis>
72 </programlisting></para>
74 <sect2 id='ForceLatin1Lookup'>
75 <title>ForceLatin1Lookup</title>
79 ForceLatin1Lookup</emphasis>
80 control is enabled, <emphasis>
81 XLookupString</emphasis>
82 only returns strings using the Latin1 character set. If <emphasis>
83 ForceLatin1Lookup</emphasis>
84 is not enabled, <emphasis>
85 XLookupString</emphasis>
86 can return characters that are not in the Latin1 set. By default, this control
87 is disabled, allowing characters outside of the Latin1 set to be returned.
92 <sect2 id='ConsumeLookupMods'>
93 <title>ConsumeLookupMods</title>
96 Simple string lookups in <emphasis>
97 XLookupString</emphasis>
98 involve two different translation phases. The first phase translates raw
99 device keycodes to individual keysyms. The second phase attempts to map the
100 resulting keysym into a string of one or more characters. In the first phase,
101 some of the modifiers are normally used to determine the appropriate shift
108 ConsumeLookupMods</emphasis>
109 control determines whether or not <emphasis>
110 XLookupString</emphasis>
113 the modifiers it uses during the first phase of processing (mapping a keycode
114 to a keysym). When a modifier is consumed, it is effectively removed from the
115 working copy of the keyboard state information <emphasis>
116 XLookupString</emphasis>
117 is using and appears to be unset for the remainder of the processing.
123 ConsumeLookupMods</emphasis>
124 control is enabled, <emphasis>
125 XLookupString</emphasis>
126 does not use the modifiers used to translate the keycode of the event to a
127 keysym when it is determining the string associated with a keysym. For example,
128 assume the keymap for the ‘A’ key only contains the shift modifier and the
130 ConsumeLookupMods</emphasis>
131 control is enabled. If a user presses the <emphasis>
133 key and the <emphasis>
135 key while the <emphasis>
137 key is locked, <emphasis>
138 XLookupString</emphasis>
141 modifier when mapping the keycode for the ‘a’ key to the keysym for
142 ‘A’; subsequently, it only uses the <emphasis>
144 modifier when determining the string associated with the keysym ‘A’.
150 ConsumeLookupMods</emphasis>
151 control is not enabled, <emphasis>
152 XLookupString</emphasis>
153 uses all of the event modifiers to determine the string associated with a
154 keysym. This behavior mirrors the behavior of <emphasis>
155 XLookupString</emphasis>
156 in the core implementation.
162 ConsumeLookupMods</emphasis>
163 control is unset by default. For more information on modifier consumption,
169 <sect2 id='AlwaysConsumeShiftAndLock'>
170 <title>AlwaysConsumeShiftAndLock</title>
174 AlwaysConsumeShiftAndLock</emphasis>
175 control, if enabled, forces <emphasis>
176 XLookupString</emphasis>
177 to consume the <emphasis>
181 modifiers when processing all keys, even if the definition for the key type
182 does not specify these modifiers. The <emphasis>
183 AlwaysConsumeShiftAndLock</emphasis>
184 control is unset by default. See section 15.2 for a discussion of key types.
190 <sect1 id='Controls_Affecting_Compose_Processing'>
191 <title>Controls Affecting Compose Processing</title>
194 The second type of string lookup performed by <emphasis>
195 XLookupString</emphasis>
196 involves translating a series of keysyms into a string. Because these lookups
197 can involve more than one key event, they require <emphasis>
198 XLookupString</emphasis>
199 to retain some state information between successive calls. The process of
200 mapping a series of keysyms to a string is known as <emphasis>
201 compose processing</emphasis>
202 . The controls affecting compose processing are:
205 <para><programlisting>
206 <emphasis>ConsumeKeysOnComposeFail</emphasis>
207 <emphasis>ComposeLED</emphasis>
208 <emphasis>BeepOnComposeFail</emphasis>
209 </programlisting></para>
212 Because different vendors have historically used different algorithms to
213 implement compose processing, and these algorithms may be incompatible with the
214 semantics required by the Xkb compose processing controls, implementation of
215 the compose processing controls is optional in an Xkb implementation.
219 <sect2 id='ConsumeKeysOnComposeFail'>
220 <title>ConsumeKeysOnComposeFail</title>
223 Some compose processing algorithms signal the start of a compose sequence by a
224 key event meaning "start compose".
226 Another possibility is to have the compose processing simply be the result of a finite state acceptor; a compose sequence would never fail for a properly written finite state acceptor.
228 The subsequent key events should normally result in a valid composition yielding a
229 valid translation to a string. If the subsequent key events do not have a valid
230 translation, some decision must be made about what to do with the key events
231 that were processed while attempting the compose. The <emphasis>
232 ConsumeKeysOnComposeFail</emphasis>
233 control allows a client to specify what happens with the key events <emphasis>
234 XLookupString</emphasis>
235 has been considering when it reaches a dead end in a compose sequence.
241 ConsumeKeysOnComposeFail</emphasis>
242 control is set, all keys associated with a failed compose sequence should be
243 consumed (discarded). If the <emphasis>
244 ConsumeKeysOnComposeFail</emphasis>
245 control is not set, the key events associated with a failed compose sequence
246 should be processed as a normal sequence of key events.
252 ConsumeKeysOnComposeFail</emphasis>
253 control is disabled by default.
258 <sect2 id='ComposeLED'>
259 <title>ComposeLED</title>
263 ComposeLED</emphasis>
264 control allows a client to specify whether or not an indicator should be set
265 and cleared to provide feedback when compose processing is in progress. The
266 control does not specify which indicator should be used; the mapping for this
267 is up to the individual implementation. If the <emphasis>
268 ComposeLED</emphasis>
269 control is enabled, it specifies that an indicator should be set when a
270 compose sequence is in progress and cleared when one is not in progress. The
272 ComposeLED</emphasis>
273 control is disabled by default.
278 While the Xkb extension does not specify the type of type of indicator to be
279 used when the <emphasis>
280 ComposeLED</emphasis>
281 control is implemented, a consistent convention between implementations is to
282 everyone’s benefit. If a named indicator is used for this purpose, the
283 recommended name is "<emphasis>
285 ". Note that some implementations may use an unnamed, custom hardware LED for
291 <sect2 id='BeepOnComposeFail'>
292 <title>BeepOnComposeFail</title>
296 BeepOnComposeFail</emphasis>
297 control allows a client to specify whether or not a bell should be activated
298 to provide feedback when a compose sequence fails. The control does not specify
299 the type of bell that should be used; the mapping for this is up to the
300 individual implementation. If the <emphasis>
301 BeepOnComposeFail</emphasis>
302 control is enabled, it specifies that a bell should be activated when a
303 compose sequence fails. The <emphasis>
304 BeepOnComposeFail</emphasis>
305 control is disabled by default. If implemented, the bell should be activated
309 XkbDeviceBell</emphasis>
315 While the Xkb extension does not specify the type of bell to be used when the
317 BeepOnComposeFail</emphasis>
318 control is implemented, a consistent convention between implementations is to
319 everyone’s benefit. If a named bell is used for this purpose, the recommended
321 ComposeFail</emphasis>
328 <sect1 id='Controls_Effecting_Event_Delivery'>
329 <title>Controls Effecting Event Delivery</title>
331 <sect2 id='IgnoreNewKeyboards'>
332 <title>IgnoreNewKeyboards</title>
335 When Xkb is initialized, it implicitly forces requests for <emphasis>
336 NewKeyboardNotify</emphasis>
337 events. These events may be used by the Xkb library extension internally; they
338 are normally translated into core protocol <emphasis>
339 MappingNotify</emphasis>
340 events before being passed to the client. While delivering the event to the
341 client is appropriate in most cases, it is not appropriate for some clients
342 that maintain per-key data structures. This is because once the server has sent
344 NewKeyboardNotify</emphasis>
345 event, it is free to send the client events for all keys in the new range and
346 that range may be outside of the per-key data structures the client is
353 IgnoreNewKeyboards</emphasis>
354 control, if enabled, prevents Xkb from mapping <emphasis>
355 NewKeyboardNotify</emphasis>
356 events to core <emphasis>
357 MappingNotify</emphasis>
358 events and passing them to the client. The control is initially disabled.
364 <sect1 id='Manipulating_the_Library_Controls'>
365 <title>Manipulating the Library Controls</title>
368 The Library Controls are manipulated using functions that deal with bitmasks to
369 indicate which controls to manipulate. The controls are identified by the masks
370 defined in Table 11.1. <!-- xref -->
373 <table frame='topbot'>
374 <title>Library Control Masks</title>
375 <?dbfo keep-together="always" ?>
376 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
377 <colspec colname='c1' colwidth='1.0*'/>
378 <colspec colname='c2' colwidth='1.0*'/>
381 <entry>Library Control Mask</entry>
387 <entry>XkbLC_ForceLatin1Lookup</entry>
388 <entry>(1 << 0)</entry>
391 <entry>XkbLC_ConsumeLookupMods</entry>
392 <entry>(1 << 1)</entry>
395 <entry>XkbLC_AlwaysConsumeShiftAndLock</entry>
396 <entry>(1 << 2)</entry>
399 <entry>XkbLC_IgnoreNewKeyboards</entry>
400 <entry>(1 << 3)</entry>
403 <entry>XkbLC_ConsumeKeysOnComposeFail</entry>
404 <entry>(1 << 29)</entry>
407 <entry>XkbLC_ComposeLED</entry>
408 <entry>(1 << 30)</entry>
411 <entry>XkbLC_BeepOnComposeFail</entry>
412 <entry>(1 << 31)</entry>
415 <entry>XkbLC_AllControls</entry>
416 <entry>(0xc0000007)</entry>
422 <sect2 id='Determining_Which_Library_Controls_are_Implemented'>
423 <title>Determining Which Library Controls are Implemented</title>
426 To determine which Library Controls are actually
427 implemented, use <emphasis>XkbXlibControlsImplemented</emphasis>.
430 <informaltable frame='none'>
431 <?dbfo keep-together="always" ?>
432 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
433 <colspec colname='c1' colwidth='1.0*'/>
436 <entry role='functiondecl'>
437 unsigned int <emphasis>
438 XkbXlibControlsImplemented</emphasis>
445 <entry role='functionargdecl'>
448 ; /* connection to X server */
457 XkbXlibControlsImplemented</emphasis>
458 returns a bitmask indicating the controls actually implemented in the Xkb
459 library and is composed of an inclusive OR of bits from Table 11.1.
464 <sect2 id='Determining_the_State_of_the_Library_Controls'>
465 <title>Determining the State of the Library Controls</title>
468 To determine the current state of the Library Controls, use <emphasis>
469 XkbGetXlibControls</emphasis>
473 <informaltable frame='none'>
474 <?dbfo keep-together="always" ?>
475 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
476 <colspec colname='c1' colwidth='1.0*'/>
479 <entry role='functiondecl'>
480 unsigned int <emphasis>
481 XkbGetXlibControls</emphasis>
488 <entry role='functionargdecl'>
491 ; /* connection to X server */
500 XkbGetXlibControls</emphasis>
501 returns the current state of the Library Controls as a bit mask that is an
502 inclusive OR of the control masks from Table 11.1 for the controls that are
503 enabled. For the optional compose processing controls, the fact that a control
504 is enabled does not imply that it is actually implemented.
508 <sect2 id='Changing_the_State_of_the_Library_Controls'>
509 <title>Changing the State of the Library Controls</title>
512 To change the state of the Library Controls, use
513 <emphasis>XkbSetXlibControls</emphasis>.
516 <informaltable frame='none'>
517 <?dbfo keep-together="always" ?>
518 <tgroup cols='1' align='left' colsep='0' rowsep='0'>
519 <colspec colname='c1' colwidth='1.0*'/>
522 <entry role='functiondecl'>
524 XkbSetXlibControls</emphasis>
526 display, bits_to_change, values_for_bits</emphasis>
531 <entry role='functionargdecl'>
534 ; /* connection to X server */
538 <entry role='functionargdecl'>
539 unsigned long <emphasis>
540 bits_to_change</emphasis>
541 ; /* selects controls to be modified */
545 <entry role='functionargdecl'>
546 unsigned long <emphasis>
547 values_for_bits</emphasis>
548 ; /* turns selected controls on (1) or off (0) */
557 XkbSetXlibControls</emphasis>
558 modifies the state of the controls selected by <emphasis>
559 bits_to_change</emphasis>
560 ; only the controls selected by <emphasis>
561 bits_to_change</emphasis>
562 are modified. If the bit corresponding to a control is on in <emphasis>
563 bits_to_change</emphasis>
564 and also on in values_for_bits, the control is enabled. If the bit
565 corresponding to a control is on in <emphasis>
566 bits_to_change</emphasis>
567 but off in <emphasis>
568 values_for_bits</emphasis>
569 , the control is disabled. <emphasis>
570 bits_to_change</emphasis>
571 should be an inclusive OR of bits from Table 11.1.