From 052917a67d7cd224c0a0204fee080737de653448 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 23 May 2021 10:23:08 -0400 Subject: [PATCH 1/5] label: Fix mnemonic activation The intention of the code is to find a focusable ancestor, so it needs to look at the focusable property, not at can-focus. This is a change from GTK 3, where can-focus was the correct property to look at. Fixes: #3965 --- gtk/gtklabel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index d75c7caf2c..68ab7fc18c 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -1930,7 +1930,7 @@ gtk_label_mnemonic_activate (GtkWidget *widget, while (parent) { - if (gtk_widget_get_can_focus (parent) || + if (gtk_widget_get_focusable (parent) || (!group_cycling && gtk_widget_can_activate (parent)) || GTK_IS_NOTEBOOK (gtk_widget_get_parent (parent))) return gtk_widget_mnemonic_activate (parent, group_cycling); From 882893259dd650ea138a845a959b19fd791f6838 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 23 May 2021 10:25:11 -0400 Subject: [PATCH 2/5] floxbox: Fix focus navigation We want to find focusable children, so we need to look at the focusable property, not at can-focus. This is a change from GTK 3, where can-focus was the correct property to look at. --- gtk/gtkflowbox.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index d994e69d08..188b76c562 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -337,8 +337,8 @@ gtk_flow_box_child_focus (GtkWidget *widget, GtkWidget *child = priv->child; gboolean had_focus = FALSE; - /* Without "can-focus" flag try to pass the focus to the child immediately */ - if (!gtk_widget_get_can_focus (widget)) + /* Without "focusable" flag try to pass the focus to the child immediately */ + if (!gtk_widget_get_focusable (widget)) { if (child) { @@ -3383,10 +3383,10 @@ gtk_flow_box_move_cursor (GtkFlowBox *box, return TRUE; } - /* If the child has its "can-focus" property set to FALSE then it will + /* If the child has its "focusable" property set to FALSE then it will * not grab the focus. We must pass the focus to its child directly. */ - if (!gtk_widget_get_can_focus (GTK_WIDGET (child))) + if (!gtk_widget_get_focusable (GTK_WIDGET (child))) { GtkWidget *subchild; From 105b12f807c0ff3cc7e19c9201b706a090ce4d38 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 23 May 2021 10:26:21 -0400 Subject: [PATCH 3/5] togglebutton: Fix mnemonic activation We want to grab the focus when we're focusable, so look at the focusable property. --- gtk/gtktogglebutton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index 3a24a0c314..4ea135ee48 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -184,7 +184,7 @@ gtk_toggle_button_mnemonic_activate (GtkWidget *widget, * gtk_widget_real_mnemonic_activate() in order to focus the widget even * if there is no mnemonic conflict. */ - if (gtk_widget_get_can_focus (widget)) + if (gtk_widget_get_focusable (widget)) gtk_widget_grab_focus (widget); if (!group_cycling) From eb61f0fc637c28ee420236f42dde18b22ad8f160 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 23 May 2021 10:33:40 -0400 Subject: [PATCH 4/5] treeexpander: Use focusable where we mean it This does not fix keyboard activation for tree expanders, but it is more correct than using can-focus. --- gtk/gtktreeexpander.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtktreeexpander.c b/gtk/gtktreeexpander.c index 39504afab8..63567235ae 100644 --- a/gtk/gtktreeexpander.c +++ b/gtk/gtktreeexpander.c @@ -311,7 +311,7 @@ gtk_tree_expander_focus (GtkWidget *widget, if (gtk_widget_is_focus (widget)) return FALSE; - if (!gtk_widget_get_can_focus (widget)) + if (!gtk_widget_get_focusable (widget)) return FALSE; gtk_widget_grab_focus (widget); From 281bb5e2c44db368a05a721351c24e119857aada Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 23 May 2021 10:37:14 -0400 Subject: [PATCH 5/5] treeviewcolumn: Use focusable when we mean it The focusable property has taken over the role that can-focus had in GTK 3. --- gtk/gtktreeviewcolumn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 66ac2ad02e..4633cacc97 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -1096,7 +1096,7 @@ gtk_tree_view_column_mnemonic_activate (GtkWidget *widget, if (priv->clickable) g_signal_emit_by_name (priv->button, "clicked"); - else if (gtk_widget_get_can_focus (priv->button)) + else if (gtk_widget_get_focusable (priv->button)) gtk_widget_grab_focus (priv->button); else gtk_widget_grab_focus (priv->tree_view);