GNOME Bugzilla – Bug 526635
_gdk_window_get_toplevel handles FOREIGN windows incorrectly
Last modified: 2008-05-25 23:28:01 UTC
In gdk/x11/gdkwindow-x11.c, _gdk_window_get_toplevel contains the lines: if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) return NULL; This should instead be written: if (!WINDOW_IS_TOPLEVEL (window)) return NULL; The difference is that WINDOW_IS_TOPLEVEL returns false both for CHILD windows, and also for FOREIGN windows. Why does this matter? Well, partly, it's just more correct this way -- WINDOW_IS_TOPLEVEL and _gdk_window_get_toplevel are inconsistent about which windows they count as being "toplevel", yet they are used interchangeably within this file. This confusion also causes real bugs. For example: if you have a FOREIGN window and call gdk_window_show on it, then gdk_window_show calls set_initial_hints, and set_initial_hints uses the return value from _gdk_window_get_toplevel to determine whether it should set window manager hints on the window in question. So for FOREIGN windows, it *does* always set window manager hints. So currently, if you use gdk_window_foreign_new_for_display to get a GdkWindow representing another application's toplevel window, then calling gdk_window_show on that GdkWindow will clobber all of that other application's window manager hints. This is obviously not a common use-case, but it is causing me major difficulty in practice, and since the fix is trivial and obviously correct I request that it be applied going forward.
Created attachment 108758 [details] [review] proposed fix Here is the fix proposed above, as a unified diff.
2008-05-25 Cody Russell <bratsche@gnome.org> Bug 526635 - _gdk_window_get_toplevel handles FOREIGN windows * gdk/x11/gdkwindow-x11.c (_gdk_window_get_toplevel): Check !WINDOW_IS_TOPLEVEL instead of checking for GDK_WINDOW_CHILD, so that we also take into account for foreign windows. Report and patch by Nathaniel Smith.