aboutsummaryrefslogtreecommitdiff
path: root/libX11/specs/XKB/ch09.xml
blob: 0241880b91cf59640492c4d5620468e2c98563d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
	  "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<chapter id='Bells'>
<title>Bells</title>
<indexterm zone="Bells"><primary>bell</primary></indexterm>

<para>
The core X protocol allows only applications to explicitly sound the system
bell with a given duration, pitch, and volume. Xkb extends this capability by
allowing clients to attach symbolic names to bells, disable audible bells, and
receive an event whenever the keyboard bell is rung. For the purposes of this
document, the
<firstterm>audible</firstterm>
<indexterm significance="preferred" zone="Bells">
<primary>audible bell</primary></indexterm>
<indexterm significance="preferred" zone="Bells">
<primary>bell</primary><secondary>audible</secondary></indexterm>
bell is defined to be the system bell, or the default keyboard bell, as
opposed to any other audible sound generated elsewhere in the system.
</para>


<para>
You can ask to receive
<symbol>XkbBellNotify</symbol>
events (see <link linkend="Detecting_Bells">section 9.4</link>) when any client rings any one of the following:
</para>

<itemizedlist>
<listitem>
  <para>
The default bell
  </para>
</listitem>
<listitem>
  <para>
Any bell on an input device that can be specified by a
<structfield>bell_class</structfield>
and
<structfield>bell_id</structfield>
pair
  </para>
</listitem>
<listitem>
  <para>
Any bell specified only by an arbitrary name. (This is, from the server’s
point of view, merely a name, and not connected with any physical
sound-generating device. Some client application must generate the sound, or
visual feedback, if any, that is associated with the name.)
  </para>
</listitem>
</itemizedlist>

<para>
You can also ask to receive
<symbol>XkbBellNotify</symbol>
events when the server rings the default bell or if any client has requested
events only (without the bell sounding) for any of the bell types previously
listed.
</para>

<para>
You can disable audible bells on a global basis (to set the
<emphasis>AudibleBell</emphasis>
control, see <xref linkend="Keyboard_Controls" />). For example, a client that replaces the keyboard
bell with some other audible cue might want to turn off the
<emphasis>AudibleBell</emphasis>
control to prevent the server from also generating a sound and avoid
cacophony. If you disable audible bells and request to receive
<symbol>XkbBellNotify</symbol>
events, you can generate feedback different from the default bell.
</para>


<para>
You can, however, override the
<emphasis>AudibleBell</emphasis>
control by calling one of the functions that force the ringing of a bell in
spite of the setting of the
<emphasis>AudibleBell</emphasis>
control —
<function>XkbForceDeviceBell</function>
or
<function>XkbForceBell</function>
(see <link linkend="Forcing_a_Server_Generated_Bell">section 9.3.3</link>). In this case the server does not generate a bell event.
</para>


<para>
Just as some keyboards can produce keyclicks to indicate when a key is pressed
or repeating, Xkb can provide feedback for the controls by using special beep
codes. The
<emphasis>AccessXFeedback</emphasis>
control is used to configure the specific types of operations that generate
feedback. See <link linkend="The_AccessXFeedback_Control">section 10.6.3</link> for a discussion on
<emphasis>AccessXFeedback</emphasis>
control.
</para>

<para>
This chapter describes bell names, the functions used to generate named bells,
and the events the server generates for bells.
</para>

<sect1 id='Bell_Names'>
<title>Bell Names</title>

<para>
You can associate a name to an act of ringing a bell by converting the name to
an Atom and then using this name when you call the functions listed in this
chapter. If an event is generated as a result, the name is then passed to all
other clients interested in receiving
<symbol>XkbBellNotify</symbol>
events. Note that these are arbitrary names and that there is no binding to
any sounds. Any sounds or other effects (such as visual bells on the screen)
must be generated by a client application upon receipt of the bell event
containing the name. There is no default name for the default keyboard bell.
The server does generate some predefined bells for the AccessX controls (see
<link linkend="The_AccessXFeedback_Control">section 10.6.3</link>).
These named bells are shown in <link linkend="table9.1">Table 9.1</link>;
the name is included
in any bell event sent to clients that have requested to receive
<symbol>XkbBellNotify</symbol>
events.
</para>

