[gtk+] range: Implement gtk_range_calc_slider() properly
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] range: Implement gtk_range_calc_slider() properly
- Date: Sat, 29 Nov 2014 03:09:51 +0000 (UTC)
commit f63fe9b7608a3bfe6134f0ca581af0bcb5591092
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 29 01:47:31 2014 +0100
range: Implement gtk_range_calc_slider() properly
gtk/gtkrange.c | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index a8c1450..861c64d 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -3625,12 +3625,39 @@ gtk_range_compute_slider_position (GtkRange *range,
}
}
+static gboolean
+rectangle_equal (const GdkRectangle *a,
+ const GdkRectangle *b)
+{
+ return a->x == b->x
+ && a->y == b->y
+ && a->width == b->width
+ && a->height == b->height;
+}
+
static void
gtk_range_calc_slider (GtkRange *range)
{
- range->priv->need_recalc = TRUE;
- gtk_range_calc_layout (range);
- gtk_widget_queue_draw (GTK_WIDGET (range));
+ GtkRangePrivate *priv = range->priv;
+ GdkRectangle new_slider;
+
+ gtk_range_compute_slider_position (range,
+ gtk_adjustment_get_value (priv->adjustment),
+ &new_slider);
+
+ if (rectangle_equal (&priv->slider, &new_slider))
+ return;
+
+ gtk_range_queue_draw_location (range, MOUSE_SLIDER);
+
+ priv->slider = new_slider;
+
+ gtk_range_queue_draw_location (range, MOUSE_SLIDER);
+
+ if (priv->has_origin)
+ gtk_range_queue_draw_location (range, MOUSE_TROUGH);
+
+ gtk_range_update_mouse_location (range);
}
static void
@@ -3790,10 +3817,6 @@ gtk_range_calc_layout (GtkRange *range)
priv->trough.y = priv->stepper_b.y + priv->stepper_b.height + stepper_spacing * has_steppers_ab;
priv->trough.width = range_rect.width;
priv->trough.height = priv->stepper_c.y - priv->trough.y - stepper_spacing * has_steppers_cd;
-
- gtk_range_compute_slider_position (range,
- gtk_adjustment_get_value (priv->adjustment),
- &priv->slider);
}
else
{
@@ -3888,12 +3911,9 @@ gtk_range_calc_layout (GtkRange *range)
priv->trough.y = range_rect.y;
priv->trough.width = priv->stepper_c.x - priv->trough.x - stepper_spacing * has_steppers_cd;
priv->trough.height = range_rect.height;
-
- gtk_range_compute_slider_position (range,
- gtk_adjustment_get_value (priv->adjustment),
- &priv->slider);
}
+ gtk_range_calc_slider (range);
gtk_range_update_mouse_location (range);
switch (priv->upper_sensitivity)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]