From 740252b0cf68b3977dd19d0c2b5b29ea00f688af Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 11 Feb 2004 01:21:14 +0000 Subject: [PATCH] Handle focus [hv]adjustment correctly when the focus is located deeper Wed Feb 11 02:23:39 2004 Matthias Clasen * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle focus [hv]adjustment correctly when the focus is located deeper down in the hierarchy. (#133489) --- ChangeLog | 7 ++++++- ChangeLog.pre-2-10 | 7 ++++++- ChangeLog.pre-2-4 | 7 ++++++- ChangeLog.pre-2-6 | 7 ++++++- ChangeLog.pre-2-8 | 7 ++++++- gtk/gtkcontainer.c | 45 +++++++++++++++++++++++++++++---------------- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b20e06d03..1399a74996 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 11 02:23:39 2004 Matthias Clasen + + * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle + focus [hv]adjustment correctly when the focus is located deeper + down in the hierarchy. (#133489) + Wed Feb 11 02:06:38 2004 Matthias Clasen * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove @@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004 Owen Taylor * tests/prop-editor.c (create_prop_editor): Free the title. (object_changed): Free the children list. ->>>>>>> 1.4914 Tue Feb 10 01:58:55 2004 Matthias Clasen * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4b20e06d03..1399a74996 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Wed Feb 11 02:23:39 2004 Matthias Clasen + + * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle + focus [hv]adjustment correctly when the focus is located deeper + down in the hierarchy. (#133489) + Wed Feb 11 02:06:38 2004 Matthias Clasen * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove @@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004 Owen Taylor * tests/prop-editor.c (create_prop_editor): Free the title. (object_changed): Free the children list. ->>>>>>> 1.4914 Tue Feb 10 01:58:55 2004 Matthias Clasen * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4b20e06d03..1399a74996 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Wed Feb 11 02:23:39 2004 Matthias Clasen + + * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle + focus [hv]adjustment correctly when the focus is located deeper + down in the hierarchy. (#133489) + Wed Feb 11 02:06:38 2004 Matthias Clasen * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove @@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004 Owen Taylor * tests/prop-editor.c (create_prop_editor): Free the title. (object_changed): Free the children list. ->>>>>>> 1.4914 Tue Feb 10 01:58:55 2004 Matthias Clasen * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4b20e06d03..1399a74996 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Wed Feb 11 02:23:39 2004 Matthias Clasen + + * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle + focus [hv]adjustment correctly when the focus is located deeper + down in the hierarchy. (#133489) + Wed Feb 11 02:06:38 2004 Matthias Clasen * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove @@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004 Owen Taylor * tests/prop-editor.c (create_prop_editor): Free the title. (object_changed): Free the children list. ->>>>>>> 1.4914 Tue Feb 10 01:58:55 2004 Matthias Clasen * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4b20e06d03..1399a74996 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Wed Feb 11 02:23:39 2004 Matthias Clasen + + * gtk/gtkcontainer.c (gtk_container_real_set_focus_child): Handle + focus [hv]adjustment correctly when the focus is located deeper + down in the hierarchy. (#133489) + Wed Feb 11 02:06:38 2004 Matthias Clasen * gtk/gtkcellrenderer.c (gtk_cell_renderer_class_init): Remove @@ -44,7 +50,6 @@ Tue Feb 10 12:02:14 2004 Owen Taylor * tests/prop-editor.c (create_prop_editor): Free the title. (object_changed): Free the children list. ->>>>>>> 1.4914 Tue Feb 10 01:58:55 2004 Matthias Clasen * gtk/gtkcontainer.c (gtk_container_set_focus_hadjustment): diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 77f18568f4..b5f1049f0e 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -1459,8 +1459,7 @@ gtk_container_real_set_focus_child (GtkContainer *container, GtkWidget *child) { g_return_if_fail (GTK_IS_CONTAINER (container)); - if (child) - g_return_if_fail (GTK_IS_WIDGET (child)); + g_return_if_fail (child == NULL || GTK_IS_WIDGET (child)); if (child != container->focus_child) { @@ -1476,21 +1475,35 @@ gtk_container_real_set_focus_child (GtkContainer *container, */ if (container->focus_child) { - GtkAdjustment *adjustment; - - adjustment = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id); - if (adjustment) - gtk_adjustment_clamp_page (adjustment, - container->focus_child->allocation.y, - (container->focus_child->allocation.y + - container->focus_child->allocation.height)); + GtkAdjustment *hadj; + GtkAdjustment *vadj; + GtkWidget *focus_child; + gint x, y; - adjustment = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id); - if (adjustment) - gtk_adjustment_clamp_page (adjustment, - container->focus_child->allocation.x, - (container->focus_child->allocation.x + - container->focus_child->allocation.width)); + hadj = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id); + vadj = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id); + if (hadj || vadj) + { + + focus_child = container->focus_child; + while (GTK_IS_CONTAINER (focus_child) && + GTK_CONTAINER (focus_child)->focus_child) + { + focus_child = GTK_CONTAINER (focus_child)->focus_child; + } + + gtk_widget_translate_coordinates (focus_child, container->focus_child, + 0, 0, &x, &y); + + x += container->focus_child->allocation.x; + y += container->focus_child->allocation.y; + + if (vadj) + gtk_adjustment_clamp_page (vadj, y, y + focus_child->allocation.height); + + if (hadj) + gtk_adjustment_clamp_page (hadj, x, x + focus_child->allocation.width); + } } }