<?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>