<table id='table9.1' frame='topbot'>
<title>Predefined Bells</title>
<?dbfo keep-together="always" ?>
<tgroup cols='2' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<colspec colname='c2' colwidth='1.0*'/>
<thead>
<row rowsep='1'>
  <entry>Action</entry>
  <entry>Named Bell</entry>
</row>
</thead>
<tbody>
<row>
    <entry>Indicator turned on</entry>
    <entry>AX_IndicatorOn</entry>
</row>
<row>
    <entry>Indicator turned off</entry>
    <entry>AX_IndicatorOff</entry>
</row>
<row>
    <entry>More than one indicator changed state</entry>
    <entry>AX_IndicatorChange</entry>
</row>
<row>
    <entry>Control turned on</entry>
    <entry>AX_FeatureOn</entry>
</row>
<row>
    <entry>Control turned off</entry>
    <entry>AX_FeatureOff</entry>
</row>
<row>
    <entry>More than one control changed state</entry>
    <entry>AX_FeatureChange</entry>
</row>
<row>
    <entry>SlowKeys and BounceKeys about to be turned on or off</entry>
    <entry>AX_SlowKeysWarning</entry>
</row>
<row>
    <entry>SlowKeys key pressed</entry>
    <entry>AX_SlowKeyPress</entry>
</row>
<row>
    <entry>SlowKeys key accepted</entry>
    <entry>AX_SlowKeyAccept</entry>
</row>
<row>
    <entry>SlowKeys key rejected</entry>
    <entry>AX_SlowKeyReject</entry>
</row>
<row>
    <entry>Accepted SlowKeys key released</entry>
    <entry>AX_SlowKeyRelease</entry>
</row>
<row>
    <entry>BounceKeys key rejected</entry>
    <entry>AX_BounceKeyReject</entry>
</row>
<row>
    <entry>StickyKeys key latched</entry>
    <entry>AX_StickyLatch</entry>
</row>
<row>
    <entry>StickyKeys key locked</entry>
    <entry>AX_StickyLock</entry>
</row>
<row>
    <entry>StickyKeys key unlocked</entry>
    <entry>AX_StickyUnlock</entry>
  </row>
</tbody>
</tgroup>
</table>

</sect1>
<sect1 id='Audible_Bells'>
<title>Audible Bells</title>

<para>
Using Xkb you can generate bell events that do not necessarily ring the system
bell. This is useful if you need to use an audio server instead of the system
beep. For example, when an audio client starts, it could disable the audible
bell (the system bell) and then listen for
<symbol>XkbBellNotify</symbol>
events (see <link linkend="Detecting_Bells">section 9.4</link>). When it receives a
<symbol>XkbBellNotify</symbol>
event, the audio client could then send a request to an audio server to play a
sound.
</para>


<para>
You can control the audible bells feature by passing the
<symbol>XkbAudibleBellMask</symbol>
to
<function>XkbChangeEnabledControls</function>
(see <link linkend="The_EnabledControls_Control">section 10.1.1</link>). If you set
<symbol>XkbAudibleBellMask</symbol>
on, the server rings the system bell when a bell event occurs. This is the
default. If you set
<symbol>XkbAudibleBellMask</symbol>
off and a bell event occurs, the server does not ring the system bell unless
you call
<function>XkbForceDeviceBell</function>
or
<function>XkbForceBell</function>
(see <link linkend="Forcing_a_Server_Generated_Bell">section 9.3.3</link>).
</para>

<para>
Audible bells are also part of the per-client auto-reset controls. For more
information on auto-reset controls, see <link linkend="The_AutoReset_Control">section 10.1.2</link>.
</para>

</sect1>
<sect1 id='Bell_Functions'>
<title>Bell Functions</title>

<para>
Use the functions described in this section to ring bells and to generate bell
events.
</para>

