/[pkgs]/devel/metacity/metacity-canberra.patch
ViewVC logotype

Contents of /devel/metacity/metacity-canberra.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Tue Feb 10 05:10:04 2009 UTC (9 months, 1 week ago) by mclasen
Branch: MAIN
CVS Tags: metacity-2_28_0-1_fc12, metacity-2_25_144-2_fc11, metacity-2_27_1-1_fc12, F-12-split, metacity-2_25_144-6_fc11, metacity-2_25_144-5_fc11, metacity-2_25_144-4_fc11, metacity-2_26_0-2_fc12, metacity-2_27_0-5_fc12, metacity-2_27_0-8_fc12, F-11-split, metacity-2_27_0-9_fc12, metacity-2_26_0-1_fc11, metacity-2_27_0-2_fc12, metacity-2_27_0-1_fc12, metacity-2_27_0-4_fc12, metacity-2_27_0-3_fc12, metacity-2_27_0-6_fc12, metacity-2_27_0-7_fc12, HEAD
File MIME type: text/x-patch
play alert sound for system bell
1 --- metacity-2.25.144/configure.in 2009-02-01 15:33:42.000000000 -0500
2 +++ hacked/configure.in 2009-02-09 21:15:32.000000000 -0500
3 @@ -107,7 +107,7 @@
4 fi
5 changequote([,])dnl
6
7 -METACITY_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0'
8 +METACITY_PC_MODULES='gtk+-2.0 >= 2.10.0 pango >= 1.2.0 libcanberra-gtk'
9
10 AC_ARG_ENABLE(gconf,
11 AC_HELP_STRING([--disable-gconf],
12 --- metacity-2.25.144/src/core/bell.c 2009-02-01 15:33:15.000000000 -0500
13 +++ hacked/src/core/bell.c 2009-02-09 23:50:43.000000000 -0500
14 @@ -52,6 +52,7 @@
15 #include "bell.h"
16 #include "screen-private.h"
17 #include "prefs.h"
18 +#include <canberra-gtk.h>
19
20 /**
21 * Flashes one entire screen. This is done by making a window the size of the
22 @@ -223,7 +224,7 @@
23 */
24 static void
25 bell_flash_frame (MetaDisplay *display,
26 - XkbAnyEvent *xkb_ev)
27 + XkbAnyEvent *xkb_ev)
28 {
29 XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent *) xkb_ev;
30 MetaWindow *window;
31 @@ -280,6 +281,47 @@
32 /* flash something */
33 if (meta_prefs_get_visual_bell ())
34 bell_visual_notify (display, xkb_ev);
35 +
36 + if (meta_prefs_bell_is_audible ())
37 + {
38 + ca_proplist *p;
39 + XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent*) xkb_ev;
40 + MetaWindow *window;
41 + int res;
42 +
43 + ca_proplist_create (&p);
44 + ca_proplist_sets (p, CA_PROP_EVENT_ID, "bell-window-system");
45 + ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, _("Bell event"));
46 + ca_proplist_sets (p, CA_PROP_MEDIA_ROLE, "event");
47 + ca_proplist_sets (p, CA_PROP_CANBERRA_ENABLE, "1");
48 +
49 + window = meta_display_lookup_x_window (display, xkb_bell_event->window);
50 + if (!window && (display->focus_window) && (display->focus_window->frame))
51 + window = display->focus_window;
52 +
53 + if (window)
54 + {
55 + ca_proplist_sets (p, CA_PROP_WINDOW_NAME, window->title);
56 + ca_proplist_setf (p, CA_PROP_WINDOW_X11_XID, "%lu", (unsigned long)window->xwindow);
57 + ca_proplist_sets (p, CA_PROP_APPLICATION_NAME, window->res_name);
58 + ca_proplist_setf (p, CA_PROP_APPLICATION_PROCESS_ID, "%d", window->net_wm_pid);
59 + }
60 +
61 + /* First, we try to play a real sound ... */
62 + res = ca_context_play_full (ca_gtk_context_get (), 1, p, NULL, NULL);
63 +
64 + ca_proplist_destroy (p);
65 +
66 + if (res != CA_SUCCESS && res != CA_ERROR_DISABLED)
67 + {
68 + /* ...and in case that failed we use the classic X11 bell. */
69 + XkbForceDeviceBell (display->xdisplay,
70 + xkb_bell_event->device,
71 + xkb_bell_event->bell_class,
72 + xkb_bell_event->bell_id,
73 + xkb_bell_event->percent);
74 + }
75 + }
76 }
77 #endif /* HAVE_XKB */
78
79 @@ -321,8 +363,7 @@
80 XkbChangeEnabledControls (display->xdisplay,
81 XkbUseCoreKbd,
82 XkbAudibleBellMask,
83 - meta_prefs_bell_is_audible ()
84 - ? XkbAudibleBellMask : 0);
85 + 0);
86 if (visual_bell_auto_reset) {
87 XkbSetAutoResetControls (display->xdisplay,
88 XkbAudibleBellMask,
89 --- metacity-2.25.144/src/core/workspace.c 2009-02-01 15:33:15.000000000 -0500
90 +++ hacked/src/core/workspace.c 2009-02-09 21:15:32.000000000 -0500
91 @@ -29,6 +29,7 @@
92 #include "prefs.h"
93 #include <X11/Xatom.h>
94 #include <string.h>
95 +#include <canberra-gtk.h>
96
97 void meta_workspace_queue_calc_showing (MetaWorkspace *workspace);
98 static void set_active_space_hint (MetaScreen *screen);
99 @@ -306,6 +307,63 @@
100 }
101 }
102
103 +static void workspace_switch_sound(MetaWorkspace *from,
104 + MetaWorkspace *to) {
105 +
106 + MetaWorkspaceLayout layout;
107 + int i, nw, x, y, fi, ti;
108 + const char *e;
109 +
110 + nw = meta_screen_get_n_workspaces(from->screen);
111 + fi = meta_workspace_index(from);
112 + ti = meta_workspace_index(to);
113 +
114 + meta_screen_calc_workspace_layout(from->screen,
115 + nw,
116 + fi,
117 + &layout);
118 +
119 + for (i = 0; i < nw; i++)
120 + if (layout.grid[i] == ti)
121 + break;
122 +
123 + if (i >= nw) {
124 + meta_bug("Failed to find destination workspace in layout\n");
125 + goto finish;
126 + }
127 +
128 + y = i / layout.cols;
129 + x = i % layout.cols;
130 +
131 + /* We priorize horizontal over vertical movements here. The
132 + rationale for this is that horizontal movements are probably more
133 + interesting for sound effects because speakers are usually
134 + positioned on a horizontal and not a vertical axis. i.e. your
135 + spatial "Woosh!" effects will easily be able to encode horizontal
136 + movement but not such much vertical movement. */
137 +
138 + if (x < layout.current_col)
139 + e = "desktop-switch-left";
140 + else if (x > layout.current_col)
141 + e = "desktop-switch-right";
142 + else if (y < layout.current_row)
143 + e = "desktop-switch-up";
144 + else if (y > layout.current_row)
145 + e = "desktop-switch-down";
146 + else {
147 + meta_bug("Uh, origin and destination workspace at same logic position!\n");
148 + goto finish;
149 + }
150 +
151 + ca_context_play(ca_gtk_context_get(), 1,
152 + CA_PROP_EVENT_ID, e,
153 + CA_PROP_EVENT_DESCRIPTION, "Desktop switched",
154 + NULL);
155 +
156 + finish:
157 + meta_screen_free_workspace_layout (&layout);
158 +}
159 +
160 void
161 meta_workspace_activate_with_focus (MetaWorkspace *workspace,
162 MetaWindow *focus_this,
163 @@ -320,6 +378,9 @@
164 if (workspace->screen->active_workspace == workspace)
165 return;
166
167 + if (workspace->screen->active_workspace)
168 + workspace_switch_sound(workspace->screen->active_workspace, workspace);
169 +
170 /* Note that old can be NULL; e.g. when starting up */
171 old = workspace->screen->active_workspace;
172

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2