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