diff options
author | Dylan McCall <[email protected]> | 2012-01-09 02:36:16 +0100 |
---|---|---|
committer | Benjamin Valentin <benpicco@rechenknecht2k7.(none)> | 2012-03-16 00:28:34 +0100 |
commit | 3f122b87a866edb62d0402058f83974cf8a8fd54 (patch) | |
tree | 94c68552e55d29a47a91bef3001449ef78f52801 | |
parent | 01aeeb15748062b183c5ec400ef7bad67cf60f27 (diff) | |
download | marco-3f122b87a866edb62d0402058f83974cf8a8fd54.tar.bz2 marco-3f122b87a866edb62d0402058f83974cf8a8fd54.tar.xz |
Use positional sound for audible window bell
Many components in the GNOME desktop use libcanberra-gtk to play sounds, which
has led us to a wonderful world of positional sounds (in many cases), where a
sound seems to come from the same direction as an interaction on the screen.
Metacity uses libcanberra for audible bells, so it is pretty straight-forward
to get the same feature. In my opinion, it would make Metacity's bell sound
suddenly awesome, for a number of reasons.
To implement the feature, Metacity needs to give a few extra properties to
Canberra, which describe the position of the window associated with the bell.
taken from https://bugzilla.gnome.org/show_bug.cgi?id=616743
-rw-r--r-- | src/core/bell.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/bell.c b/src/core/bell.c index 560b3569..efbfb7fd 100644 --- a/src/core/bell.c +++ b/src/core/bell.c @@ -300,10 +300,46 @@ meta_bell_notify (MetaDisplay *display, if (window) { + int x=-1, y=-1, width=-1, height=-1, screen_width=-1, screen_height=-1; + MetaScreen *screen; + + screen = meta_window_get_screen (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_setf (p, CA_PROP_WINDOW_X11_SCREEN, "%i", meta_screen_get_screen_number(screen)); 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); + + /* properties for positional sound based on window placement */ + meta_window_get_geometry (window, &x, &y, &width, &height); + ca_proplist_setf (p, CA_PROP_WINDOW_X, "%i", x); + ca_proplist_setf (p, CA_PROP_WINDOW_Y, "%i", y); + ca_proplist_setf (p, CA_PROP_WINDOW_WIDTH, "%i", width); + ca_proplist_setf (p, CA_PROP_WINDOW_HEIGHT, "%i", height); + + meta_screen_get_size (screen, &screen_width, &screen_height); + if (screen_width > 1) + { + x += width/2; + x = CLAMP(x, 0, screen_width-1); + + /* From libcanberra-gtk. + * We use these strange format strings here to avoid that libc + * applies locale information on the formatting of floating + * numbers. */ + + ca_proplist_setf (p, CA_PROP_WINDOW_HPOS, "%i.%03i", + (int) (x/(screen_width-1)), (int) (1000.0*x/(screen_width-1)) % 1000); + } + if (screen_height > 1) + { + y += height/2; + y = CLAMP(y, 0, screen_height-1); + + ca_proplist_setf (p, CA_PROP_WINDOW_VPOS, "%i.%03i", + (int) (y/(screen_height-1)), (int) (1000.0*y/(screen_height-1)) % 1000); + } } /* First, we try to play a real sound ... */ |