st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
Currently compilation fails with -Werror, as we don't handle the (newly introduced) smooth scroll events in switch statements; add some basic support, which should make the compiler happy. https://bugzilla.gnome.org/show_bug.cgi?id=672413
This commit is contained in:
parent
369c1b0a41
commit
a7d4c7d8de
@ -32,6 +32,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
#include "st-scroll-bar.h"
|
#include "st-scroll-bar.h"
|
||||||
@ -443,7 +444,7 @@ st_scroll_bar_scroll_event (ClutterActor *actor,
|
|||||||
ClutterScrollEvent *event)
|
ClutterScrollEvent *event)
|
||||||
{
|
{
|
||||||
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
|
||||||
gdouble lower, step, upper, value;
|
gdouble lower, step, upper, value, delta_x, delta_y;
|
||||||
|
|
||||||
if (priv->adjustment)
|
if (priv->adjustment)
|
||||||
{
|
{
|
||||||
@ -461,6 +462,14 @@ st_scroll_bar_scroll_event (ClutterActor *actor,
|
|||||||
|
|
||||||
switch (event->direction)
|
switch (event->direction)
|
||||||
{
|
{
|
||||||
|
case CLUTTER_SCROLL_SMOOTH:
|
||||||
|
clutter_event_get_scroll_delta ((ClutterEvent *)event,
|
||||||
|
&delta_x, &delta_y);
|
||||||
|
if (fabs (delta_x) > fabs (delta_y))
|
||||||
|
st_adjustment_set_value (priv->adjustment, value + delta_x);
|
||||||
|
else
|
||||||
|
st_adjustment_set_value (priv->adjustment, value + delta_y);
|
||||||
|
break;
|
||||||
case CLUTTER_SCROLL_UP:
|
case CLUTTER_SCROLL_UP:
|
||||||
case CLUTTER_SCROLL_LEFT:
|
case CLUTTER_SCROLL_LEFT:
|
||||||
if (value == lower)
|
if (value == lower)
|
||||||
|
@ -687,7 +687,7 @@ st_scroll_view_scroll_event (ClutterActor *self,
|
|||||||
ClutterScrollEvent *event)
|
ClutterScrollEvent *event)
|
||||||
{
|
{
|
||||||
StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;
|
StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;
|
||||||
gdouble lower, value, upper, step;
|
gdouble lower, value, upper, step, hvalue, vvalue, delta_x, delta_y;
|
||||||
|
|
||||||
/* don't handle scroll events if requested not to */
|
/* don't handle scroll events if requested not to */
|
||||||
if (!priv->mouse_scroll)
|
if (!priv->mouse_scroll)
|
||||||
@ -695,6 +695,16 @@ st_scroll_view_scroll_event (ClutterActor *self,
|
|||||||
|
|
||||||
switch (event->direction)
|
switch (event->direction)
|
||||||
{
|
{
|
||||||
|
case CLUTTER_SCROLL_SMOOTH:
|
||||||
|
clutter_event_get_scroll_delta ((ClutterEvent *)event,
|
||||||
|
&delta_x, &delta_y);
|
||||||
|
g_object_get (priv->hadjustment,
|
||||||
|
"value", &hvalue,
|
||||||
|
NULL);
|
||||||
|
g_object_get (priv->vadjustment,
|
||||||
|
"value", &vvalue,
|
||||||
|
NULL);
|
||||||
|
break;
|
||||||
case CLUTTER_SCROLL_UP:
|
case CLUTTER_SCROLL_UP:
|
||||||
case CLUTTER_SCROLL_DOWN:
|
case CLUTTER_SCROLL_DOWN:
|
||||||
g_object_get (priv->vadjustment,
|
g_object_get (priv->vadjustment,
|
||||||
@ -717,6 +727,10 @@ st_scroll_view_scroll_event (ClutterActor *self,
|
|||||||
|
|
||||||
switch (event->direction)
|
switch (event->direction)
|
||||||
{
|
{
|
||||||
|
case CLUTTER_SCROLL_SMOOTH:
|
||||||
|
st_adjustment_set_value (priv->hadjustment, hvalue + delta_x);
|
||||||
|
st_adjustment_set_value (priv->vadjustment, vvalue + delta_y);
|
||||||
|
break;
|
||||||
case CLUTTER_SCROLL_UP:
|
case CLUTTER_SCROLL_UP:
|
||||||
if (value == lower)
|
if (value == lower)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user