<para>
The input extension has two types of feedbacks that can generate bells — bell
feedback and keyboard feedback. Some of the functions in this section have
<structfield>bell_class</structfield>
and
<structfield>bell_id</structfield>
parameters; set them as follows: Set
<structfield>bell_class</structfield>
to
<symbol>BellFeedbackClass</symbol>
or
<symbol>KbdFeedbackClass</symbol>.
A device can have more than one feedback of each type; set
<structfield>bell_id</structfield>
to the particular bell feedback of
<structfield>bell_class</structfield>
type.
</para>

<para>
<link linkend="table9.2">Table 9.2</link> shows the conditions that cause
a bell to sound or an <structname>XkbBellNotifyEvent</structname>
to be generated when a bell function is called.
</para>

<table id='table9.2' frame='topbot'>
<title>Bell Sounding and Bell Event Generating</title>
<?dbfo keep-together="always" ?>
<tgroup cols='4' align='left' colsep='0' rowsep='0'>
<colspec colname='c1' colwidth='1.0*'/>
<colspec colname='c2' colwidth='1.0*'/>
<colspec colname='c3' colwidth='1.0*'/>
<colspec colname='c4' colwidth='1.0*'/>
<thead>
  <row rowsep='1'>
    <entry>Function called</entry>
    <entry>AudibleBell</entry>
    <entry>Server sounds a bell</entry>
    <entry>Server sends an XkbBellNotifyEvent</entry>
  </row>
</thead>
<tbody>
<row>
    <entry>XkbDeviceBell</entry>
    <entry>On</entry>
    <entry>Yes</entry>
    <entry>Yes</entry>
</row>
<row>
    <entry>XkbDeviceBell</entry>
    <entry>Off</entry>
    <entry>No</entry>
    <entry>Yes</entry>
</row>
<row>
    <entry>XkbBell</entry>
    <entry>On</entry>
    <entry>Yes</entry>
    <entry>Yes</entry>
</row>
<row>
    <entry>XkbBell</entry>
    <entry>Off</entry>
    <entry>No</entry>
    <entry>Yes</entry>
</row>
<row>
    <entry>XkbDeviceBellEvent</entry>
    <entry>On or Off</entry>
    <entry>No</entry>
    <entry>Yes</entry>
</row>
<row>
    <entry>XkbBellEvent</entry>
    <entry>On or Off</entry>
    <entry>No</entry>
    <entry>Yes</entry>
</row>
<row>
    <entry>XkbDeviceForceBell</entry>
    <entry>On or Off</entry>
    <entry>Yes</entry>
    <entry>No</entry>
</row>
<row>
    <entry>XkbForceBell</entry>
    <entry>On or Off</entry>
    <entry>Yes</entry>
    <entry>No</entry>
  </row>
</tbody>
</tgroup>
</table>

<sect2 id='Generating_Named_Bells'>
<title>Generating Named Bells</title>

<para>
To ring the bell on an X input extension device or the default keyboard, use
<function>XkbDeviceBell</function>.
</para>

<indexterm significance="preferred" zone="XkbDeviceBell"><primary><function>XkbDeviceBell</function></primary></indexterm>
<funcsynopsis id="XkbDeviceBell">
  <funcprototype>
    <funcdef>Bool <function>XkbDeviceBell</function></funcdef>
<!-- (
<parameter>display, window, device_id, bell_class, bell_id, percent, name</parameter>
) -->

    <paramdef>Display *<parameter>display</parameter></paramdef>
    <paramdef>Window <parameter>window</parameter></paramdef>
    <paramdef>unsigned int <parameter>device_spec</parameter></paramdef>
    <paramdef>unsigned int <parameter>bell_class</parameter></paramdef>
    <paramdef>unsigned int <parameter>bell_id</parameter></paramdef>
    <paramdef>int <parameter>percent</parameter></paramdef>
    <paramdef>Atom <parameter>name</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>display</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>window</parameter>
    </term>
    <listitem>
      <para>
        window for which the bell is generated, or None
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>device_spec</parameter>
    </term>
    <listitem>
      <para>
        device ID, or <symbol>XkbUseCoreKbd</symbol>
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>bell_class</parameter>
    </term>
    <listitem>
      <para>
        X input extension bell class of the bell to be rung
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>bell_id</parameter>
    </term>
    <listitem>
      <para>
        X input extension bell ID of the bell to be rung
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>percent</parameter>
    </term>
    <listitem>
      <para>
        bell volume, from &minus;100 to 100 inclusive
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>name</parameter>
    </term>
    <listitem>
      <para>
        a name for the bell, or <symbol>NULL</symbol>
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
Set
<parameter>percent</parameter>
to be the volume relative to the base volume for the keyboard as described for
<function>XBell</function>.
</para>

