[gtk/matthiasc/for-master: 16/19] listbox: Don't steal focus-on-click
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 16/19] listbox: Don't steal focus-on-click
- Date: Thu, 14 May 2020 00:36:57 +0000 (UTC)
commit 7ef51da1c1650586a51a650042815dab97e3be3f
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 13 19:43:04 2020 -0400
listbox: Don't steal focus-on-click
If a row has content that is focus-on-click, and is set
to focus-on-click itself, then the row steals the focus
fromt he content, since it uses focus-on-click on button
release, as opposed to button press. Avoid that by
refusing to take focus if it is already on some
descendent of the row.
This was showing up in the widget-factory listbox on
page 2, where clicking on the spinbutton would briefly
put the focus on the spinbutton, only to lose it to
the row.
gtk/gtklistbox.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 8e2c5409ea..bc4676566f 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1516,7 +1516,13 @@ gtk_list_box_update_cursor (GtkListBox *box,
box->cursor_row = row;
ensure_row_visible (box, row);
if (grab_focus)
- gtk_widget_grab_focus (GTK_WIDGET (row));
+ {
+ GtkWidget *focus;
+
+ focus = gtk_root_get_focus (gtk_widget_get_root (GTK_WIDGET (box)));
+ if (!focus || !gtk_widget_is_ancestor (focus, GTK_WIDGET (row)))
+ gtk_widget_grab_focus (GTK_WIDGET (row));
+ }
gtk_widget_queue_draw (GTK_WIDGET (row));
_gtk_list_box_accessible_update_cursor (box, row);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]