Merge lp:~indicator-applet-developers/indicator-appmenu/dont-use-gdk-window-foreign into lp:indicator-appmenu/0.3

Proposed by Neil J. Patel
Status: Merged
Merged at revision: 66
Proposed branch: lp:~indicator-applet-developers/indicator-appmenu/dont-use-gdk-window-foreign
Merge into: lp:indicator-appmenu/0.3
Diff against target: 136 lines (+18/-32)
3 files modified
src/gdk-get-func.c (+12/-19)
src/gdk-get-func.h (+1/-3)
src/indicator-appmenu.c (+5/-10)
To merge this branch: bzr merge lp:~indicator-applet-developers/indicator-appmenu/dont-use-gdk-window-foreign
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+35659@code.launchpad.net

Description of the change

This fixes the attached bug. Don't ask me why, because I honestly don't know. The code change should be safe, though, so I'm okay with proposing it.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gdk-get-func.c'
2--- src/gdk-get-func.c 2010-06-25 02:30:47 +0000
3+++ src/gdk-get-func.c 2010-09-16 13:15:59 +0000
4@@ -80,7 +80,7 @@
5 GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
6
7 static MotifWmHints *
8-gdk_window_get_mwm_hints (GdkWindow *window)
9+gdk_xid_get_mwm_hints (Window window)
10 {
11 GdkDisplay *display;
12 Atom hints_atom = None;
13@@ -90,14 +90,11 @@
14 gulong nitems;
15 gulong bytes_after;
16
17- if (GDK_WINDOW_DESTROYED (window))
18- return NULL;
19-
20- display = gdk_drawable_get_display (window);
21+ display = gdk_display_get_default ();
22
23 hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
24
25- XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
26+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), window,
27 hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
28 False, AnyPropertyType, &type, &format, &nitems,
29 &bytes_after, &data);
30@@ -110,33 +107,29 @@
31
32 /**
33 * gdk_window_get_functions:
34- * @window: The toplevel #GdkWindow to get the functions from
35+ * @window: The toplevel #X11Window to get the functions for
36 * @functions: The window functions will be written here
37 *
38 * Returns the functions set on the GdkWindow with #gdk_window_set_functions
39 * Returns: TRUE if the window has functions set, FALSE otherwise.
40 **/
41 gboolean
42-egg_window_get_functions(GdkWindow *window,
43- GdkWMFunction *functions)
44+egg_xid_get_functions (Window window,
45+ GdkWMFunction *functions)
46 {
47 MotifWmHints *hints;
48 gboolean result = FALSE;
49
50- if (GDK_WINDOW_DESTROYED (window) ||
51- !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
52- return FALSE;
53-
54- hints = gdk_window_get_mwm_hints (window);
55+ hints = gdk_xid_get_mwm_hints (window);
56
57 if (hints)
58 {
59 if (hints->flags & MWM_HINTS_FUNCTIONS)
60- {
61- if (functions)
62- *functions = hints->functions;
63- result = TRUE;
64- }
65+ {
66+ if (functions)
67+ *functions = hints->functions;
68+ result = TRUE;
69+ }
70
71 XFree (hints);
72 }
73
74=== modified file 'src/gdk-get-func.h'
75--- src/gdk-get-func.h 2010-06-25 02:30:47 +0000
76+++ src/gdk-get-func.h 2010-09-16 13:15:59 +0000
77@@ -1,3 +1,1 @@
78-
79-gboolean egg_window_get_functions(GdkWindow *window, GdkWMFunction *functions);
80-
81+gboolean egg_xid_get_functions (Window window, GdkWMFunction *functions);
82
83=== modified file 'src/indicator-appmenu.c'
84--- src/indicator-appmenu.c 2010-09-15 19:08:47 +0000
85+++ src/indicator-appmenu.c 2010-09-16 13:15:59 +0000
86@@ -757,15 +757,9 @@
87 if (xid == 0) {
88 return;
89 }
90-
91- GdkWindow * window = gdk_window_foreign_new(xid);
92- if (window == NULL) {
93- g_warning("Unable to get foreign window for: %d", xid);
94- return;
95- }
96-
97+
98 GdkWMFunction functions;
99- if (!egg_window_get_functions(window, &functions)) {
100+ if (!egg_xid_get_functions(xid, &functions)) {
101 g_debug("Unable to get MWM functions for: %d", xid);
102 functions = GDK_FUNC_ALL;
103 }
104@@ -774,8 +768,6 @@
105 gtk_widget_set_sensitive(GTK_WIDGET(iapp->close_item), TRUE);
106 }
107
108- g_object_unref(window);
109-
110 return;
111 }
112
113@@ -794,6 +786,7 @@
114 switch_active_window(iapp, active_window);
115 return;
116 }
117+
118 if (iapp->default_app == NULL && iapp->active_window == active_window && newdef == NULL) {
119 /* There's no application menus, but the active window hasn't
120 changed. So there's no change. */
121@@ -802,6 +795,7 @@
122
123 entry_head = indicator_object_get_entries(INDICATOR_OBJECT(iapp));
124
125+
126 for (entries = entry_head; entries != NULL; entries = g_list_next(entries)) {
127 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
128
129@@ -817,6 +811,7 @@
130 }
131
132 g_list_free(entry_head);
133+
134
135 /* Disconnect signals */
136 if (iapp->sig_entry_added != 0) {

Subscribers

People subscribed via source and target branches