Move destroyed check to common code for get_origin & get_root_coords

Also remove weird return value from get_root_coords
This commit is contained in:
Alexander Larsson 2009-06-30 09:30:53 +02:00
parent 64e7c7828d
commit 3b6cf72f39
3 changed files with 27 additions and 16 deletions

View File

@ -6990,6 +6990,15 @@ gdk_window_get_origin (GdkWindow *window,
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
if (GDK_WINDOW_DESTROYED (window))
{
if (x)
*x = 0;
if (y)
*y = 0;
return 0;
}
private = (GdkWindowObject *) window;
GDK_WINDOW_IMPL_GET_IFACE (private->impl)->get_root_coords (window,
@ -7012,10 +7021,8 @@ gdk_window_get_origin (GdkWindow *window,
* window coordinates. This is similar to
* gdk_window_get_origin() but allows you go pass
* in any position in the window, not just the origin.
*
* Return value: not meaningful, ignore
*/
gint
void
gdk_window_get_root_coords (GdkWindow *window,
gint x,
gint y,
@ -7028,6 +7035,15 @@ gdk_window_get_root_coords (GdkWindow *window,
private = (GdkWindowObject *) window;
if (GDK_WINDOW_DESTROYED (window))
{
if (x)
*root_x = x;
if (y)
*root_y = y;
return;
}
GDK_WINDOW_IMPL_GET_IFACE (private->impl)->get_root_coords (window,
x + private->abs_x,
y + private->abs_y,

View File

@ -531,7 +531,7 @@ void gdk_window_get_position (GdkWindow *window,
gint gdk_window_get_origin (GdkWindow *window,
gint *x,
gint *y);
gint gdk_window_get_root_coords (GdkWindow *window,
void gdk_window_get_root_coords (GdkWindow *window,
gint x,
gint y,
gint *root_x,

View File

@ -2788,19 +2788,14 @@ gdk_window_x11_get_root_coords (GdkWindow *window,
{
gint return_val;
Window child;
gint tx = 0;
gint ty = 0;
gint tx;
gint ty;
if (!GDK_WINDOW_DESTROYED (window))
{
return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
GDK_WINDOW_XROOTWIN (window),
x, y, &tx, &ty,
&child);
}
else
return_val = 0;
return_val = XTranslateCoordinates (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
GDK_WINDOW_XROOTWIN (window),
x, y, &tx, &ty,
&child);
if (root_x)
*root_x = tx;