After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 526635 - _gdk_window_get_toplevel handles FOREIGN windows incorrectly
_gdk_window_get_toplevel handles FOREIGN windows incorrectly
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
2.13.x
Other Linux
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-04-07 03:05 UTC by Nathaniel Smith
Modified: 2008-05-25 23:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed fix (348 bytes, patch)
2008-04-07 03:08 UTC, Nathaniel Smith
committed Details | Review

Description Nathaniel Smith 2008-04-07 03:05:22 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.
Comment 1 Nathaniel Smith 2008-04-07 03:08:48 UTC
Created attachment 108758 [details] [review]
proposed fix

Here is the fix proposed above, as a unified diff.
Comment 2 Cody Russell 2008-05-25 23:27:42 UTC
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.