bell: Let the X11 caller deal with the X11 fallback

To support invoking the system bell on Wayland we shouldn't have paths
that fallback to X11. Let the X11 caller deal with the absence of
libcanberra, and change API to not take any X events.

https://bugzilla.gnome.org/show_bug.cgi?id=763284
This commit is contained in:
Jonas Ådahl 2016-03-07 12:46:18 +08:00
parent 9f1d1151b7
commit 417cb2b213
3 changed files with 36 additions and 29 deletions

View File

@ -203,33 +203,18 @@ bell_audible_notify (MetaDisplay *display,
return FALSE; return FALSE;
} }
void gboolean
meta_bell_notify (MetaDisplay *display, 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 */ /* flash something */
if (meta_prefs_get_visual_bell ()) if (meta_prefs_get_visual_bell ())
bell_visual_notify (display, window); bell_visual_notify (display, window);
if (meta_prefs_bell_is_audible ()) if (meta_prefs_bell_is_audible ())
{ return bell_audible_notify (display, window);
if (!bell_audible_notify (display, window))
{ return TRUE;
/* 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);
}
}
} }
void void

View File

@ -25,15 +25,14 @@
/** /**
* meta_bell_notify: * meta_bell_notify:
* @display: The display the bell event came in on * @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 * Gives the user some kind of aural or visual feedback, such as a bell sound
* to any kind of bell request, but we set it up so that we only get * or flash. What type of feedback is invoked depends on the configuration.
* notified about visual bells, and X deals with audible ones. * If the aural feedback could not be invoked, FALSE is returned.
*
* If the configure script found we had no XKB, this does not exist.
*/ */
void meta_bell_notify (MetaDisplay *display, XkbAnyEvent *xkb_ev); gboolean meta_bell_notify (MetaDisplay *display,
MetaWindow *window);
/** /**
* meta_bell_set_audible: * meta_bell_set_audible:

View File

@ -1162,6 +1162,30 @@ process_selection_clear (MetaDisplay *display,
return TRUE; 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 static gboolean
handle_other_xevent (MetaDisplay *display, handle_other_xevent (MetaDisplay *display,
XEvent *event) XEvent *event)
@ -1618,8 +1642,7 @@ handle_other_xevent (MetaDisplay *display,
if (XSERVER_TIME_IS_BEFORE(display->last_bell_time, if (XSERVER_TIME_IS_BEFORE(display->last_bell_time,
xkb_ev->time - 100)) xkb_ev->time - 100))
{ {
display->last_bell_time = xkb_ev->time; notify_bell (display, xkb_ev);
meta_bell_notify (display, xkb_ev);
} }
break; break;
default: default: