Merge lp:~ted/indicator-appmenu/transient-windows into lp:indicator-appmenu/0.3

Proposed by Ted Gould
Status: Merged
Merged at revision: 24
Proposed branch: lp:~ted/indicator-appmenu/transient-windows
Merge into: lp:indicator-appmenu/0.3
Diff against target: 43 lines (+14/-10)
1 file modified
src/indicator-appmenu.c (+14/-10)
To merge this branch: bzr merge lp:~ted/indicator-appmenu/transient-windows
Reviewer Review Type Date Requested Status
David Barth Needs Information
Review via email: mp+27669@code.launchpad.net

Description of the change

Use the new transient window functions in bamf to try and choose the right menu.

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

I don't like that the 'while' may loop endlessly if there is an issue with the stack of parent and transient windows, especially for unsupported applications which will have no menus.
I would have expected the transient window to be the focused one, and the code to look for the /parent/ menu (ie bamf_get_parent?).

If bamf already takes care of mapping app windows and their transient windows, why is a traversal of the stack required?

review: Needs Information
Revision history for this message
Ted Gould (ted) wrote :

On Wed, 2010-06-16 at 14:07 +0000, David Barth wrote:
> I don't like that the 'while' may loop endlessly if there is an issue with
> the stack of parent and transient windows, especially for unsupported
> applications which will have no menus.

I'm not sure what you want to do here. Some sort of max number of
parented windows? What would that max be?

> I would have expected the transient window to be the focused one, and the
> code to look for the /parent/ menu (ie bamf_get_parent?).
>
> If bamf already takes care of mapping app windows and their transient
> windows, why is a traversal of the stack required?

My understanding is that you can be transient for a transient window in
theory. So we should be able to have about on top of the GIMP toolbox
which is on top of the GIMP image window.

Revision history for this message
Jason Smith (jassmith) wrote :

From a technical standpoint there is no potential for infinite loop with this. Bamf clearly separates transient windows from non-transient windows. Excluding cases where WM_TRANSIENT_FOR is set (which wont contain loops) bamf only allows transient windows to be transients for non-transient windows to avoid just this kind of loop.

Excluding a couple rare conditions with misbehaving applications, the parent transient tree will not be more than 1 deep.

Revision history for this message
Jason Smith (jassmith) wrote :

Except gimp doesn't set the transient hint HUZZAH!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-appmenu.c'
2--- src/indicator-appmenu.c 2010-06-12 02:30:44 +0000
3+++ src/indicator-appmenu.c 2010-06-16 04:36:27 +0000
4@@ -408,10 +408,20 @@
5
6 IndicatorAppmenu * appmenu = INDICATOR_APPMENU(user_data);
7
8- guint32 xid = bamf_window_get_xid(window);
9- g_debug("window changed to %d", xid);
10+ WindowMenus * menus = NULL;
11+ guint32 xid = 0;
12+
13+ while (window != NULL && menus == NULL) {
14+ xid = bamf_window_get_xid(window);
15
16- WindowMenus * menus = g_hash_table_lookup(appmenu->apps, GINT_TO_POINTER(xid));
17+ menus = g_hash_table_lookup(appmenu->apps, GUINT_TO_POINTER(xid));
18+
19+ if (menus == NULL) {
20+ window = bamf_window_get_transient(window);
21+ }
22+ }
23+
24+ g_debug("Switching to windows from XID %d", xid);
25
26 /* Note: This function can handle menus being NULL */
27 switch_default_app(appmenu, menus);
28@@ -457,14 +467,8 @@
29
30 /* Node: Does not cause ref */
31 BamfWindow * win = bamf_matcher_get_active_window(iapp->matcher);
32- guint32 xid = 0;
33- if (BAMF_IS_WINDOW(win)) {
34- xid = bamf_window_get_xid(win);
35- }
36
37- if (xid != 0 && xid == windowid) {
38- switch_default_app(iapp, wm);
39- }
40+ active_window_changed(iapp->matcher, NULL, BAMF_VIEW(win), iapp);
41 } else {
42 g_warning("Already have a menu for window ID %d with path %s from %s", windowid, objectpath, dbus_g_method_get_sender(method));
43 }

Subscribers

People subscribed via source and target branches