[gtk+/client-side-windows] window_get_pointer should return the direct child
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-windows] window_get_pointer should return the direct child
- Date: Mon, 8 Jun 2009 14:13:41 -0400 (EDT)
commit 247e1945a0b915725e752764bd8f7d8d46223849
Author: Alexander Larsson <alexl redhat com>
Date: Thu Jun 4 18:45:35 2009 +0200
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).
---
gdk/gdkdisplay.c | 35 ++++++++++-------------------------
gdk/gdkinternals.h | 2 ++
gdk/gdkwindow.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index ae9c8f9..7ee0048 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -517,17 +517,17 @@ gdk_display_real_get_window_at_pointer (GdkDisplay *display,
if (window)
{
double xx, yy;
-
+
window = _gdk_window_find_descendant_at (window,
- x, y,
+ x, y,
&xx, &yy);
x = floor (xx + 0.5);
y = floor (yy + 0.5);
}
-
+
*win_x = x;
*win_y = y;
-
+
return window;
}
@@ -545,35 +545,20 @@ gdk_window_real_window_get_pointer (GdkDisplay *display,
private = (GdkWindowObject *) window;
- pointer_window = _gdk_windowing_window_get_pointer (display,
- window,
- &tmpx, &tmpy,
- mask);
+ _gdk_windowing_window_get_pointer (display,
+ window,
+ &tmpx, &tmpy,
+ mask);
/* We got the coords on the impl, conver to the window */
tmpx -= private->abs_x;
tmpy -= private->abs_y;
-
+
if (x)
*x = tmpx;
if (y)
*y = tmpy;
- /* We need to recalculate the true child window with the pointer in it
- 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;
+ return _gdk_window_find_child_at (window, x, y);
}
/**
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index d3c74cd..f1124a3 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -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,
int width,
int height);
+GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
+ int x, int y);
GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
double x, double y,
double *found_x,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 3619a1c..d85c067 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -7796,6 +7796,38 @@ convert_toplevel_coords_to_window (GdkWindow *window,
}
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 *
_gdk_window_find_descendant_at (GdkWindow *toplevel,
double x, double y,
double *found_x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]