Make libcanberra support optional

Add a configure switch:

 --with-libcanberra=[yes/no/auto]

(defaulting to auto); if libcanberra is not found or explicitly
disabled, then the default system bell will be used for the bell
sound and no switch workspace sound is played.

https://bugzilla.gnome.org/show_bug.cgi?id=609585
This commit is contained in:
Owen W. Taylor 2010-02-11 10:28:20 -05:00
parent 1253e6c64e
commit 857c8aaaa2
3 changed files with 48 additions and 5 deletions

View File

@ -124,7 +124,7 @@ if test "x$GCC" = "xyes"; then
fi fi
changequote([,])dnl changequote([,])dnl
MUTTER_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0 libcanberra-gtk' MUTTER_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0'
AC_ARG_ENABLE(gconf, AC_ARG_ENABLE(gconf,
AC_HELP_STRING([--disable-gconf], AC_HELP_STRING([--disable-gconf],
@ -160,6 +160,11 @@ AC_ARG_WITH(introspection,
[disable the use of GObject introspection]),, [disable the use of GObject introspection]),,
with_introspection=auto) with_introspection=auto)
AC_ARG_WITH(libcanberra,
AC_HELP_STRING([--without-libcanberra],
[disable the use of libcanberra for playing sounds]),,
with_libcanberra=auto)
AC_ARG_ENABLE(xsync, AC_ARG_ENABLE(xsync,
AC_HELP_STRING([--disable-xsync], AC_HELP_STRING([--disable-xsync],
[disable mutter's use of the XSync extension]),, [disable mutter's use of the XSync extension]),,
@ -212,6 +217,24 @@ else
echo "Building without libstartup-notification" echo "Building without libstartup-notification"
fi fi
have_libcanberra=no
AC_MSG_CHECKING([libcanberra-gtk])
if test x$with_libcanberra = xno ; then
AC_MSG_RESULT([disabled])
else
if $PKG_CONFIG --exists libcanberra-gtk; then
have_libcanberra=yes
AC_MSG_RESULT(yes)
MUTTER_PC_MODULES="$MUTTER_PC_MODULES libcanberra-gtk"
AC_DEFINE([HAVE_LIBCANBERRA], 1, [Building with libcanberra for playing sounds])
else
AC_MSG_RESULT(no)
if test x$with_libcanberra = xyes ; then
AC_MSG_ERROR([libcanberra forced and libcanberra-gtk was not found])
fi
fi
fi
XCOMPOSITE_VERSION=0.2 XCOMPOSITE_VERSION=0.2
AC_MSG_CHECKING([Xcomposite >= $XCOMPOSITE_VERSION]) AC_MSG_CHECKING([Xcomposite >= $XCOMPOSITE_VERSION])
@ -532,6 +555,7 @@ mutter-$VERSION:
XFree86 Xinerama: ${use_xfree_xinerama} XFree86 Xinerama: ${use_xfree_xinerama}
Solaris Xinerama: ${use_solaris_xinerama} Solaris Xinerama: ${use_solaris_xinerama}
Startup notification: ${have_startup_notification} Startup notification: ${have_startup_notification}
libcanberra: ${have_libcanberra}
Introspection: ${have_introspection} Introspection: ${have_introspection}
Session management: ${found_sm} Session management: ${found_sm}
Shape extension: ${found_shape} Shape extension: ${found_shape}

View File

@ -52,7 +52,9 @@
#include "bell.h" #include "bell.h"
#include "screen-private.h" #include "screen-private.h"
#include "prefs.h" #include "prefs.h"
#ifdef HAVE_LIBCANBERRA
#include <canberra-gtk.h> #include <canberra-gtk.h>
#endif
/** /**
* Flashes one entire screen. This is done by making a window the size of the * Flashes one entire screen. This is done by making a window the size of the
@ -287,6 +289,7 @@ meta_bell_notify (MetaDisplay *display,
if (meta_prefs_get_visual_bell ()) if (meta_prefs_get_visual_bell ())
bell_visual_notify (display, xkb_ev); bell_visual_notify (display, xkb_ev);
#ifdef HAVE_LIBCANBERRA
if (meta_prefs_bell_is_audible ()) if (meta_prefs_bell_is_audible ())
{ {
ca_proplist *p; ca_proplist *p;
@ -326,12 +329,27 @@ meta_bell_notify (MetaDisplay *display,
xkb_bell_event->percent); xkb_bell_event->percent);
} }
} }
#endif /* HAVE_LIBCANBERRA */
} }
#endif /* HAVE_XKB */ #endif /* HAVE_XKB */
void void
meta_bell_set_audible (MetaDisplay *display, gboolean audible) meta_bell_set_audible (MetaDisplay *display, gboolean audible)
{ {
#ifdef HAVE_XKB
#ifdef HAVE_LIBCANBERRA
/* When we are playing sounds using libcanberra support, we handle the
* bell whether its an audible bell or a visible bell */
gboolean enable_system_bell = FALSE;
#else
gboolean enable_system_bell = audible;
#endif /* HAVE_LIBCANBERRA */
XkbChangeEnabledControls (display->xdisplay,
XkbUseCoreKbd,
XkbAudibleBellMask,
enable_system_bell ? XkbAudibleBellMask : 0);
#endif /* HAVE_XKB */
} }
gboolean gboolean
@ -358,10 +376,7 @@ meta_bell_init (MetaDisplay *display)
XkbUseCoreKbd, XkbUseCoreKbd,
XkbBellNotifyMask, XkbBellNotifyMask,
XkbBellNotifyMask); XkbBellNotifyMask);
XkbChangeEnabledControls (display->xdisplay, meta_bell_set_audible (display, meta_prefs_bell_is_audible ());
XkbUseCoreKbd,
XkbAudibleBellMask,
0);
if (visual_bell_auto_reset) { if (visual_bell_auto_reset) {
XkbSetAutoResetControls (display->xdisplay, XkbSetAutoResetControls (display->xdisplay,
XkbAudibleBellMask, XkbAudibleBellMask,

View File

@ -33,7 +33,9 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <string.h> #include <string.h>
#ifdef HAVE_LIBCANBERRA
#include <canberra-gtk.h> #include <canberra-gtk.h>
#endif
enum { enum {
PROP_0, PROP_0,
@ -444,6 +446,7 @@ static void
workspace_switch_sound(MetaWorkspace *from, workspace_switch_sound(MetaWorkspace *from,
MetaWorkspace *to) MetaWorkspace *to)
{ {
#ifdef HAVE_LIBCANBERRA
MetaWorkspaceLayout layout; MetaWorkspaceLayout layout;
int i, nw, x, y, fi, ti; int i, nw, x, y, fi, ti;
const char *e; const char *e;
@ -499,6 +502,7 @@ workspace_switch_sound(MetaWorkspace *from,
finish: finish:
meta_screen_free_workspace_layout (&layout); meta_screen_free_workspace_layout (&layout);
#endif /* HAVE_LIBCANBERRA */
} }
/** /**