Merge lp:~3v1n0/indicator-appmenu/activate-all-menus into lp:indicator-appmenu/15.04

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 276
Merged at revision: 271
Proposed branch: lp:~3v1n0/indicator-appmenu/activate-all-menus
Merge into: lp:indicator-appmenu/15.04
Diff against target: 256 lines (+69/-54)
5 files modified
configure.ac (+0/-1)
src/indicator-appmenu.c (+64/-49)
src/window-menu-dbusmenu.c (+2/-2)
src/window-menu-model.c (+1/-0)
src/window-menu.c (+2/-2)
To merge this branch: bzr merge lp:~3v1n0/indicator-appmenu/activate-all-menus
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Azzarone (community) Approve
Review via email: mp+268738@code.launchpad.net

Commit message

IndicatorAppmenu: make sure we call window_menu_entry_activate also in AllMenus mode

Description of the change

Backporting fix to 15.04

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2015-02-03 10:07:34 +0000
3+++ configure.ac 2015-08-21 11:38:19 +0000
4@@ -45,7 +45,6 @@
5 ###########################
6
7 GTK_DOC_CHECK([1.9], [--flavour=no-tmpl])
8-AC_CONFIG_MACRO_DIR(m4)
9
10 ###########################
11 # GLib GSettings
12
13=== modified file 'src/indicator-appmenu.c'
14--- src/indicator-appmenu.c 2015-03-02 14:47:00 +0000
15+++ src/indicator-appmenu.c 2015-08-21 11:38:19 +0000
16@@ -181,6 +181,8 @@
17 BamfView * oldview,
18 BamfView * newview,
19 gpointer user_data);
20+static WindowMenu * update_active_window (IndicatorAppmenu * appmenu,
21+ BamfWindow *window);
22 static GQuark error_quark (void);
23 static void bus_method_call (GDBusConnection * connection,
24 const gchar * sender,
25@@ -750,6 +752,22 @@
26 {
27 guint count = 0;
28 IndicatorAppmenu * iapp = INDICATOR_APPMENU(io);
29+
30+ if (iapp->mode == MODE_UNITY_ALL_MENUS) {
31+ GHashTableIter iter;
32+ gpointer value;
33+
34+ g_hash_table_iter_init(&iter, iapp->apps);
35+ while (g_hash_table_iter_next(&iter, NULL, &value)) {
36+ count = window_menu_get_location(WINDOW_MENU (value), entry);
37+
38+ if (count != G_MAXUINT)
39+ return count;
40+ }
41+
42+ return 0;
43+ }
44+
45 if (iapp->default_app != NULL) {
46 /* Find the location in the app */
47 count = window_menu_get_location(iapp->default_app, entry);
48@@ -762,7 +780,7 @@
49 }
50 if (count == iapp->window_menus->len) {
51 g_warning("Unable to find entry in default window menus");
52- count = 0;
53+ count = G_MAXUINT;
54 }
55 } else {
56 /* Find the location in the desktop menu */
57@@ -770,7 +788,8 @@
58 count = window_menu_get_location(iapp->desktop_menu, entry);
59 }
60 }
61- return count;
62+
63+ return (count == G_MAXUINT) ? 0 : count;
64 }
65
66 /* Responds to a menuitem being activated on the panel. */
67@@ -811,33 +830,30 @@
68 static void
69 entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp)
70 {
71+ WindowMenu * menus = NULL;
72 IndicatorAppmenu * iapp = INDICATOR_APPMENU(io);
73
74 /* We need to force a focus change in this case as we probably
75 just haven't gotten the signal from BAMF yet */
76 if (windowid != 0) {
77- BamfView * newwindow = BAMF_VIEW(xid_to_bamf_window(iapp, windowid));
78+ BamfWindow * newwindow = xid_to_bamf_window(iapp, windowid);
79
80 if (newwindow != NULL) {
81- active_window_changed(iapp->matcher, BAMF_VIEW(iapp->active_window), newwindow, iapp);
82- }
83- }
84-
85- if (iapp->default_app != NULL) {
86- window_menu_entry_activate(iapp->default_app, entry, timestamp);
87- return;
88- }
89-
90- if (iapp->active_window == NULL) {
91- if (iapp->desktop_menu != NULL) {
92- window_menu_entry_activate(iapp->desktop_menu, entry, timestamp);
93- }
94- return;
95- }
96-
97- /* Else we've got stubs, and the stubs don't care. */
98-
99- return;
100+ menus = update_active_window(iapp, newwindow);
101+ }
102+ }
103+
104+ if (iapp->mode != MODE_UNITY_ALL_MENUS && iapp->default_app != NULL) {
105+ menus = iapp->default_app;
106+
107+ if (!menus && iapp->active_window == NULL) {
108+ menus = iapp->desktop_menu;
109+ }
110+ }
111+
112+ if (menus) {
113+ window_menu_entry_activate(menus, entry, timestamp);
114+ }
115 }
116
117 /* Checks to see we cared about a window that's going
118@@ -858,7 +874,7 @@
119
120 /* We're going to a state where we don't know what the active
121 window is, hopefully BAMF will save us */
122- active_window_changed (iapp->matcher, NULL, NULL, iapp);
123+ active_window_changed(iapp->matcher, NULL, NULL, iapp);
124
125 return;
126 }
127@@ -1072,41 +1088,41 @@
128 static void
129 active_window_changed (BamfMatcher * matcher, BamfView * oldview, BamfView * newview, gpointer user_data)
130 {
131- BamfWindow * window = NULL;
132-
133- if (newview != NULL) {
134- window = BAMF_WINDOW(newview);
135- if (window == NULL) {
136+ update_active_window(INDICATOR_APPMENU(user_data), (BamfWindow *) newview);
137+}
138+
139+static WindowMenu *
140+update_active_window (IndicatorAppmenu * appmenu, BamfWindow *window)
141+{
142+ WindowMenu * menus = NULL;
143+
144+ if (window != NULL) {
145+ if (!BAMF_IS_WINDOW(window)) {
146+ window = NULL;
147 g_warning("Active window changed to View thats not a window.");
148 }
149 } else {
150 g_debug("Active window is: NULL");
151 }
152
153- IndicatorAppmenu * appmenu = INDICATOR_APPMENU(user_data);
154-
155- if (window != NULL && appmenu->mode == MODE_UNITY_ALL_MENUS) {
156- ensure_menus(appmenu, window);
157- return;
158+ if (appmenu->mode == MODE_UNITY_ALL_MENUS) {
159+ if (window != NULL) {
160+ menus = ensure_menus(appmenu, window);
161+ }
162+ return menus;
163 }
164
165 if (window != NULL && bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) {
166 g_debug("Switching to menus from desktop");
167 switch_default_app(appmenu, NULL, NULL);
168- return;
169- }
170-
171- WindowMenu * menus = ensure_menus (appmenu, window);
172-
173- /* Note: We're not using window here, but re-casting the
174- newwindow variable. Which means we stay where we were
175- but get the menus from parents. */
176- g_debug("Switching to menus from XID %d", newview ? bamf_window_get_xid(BAMF_WINDOW(newview)) : 0);
177- if (newview != NULL) {
178- switch_default_app(appmenu, menus, BAMF_WINDOW(newview));
179- } else {
180- switch_default_app(appmenu, menus, NULL);
181- }
182+ return menus;
183+ }
184+
185+ g_debug("Switching to menus from XID %d", window ? bamf_window_get_xid(window) : 0);
186+ menus = ensure_menus(appmenu, window);
187+ switch_default_app(appmenu, menus, window);
188+
189+ return menus;
190 }
191
192 /* Respond to the menus being destroyed. We need to deregister
193@@ -1176,8 +1192,7 @@
194
195 /* Note: Does not cause ref */
196 BamfWindow * win = bamf_matcher_get_active_window(iapp->matcher);
197-
198- active_window_changed(iapp->matcher, NULL, BAMF_VIEW(win), iapp);
199+ update_active_window(iapp, win);
200 } else {
201 if (windowid == 0) {
202 g_warning("Can't build windows for a NULL window ID %d with path %s from %s", windowid, objectpath, sender);
203
204=== modified file 'src/window-menu-dbusmenu.c'
205--- src/window-menu-dbusmenu.c 2015-01-29 14:46:43 +0000
206+++ src/window-menu-dbusmenu.c 2015-08-21 11:38:19 +0000
207@@ -455,7 +455,7 @@
208 g_return_val_if_fail(IS_WINDOW_MENU_DBUSMENU(wm), 0);
209
210 if (entry == NULL) {
211- return 0;
212+ return G_MAXUINT;
213 }
214
215 guint i;
216@@ -467,7 +467,7 @@
217 }
218
219 if (i == priv->entries->len) {
220- return 0;
221+ return G_MAXUINT;
222 }
223
224 return i;
225
226=== modified file 'src/window-menu-model.c'
227--- src/window-menu-model.c 2015-03-02 14:37:03 +0000
228+++ src/window-menu-model.c 2015-08-21 11:38:19 +0000
229@@ -602,6 +602,7 @@
230 /* NOTE: Not printing any of the values here because there's
231 a pretty good chance that they're not valid. Let's not crash
232 things here. */
233+ pos = G_MAXUINT;
234 g_warning("Unable to find entry: %p", entry);
235 }
236
237
238=== modified file 'src/window-menu.c'
239--- src/window-menu.c 2014-03-19 13:07:30 +0000
240+++ src/window-menu.c 2015-08-21 11:38:19 +0000
241@@ -150,14 +150,14 @@
242 guint
243 window_menu_get_location (WindowMenu * wm, IndicatorObjectEntry * entry)
244 {
245- g_return_val_if_fail (IS_WINDOW_MENU(wm), 0);
246+ g_return_val_if_fail (IS_WINDOW_MENU(wm), G_MAXUINT);
247
248 WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm);
249
250 if (class->get_location != NULL) {
251 return class->get_location(wm, entry);
252 } else {
253- return 0;
254+ return G_MAXUINT;
255 }
256 }
257

Subscribers

People subscribed via source and target branches