<para>
Note that
<parameter>bell_class</parameter>
and
<parameter>bell_id</parameter>
indicate the bell to physically ring.
<parameter>name</parameter>
is simply an arbitrary moniker for the client application’s use.
</para>

<para>
To determine the current feedback settings of an extension input device, use
<function>XGetFeedbackControl</function>.
See <olink targetdoc='inputlib' targetptr='Controlling_Device_Feedback'>the
X input extension documentation</olink> for more information on
<function>XGetFeedbackControl</function>
and related data structures.
</para>

<para>
If a compatible keyboard extension is not present in the X server,
<function>XkbDeviceBell</function>
immediately returns
<symbol>False</symbol>.
Otherwise,
<function>XkbDeviceBell</function>
rings the bell as specified for the display and keyboard device and returns
<symbol>True</symbol>.
If you have disabled the audible bell, the server does not ring the system
bell, although it does generate a
<symbol>XkbBellNotify</symbol>
event.
</para>

<para>
You can call
<function>XkbDeviceBell</function>
without first initializing the keyboard extension.
</para>

<para>
As a convenience function, Xkb provides a function to ring the bell on the
default keyboard:
<function>XkbBell</function>.
</para>

<indexterm significance="preferred" zone="XkbBell"><primary><function>XkbBell</function></primary></indexterm>
<funcsynopsis id="XkbBell">
  <funcprototype>
    <funcdef>Bool <function>XkbBell</function></funcdef>
<!-- (
<parameter>display, window, percent, name</parameter>
) -->

    <paramdef>Display *<parameter>display</parameter></paramdef>
    <paramdef>Window <parameter>window</parameter></paramdef>
    <paramdef>int <parameter>percent</parameter></paramdef>
    <paramdef>Atom <parameter>name</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>display</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>window</parameter>
    </term>
    <listitem>
      <para>
        event window, or None
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>percent</parameter>
    </term>
    <listitem>
      <para>
        relative volume, which can range from &minus;100 to 100 inclusive
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>name</parameter>
    </term>
    <listitem>
      <para>
        a bell name, or <symbol>NULL</symbol>
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
If a compatible keyboard extension isn’t present in the X server,
<function>XkbBell</function>
calls
<function>XBell</function>
with the specified
<parameter>display</parameter>
and
<parameter>percent</parameter>,
and returns
<symbol>False</symbol>.
Otherwise,
<function>XkbBell</function>
calls
<function>XkbDeviceBell</function>
with the specified
<parameter>display</parameter>,
<parameter>window</parameter>,
<parameter>percent</parameter>,
and
<parameter>name</parameter>,
a
<structfield>device_spec</structfield>
of
<symbol>XkbUseCoreKbd</symbol>,
a
<structfield>bell_class</structfield>
of
<symbol>XkbDfltXIClass</symbol>,
and a
<structfield>bell_id</structfield>
of
<symbol>XkbDfltXIId</symbol>,
and returns
<symbol>True</symbol>.
</para>

<para>
If you have disabled the audible bell, the server does not ring the system
bell, although it does generate a
<symbol>XkbBellNotify</symbol>
event.
</para>

<para>
You can call
<function>XkbBell</function>
without first initializing the keyboard extension.
</para>

</sect2>
<sect2 id='Generating_Named_Bell_Events'>
<title>Generating Named Bell Events</title>

