[gtk/gtk-4-2: 42/91] window: Fix deferred focus unsetting




commit 83b38e55c06903b4852787424149148dd60bd667
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Apr 16 07:26:32 2021 -0400

    window: Fix deferred focus unsetting
    
    In commit 4a76abffd4d62cbb, we deferred unsetting focus
    and default until after the next draw, overlooking the
    case where the focus is set to another widget before we
    ever get to the unsetting.
    
    Fixes: #3413

 gtk/gtkwindow.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 99bb28feb6..17beb19fa3 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2011,6 +2011,8 @@ gtk_window_root_set_focus (GtkRoot   *root,
 
   g_clear_object (&old_focus);
 
+  priv->move_focus = FALSE;
+
   g_object_notify (G_OBJECT (self), "focus-widget");
 }
 
@@ -2288,6 +2290,8 @@ gtk_window_set_default_widget (GtkWindow *window,
 
       priv->default_widget = default_widget;
 
+      priv->unset_default = FALSE;
+
       if (priv->default_widget)
        {
           if (priv->focus_widget == NULL ||
@@ -4671,16 +4675,10 @@ 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);
-      priv->move_focus = FALSE;
-    }
+    gtk_widget_child_focus (GTK_WIDGET (window), GTK_DIR_TAB_FORWARD);
 
   if (priv->unset_default)
-    {
-      gtk_window_set_default_widget (window, NULL);
-      priv->unset_default = FALSE;
-    }
+    gtk_window_set_default_widget (window, NULL);
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]