[gtk/fix-focus-changes] window: Don't focus invisible widgets




commit f5063c14357b2206c895e297ce855ac8363322e5
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 17 15:10:51 2022 -0400

    window: Don't focus invisible widgets
    
    Only clear a queued move_focus if the widget
    we are focusing is actually visible.
    
    This was happening in some cases when popovers
    are dismissed by clicking outside, and it was
    causing us to miss proper focus updates that
    were already queued.

 gtk/gtkwindow.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index ff16a68104..1de17f9048 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2004,7 +2004,9 @@ gtk_window_root_set_focus (GtkRoot   *root,
 
   if (focus == priv->focus_widget)
     {
-      priv->move_focus = FALSE;
+      if (priv->move_focus &&
+          focus && gtk_widget_is_visible (focus))
+        priv->move_focus = FALSE;
       return;
     }
 
@@ -2024,7 +2026,9 @@ gtk_window_root_set_focus (GtkRoot   *root,
 
   g_clear_object (&old_focus);
 
-  priv->move_focus = FALSE;
+  if (priv->move_focus &&
+      focus && gtk_widget_is_visible (focus))
+    priv->move_focus = FALSE;
 
   g_object_notify (G_OBJECT (self), "focus-widget");
 }
@@ -4689,7 +4693,7 @@ maybe_unset_focus_and_default (GtkWindow *window)
                 break;
             }
 
-           parent = _gtk_widget_get_parent (parent);
+          parent = _gtk_widget_get_parent (parent);
         }
     }
 


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