diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-03-11 01:27:21 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-03-11 01:27:21 -0500 |
commit | 1d1906597908b2bcd61a1aec10119c13817092af (patch) | |
tree | 764adbff0dbf6de82c90d84f1dec62c1ed16c23e /gtk/gtkrange.c | |
parent | 1a5cb41bd93434d0263bb1bd4b16ec14b284dbab (diff) | |
download | gtk+-1d1906597908b2bcd61a1aec10119c13817092af.tar.gz |
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.
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r-- | gtk/gtkrange.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index b9fada2dc7..50357c2cb6 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; |