diff options
author | Benjamin Otte <otte@redhat.com> | 2020-06-03 18:12:00 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2020-06-03 18:12:00 +0200 |
commit | a84f6228ca9f9f95ad890196855c824e58723b35 (patch) | |
tree | db7dee48baabc358b04c73d55e0f89def137970d /gtk/gtklistitemwidget.c | |
parent | aa38fc712fa76c60ccc13b75c6de9243b55748b3 (diff) | |
download | gtk+-a84f6228ca9f9f95ad890196855c824e58723b35.tar.gz |
listitemwidget: Fix focus handling for columnview
ListItemWidget needs to be aware of potentially having multiple
children, so make it aware.
Diffstat (limited to 'gtk/gtklistitemwidget.c')
-rw-r--r-- | gtk/gtklistitemwidget.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c index 2e6078d704..3057dac55d 100644 --- a/gtk/gtklistitemwidget.c +++ b/gtk/gtklistitemwidget.c @@ -83,8 +83,7 @@ static gboolean gtk_list_item_widget_focus (GtkWidget *widget, GtkDirectionType direction) { - GtkListItemWidget *self = GTK_LIST_ITEM_WIDGET (widget); - GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self); + GtkWidget *child, *focus_child; /* The idea of this function is the following: * 1. If any child can take focus, do not ever attempt @@ -96,19 +95,24 @@ gtk_list_item_widget_focus (GtkWidget *widget, * activation and selection handling, but no useless widgets * get focused and moving focus is as fast as possible. */ - if (priv->list_item && priv->list_item->child) + + focus_child = gtk_widget_get_focus_child (widget); + if (focus_child && gtk_widget_child_focus (focus_child, direction)) + return TRUE; + + for (child = focus_child ? gtk_widget_get_next_sibling (focus_child) + : gtk_widget_get_first_child (widget); + child; + child = gtk_widget_get_next_sibling (child)) { - if (gtk_widget_get_focus_child (widget)) - return FALSE; - if (gtk_widget_child_focus (priv->list_item->child, direction)) + if (gtk_widget_child_focus (child, direction)) return TRUE; } - if (gtk_widget_is_focus (widget)) + if (focus_child) return FALSE; - if (!gtk_widget_get_can_focus (widget) || - !priv->list_item->selectable) + if (gtk_widget_is_focus (widget)) return FALSE; return gtk_widget_grab_focus (widget); @@ -119,9 +123,19 @@ gtk_list_item_widget_grab_focus (GtkWidget *widget) { GtkListItemWidget *self = GTK_LIST_ITEM_WIDGET (widget); GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self); + GtkWidget *child; - if (priv->list_item && priv->list_item->child && gtk_widget_grab_focus (priv->list_item->child)) - return TRUE; + for (child = gtk_widget_get_first_child (widget); + child; + child = gtk_widget_get_next_sibling (child)) + { + if (gtk_widget_grab_focus (child)) + return TRUE; + } + + if (priv->list_item == NULL || + !priv->list_item->selectable) + return FALSE; return GTK_WIDGET_CLASS (gtk_list_item_widget_parent_class)->grab_focus (widget); } |