<para>
Using Xkb, you can also generate a named bell event that does not ring any
bell. This allows you to do things such as generate events when your
application starts.
</para>

<para>
For example, if an audio client listens for these types of bells, it can
produce a <quote>whoosh</quote> sound when it receives a named bell event to indicate a
client just started. In this manner, applications can generate start-up
feedback and not worry about producing annoying beeps if an audio server is not
running.
</para>


<para>
To cause a bell event for an X input extension device or for the keyboard,
without ringing the corresponding bell, use
<function>XkbDeviceBellEvent</function>.
</para>

<indexterm significance="preferred" zone="XkbDeviceBellEvent"><primary><function>XkbDeviceBellEvent</function></primary></indexterm>
<funcsynopsis id="XkbDeviceBellEvent">
  <funcprototype>
    <funcdef>Bool <function>XkbDeviceBellEvent</function></funcdef>
<!-- (
<parameter>display, window, device_spec, bell_class, bell_id, percent, name</parameter>
) -->

    <paramdef>Display *<parameter>display</parameter></paramdef>
    <paramdef>Window <parameter>window</parameter></paramdef>
    <paramdef>unsigned int <parameter>device_spec</parameter></paramdef>
    <paramdef>unsigned int <parameter>bell_class</parameter></paramdef>
    <paramdef>unsigned int <parameter>bell_id</parameter></paramdef>
    <paramdef>int <parameter>percent</parameter></paramdef>
    <paramdef>Atom <parameter>name</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>display</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>window</parameter>
    </term>
    <listitem>
      <para>
        event window, or None
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>device_spec</parameter>
    </term>
    <listitem>
      <para>
        device ID, or <symbol>XkbUseCoreKbd</symbol>
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>bell_class</parameter>
    </term>
    <listitem>
      <para>
        input extension bell class for the event
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>bell_id</parameter>
    </term>
    <listitem>
      <para>
        input extension bell ID for the event
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>percent</parameter>
    </term>
    <listitem>
      <para>
        volume for the bell, which can range from &minus;100 to 100 inclusive
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>name</parameter>
    </term>
    <listitem>
      <para>
        a bell name, or <symbol>NULL</symbol>
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
If a compatible keyboard extension isn’t present in the X server,
<function>XkbDeviceBellEvent</function>
immediately returns
<symbol>False</symbol>.
Otherwise,
<function>XkbDeviceBellEvent</function>
causes an
<symbol>XkbBellNotify</symbol>
event to be sent to all interested clients and returns
<symbol>True</symbol>.
Set
<parameter>percent</parameter>
to be the volume relative to the base volume for the keyboard as described for
<function>XBell</function>.
</para>


<para>
In addition,
<function>XkbDeviceBellEvent</function>
may generate
<type>Atom</type>
protocol errors as well as
<symbol>XkbBellNotify</symbol>
events. You can call
<function>XkbBell</function>
without first initializing the keyboard extension.
</para>


<para>
As a convenience function, Xkb provides a function to cause a bell event for
the keyboard without ringing the bell:
<function>XkbBellEvent</function>.
</para>


<indexterm significance="preferred" zone="XkbBellEvent"><primary><function>XkbBellEvent</function></primary></indexterm>
<funcsynopsis id="XkbBellEvent">
  <funcprototype>
    <funcdef>Bool <function>XkbBellEvent</function></funcdef>
