diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2012-01-05 00:21:36 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2012-01-05 02:03:26 +0100 |
commit | d94d6e560b3eff4e6693d4ed2cfc5b65ab8b959f (patch) | |
tree | 12b2acd3aa91350b130fa67a2253f81fe952d846 | |
parent | 33b160569fcf8aa3d7bb069339081c666700c30c (diff) | |
download | gtk+-touchscreens.tar.gz |
gtk,range: Have slider jump to the pointer coordinates on touch devicestouchscreens
This widget is too narrow to make touch interaction tricky enough, so
don't add the penalty of having the slider run farther from the touch
coordinates if it happens to miss the slider.
-rw-r--r-- | gtk/gtkrange.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index bf9987529f..f6455e738f 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -2529,7 +2529,8 @@ gtk_range_button_press (GtkWidget *widget, { GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = range->priv; - GdkDevice *device; + GdkDevice *device, *source_device; + GdkInputSource source; if (!gtk_widget_has_focus (widget)) gtk_widget_grab_focus (widget); @@ -2539,13 +2540,17 @@ gtk_range_button_press (GtkWidget *widget, return FALSE; device = gdk_event_get_device ((GdkEvent *) event); + source_device = gdk_event_get_source_device ((GdkEvent *) event); + source = gdk_device_get_source (source_device); + priv->mouse_x = event->x; priv->mouse_y = event->y; if (gtk_range_update_mouse_location (range)) gtk_widget_queue_draw (widget); - if (priv->mouse_location == MOUSE_TROUGH && + if (source != GDK_SOURCE_TOUCH && + priv->mouse_location == MOUSE_TROUGH && event->button == 1) { /* button 1 steps by page increment, as with button 2 on a stepper @@ -2594,17 +2599,17 @@ gtk_range_button_press (GtkWidget *widget, return TRUE; } else if ((priv->mouse_location == MOUSE_TROUGH && - event->button == 2) || + (source == GDK_SOURCE_TOUCH || event->button == 2)) || priv->mouse_location == MOUSE_SLIDER) { gboolean need_value_update = FALSE; /* Any button can be used to drag the slider, but you can start * dragging the slider with a trough click using button 2; - * On button 2 press, we warp the slider to mouse position, - * then begin the slider drag. + * On button 2 press and touch devices, we warp the slider to + * mouse position, then begin the slider drag. */ - if (event->button == 2) + if (event->button == 2 || source == GDK_SOURCE_TOUCH) { gdouble slider_low_value, slider_high_value, new_value; |