GNOME Bugzilla – Bug 152481
gdk_window_get_root_origin fails on Windows
Last modified: 2004-12-22 21:47:04 UTC
calling this function on Windows, with a window type of GTK_WINDOW_POPUP only returns 0 for x and y. calling gdk_window_get_position works fine.
Created attachment 31525 [details] test case to demonstrate the bug.
This is caused by of the patch for bug #145481 . That patch added a call to gdk_window_set_skip_taskbar_hint (window, TRUE) for GDK_WINDOW_TEMP windows after they have been created, so that TEMP windows aren't visible in the task manager. Now, gdk_window_set_skip_taskbar_hint() works by setting the owner of a toplevel window. The Win32 concepts of owner and parent windows are often confused, but they are different. Toplevel windows can be owned, but don't have to be. Toplevel windows don't have parents. The GetParent() API furthers the confusion by actually returning *either* the parent *or* owner of a window, and even more confusing, to set the owner of a toplevel window you set something called GWL_HWNDPARENT... The problem with gdk_window_get_root_origin() and TEMP windows is actually in gdk_window_get_frame_extents(), which it calls. That function has a quite bogus loop that claims to "find the frame window" by calling GetParent() until the arriving at HWND_DESKTOP. This is crap, leftovers from blindly copying what the X11 backend does. Unlike how window managers on X11 work, in Windows the "decorations" of toplevel windows aren't windows by themselves. There is no "frame window". And the parent of toplevel windows isn't the HWND_DEKSTOP either, unlike X11 where the root window is the ultimate parent of all windows. The loop in gdk_window_get_frame_extents() happens to work because the value of HWND_DESKTOP is actually 0, so when GetParent() returns 0 for errors or unowned toplevel windows, the code thinks it means the desktop window... Thus it used to work, more or less by accident, but now when TEMP windows are owned, the loop finds the (hidden) owner window and thinks that it is a "frame window". Oooh aaah smack me harder. That loop serves no purpose and can be removed altogether.
Fixed in HEAD and gtk-2-4.