Commit 247e1945 authored by Alexander Larsson's avatar Alexander Larsson
Browse files

window_get_pointer should return the direct child

We returned the innermost child that has the pointer, which is not right.
Only the direct child that has the pointer in it should be reported (if any).
parent 55ee12c2
...@@ -517,17 +517,17 @@ gdk_display_real_get_window_at_pointer (GdkDisplay *display, ...@@ -517,17 +517,17 @@ gdk_display_real_get_window_at_pointer (GdkDisplay *display,
if (window) if (window)
{ {
double xx, yy; double xx, yy;
window = _gdk_window_find_descendant_at (window, window = _gdk_window_find_descendant_at (window,
x, y, x, y,
&xx, &yy); &xx, &yy);
x = floor (xx + 0.5); x = floor (xx + 0.5);
y = floor (yy + 0.5); y = floor (yy + 0.5);
} }
*win_x = x; *win_x = x;
*win_y = y; *win_y = y;
return window; return window;
} }
...@@ -545,35 +545,20 @@ gdk_window_real_window_get_pointer (GdkDisplay *display, ...@@ -545,35 +545,20 @@ gdk_window_real_window_get_pointer (GdkDisplay *display,
private = (GdkWindowObject *) window; private = (GdkWindowObject *) window;
pointer_window = _gdk_windowing_window_get_pointer (display, _gdk_windowing_window_get_pointer (display,
window, window,
&tmpx, &tmpy, &tmpx, &tmpy,
mask); mask);
/* We got the coords on the impl, conver to the window */ /* We got the coords on the impl, conver to the window */
tmpx -= private->abs_x; tmpx -= private->abs_x;
tmpy -= private->abs_y; tmpy -= private->abs_y;
if (x) if (x)
*x = tmpx; *x = tmpx;
if (y) if (y)
*y = tmpy; *y = tmpy;
/* We need to recalculate the true child window with the pointer in it return _gdk_window_find_child_at (window, x, y);
due to possible client side child windows */
if (pointer_window != NULL)
{
/* First get the pointer coords relative to pointer_window */
_gdk_windowing_window_get_pointer (display,
pointer_window,
&tmpx, &tmpy,
&tmp_mask);
/* Then convert that to a client side window */
pointer_window = _gdk_window_find_descendant_at (pointer_window,
tmpx, tmpy,
NULL, NULL);
}
return pointer_window;
} }
/** /**
......
...@@ -606,6 +606,8 @@ void _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface, ...@@ -606,6 +606,8 @@ void _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
cairo_surface_t * _gdk_windowing_create_cairo_surface (GdkDrawable *drawable, cairo_surface_t * _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
int width, int width,
int height); int height);
GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
int x, int y);
GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel, GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
double x, double y, double x, double y,
double *found_x, double *found_x,
......
...@@ -7795,6 +7795,38 @@ convert_toplevel_coords_to_window (GdkWindow *window, ...@@ -7795,6 +7795,38 @@ convert_toplevel_coords_to_window (GdkWindow *window,
*window_y = y; *window_y = y;
} }
GdkWindow *
_gdk_window_find_child_at (GdkWindow *window,
int x, int y)
{
GdkWindowObject *private, *sub;
double child_x, child_y;
GList *l;
private = (GdkWindowObject *)window;
if (point_in_window (private, x, y))
{
/* Children is ordered in reverse stack order, i.e. first is topmost */
for (l = private->children; l != NULL; l = l->next)
{
sub = l->data;
if (!GDK_WINDOW_IS_MAPPED (sub))
continue;
convert_coords_to_child (sub,
x, y,
&child_x, &child_y);
if (point_in_window (sub, child_x, child_y))
return (GdkWindow *)sub;
}
}
return NULL;
}
GdkWindow * GdkWindow *
_gdk_window_find_descendant_at (GdkWindow *toplevel, _gdk_window_find_descendant_at (GdkWindow *toplevel,
double x, double y, double x, double y,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment