ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #02357
lp:~indicator-applet-developers/indicator-appmenu/dont-use-gdk-window-foreign into lp:indicator-appmenu
Neil J. Patel has proposed merging lp:~indicator-applet-developers/indicator-appmenu/dont-use-gdk-window-foreign into lp:indicator-appmenu.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
Related bugs:
#637108 Maximised windows are automatically closed
https://bugs.launchpad.net/bugs/637108
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.
--
https://code.launchpad.net/~indicator-applet-developers/indicator-appmenu/dont-use-gdk-window-foreign/+merge/35659
Your team ayatana-commits is subscribed to branch lp:indicator-appmenu.
=== modified file 'src/gdk-get-func.c'
--- src/gdk-get-func.c 2010-06-25 02:30:47 +0000
+++ src/gdk-get-func.c 2010-09-16 13:15:59 +0000
@@ -80,7 +80,7 @@
GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
static MotifWmHints *
-gdk_window_get_mwm_hints (GdkWindow *window)
+gdk_xid_get_mwm_hints (Window window)
{
GdkDisplay *display;
Atom hints_atom = None;
@@ -90,14 +90,11 @@
gulong nitems;
gulong bytes_after;
- if (GDK_WINDOW_DESTROYED (window))
- return NULL;
-
- display = gdk_drawable_get_display (window);
+ display = gdk_display_get_default ();
hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
- XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), window,
hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
False, AnyPropertyType, &type, &format, &nitems,
&bytes_after, &data);
@@ -110,33 +107,29 @@
/**
* gdk_window_get_functions:
- * @window: The toplevel #GdkWindow to get the functions from
+ * @window: The toplevel #X11Window to get the functions for
* @functions: The window functions will be written here
*
* Returns the functions set on the GdkWindow with #gdk_window_set_functions
* Returns: TRUE if the window has functions set, FALSE otherwise.
**/
gboolean
-egg_window_get_functions(GdkWindow *window,
- GdkWMFunction *functions)
+egg_xid_get_functions (Window window,
+ GdkWMFunction *functions)
{
MotifWmHints *hints;
gboolean result = FALSE;
- if (GDK_WINDOW_DESTROYED (window) ||
- !WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
- return FALSE;
-
- hints = gdk_window_get_mwm_hints (window);
+ hints = gdk_xid_get_mwm_hints (window);
if (hints)
{
if (hints->flags & MWM_HINTS_FUNCTIONS)
- {
- if (functions)
- *functions = hints->functions;
- result = TRUE;
- }
+ {
+ if (functions)
+ *functions = hints->functions;
+ result = TRUE;
+ }
XFree (hints);
}
=== modified file 'src/gdk-get-func.h'
--- src/gdk-get-func.h 2010-06-25 02:30:47 +0000
+++ src/gdk-get-func.h 2010-09-16 13:15:59 +0000
@@ -1,3 +1,1 @@
-
-gboolean egg_window_get_functions(GdkWindow *window, GdkWMFunction *functions);
-
+gboolean egg_xid_get_functions (Window window, GdkWMFunction *functions);
=== modified file 'src/indicator-appmenu.c'
--- src/indicator-appmenu.c 2010-09-15 19:08:47 +0000
+++ src/indicator-appmenu.c 2010-09-16 13:15:59 +0000
@@ -757,15 +757,9 @@
if (xid == 0) {
return;
}
-
- GdkWindow * window = gdk_window_foreign_new(xid);
- if (window == NULL) {
- g_warning("Unable to get foreign window for: %d", xid);
- return;
- }
-
+
GdkWMFunction functions;
- if (!egg_window_get_functions(window, &functions)) {
+ if (!egg_xid_get_functions(xid, &functions)) {
g_debug("Unable to get MWM functions for: %d", xid);
functions = GDK_FUNC_ALL;
}
@@ -774,8 +768,6 @@
gtk_widget_set_sensitive(GTK_WIDGET(iapp->close_item), TRUE);
}
- g_object_unref(window);
-
return;
}
@@ -794,6 +786,7 @@
switch_active_window(iapp, active_window);
return;
}
+
if (iapp->default_app == NULL && iapp->active_window == active_window && newdef == NULL) {
/* There's no application menus, but the active window hasn't
changed. So there's no change. */
@@ -802,6 +795,7 @@
entry_head = indicator_object_get_entries(INDICATOR_OBJECT(iapp));
+
for (entries = entry_head; entries != NULL; entries = g_list_next(entries)) {
IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
@@ -817,6 +811,7 @@
}
g_list_free(entry_head);
+
/* Disconnect signals */
if (iapp->sig_entry_added != 0) {
Follow ups