[gtk/fix-focus-changes] window: Fix focus updates
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-focus-changes] window: Fix focus updates
- Date: Mon, 17 Oct 2022 16:32:43 +0000 (UTC)
commit 281c217afb6c2398ac9790901932b04bd7ede781
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 17 12:29:44 2022 -0400
window: Fix focus updates
This partially undoes changes from 3dbf5038fab8eb0.
That commit did two things:
1) Move the focus update to after-paint time
2) Change from grabbing focus to the visible parent
to calling move_focus (TAB)
The second part did have the unintended consequence
of moving focus laterally.
Fixes: #4903
gtk/gtkwindow.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 21e0ac3036..2b195d775c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -184,6 +184,7 @@ typedef struct
GtkWidget *default_widget;
GtkWidget *focus_widget;
+ GtkWidget *move_focus_widget;
GtkWindow *transient_parent;
GtkWindowGeometryInfo *geometry_info;
GtkWindowGroup *group;
@@ -4675,7 +4676,20 @@ maybe_unset_focus_and_default (GtkWindow *window)
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
if (priv->move_focus)
- gtk_widget_child_focus (GTK_WIDGET (window), GTK_DIR_TAB_FORWARD);
+ {
+ GtkWidget *parent;
+
+ parent = _gtk_widget_get_parent (priv->move_focus_widget);
+
+ while (parent)
+ {
+ if (_gtk_widget_get_visible (parent))
+ {
+ if (gtk_widget_grab_focus (parent))
+ break;
+ }
+ }
+ }
if (priv->unset_default)
gtk_window_set_default_widget (window, NULL);
@@ -5134,7 +5148,10 @@ _gtk_window_unset_focus_and_default (GtkWindow *window,
child = priv->focus_widget;
if (child && (child == widget || gtk_widget_is_ancestor (child, widget)))
- priv->move_focus = TRUE;
+ {
+ priv->move_focus_widget = widget;
+ priv->move_focus = TRUE;
+ }
child = priv->default_widget;
if (child && (child == widget || gtk_widget_is_ancestor (child, widget)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]