GNOME Bugzilla – Bug 405868
Missing implementation of gdk_window_get_geometry()
Last modified: 2007-08-02 09:17:26 UTC
Please describe the problem: gdk_window_get_geometry() in gdkwindow-quartz.c is unimplemented. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 82175 [details] [review] simple implementation
Thanks! Adding my comments from gtk-devel-list: This looks like a good start. I wonder if we perhaps should try to mimic the X11 backend more closely and get the geometry from the NSWindow instead of using get_position/get_size that use the latest cached value? I think that you also need to check for a destroyed window (and perhaps special-case the root window).
Created attachment 92171 [details] [review] (More complete?) Patch Handles toplevel-, child- and root-window Patch does build and did not cause any sideeffects on my GKrellM build. No intensive testing done so far.
Thanks, looks good. One small comment, we are using the GNU coding style i GTK+, so patches in that style are appreciated. This is a small one so I can just fix it and commit, but for any bigger ones please consider trying to follow the style of the rest of the code. Thanks again!
I have committed a variant of the patch. I made some changes: First, we need to accept NULL and treat it as the root window. Second, the coordinates should actually be relative to the parent window in the X sense of it, i.e. for windows with borders, it should be relative to the window manager's frame, which unfortunately seems impossible to do without poking at private cocoa APIs, so I made it return (0, 0) for that case instead. For borderless windows it should be relative to the root, which works nicely. The bordered case seems kind of useless to me, so I will close this as fixed. If someone wants to look at fixing the less common case, feel free. Thanks again!
small comment on this part: ---- g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); if (!window) window = _gdk_root; ---- I'd say the if() part is never reached. If you want it to work for the root-window you have to remove "window == NULL", no? :)
No, that part makes sure that the window either is NULL, or a valid window object.