From c9d9db0fcc8f29ab014c1e0b4b0b4f269f22f99c Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 9 Apr 2002 23:32:35 +0000 Subject: [PATCH] Fix problems with HandleBox and focusing - #78232 Tue Apr 9 19:01:28 2002 Owen Taylor Fix problems with HandleBox and focusing - #78232 * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle GtkHandleBox / GnomeDock style window heirarchy / widget heirarchy disconnects. :-(. * gtk/gtkcontainer.c: Handle failures from gtk_widget_translate_coordinates (Focusing is not right, but at least it doesn't go into infinite loops.) --- ChangeLog | 12 +++++++++ ChangeLog.pre-2-10 | 12 +++++++++ ChangeLog.pre-2-2 | 12 +++++++++ ChangeLog.pre-2-4 | 12 +++++++++ ChangeLog.pre-2-6 | 12 +++++++++ ChangeLog.pre-2-8 | 12 +++++++++ gtk/gtkcontainer.c | 67 +++++++++++++++++++++++++--------------------- gtk/gtkwidget.c | 6 +++++ 8 files changed, 114 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index c643fc778b..bf30889e5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue Apr 9 19:01:28 2002 Owen Taylor + + Fix problems with HandleBox and focusing - #78232 + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle + GtkHandleBox / GnomeDock style window heirarchy / widget + heirarchy disconnects. :-(. + + * gtk/gtkcontainer.c: Handle failures from + gtk_widget_translate_coordinates (Focusing is not right, but at + least it doesn't go into infinite loops.) + Tue Apr 9 18:34:58 2002 Owen Taylor * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c643fc778b..bf30889e5f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Tue Apr 9 19:01:28 2002 Owen Taylor + + Fix problems with HandleBox and focusing - #78232 + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle + GtkHandleBox / GnomeDock style window heirarchy / widget + heirarchy disconnects. :-(. + + * gtk/gtkcontainer.c: Handle failures from + gtk_widget_translate_coordinates (Focusing is not right, but at + least it doesn't go into infinite loops.) + Tue Apr 9 18:34:58 2002 Owen Taylor * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index c643fc778b..bf30889e5f 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +Tue Apr 9 19:01:28 2002 Owen Taylor + + Fix problems with HandleBox and focusing - #78232 + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle + GtkHandleBox / GnomeDock style window heirarchy / widget + heirarchy disconnects. :-(. + + * gtk/gtkcontainer.c: Handle failures from + gtk_widget_translate_coordinates (Focusing is not right, but at + least it doesn't go into infinite loops.) + Tue Apr 9 18:34:58 2002 Owen Taylor * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index c643fc778b..bf30889e5f 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Tue Apr 9 19:01:28 2002 Owen Taylor + + Fix problems with HandleBox and focusing - #78232 + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle + GtkHandleBox / GnomeDock style window heirarchy / widget + heirarchy disconnects. :-(. + + * gtk/gtkcontainer.c: Handle failures from + gtk_widget_translate_coordinates (Focusing is not right, but at + least it doesn't go into infinite loops.) + Tue Apr 9 18:34:58 2002 Owen Taylor * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c643fc778b..bf30889e5f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Tue Apr 9 19:01:28 2002 Owen Taylor + + Fix problems with HandleBox and focusing - #78232 + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle + GtkHandleBox / GnomeDock style window heirarchy / widget + heirarchy disconnects. :-(. + + * gtk/gtkcontainer.c: Handle failures from + gtk_widget_translate_coordinates (Focusing is not right, but at + least it doesn't go into infinite loops.) + Tue Apr 9 18:34:58 2002 Owen Taylor * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c643fc778b..bf30889e5f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Tue Apr 9 19:01:28 2002 Owen Taylor + + Fix problems with HandleBox and focusing - #78232 + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle + GtkHandleBox / GnomeDock style window heirarchy / widget + heirarchy disconnects. :-(. + + * gtk/gtkcontainer.c: Handle failures from + gtk_widget_translate_coordinates (Focusing is not right, but at + least it doesn't go into infinite loops.) + Tue Apr 9 18:34:58 2002 Owen Taylor * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index f35ab73254..b9aeea334e 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -1564,8 +1564,10 @@ up_down_compare (gconstpointer a, CompareInfo *compare = data; gint y1, y2; - get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1); - get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2); + if (!get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1)) + return 0; + if (!get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2)) + return 0; y1 = allocation1.y + allocation1.height / 2; y2 = allocation2.y + allocation2.height / 2; @@ -1592,6 +1594,7 @@ gtk_container_focus_sort_up_down (GtkContainer *container, { CompareInfo compare; GList *tmp_list; + GdkRectangle old_allocation; compare.container = container; compare.reverse = (direction == GTK_DIR_UP); @@ -1599,17 +1602,14 @@ gtk_container_focus_sort_up_down (GtkContainer *container, if (!old_focus) old_focus = find_old_focus (container, children); - if (old_focus) + if (old_focus && get_allocation_coords (container, old_focus, &old_allocation)) { - GdkRectangle old_allocation; gint compare_x1; gint compare_x2; gint compare_y; /* Delete widgets from list that don't match minimum criteria */ - get_allocation_coords (container, old_focus, &old_allocation); - compare_x1 = old_allocation.x; compare_x2 = old_allocation.x + old_allocation.width; @@ -1628,17 +1628,20 @@ gtk_container_focus_sort_up_down (GtkContainer *container, if (child != old_focus) { - get_allocation_coords (container, child, &child_allocation); - - child_x1 = child_allocation.x; - child_x2 = child_allocation.x + child_allocation.width; - - if ((child_x2 <= compare_x1 || child_x1 >= compare_x2) /* No horizontal overlap */ || - (direction == GTK_DIR_DOWN && child_allocation.y + child_allocation.height < compare_y) || /* Not below */ - (direction == GTK_DIR_UP && child_allocation.y > compare_y)) /* Not above */ + if (get_allocation_coords (container, child, &child_allocation)) { - children = g_list_delete_link (children, tmp_list); + child_x1 = child_allocation.x; + child_x2 = child_allocation.x + child_allocation.width; + + if ((child_x2 <= compare_x1 || child_x1 >= compare_x2) /* No horizontal overlap */ || + (direction == GTK_DIR_DOWN && child_allocation.y + child_allocation.height < compare_y) || /* Not below */ + (direction == GTK_DIR_UP && child_allocation.y > compare_y)) /* Not above */ + { + children = g_list_delete_link (children, tmp_list); + } } + else + children = g_list_delete_link (children, tmp_list); } tmp_list = next; @@ -1690,8 +1693,10 @@ left_right_compare (gconstpointer a, CompareInfo *compare = data; gint x1, x2; - get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1); - get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2); + if (!get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1)) + return 0; + if (!get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2)) + return 0; x1 = allocation1.x + allocation1.width / 2; x2 = allocation2.x + allocation2.width / 2; @@ -1718,6 +1723,7 @@ gtk_container_focus_sort_left_right (GtkContainer *container, { CompareInfo compare; GList *tmp_list; + GdkRectangle old_allocation; compare.container = container; compare.reverse = (direction == GTK_DIR_LEFT); @@ -1725,18 +1731,14 @@ gtk_container_focus_sort_left_right (GtkContainer *container, if (!old_focus) old_focus = find_old_focus (container, children); - if (old_focus) + if (old_focus && get_allocation_coords (container, old_focus, &old_allocation)) { - GdkRectangle old_allocation; - gint compare_y1; gint compare_y2; gint compare_x; /* Delete widgets from list that don't match minimum criteria */ - get_allocation_coords (container, old_focus, &old_allocation); - compare_y1 = old_allocation.y; compare_y2 = old_allocation.y + old_allocation.height; @@ -1755,17 +1757,20 @@ gtk_container_focus_sort_left_right (GtkContainer *container, if (child != old_focus) { - get_allocation_coords (container, child, &child_allocation); - - child_y1 = child_allocation.y; - child_y2 = child_allocation.y + child_allocation.height; - - if ((child_y2 <= compare_y1 || child_y1 >= compare_y2) /* No vertical overlap */ || - (direction == GTK_DIR_RIGHT && child_allocation.x + child_allocation.width < compare_x) || /* Not to left */ - (direction == GTK_DIR_LEFT && child_allocation.x > compare_x)) /* Not to right */ + if (get_allocation_coords (container, child, &child_allocation)) { - children = g_list_delete_link (children, tmp_list); + child_y1 = child_allocation.y; + child_y2 = child_allocation.y + child_allocation.height; + + if ((child_y2 <= compare_y1 || child_y1 >= compare_y2) /* No vertical overlap */ || + (direction == GTK_DIR_RIGHT && child_allocation.x + child_allocation.width < compare_x) || /* Not to left */ + (direction == GTK_DIR_LEFT && child_allocation.x > compare_x)) /* Not to right */ + { + children = g_list_delete_link (children, tmp_list); + } } + else + children = g_list_delete_link (children, tmp_list); } tmp_list = next; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8a91b0ac3e..16587033dd 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2481,6 +2481,9 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget, src_y += dy; window = gdk_window_get_parent (window); + + if (!window) /* Handle GtkHandleBox */ + return FALSE; } /* And back */ @@ -2495,6 +2498,9 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget, src_y -= dy; window = gdk_window_get_parent (window); + + if (!window) /* Handle GtkHandleBox */ + return FALSE; } /* Translate from window relative to allocation relative */