gtk: fixes for offscreen widgets

Fix gtk_widget_translate_coordinates() and
_gtk_widget_synthesize_crossing() so they work in hierarchies with
offscreen widgets.
This commit is contained in:
Michael Natterer 2010-04-15 13:02:04 +02:00
parent 5a52d2a2f0
commit fdf936b5ad

View File

@ -4183,6 +4183,7 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget,
{
GtkWidget *ancestor;
GdkWindow *window;
GList *dest_list = NULL;
g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
@ -4210,14 +4211,14 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget,
window = src_widget->window;
while (window != ancestor->window)
{
gint dx, dy;
gdk_window_get_position (window, &dx, &dy);
src_x += dx;
src_y += dy;
window = gdk_window_get_parent (window);
gdouble dx, dy;
gdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
src_x = dx;
src_y = dy;
window = gdk_window_get_effective_parent (window);
if (!window) /* Handle GtkHandleBox */
return FALSE;
@ -4227,17 +4228,27 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget,
window = dest_widget->window;
while (window != ancestor->window)
{
gint dx, dy;
gdk_window_get_position (window, &dx, &dy);
src_x -= dx;
src_y -= dy;
window = gdk_window_get_parent (window);
dest_list = g_list_prepend (dest_list, window);
window = gdk_window_get_effective_parent (window);
if (!window) /* Handle GtkHandleBox */
return FALSE;
{
g_list_free (dest_list);
return FALSE;
}
}
while (dest_list)
{
gdouble dx, dy;
gdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
src_x = dx;
src_y = dy;
dest_list = g_list_remove (dest_list, dest_list->data);
}
/* Translate from window relative to allocation relative */
@ -9030,7 +9041,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from,
while (from_ancestor != NULL)
{
from_ancestor = gdk_window_get_parent (from_ancestor);
from_ancestor = gdk_window_get_effective_parent (from_ancestor);
if (from_ancestor == NULL)
break;
from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
@ -9055,7 +9066,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from,
while (to_ancestor != NULL)
{
to_ancestor = gdk_window_get_parent (to_ancestor);
to_ancestor = gdk_window_get_effective_parent (to_ancestor);
if (to_ancestor == NULL)
break;
to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
@ -9084,7 +9095,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from,
{
if (from_ancestor != NULL)
{
from_ancestor = gdk_window_get_parent (from_ancestor);
from_ancestor = gdk_window_get_effective_parent (from_ancestor);
if (from_ancestor == to_window)
break;
if (from_ancestor)
@ -9092,7 +9103,7 @@ _gtk_widget_synthesize_crossing (GtkWidget *from,
}
if (to_ancestor != NULL)
{
to_ancestor = gdk_window_get_parent (to_ancestor);
to_ancestor = gdk_window_get_effective_parent (to_ancestor);
if (to_ancestor == from_window)
break;
if (to_ancestor)