[gtk+/wip/matthiasc/visible-focus: 1/3] Set the new state flag



commit 111188de45279993b1937212e7a27b2045fac195
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 |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b2e13df..fb86369 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15486,10 +15486,24 @@ 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;
+      gboolean draw_focus;
+
+      toplevel = _gtk_widget_get_toplevel (widget);
+      if (GTK_IS_WINDOW (toplevel))
+        draw_focus = gtk_window_get_focus_visible (GTK_WINDOW (toplevel));
+      else
+        draw_focus = TRUE;
+
+      gtk_widget_set_state_flags (child,
+                                  GTK_STATE_FLAG_FOCUSED|(draw_focus ? GTK_STATE_FLAG_FOCUS_VISIBLE : 0),
+                                  FALSE);
+    }
 
   g_set_object (&priv->focus_child, child);
 


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