Commit bb3a8edb authored by Carlos Garnacho's avatar Carlos Garnacho

scalebutton: Handle smooth scroll events

This has the double effect to make scale button truly smooth, and make
scrolling work on wayland, since all scrolling is "smooth" there.
parent 2e7d5b22
......@@ -357,7 +357,7 @@ gtk_scale_button_init (GtkScaleButton *button)
/* Need a local reference to the adjustment */
g_object_ref (priv->adjustment);
gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK);
gtk_widget_add_events (GTK_WIDGET (button), GDK_SMOOTH_SCROLL_MASK);
static void
......@@ -786,12 +786,18 @@ gtk_scale_button_scroll (GtkWidget *widget,
if (d > gtk_adjustment_get_upper (adjustment))
d = gtk_adjustment_get_upper (adjustment);
else if (event->direction == GDK_SCROLL_DOWN)
d -= gtk_adjustment_get_step_increment (adjustment);
if (d < gtk_adjustment_get_lower (adjustment))
d = gtk_adjustment_get_lower (adjustment);
else if (event->direction == GDK_SCROLL_SMOOTH)
d += event->delta_y * gtk_adjustment_get_step_increment (adjustment);
d = CLAMP (d, gtk_adjustment_get_lower (adjustment),
gtk_adjustment_get_upper (adjustment));
gtk_scale_button_set_value (button, d);
return TRUE;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment