[gtk+] Set the new state flag



commit 8b15eabad20e6f303229f17501aa137b3fe7a53c
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Aug 28 22:25:06 2017 -0400

    Set the new state flag
    
    For now, we only set the new visible focus state
    on the focus widget, when we have visible focus.
    Later on, we will allow setting it on other widgets.

 gtk/gtkwidget.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 3637712..c0977d5 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15479,10 +15479,20 @@ gtk_widget_set_focus_child (GtkWidget *widget,
     }
 
   if (priv->focus_child)
-    gtk_widget_unset_state_flags (priv->focus_child, GTK_STATE_FLAG_FOCUSED);
+    gtk_widget_unset_state_flags (priv->focus_child,
+                                  GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_FOCUS_VISIBLE);
 
   if (child)
-    gtk_widget_set_state_flags (child, GTK_STATE_FLAG_FOCUSED, FALSE);
+    {
+      GtkWidget *toplevel;
+      GtkStateFlags flags = GTK_STATE_FLAG_FOCUSED;
+
+      toplevel = _gtk_widget_get_toplevel (widget);
+      if (!GTK_IS_WINDOW (toplevel) || gtk_window_get_focus_visible (GTK_WINDOW (toplevel)))
+        flags |= GTK_STATE_FLAG_FOCUS_VISIBLE;
+
+      gtk_widget_set_state_flags (child, flags, FALSE);
+    }
 
   g_set_object (&priv->focus_child, child);
 


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