From 382252b812129ba894ec105d3075b1f80a6f7085 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 10 Feb 2009 05:10:04 +0000 Subject: play alert sound for system bell --- metacity-canberra.patch | 172 ++++++++++++++++++++++++++++++++++++++++++++++++ metacity.spec | 15 ++++- 2 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 metacity-canberra.patch diff --git a/metacity-canberra.patch b/metacity-canberra.patch new file mode 100644 index 0000000..53f1441 --- /dev/null +++ b/metacity-canberra.patch @@ -0,0 +1,172 @@ +--- metacity-2.25.144/configure.in 2009-02-01 15:33:42.000000000 -0500 ++++ hacked/configure.in 2009-02-09 21:15:32.000000000 -0500 +@@ -107,7 +107,7 @@ + fi + changequote([,])dnl + +-METACITY_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0' ++METACITY_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0 libcanberra-gtk' + + AC_ARG_ENABLE(gconf, + AC_HELP_STRING([--disable-gconf], +--- metacity-2.25.144/src/core/bell.c 2009-02-01 15:33:15.000000000 -0500 ++++ hacked/src/core/bell.c 2009-02-09 23:50:43.000000000 -0500 +@@ -52,6 +52,7 @@ + #include "bell.h" + #include "screen-private.h" + #include "prefs.h" ++#include + + /** + * Flashes one entire screen. This is done by making a window the size of the +@@ -223,7 +224,7 @@ + */ + static void + bell_flash_frame (MetaDisplay *display, +- XkbAnyEvent *xkb_ev) ++ XkbAnyEvent *xkb_ev) + { + XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent *) xkb_ev; + MetaWindow *window; +@@ -280,6 +281,47 @@ + /* flash something */ + if (meta_prefs_get_visual_bell ()) + bell_visual_notify (display, xkb_ev); ++ ++ if (meta_prefs_bell_is_audible ()) ++ { ++ ca_proplist *p; ++ XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent*) xkb_ev; ++ MetaWindow *window; ++ int res; ++ ++ ca_proplist_create (&p); ++ ca_proplist_sets (p, CA_PROP_EVENT_ID, "bell-window-system"); ++ ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, _("Bell event")); ++ ca_proplist_sets (p, CA_PROP_MEDIA_ROLE, "event"); ++ ca_proplist_sets (p, CA_PROP_CANBERRA_ENABLE, "1"); ++ ++ window = meta_display_lookup_x_window (display, xkb_bell_event->window); ++ if (!window && (display->focus_window) && (display->focus_window->frame)) ++ window = display->focus_window; ++ ++ if (window) ++ { ++ ca_proplist_sets (p, CA_PROP_WINDOW_NAME, window->title); ++ ca_proplist_setf (p, CA_PROP_WINDOW_X11_XID, "%lu", (unsigned long)window->xwindow); ++ ca_proplist_sets (p, CA_PROP_APPLICATION_NAME, window->res_name); ++ ca_proplist_setf (p, CA_PROP_APPLICATION_PROCESS_ID, "%d", window->net_wm_pid); ++ } ++ ++ /* First, we try to play a real sound ... */ ++ res = ca_context_play_full (ca_gtk_context_get (), 1, p, NULL, NULL); ++ ++ ca_proplist_destroy (p); ++ ++ if (res != CA_SUCCESS && res != CA_ERROR_DISABLED) ++ { ++ /* ...and in case that failed we use the classic X11 bell. */ ++ XkbForceDeviceBell (display->xdisplay, ++ xkb_bell_event->device, ++ xkb_bell_event->bell_class, ++ xkb_bell_event->bell_id, ++ xkb_bell_event->percent); ++ } ++ } + } + #endif /* HAVE_XKB */ + +@@ -321,8 +363,7 @@ + XkbChangeEnabledControls (display->xdisplay, + XkbUseCoreKbd, + XkbAudibleBellMask, +- meta_prefs_bell_is_audible () +- ? XkbAudibleBellMask : 0); ++ 0); + if (visual_bell_auto_reset) { + XkbSetAutoResetControls (display->xdisplay, + XkbAudibleBellMask, +--- metacity-2.25.144/src/core/workspace.c 2009-02-01 15:33:15.000000000 -0500 ++++ hacked/src/core/workspace.c 2009-02-09 21:15:32.000000000 -0500 +@@ -29,6 +29,7 @@ + #include "prefs.h" + #include + #include ++#include + + void meta_workspace_queue_calc_showing (MetaWorkspace *workspace); + static void set_active_space_hint (MetaScreen *screen); +@@ -306,6 +307,63 @@ + } + } + ++static void workspace_switch_sound(MetaWorkspace *from, ++ MetaWorkspace *to) { ++ ++ MetaWorkspaceLayout layout; ++ int i, nw, x, y, fi, ti; ++ const char *e; ++ ++ nw = meta_screen_get_n_workspaces(from->screen); ++ fi = meta_workspace_index(from); ++ ti = meta_workspace_index(to); ++ ++ meta_screen_calc_workspace_layout(from->screen, ++ nw, ++ fi, ++ &layout); ++ ++ for (i = 0; i < nw; i++) ++ if (layout.grid[i] == ti) ++ break; ++ ++ if (i >= nw) { ++ meta_bug("Failed to find destination workspace in layout\n"); ++ goto finish; ++ } ++ ++ y = i / layout.cols; ++ x = i % layout.cols; ++ ++ /* We priorize horizontal over vertical movements here. The ++ rationale for this is that horizontal movements are probably more ++ interesting for sound effects because speakers are usually ++ positioned on a horizontal and not a vertical axis. i.e. your ++ spatial "Woosh!" effects will easily be able to encode horizontal ++ movement but not such much vertical movement. */ ++ ++ if (x < layout.current_col) ++ e = "desktop-switch-left"; ++ else if (x > layout.current_col) ++ e = "desktop-switch-right"; ++ else if (y < layout.current_row) ++ e = "desktop-switch-up"; ++ else if (y > layout.current_row) ++ e = "desktop-switch-down"; ++ else { ++ meta_bug("Uh, origin and destination workspace at same logic position!\n"); ++ goto finish; ++ } ++ ++ ca_context_play(ca_gtk_context_get(), 1, ++ CA_PROP_EVENT_ID, e, ++ CA_PROP_EVENT_DESCRIPTION, "Desktop switched", ++ NULL); ++ ++ finish: ++ meta_screen_free_workspace_layout (&layout); ++} ++ + void + meta_workspace_activate_with_focus (MetaWorkspace *workspace, + MetaWindow *focus_this, +@@ -320,6 +378,9 @@ + if (workspace->screen->active_workspace == workspace) + return; + ++ if (workspace->screen->active_workspace) ++ workspace_switch_sound(workspace->screen->active_workspace, workspace); ++ + /* Note that old can be NULL; e.g. when starting up */ + old = workspace->screen->active_workspace; + diff --git a/metacity.spec b/metacity.spec index 4d73280..451d441 100644 --- a/metacity.spec +++ b/metacity.spec @@ -1,12 +1,14 @@ Summary: Unobtrusive window manager Name: metacity Version: 2.25.144 -Release: 1%{?dist} +Release: 2%{?dist} URL: http://download.gnome.org/sources/metacity/ Source0: http://download.gnome.org/sources/metacity/2.25/metacity-%{version}.tar.bz2 Patch0: default-theme.patch # http://bugzilla.gnome.org/show_bug.cgi?id=558723 Patch4: stop-spamming-xsession-errors.patch +# http://bugzilla.gnome.org/show_bug.cgi?id=557921 +Patch5: metacity-canberra.patch License: GPLv2+ Group: User Interface/Desktops @@ -17,6 +19,7 @@ BuildRequires: fontconfig-devel BuildRequires: GConf2-devel >= 2.2.0 BuildRequires: desktop-file-utils >= 0.3 BuildRequires: libglade2-devel >= 2.0.0 +BuildRequires: autoconf, automake, libtool BuildRequires: intltool >= 0.35 BuildRequires: startup-notification-devel >= 0.7 BuildRequires: libtool automake autoconf gettext @@ -66,6 +69,9 @@ API. This package exists purely for technical reasons. %setup -q %patch0 -p1 -b .default-theme %patch4 -p1 -b .stop-spamming-xsession-errors +%patch5 -p1 -b .canberra + +autoreconf -i -f %build rm -rf $RPM_BUILD_ROOT @@ -90,6 +96,7 @@ done make CPPFLAGS="$CPPFLAGS" LIBS="$LIBS" +%if 0 # strip unneeded translations from .mo files cd po grep -v ".*[.]desktop[.]in$\|.*[.]server[.]in$\|.*[.]schemas[.]in$" POTFILES.in > POTFILES.keep @@ -99,7 +106,7 @@ for p in *.po; do msgmerge $p metacity.pot > $p.out msgfmt -o `basename $p .po`.gmo $p.out done - +%endif %install rm -rf $RPM_BUILD_ROOT @@ -168,6 +175,10 @@ fi %{_mandir}/man1/metacity-window-demo.1.gz %changelog +* Tue Feb 10 2009 Matthias Clasen - 2.25.144-2 +- Use libcanberra to play the alert sound from the sound theme + for the audible system bell + * Tue Feb 3 2009 Matthias Clasen - 2.25.144-1 - Update to 2.25.144 -- cgit