<!-- (
<parameter>display, window, percent, name</parameter>
) -->

    <paramdef>Display *<parameter>display</parameter></paramdef>
    <paramdef>Window <parameter>window</parameter></paramdef>
    <paramdef>int <parameter>percent</parameter></paramdef>
    <paramdef>Atom <parameter>name</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>display</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>window</parameter>
    </term>
    <listitem>
      <para>
        the event window, or None
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>percent</parameter>
    </term>
    <listitem>
      <para>
        relative volume, which can range from &minus;100 to 100 inclusive
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>name</parameter>
    </term>
    <listitem>
      <para>
        a bell name, or <symbol>NULL</symbol>
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
If a compatible keyboard extension isn’t present in the X server,
<function>XkbBellEvent</function>
immediately returns
<symbol>False</symbol>.
Otherwise,
<function>XkbBellEvent</function>
calls
<function>XkbDeviceBellEvent</function>
with the specified
<parameter>display</parameter>,
<parameter>window</parameter>,
<parameter>percent</parameter>,
and
<parameter>name</parameter>,
a
<structfield>device_spec</structfield>
of
<symbol>XkbUseCoreKbd</symbol>,
a
<structfield>bell_class</structfield>
of
<symbol>XkbDfltXIClass</symbol>,
and a
<structfield>bell_id</structfield>
of
<symbol>XkbDfltXIId</symbol>,
and returns what
<function>XkbDeviceBellEvent</function>
returns.
</para>

<para>
<function>XkbBellEvent</function>
generates a <symbol>XkbBellNotify</symbol>
event.
</para>


<para>
You can call
<function>XkbBellEvent</function>
without first initializing the keyboard extension.
</para>

</sect2>
<sect2 id='Forcing_a_Server_Generated_Bell'>
<title>Forcing a Server-Generated Bell</title>

<para>
To ring the bell on any keyboard, overriding user preference settings for
audible bells, use <function>XkbForceDeviceBell</function>.
</para>

<indexterm significance="preferred" zone="XkbForceDeviceBell"><primary><function>XkbForceDeviceBell</function></primary></indexterm>
<funcsynopsis id="XkbForceDeviceBell">
  <funcprototype>
    <funcdef>Bool <function>XkbForceDeviceBell</function></funcdef>
<!-- (
<parameter>display, window, device_spec, bell_class, bell_id, percent</parameter>
) -->

    <paramdef>Display *<parameter>display</parameter></paramdef>
    <paramdef>Window <parameter>window</parameter></paramdef>
    <paramdef>unsigned int <parameter>device_spec</parameter></paramdef>
    <paramdef>unsigned int <parameter>bell_class</parameter></paramdef>
    <paramdef>unsigned int <parameter>bell_id</parameter></paramdef>
    <paramdef>int <parameter>percent</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>display</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>window</parameter>
    </term>
    <listitem>
      <para>
        event window, or None
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>device_spec</parameter>
    </term>
    <listitem>
      <para>
        device ID, or <symbol>XkbUseCoreKbd</symbol>
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>bell_class</parameter>
    </term>
    <listitem>
      <para>
        input extension class of the bell to be rung
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>bell_id</parameter>
    </term>
    <listitem>
      <para>
        input extension ID of the bell to be rung
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>percent</parameter>
    </term>
    <listitem>
      <para>
        relative volume, which can range from &minus;100 to 100 inclusive
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
If a compatible keyboard extension isn’t present in the X server,
<function>XkbForceDeviceBell</function>
immediately returns
<symbol>False</symbol>.
Otherwise,
<function>XkbForceDeviceBell</function>
rings the bell as specified for the display and keyboard device and returns
<symbol>True</symbol>.
Set
<parameter>percent</parameter>
to be the volume relative to the base volume for the keyboard as described for
<function>XBell</function>.
There is no
<structfield>name</structfield>
parameter because
<function>XkbForceDeviceBell</function>
does not cause an
<symbol>XkbBellNotify</symbol>
event.
</para>

<para>
You can call
<function>XkbBell</function>
without first initializing the keyboard extension.
</para>

<para>
To ring the bell on the default keyboard, overriding user preference settings
for audible bells, use
<function>XkbForceBell</function>.
</para>

<indexterm significance="preferred" zone="XkbForceBell"><primary><function>XkbForceBell</function></primary></indexterm>
<funcsynopsis id="XkbForceBell">
  <funcprototype>
    <funcdef>Bool <function>XkbForceBell</function></funcdef>
<!-- (
<parameter>display, percent)</parameter> -->

    <paramdef>Display *<parameter>display</parameter></paramdef>
    <paramdef>int <parameter>percent</parameter></paramdef>
  </funcprototype>
