[gtk+] range: Fix trough clickability
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] range: Fix trough clickability
- Date: Fri, 11 Mar 2016 06:28:54 +0000 (UTC)
commit 1d1906597908b2bcd61a1aec10119c13817092af
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 11 01:27:21 2016 -0500
range: Fix trough clickability
We previously considered any click inside the trough if it
hit an area that the slider might cover. Bring this behavior
back; the trough of scales is otherwise just too narrow to
hit easily with a click.
gtk/gtkrange.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index b9fada2..50357c2 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -3429,6 +3429,15 @@ gtk_range_move_slider (GtkRange *range,
gtk_widget_error_bell (GTK_WIDGET (range));
}
+static gboolean
+rectangle_contains_point (GdkRectangle *rect,
+ gint x,
+ gint y)
+{
+ return (x >= rect->x) && (x < rect->x + rect->width) &&
+ (y >= rect->y) && (y < rect->y + rect->height);
+}
+
/* Update mouse location, return TRUE if it changes */
static void
gtk_range_update_mouse_location (GtkRange *range)
@@ -3437,12 +3446,17 @@ gtk_range_update_mouse_location (GtkRange *range)
gint x, y;
MouseLocation old;
GtkWidget *widget = GTK_WIDGET (range);
+ GdkRectangle trough_alloc, slider_alloc, slider_trace;
old = priv->mouse_location;
x = priv->mouse_x;
y = priv->mouse_y;
+ gtk_css_gadget_get_border_box (priv->trough_gadget, &trough_alloc);
+ gtk_css_gadget_get_border_box (priv->slider_gadget, &slider_alloc);
+ gdk_rectangle_union (&slider_alloc, &trough_alloc, &slider_trace);
+
if (priv->grab_location != MOUSE_OUTSIDE)
priv->mouse_location = priv->grab_location;
else if (priv->stepper_a_gadget &&
@@ -3459,7 +3473,7 @@ gtk_range_update_mouse_location (GtkRange *range)
priv->mouse_location = MOUSE_STEPPER_D;
else if (gtk_css_gadget_border_box_contains_point (priv->slider_gadget, x, y))
priv->mouse_location = MOUSE_SLIDER;
- else if (gtk_css_gadget_border_box_contains_point (priv->trough_gadget, x, y))
+ else if (rectangle_contains_point (&slider_trace, x, y))
priv->mouse_location = MOUSE_TROUGH;
else if (gtk_css_gadget_margin_box_contains_point (priv->gadget, x, y))
priv->mouse_location = MOUSE_WIDGET;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]