[gtk+/wip/window-unfocused-fixes: 2/13] range: Set GTK_STATE_FLAG_WINDOW_UNFOCUSED on draw
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/window-unfocused-fixes: 2/13] range: Set GTK_STATE_FLAG_WINDOW_UNFOCUSED on draw
- Date: Tue, 13 Dec 2011 21:03:20 +0000 (UTC)
commit 2946772be05b5ae742cb4a2d7c75ae6a8ec38a03
Author: Rui Matos <tiagomatos gmail com>
Date: Sun Dec 11 22:50:10 2011 +0000
range: Set GTK_STATE_FLAG_WINDOW_UNFOCUSED on draw
https://bugzilla.gnome.org/show_bug.cgi?id=666126
gtk/gtkrange.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index ca7390f..421d8ec 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1910,6 +1910,8 @@ draw_stepper (GtkRange *range,
state |= GTK_STATE_FLAG_PRELIGHT;
}
+ state |= (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_WINDOW_UNFOCUSED);
+
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
@@ -1999,6 +2001,7 @@ gtk_range_draw (GtkWidget *widget,
GtkRangePrivate *priv = range->priv;
gboolean sensitive;
GtkStateFlags state = 0;
+ GtkStateFlags widget_state;
gint focus_line_width = 0;
gint focus_padding = 0;
gboolean touchscreen;
@@ -2028,7 +2031,12 @@ gtk_range_draw (GtkWidget *widget,
gtk_range_calc_marks (range);
gtk_range_calc_layout (range, gtk_adjustment_get_value (priv->adjustment));
- sensitive = gtk_widget_is_sensitive (widget);
+ widget_state = gtk_widget_get_state_flags (widget);
+ state |= (widget_state & GTK_STATE_FLAG_WINDOW_UNFOCUSED);
+
+ sensitive = (widget_state & GTK_STATE_FLAG_INSENSITIVE) == 0;
+ if (!sensitive)
+ state |= GTK_STATE_FLAG_INSENSITIVE;
/* Just to be confusing, we draw the trough for the whole
* range rectangle, not the trough rectangle (the trough
@@ -2058,9 +2066,7 @@ gtk_range_draw (GtkWidget *widget,
NULL);
gtk_style_context_save (context);
-
- if (!sensitive)
- gtk_style_context_set_state (context, GTK_STATE_FLAG_INSENSITIVE);
+ gtk_style_context_set_state (context, state);
if (!trough_under_steppers)
{
@@ -2216,8 +2222,7 @@ gtk_range_draw (GtkWidget *widget,
if (sensitive && gtk_widget_has_visible_focus (widget))
{
gtk_style_context_save (context);
- gtk_style_context_set_state (context,
- gtk_widget_get_state_flags (widget));
+ gtk_style_context_set_state (context, widget_state);
gtk_render_focus (context, cr,
priv->range_rect.x,
@@ -2231,10 +2236,8 @@ gtk_range_draw (GtkWidget *widget,
cairo_restore (cr);
- if (!sensitive)
- state = GTK_STATE_FLAG_INSENSITIVE;
- else if (!touchscreen && priv->mouse_location == MOUSE_SLIDER)
- state = GTK_STATE_FLAG_PRELIGHT;
+ if (sensitive && !touchscreen && priv->mouse_location == MOUSE_SLIDER)
+ state |= GTK_STATE_FLAG_PRELIGHT;
if (priv->grab_location == MOUSE_SLIDER)
state |= GTK_STATE_FLAG_ACTIVE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]