ch09.xml revision eb411b4b
1<chapter id='Bells'>
2<title>Bells</title>
3
4<para>
5The core X protocol allows only applications to explicitly sound the system
6bell with a given duration, pitch, and volume. Xkb extends this capability by
7allowing clients to attach symbolic names to bells, disable audible bells, and
8receive an event whenever the keyboard bell is rung. For the purposes of this
9document, the <emphasis>
10audible</emphasis>
11 bell is defined to be the system bell, or the default keyboard bell, as
12opposed to any other audible sound generated elsewhere in the system.
13</para>
14
15
16<para>
17You can ask to receive <emphasis>
18XkbBellNotify</emphasis>
19 events (see section 9.4) when any client rings any one of the following: <!-- xref -->
20</para>
21
22<itemizedlist>
23<listitem>
24  <para>
25The default bell
26  </para>
27</listitem>
28<listitem>
29  <para>
30Any bell on an input device that can be specified by a <emphasis>
31bell_class</emphasis>
32 and <emphasis>
33bell_id</emphasis>
34 pair
35  </para>
36</listitem>
37<listitem>
38  <para>
39Any bell specified only by an arbitrary name. (This is, from the server’s
40point of view, merely a name, and not connected with any physical
41sound-generating device. Some client application must generate the sound, or
42visual feedback, if any, that is associated with the name.)
43  </para>
44</listitem>
45</itemizedlist>
46
47<para>
48You can also ask to receive <emphasis>
49XkbBellNotify</emphasis>
50 events when the server rings the default bell or if any client has requested
51events only (without the bell sounding) for any of the bell types previously
52listed.
53</para>
54
55<para>
56You can disable audible bells on a global basis (to set the <emphasis>
57AudibleBell</emphasis>
58 control, see Chapter 10). For example, a client that replaces the keyboard
59bell with some other audible cue might want to turn off the <emphasis>
60AudibleBell</emphasis>
61 control to prevent the server from also generating a sound and avoid
62cacophony. If you disable audible bells and request to receive <emphasis>
63XkbBellNotify</emphasis>
64 events, you can generate feedback different from the default bell.
65</para>
66
67
68<para>
69You can, however, override the <emphasis>
70AudibleBell</emphasis>
71 control by calling one of the functions that force the ringing of a bell in
72spite of the setting of the <emphasis>
73AudibleBell</emphasis>
74 control — <emphasis>
75XkbForceDeviceBell</emphasis>
76 or <emphasis>
77XkbForceBell</emphasis>
78 (see section 9.3.3). In this case the server does not generate a bell event. <!-- xref -->
79</para>
80
81
82<para>
83Just as some keyboards can produce keyclicks to indicate when a key is pressed
84or repeating, Xkb can provide feedback for the controls by using special beep
85codes. The <emphasis>
86AccessXFeedback</emphasis>
87 control is used to configure the specific types of operations that generate
88feedback. See section 10.6.3 for a discussion on <emphasis> <!-- xref -->
89AccessXFeedback</emphasis>
90 control.
91</para>
92
93<para>
94This chapter describes bell names, the functions used to generate named bells,
95and the events the server generates for bells.
96</para>
97
98<sect1 id='Bell_Names'>
99<title>Bell Names</title>
100
101<para>
102You can associate a name to an act of ringing a bell by converting the name to
103an Atom and then using this name when you call the functions listed in this
104chapter. If an event is generated as a result, the name is then passed to all
105other clients interested in receiving <emphasis>
106XkbBellNotify</emphasis>
107 events. Note that these are arbitrary names and that there is no binding to
108any sounds. Any sounds or other effects (such as visual bells on the screen)
109must be generated by a client application upon receipt of the bell event
110containing the name. There is no default name for the default keyboard bell.
111The server does generate some predefined bells for the AccessX controls (see
112section 10.6.3). These named bells are shown in Table 9.1; the name is included
113in any bell event sent to clients that have requested to receive <emphasis>
114XkbBellNotify</emphasis>
115 events.
116</para>
117
118<table frame='topbot'>
119<title>Predefined Bells</title>
120<?dbfo keep-together="always" ?>
121<tgroup cols='2' align='left' colsep='0' rowsep='0'>
122<colspec colname='c1' colwidth='1.0*'/>
123<colspec colname='c2' colwidth='1.0*'/>
124<thead>
125<row rowsep='1'>
126  <entry>Action</entry>
127  <entry>Named Bell</entry>
128</row>
129</thead>
130<tbody>
131<row>
132    <entry>Indicator turned on</entry>
133    <entry>AX_IndicatorOn</entry>
134</row>
135<row>
136    <entry>Indicator turned off</entry>
137    <entry>AX_IndicatorOff</entry>
138</row>
139<row>
140    <entry>More than one indicator changed state</entry>
141    <entry>AX_IndicatorChange</entry>
142</row>
143<row>
144    <entry>Control turned on</entry>
145    <entry>AX_FeatureOn</entry>
146</row>
147<row>
148    <entry>Control turned off</entry>
149    <entry>AX_FeatureOff</entry>
150</row>
151<row>
152    <entry>More than one control changed state</entry>
153    <entry>AX_FeatureChange</entry>
154</row>
155<row>
156    <entry>SlowKeys and BounceKeys about to be turned on or off</entry>
157    <entry>AX_SlowKeysWarning</entry>
158</row>
159<row>
160    <entry>SlowKeys key pressed</entry>
161    <entry>AX_SlowKeyPress</entry>
162</row>
163<row>
164    <entry>SlowKeys key accepted</entry>
165    <entry>AX_SlowKeyAccept</entry>
166</row>
167<row>
168    <entry>SlowKeys key rejected</entry>
169    <entry>AX_SlowKeyReject</entry>
170</row>
171<row>
172    <entry>Accepted SlowKeys key released</entry>
173    <entry>AX_SlowKeyRelease</entry>
174</row>
175<row>
176    <entry>BounceKeys key rejected</entry>
177    <entry>AX_BounceKeyReject</entry>
178</row>
179<row>
180    <entry>StickyKeys key latched</entry>
181    <entry>AX_StickyLatch</entry>
182</row>
183<row>
184    <entry>StickyKeys key locked</entry>
185    <entry>AX_StickyLock</entry>
186</row>
187<row>
188    <entry>StickyKeys key unlocked</entry>
189    <entry>AX_StickyUnlock</entry>
190  </row>
191</tbody>
192</tgroup>
193</table>
194
195</sect1>
196<sect1 id='Audible_Bells'>
197<title>Audible Bells</title>
198
199<para>
200Using Xkb you can generate bell events that do not necessarily ring the system
201bell. This is useful if you need to use an audio server instead of the system
202beep. For example, when an audio client starts, it could disable the audible
203bell (the system bell) and then listen for <emphasis>
204XkbBellNotify</emphasis>
205 events (see section 9.4). When it receives a <emphasis> <!-- xref -->
206XkbBellNotify</emphasis>
207 event, the audio client could then send a request to an audio server to play a
208sound.
209</para>
210
211
212<para>
213You can control the audible bells feature by passing the <emphasis>
214XkbAudibleBellMask</emphasis>
215 to <emphasis>
216XkbChangeEnabledControls</emphasis>
217 (see section 10.1.1). If you set <emphasis> <!-- xref -->
218XkbAudibleBellMask</emphasis>
219 on, the server rings the system bell when a bell event occurs. This is the
220default. If you set <emphasis>
221XkbAudibleBellMask</emphasis>
222 off and a bell event occurs, the server does not ring the system bell unless
223you call <emphasis>
224XkbForceDeviceBell</emphasis>
225 or <emphasis>
226XkbForceBell</emphasis>
227 (see section 9.3.3). <!-- xref -->
228</para>
229
230<para>
231Audible bells are also part of the per-client auto-reset controls. For more
232information on auto-reset controls, see section 10.1.2. <!-- xref -->
233</para>
234
235</sect1>
236<sect1 id='Bell_Functions'>
237<title>Bell Functions</title>
238
239<para>
240Use the functions described in this section to ring bells and to generate bell
241events.
242</para>
243
244<para>
245The input extension has two types of feedbacks that can generate bells — bell
246feedback and keyboard feedback. Some of the functions in this section have
247<emphasis>
248bell_class</emphasis>
249 and <emphasis>
250bell_id</emphasis>
251 parameters; set them as follows: Set <emphasis>
252bell_class</emphasis>
253 to <emphasis>
254BellFeedbackClass</emphasis>
255 or <emphasis>
256KbdFeedbackClass</emphasis>
257. A device can have more than one feedback of each type; set <emphasis>
258bell_id</emphasis>
259 to the particular bell feedback of <emphasis>
260bell_class</emphasis>
261 type.
262</para>
263
264<para>
265Table 9.2 shows the conditions that cause a bell to sound or an <emphasis> <!-- xref -->
266XkbBellNotifyEvent</emphasis>
267 to be generated when a bell function is called.
268</para>
269
270<table frame='topbot'>
271<title>Bell Sounding and Bell Event Generating</title>
272<?dbfo keep-together="always" ?>
273<tgroup cols='4' align='left' colsep='0' rowsep='0'>
274<colspec colname='c1' colwidth='1.0*'/>
275<colspec colname='c2' colwidth='1.0*'/>
276<colspec colname='c3' colwidth='1.0*'/>
277<colspec colname='c4' colwidth='1.0*'/>
278<thead>
279  <row rowsep='1'>
280    <entry>Function called</entry>
281    <entry>AudibleBell</entry>
282    <entry>Server sounds a bell</entry>
283    <entry>Server sends an XkbBellNotifyEvent</entry>
284  </row>
285</thead>
286<tbody>
287<row>
288    <entry>XkbDeviceBell</entry>
289    <entry>On</entry>
290    <entry>Yes</entry>
291    <entry>Yes</entry>
292</row>
293<row>
294    <entry>XkbDeviceBell</entry>
295    <entry>Off</entry>
296    <entry>No</entry>
297    <entry>Yes</entry>
298</row>
299<row>
300    <entry>XkbBell</entry>
301    <entry>On</entry>
302    <entry>Yes</entry>
303    <entry>Yes</entry>
304</row>
305<row>
306    <entry>XkbBell</entry>
307    <entry>Off</entry>
308    <entry>No</entry>
309    <entry>Yes</entry>
310</row>
311<row>
312    <entry>XkbDeviceBellEvent</entry>
313    <entry>On or Off</entry>
314    <entry>No</entry>
315    <entry>Yes</entry>
316</row>
317<row>
318    <entry>XkbBellEvent</entry>
319    <entry>On or Off</entry>
320    <entry>No</entry>
321    <entry>Yes</entry>
322</row>
323<row>
324    <entry>XkbDeviceForceBell</entry>
325    <entry>On or Off</entry>
326    <entry>Yes</entry>
327    <entry>No</entry>
328</row>
329<row>
330    <entry>XkbForceBell</entry>
331    <entry>On or Off</entry>
332    <entry>Yes</entry>
333    <entry>No</entry>
334  </row>
335</tbody>
336</tgroup>
337</table>
338
339<sect2 id='Generating_Named_Bells'>
340<title>Generating Named Bells</title>
341
342<para>
343To ring the bell on an X input extension device or the default keyboard, use
344<emphasis>
345XkbDeviceBell.</emphasis>
346</para>
347
348<informaltable frame='none'>
349<?dbfo keep-together="always" ?>
350<tgroup cols='1' align='left' colsep='0' rowsep='0'>
351<colspec colname='c1' colwidth='1.0*'/>
352<tbody>
353  <row>
354    <entry role='functiondecl'>
355Bool <emphasis>
356XkbDeviceBell</emphasis>
357(<emphasis>
358display, window, device_id, bell_class, bell_id, percent, name</emphasis>
359)
360    </entry>
361  </row>
362  <row>
363    <entry role='functionargdecl'>
364Display *<emphasis>
365      display</emphasis>
366;            /* connection to the X server */
367    </entry>
368  </row>
369  <row>
370    <entry role='functionargdecl'>
371Window<emphasis>
372      window</emphasis>
373;            /* window for which the bell is generated, or None */
374    </entry>
375  </row>
376  <row>
377    <entry role='functionargdecl'>
378unsigned int      <emphasis>
379device_spec</emphasis>
380;            /* device ID, or <emphasis>
381XkbUseCoreKbd</emphasis>
382 */
383    </entry>
384  </row>
385  <row>
386    <entry role='functionargdecl'>
387unsigned int      <emphasis>
388bell_class</emphasis>
389;            /* X input extension bell class of the bell to be rung */
390    </entry>
391  </row>
392  <row>
393    <entry role='functionargdecl'>
394unsigned int      <emphasis>
395bell_id</emphasis>
396;            /* X input extension bell ID of the bell to be rung */
397    </entry>
398  </row>
399  <row>
400    <entry role='functionargdecl'>
401int      <emphasis>
402percent</emphasis>
403;            /* bell volume, from -100 to 100 inclusive */
404    </entry>
405  </row>
406  <row>
407    <entry role='functionargdecl'>
408Atom      <emphasis>
409name</emphasis>
410;            /* a name for the bell, or <emphasis>
411NULL</emphasis>
412 */
413    </entry>
414</row>
415</tbody>
416</tgroup>
417</informaltable>
418
419<para>
420Set <emphasis>
421percent</emphasis>
422 to be the volume relative to the base volume for the keyboard as described for
423<emphasis>
424XBell</emphasis>.
425</para>
426
427<para>
428Note that <emphasis>
429bell_class</emphasis>
430 and <emphasis>
431bell_id</emphasis>
432 indicate the bell to physically ring. <emphasis>
433name</emphasis>
434 is simply an arbitrary moniker for the client application’s use.
435</para>
436
437<para>
438To determine the current feedback settings of an extension input device, use
439<emphasis>
440XGetFeedbackControl</emphasis>
441. See the X input extension documentation for more information on <emphasis>
442XGetFeedbackControl</emphasis>
443 and related data structures.
444</para>
445
446<para>
447If a compatible keyboard extension is not present in the X server, <emphasis>
448XkbDeviceBell</emphasis>
449 immediately returns <emphasis>
450False</emphasis>
451. Otherwise, <emphasis>
452XkbDeviceBell </emphasis>
453rings the bell as specified for the display and keyboard device and returns
454<emphasis>
455True</emphasis>
456. If you have disabled the audible bell, the server does not ring the system
457bell, although it does generate a <emphasis>
458XkbBellNotify</emphasis>
459 event.
460</para>
461
462<para>
463You can call <emphasis>
464XkbDeviceBell</emphasis>
465 without first initializing the keyboard extension.
466</para>
467
468<para>
469As a convenience function, Xkb provides a function to ring the bell on the
470default keyboard: <emphasis>
471XkbBell.</emphasis>
472</para>
473
474<informaltable frame='none'>
475<?dbfo keep-together="always" ?>
476<tgroup cols='1' align='left' colsep='0' rowsep='0'>
477<colspec colname='c1' colwidth='1.0*'/>
478<tbody>
479  <row>
480    <entry role='functiondecl'>
481Bool <emphasis>
482XkbBell</emphasis>
483(<emphasis>
484display, window, percent, name</emphasis>
485)
486    </entry>
487  </row>
488  <row>
489    <entry role='functionargdecl'>
490Display *      <emphasis>
491display</emphasis>
492;            /* connection to the X server */
493    </entry>
494  </row>
495  <row>
496    <entry role='functionargdecl'>
497Window<emphasis>
498      window</emphasis>
499;            /* event window, or None*/
500    </entry>
501  </row>
502  <row>
503    <entry role='functionargdecl'>
504int<emphasis>
505      percent</emphasis>
506;            /* relative volume, which can range from -100 to 100 inclusive */
507    </entry>
508  </row>
509  <row>
510    <entry role='functionargdecl'>
511Atom<emphasis>
512      name</emphasis>
513;            /* a bell name, or <emphasis>
514NULL</emphasis>
515 */
516    </entry>
517</row>
518</tbody>
519</tgroup>
520</informaltable>
521
522<para>
523If a compatible keyboard extension isn’t present in the X server, <emphasis>
524XkbBell</emphasis>
525 calls <emphasis>
526XBell </emphasis>
527with the specified <emphasis>
528display</emphasis>
529 and <emphasis>
530percent</emphasis>
531, and returns <emphasis>
532False</emphasis>
533. Otherwise, <emphasis>
534XkbBell </emphasis>
535calls <emphasis>
536XkbDeviceBell</emphasis>
537 with the specified <emphasis>
538display, window, percent, </emphasis>
539and <emphasis>
540name</emphasis>
541, a <emphasis>
542device_spec</emphasis>
543 of <emphasis>
544XkbUseCoreKbd</emphasis>
545, a <emphasis>
546bell_class </emphasis>
547of <emphasis>
548XkbDfltXIClass</emphasis>
549, and a <emphasis>
550bell_id </emphasis>
551of <emphasis>
552XkbDfltXIId,</emphasis>
553 and returns <emphasis>
554True</emphasis>.
555</para>
556
557<para>
558If you have disabled the audible bell, the server does not ring the system
559bell, although it does generate a <emphasis>
560XkbBellNotify</emphasis>
561 event.
562</para>
563
564<para>
565You can call <emphasis>
566XkbBell</emphasis>
567 without first initializing the keyboard extension.
568</para>
569
570</sect2>
571<sect2 id='Generating_Named_Bell_Events'>
572<title>Generating Named Bell Events</title>
573
574<para>
575Using Xkb, you can also generate a named bell event that does not ring any
576bell. This allows you to do things such as generate events when your
577application starts.
578</para>
579
580<para>
581For example, if an audio client listens for these types of bells, it can
582produce a "whoosh" sound when it receives a named bell event to indicate a
583client just started. In this manner, applications can generate start-up
584feedback and not worry about producing annoying beeps if an audio server is not
585running.
586</para>
587
588
589<para>
590To cause a bell event for an X input extension device or for the keyboard,
591without ringing the corresponding bell, use <emphasis>
592XkbDeviceBellEvent.</emphasis>
593</para>
594
595<informaltable frame='none'>
596<?dbfo keep-together="always" ?>
597<tgroup cols='1' align='left' colsep='0' rowsep='0'>
598<colspec colname='c1' colwidth='1.0*'/>
599<tbody>
600  <row>
601    <entry role='functiondecl'>
602Bool <emphasis>
603XkbDeviceBellEvent</emphasis>
604(<emphasis>
605display, window, device_spec, bell_class, bell_id, percent, name</emphasis>
606)
607    </entry>
608  </row>
609  <row>
610    <entry role='functionargdecl'>
611Display *      <emphasis>
612display</emphasis>
613;      /* connection to the X server */
614    </entry>
615  </row>
616  <row>
617    <entry role='functionargdecl'>
618Window      <emphasis>
619window</emphasis>
620;      /* event window, or None*/
621    </entry>
622  </row>
623  <row>
624    <entry role='functionargdecl'>
625unsigned int      <emphasis>
626device_spec</emphasis>
627;      /* device ID, or <emphasis>
628XkbUseCoreKbd</emphasis>
629 */
630    </entry>
631  </row>
632  <row>
633    <entry role='functionargdecl'>
634unsigned int      <emphasis>
635bell_class;</emphasis>
636      /* input extension bell class for the event */
637    </entry>
638  </row>
639  <row>
640    <entry role='functionargdecl'>
641unsigned int      <emphasis>
642bell_id</emphasis>
643;      /* input extension bell ID for the event */
644    </entry>
645  </row>
646  <row>
647    <entry role='functionargdecl'>
648int      <emphasis>
649percent</emphasis>
650;      /* volume for the bell, which can range from -100 to 100 inclusive */
651    </entry>
652  </row>
653  <row>
654    <entry role='functionargdecl'>
655Atom      <emphasis>
656name</emphasis>
657;      /* a bell name, or <emphasis>
658NULL</emphasis>
659 */
660    </entry>
661</row>
662</tbody>
663</tgroup>
664</informaltable>
665
666<para>
667If a compatible keyboard extension isn’t present in the X server, <emphasis>
668XkbDeviceBellEvent</emphasis>
669 immediately returns <emphasis>
670False</emphasis>
671. Otherwise, <emphasis>
672XkbDeviceBellEvent</emphasis>
673 causes an <emphasis>
674XkbBellNotify</emphasis>
675 event to be sent to all interested clients and returns <emphasis>
676True</emphasis>
677. Set <emphasis>
678percent</emphasis>
679 to be the volume relative to the base volume for the keyboard as described for
680<emphasis>XBell</emphasis>.
681</para>
682
683
684<para>
685In addition, <emphasis>
686XkbDeviceBellEvent</emphasis>
687 may generate <emphasis>
688Atom</emphasis>
689 protocol errors as well as <emphasis>
690XkbBellNotify</emphasis>
691 events. You can call <emphasis>
692XkbBell</emphasis>
693 without first initializing the keyboard extension.
694</para>
695
696
697<para>
698As a convenience function, Xkb provides a function to cause a bell event for
699the keyboard without ringing the bell: <emphasis>
700XkbBellEvent.</emphasis>
701</para>
702
703
704<informaltable frame='none'>
705<?dbfo keep-together="always" ?>
706<tgroup cols='1' align='left' colsep='0' rowsep='0'>
707<colspec colname='c1' colwidth='1.0*'/>
708<tbody>
709  <row>
710    <entry role='functiondecl'>
711Bool <emphasis>
712XkbBellEvent</emphasis>
713(<emphasis>
714display, window, percent, name</emphasis>
715)
716    </entry>
717  </row>
718  <row>
719    <entry role='functionargdecl'>
720Display *      <emphasis>
721display</emphasis>
722;            /* connection to the X server */
723    </entry>
724  </row>
725  <row>
726    <entry role='functionargdecl'>
727Window      <emphasis>
728window</emphasis>
729;            /* the event window, or None */
730    </entry>
731  </row>
732  <row>
733    <entry role='functionargdecl'>
734int      <emphasis>
735percent</emphasis>
736;            /* relative volume, which can range from -100 to 100 inclusive */
737    </entry>
738  </row>
739  <row>
740    <entry role='functionargdecl'>
741Atom      <emphasis>
742name</emphasis>
743;            /* a bell name, or <emphasis>
744NULL</emphasis>
745 */
746    </entry>
747</row>
748</tbody>
749</tgroup>
750</informaltable>
751
752<para>
753If a compatible keyboard extension isn’t present in the X server, <emphasis>
754XkbBellEvent</emphasis>
755 immediately returns <emphasis>
756False</emphasis>
757. Otherwise, <emphasis>
758XkbBellEvent </emphasis>
759calls<emphasis>
760 XkbDeviceBellEvent</emphasis>
761 with the specified <emphasis>
762display, window, percent, </emphasis>
763and <emphasis>
764name</emphasis>
765, a <emphasis>
766device_spec</emphasis>
767 of <emphasis>
768XkbUseCoreKbd</emphasis>
769, a <emphasis>
770bell_class </emphasis>
771of <emphasis>
772XkbDfltXIClass</emphasis>
773, and a <emphasis>
774bell_id </emphasis>
775of <emphasis>
776XkbDfltXIId,</emphasis>
777 and returns what <emphasis>
778XkbDeviceBellEvent</emphasis>
779 returns.
780</para>
781
782<para>
783<emphasis>XkbBellEvent</emphasis>
784generates a <emphasis>XkbBellNotify</emphasis>
785event.
786</para>
787
788
789<para>
790You can call <emphasis>
791XkbBellEvent</emphasis>
792without first initializing the keyboard extension.
793</para>
794
795</sect2>
796<sect2 id='Forcing_a_Server_Generated_Bell'>
797<title>Forcing a Server-Generated Bell</title>
798
799<para>
800To ring the bell on any keyboard, overriding user preference settings for
801audible bells, use <emphasis>XkbForceDeviceBell</emphasis>.
802</para>
803
804<informaltable frame='none'>
805<?dbfo keep-together="always" ?>
806<tgroup cols='1' align='left' colsep='0' rowsep='0'>
807<colspec colname='c1' colwidth='1.0*'/>
808<tbody>
809  <row>
810    <entry role='functiondecl'>
811Bool <emphasis>
812XkbForceDeviceBell</emphasis>
813(<emphasis>
814display, window, device_spec, bell_class, bell_id, percent</emphasis>
815)
816    </entry>
817  </row>
818  <row>
819    <entry role='functionargdecl'>
820Display *      <emphasis>
821display</emphasis>
822;            /* connection to the X server */
823    </entry>
824  </row>
825  <row>
826    <entry role='functionargdecl'>
827Window      <emphasis>
828window</emphasis>
829;            /* event window, or None */
830    </entry>
831  </row>
832  <row>
833    <entry role='functionargdecl'>
834unsigned int      <emphasis>
835device_spec</emphasis>
836;            /* device ID, or <emphasis>
837XkbUseCoreKbd</emphasis>
838 */
839    </entry>
840  </row>
841  <row>
842    <entry role='functionargdecl'>
843unsigned int      <emphasis>
844bell_class</emphasis>
845;            /* input extension class of the bell to be rung */
846    </entry>
847  </row>
848  <row>
849    <entry role='functionargdecl'>
850unsigned int      <emphasis>
851bell_id</emphasis>
852;            /* input extension ID of the bell to be rung */
853    </entry>
854  </row>
855  <row>
856    <entry role='functionargdecl'>
857int      <emphasis>
858percent</emphasis>
859;            /* relative volume, which can range from -100 to 100 inclusive */
860    </entry>
861</row>
862</tbody>
863</tgroup>
864</informaltable>
865
866<para>
867If a compatible keyboard extension isn’t present in the X server, <emphasis>
868XkbForceDeviceBell</emphasis>
869 immediately returns <emphasis>
870False</emphasis>
871. Otherwise, <emphasis>
872XkbForceDeviceBell </emphasis>
873rings the bell as specified for the display and keyboard device and returns
874<emphasis>
875True</emphasis>
876. Set <emphasis>
877percent</emphasis>
878 to be the volume relative to the base volume for the keyboard as described for
879<emphasis>
880XBell</emphasis>
881. There is no <emphasis>
882name</emphasis>
883 parameter because <emphasis>
884XkbForceDeviceBell </emphasis>
885does not cause an <emphasis>
886XkbBellNotify</emphasis>
887 event.
888</para>
889
890<para>
891You can call <emphasis>
892XkbBell</emphasis>
893 without first initializing the keyboard extension.
894</para>
895
896<para>
897To ring the bell on the default keyboard, overriding user preference settings
898for audible bells, use <emphasis>
899XkbForceBell</emphasis>.
900</para>
901
902<informaltable frame='none'>
903<?dbfo keep-together="always" ?>
904<tgroup cols='1' align='left' colsep='0' rowsep='0'>
905<colspec colname='c1' colwidth='1.0*'/>
906<tbody>
907  <row>
908    <entry role='functiondecl'>
909Bool <emphasis>
910XkbForceBell</emphasis>
911(<emphasis>
912display, percent)</emphasis>
913    </entry>
914  </row>
915  <row>
916    <entry role='functionargdecl'>
917Display *      <emphasis>
918display</emphasis>
919;      /* connection to the X server */
920    </entry>
921  </row>
922  <row>
923    <entry role='functionargdecl'>
924int      <emphasis>
925percent</emphasis>
926;      /* volume for the bell, which can range from -100 to 100 inclusive */
927    </entry>
928</row>
929</tbody>
930</tgroup>
931</informaltable>
932
933<para>
934If a compatible keyboard extension isn’t present in the X server, <emphasis>
935XkbForceBell</emphasis>
936 calls <emphasis>
937XBell </emphasis>
938with the specified <emphasis>
939display</emphasis>
940 and <emphasis>
941percent</emphasis>
942 and returns <emphasis>
943False</emphasis>
944. Otherwise, <emphasis>
945XkbForceBell </emphasis>
946calls <emphasis>
947XkbForceDeviceBell</emphasis>
948 with the specified <emphasis>
949display </emphasis>
950and<emphasis>
951 percent</emphasis>
952, <emphasis>
953device_spec</emphasis>
954 =<emphasis>
955XkbUseCoreKbd</emphasis>
956, <emphasis>
957bell_class </emphasis>
958= <emphasis>
959XkbDfltXIClass</emphasis>
960, <emphasis>
961bell_id </emphasis>
962= <emphasis>
963XkbDfltXIId,</emphasis>
964 <emphasis>
965window</emphasis>
966 = None, and <emphasis>
967name</emphasis>
968 = <emphasis>
969NULL</emphasis>
970, and returns what<emphasis>
971 XkbForceDeviceBell</emphasis>
972 returns.
973</para>
974
975<para>
976<emphasis>
977XkbForceBell </emphasis>
978does not cause an <emphasis>
979XkbBellNotify</emphasis>
980 event.
981</para>
982
983<para>
984You can call <emphasis>
985XkbBell</emphasis>
986 without first initializing the keyboard extension.
987</para>
988
989</sect2>
990</sect1>
991<sect1 id='Detecting_Bells'>
992<title>Detecting Bells</title>
993
994<para>
995Xkb generates <emphasis>
996XkbBellNotify</emphasis>
997 events for all bells except for those resulting from calls to <emphasis>
998XkbForceDeviceBell</emphasis>
999 and <emphasis>
1000XkbForceBell</emphasis>
1001. To receive <emphasis>
1002XkbBellNotify</emphasis>
1003 events under all possible conditions, pass <emphasis>
1004XkbBellNotifyMask</emphasis>
1005 in both the <emphasis>
1006bits_to_change </emphasis>
1007and<emphasis>
1008 values_for_bits</emphasis>
1009 parameters to <emphasis>
1010XkbSelectEvents</emphasis>
1011 (see section 4.3). <!-- xref -->
1012</para>
1013
1014<para>
1015The <emphasis>
1016XkbBellNotify</emphasis>
1017 event has no event details. It is either selected or it is not. However, you
1018can call <emphasis>
1019XkbSelectEventDetails</emphasis>
1020 using <emphasis>
1021XkbBellNotify</emphasis>
1022 as the <emphasis>
1023event_type</emphasis>
1024 and specifying <emphasis>
1025XkbAllBellNotifyMask</emphasis>
1026 in <emphasis>
1027bits_to_change</emphasis>
1028 and <emphasis>
1029values_for_bits.</emphasis>
1030 This has the same effect as a call to <emphasis>
1031XkbSelectEvents</emphasis>.
1032</para>
1033
1034<para>
1035The structure for the <emphasis>
1036XkbBellNotify</emphasis>
1037 event type contains:
1038</para>
1039
1040<para><programlisting>
1041typedef struct _XkbBellNotify {
1042      int             type;        /* Xkb extension base event code */
1043      unsigned long   serial;      /* X server serial number for event */
1044      Bool            send_event;  /* <emphasis> True</emphasis> =&gt; synthetically generated */
1045      Display *       display;     /* server connection where event generated */
1046      Time            time;        /* server time when event generated */
1047      int             xkb_type;    /* <emphasis> XkbBellNotify</emphasis> */
1048      unsigned int    device;      /* Xkb device ID, will not be <emphasis> XkbUseCoreKbd</emphasis> */
1049      int             percent;     /* requested volume as % of max */
1050      int             pitch;       /* requested pitch in Hz */
1051      int             duration;    /* requested duration in microseconds */
1052      unsigned int    bell_class;  /* X input extension feedback class */
1053      unsigned int    bell_id;     /* X input extension feedback ID */
1054      Atom            name;        /* "name" of requested bell */
1055      Window          window;      /* window associated with event */
1056      Bool            event_only;  /* <emphasis> False</emphasis> -&gt; the server did not produce a beep */
1057} <emphasis>XkbBellNotifyEvent</emphasis>;
1058</programlisting></para>
1059
1060<para>
1061If your application needs to generate visual bell feedback on the screen when
1062it receives a bell event, use the window ID in the <emphasis>
1063XkbBellNotifyEvent</emphasis>
1064, if present.
1065</para>
1066
1067</sect1>
1068</chapter>
1069