diff --git a/src/core/bell.c b/src/core/bell.c index cf7a0f80a..4ac30dc17 100644 --- a/src/core/bell.c +++ b/src/core/bell.c @@ -203,33 +203,18 @@ bell_audible_notify (MetaDisplay *display, return FALSE; } -void +gboolean meta_bell_notify (MetaDisplay *display, - XkbAnyEvent *xkb_ev) + MetaWindow *window) { - MetaWindow *window; - XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent*) xkb_ev; - - window = meta_display_lookup_x_window (display, xkb_bell_event->window); - if (!window && display->focus_window && display->focus_window->frame) - window = display->focus_window; - /* flash something */ if (meta_prefs_get_visual_bell ()) bell_visual_notify (display, window); if (meta_prefs_bell_is_audible ()) - { - if (!bell_audible_notify (display, window)) - { - /* Force a classic bell if the libcanberra bell failed. */ - XkbForceDeviceBell (display->xdisplay, - xkb_bell_event->device, - xkb_bell_event->bell_class, - xkb_bell_event->bell_id, - xkb_bell_event->percent); - } - } + return bell_audible_notify (display, window); + + return TRUE; } void diff --git a/src/core/bell.h b/src/core/bell.h index 6b8ed1e28..2e9cd3906 100644 --- a/src/core/bell.h +++ b/src/core/bell.h @@ -25,15 +25,14 @@ /** * meta_bell_notify: * @display: The display the bell event came in on - * @xkb_ev: The bell event we just received + * @window: The window the bell event was received on * - * Gives the user some kind of visual bell; in fact, this is our response - * to any kind of bell request, but we set it up so that we only get - * notified about visual bells, and X deals with audible ones. - * - * If the configure script found we had no XKB, this does not exist. + * Gives the user some kind of aural or visual feedback, such as a bell sound + * or flash. What type of feedback is invoked depends on the configuration. + * If the aural feedback could not be invoked, FALSE is returned. */ -void meta_bell_notify (MetaDisplay *display, XkbAnyEvent *xkb_ev); +gboolean meta_bell_notify (MetaDisplay *display, + MetaWindow *window); /** * meta_bell_set_audible: diff --git a/src/x11/events.c b/src/x11/events.c index 3270f81f5..6bead5a45 100644 --- a/src/x11/events.c +++ b/src/x11/events.c @@ -1162,6 +1162,30 @@ process_selection_clear (MetaDisplay *display, return TRUE; } +static void +notify_bell (MetaDisplay *display, + XkbAnyEvent *xkb_ev) +{ + XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent*) xkb_ev; + MetaWindow *window; + + window = meta_display_lookup_x_window (display, xkb_bell_event->window); + if (!window && display->focus_window && display->focus_window->frame) + window = display->focus_window; + + display->last_bell_time = xkb_ev->time; + if (!meta_bell_notify (display, window) && + meta_prefs_bell_is_audible ()) + { + /* Force a classic bell if the libcanberra bell failed. */ + XkbForceDeviceBell (display->xdisplay, + xkb_bell_event->device, + xkb_bell_event->bell_class, + xkb_bell_event->bell_id, + xkb_bell_event->percent); + } +} + static gboolean handle_other_xevent (MetaDisplay *display, XEvent *event) @@ -1618,8 +1642,7 @@ handle_other_xevent (MetaDisplay *display, if (XSERVER_TIME_IS_BEFORE(display->last_bell_time, xkb_ev->time - 100)) { - display->last_bell_time = xkb_ev->time; - meta_bell_notify (display, xkb_ev); + notify_bell (display, xkb_ev); } break; default: