[gtk+] Make gtk_widget_get_state_flags() avoid propagating the focused flag down the hierarchy
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Make gtk_widget_get_state_flags() avoid propagating the focused flag down the hierarchy
- Date: Fri, 21 Jan 2011 14:31:14 +0000 (UTC)
commit 6e553324f9081b5ca002f7e26269ee23268245fe
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jan 21 15:19:44 2011 +0100
Make gtk_widget_get_state_flags() avoid propagating the focused flag down the hierarchy
There is only one widget supposed to have the focused flag at a given time,
so avoid propagating the state down the hierarchy, the focused flag is now
also set in _gtk_widget_set_has_focus().
gtk/gtkwidget.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index a152b3f..c195089 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6971,6 +6971,14 @@ _gtk_widget_update_state_flags (GtkWidget *widget,
flags &= ~(GTK_STATE_FLAG_INSENSITIVE);
+ /* Focused state is meant to be set only on the widget
+ * being changed itself, not on the children */
+ if ((flags & GTK_STATE_FLAG_FOCUSED) !=
+ (priv->state_flags & GTK_STATE_FLAG_FOCUSED))
+ priv->state_flags |= GTK_STATE_FLAG_FOCUSED;
+
+ flags &= ~(GTK_STATE_FLAG_FOCUSED);
+
if (flags != 0 ||
operation == STATE_CHANGE_REPLACE)
{
@@ -7075,6 +7083,9 @@ gtk_widget_get_state_flags (GtkWidget *widget)
if (!gtk_widget_is_sensitive (widget))
flags |= GTK_STATE_FLAG_INSENSITIVE;
+ if (gtk_widget_has_focus (widget))
+ flags |= GTK_STATE_FLAG_FOCUSED;
+
return flags;
}
@@ -13906,6 +13917,11 @@ _gtk_widget_set_has_focus (GtkWidget *widget,
gboolean has_focus)
{
widget->priv->has_focus = has_focus;
+
+ if (has_focus)
+ gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_FOCUSED, FALSE);
+ else
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_FOCUSED);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]