</funcsynopsis>
<variablelist>
  <varlistentry>
    <term>
      <parameter>display</parameter>
    </term>
    <listitem>
      <para>
        connection to the X server
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <parameter>percent</parameter>
    </term>
    <listitem>
      <para>
        volume for the bell, which can range from &minus;100 to 100 inclusive
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
If a compatible keyboard extension isn’t present in the X server,
<function>XkbForceBell</function>
calls
<function>XBell</function>
with the specified
<parameter>display</parameter>
and
<parameter>percent</parameter>
and returns
<symbol>False</symbol>.
Otherwise,
<function>XkbForceBell</function>
calls
<function>XkbForceDeviceBell</function>
with the specified
<parameter>display</parameter>
and
<parameter>percent</parameter>,
<structfield>device_spec</structfield>
=
<symbol>XkbUseCoreKbd</symbol>,
<structfield>bell_class</structfield>
=
<symbol>XkbDfltXIClass</symbol>,
<structfield>bell_id</structfield>
=
<symbol>XkbDfltXIId</symbol>,
<structfield>window</structfield>
= None, and
<structfield>name</structfield>
=
<symbol>NULL</symbol>,
and returns what
<function>XkbForceDeviceBell</function>
returns.
</para>

<para>
<function>XkbForceBell</function>
does not cause an
<symbol>XkbBellNotify</symbol>
event.
</para>

<para>
You can call
<function>XkbBell</function>
without first initializing the keyboard extension.
</para>

</sect2>
</sect1>
<sect1 id='Detecting_Bells'>
<title>Detecting Bells</title>

<para>
Xkb generates
<symbol>XkbBellNotify</symbol>
events for all bells except for those resulting from calls to
<function>XkbForceDeviceBell</function>
and
<function>XkbForceBell</function>.
To receive
<symbol>XkbBellNotify</symbol>
events under all possible conditions, pass
<symbol>XkbBellNotifyMask</symbol>
in both the
<parameter>bits_to_change</parameter>
and
<parameter>values_for_bits</parameter>
parameters to
<function>XkbSelectEvents</function>
(see <link linkend="Selecting_Xkb_Events">section 4.3</link>).
</para>

<para>
The
<symbol>XkbBellNotify</symbol>
event has no event details. It is either selected or it is not. However, you
can call
<function>XkbSelectEventDetails</function>
using
<symbol>XkbBellNotify</symbol>
as the
<structfield>event_type</structfield>
and specifying
<symbol>XkbAllBellEventsMask</symbol>
in
<parameter>bits_to_change</parameter>
and
<parameter>values_for_bits</parameter>.
This has the same effect as a call to
<function>XkbSelectEvents</function>.
</para>

<para>
The structure for the
<symbol>XkbBellNotify</symbol>
event type contains:

<programlisting>
typedef struct _XkbBellNotify {
    int             type;        /* Xkb extension base event code */
    unsigned long   serial;      /* X server serial number for event */
    Bool            send_event;  /* <symbol>True</symbol> &rArr; synthetically generated */
    Display *       display;     /* server connection where event generated */
    Time            time;        /* server time when event generated */
    int             xkb_type;    /* <symbol>XkbBellNotify</symbol> */
    unsigned int    device;      /* Xkb device ID, will not be <symbol>XkbUseCoreKbd</symbol> */
    int             percent;     /* requested volume as % of max */
    int             pitch;       /* requested pitch in Hz */
    int             duration;    /* requested duration in microseconds */
    unsigned int    bell_class;  /* X input extension feedback class */
    unsigned int    bell_id;     /* X input extension feedback ID */
    Atom            name;        /* "name" of requested bell */
    Window          window;      /* window associated with event */
    Bool            event_only;  /* <symbol>False</symbol> &rarr; the server did not produce a beep */
} <structname>XkbBellNotifyEvent</structname>;
</programlisting></para>

<para>
If your application needs to generate visual bell feedback on the screen when
it receives a bell event, use the window ID in the
<structname>XkbBellNotifyEvent</structname>,
if present.
</para>

</sect1>
</chapter>