st: Clean up scroll event code

Currently the scroll event code only handles scroll events if the
adjustment's value is within the "lower" and "upper" limits. The
likely intent was to pass events to a parent scroll view when
reaching the bounds (uh, nested scroll views!), but apparently
we never made use of this, as the upper bound is actually wrong
(an adjustment's maximum value is upper - page_size, not upper).
Just handle all scroll events unconditionally and rely on the
bound checks in StAdjustment.

https://bugzilla.gnome.org/show_bug.cgi?id=672413
This commit is contained in:
Florian Müllner 2012-03-20 00:19:08 +01:00
parent 4fea5b5ca3
commit 700c06023e
2 changed files with 8 additions and 32 deletions

View File

@ -444,14 +444,12 @@ 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, delta_x, delta_y; gdouble step, value, delta_x, delta_y;
if (priv->adjustment) if (priv->adjustment)
{ {
g_object_get (priv->adjustment, g_object_get (priv->adjustment,
"lower", &lower,
"step-increment", &step, "step-increment", &step,
"upper", &upper,
"value", &value, "value", &value,
NULL); NULL);
} }
@ -472,17 +470,11 @@ st_scroll_bar_scroll_event (ClutterActor *actor,
break; break;
case CLUTTER_SCROLL_UP: case CLUTTER_SCROLL_UP:
case CLUTTER_SCROLL_LEFT: case CLUTTER_SCROLL_LEFT:
if (value == lower) st_adjustment_set_value (priv->adjustment, value - step);
return FALSE;
else
st_adjustment_set_value (priv->adjustment, value - step);
break; break;
case CLUTTER_SCROLL_DOWN: case CLUTTER_SCROLL_DOWN:
case CLUTTER_SCROLL_RIGHT: case CLUTTER_SCROLL_RIGHT:
if (value == upper) st_adjustment_set_value (priv->adjustment, value + step);
return FALSE;
else
st_adjustment_set_value (priv->adjustment, value + step);
break; break;
} }

View File

@ -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, hvalue, vvalue, delta_x, delta_y; gdouble value, 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)
@ -708,19 +708,15 @@ st_scroll_view_scroll_event (ClutterActor *self,
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,
"lower", &lower,
"step-increment", &step, "step-increment", &step,
"value", &value, "value", &value,
"upper", &upper,
NULL); NULL);
break; break;
case CLUTTER_SCROLL_LEFT: case CLUTTER_SCROLL_LEFT:
case CLUTTER_SCROLL_RIGHT: case CLUTTER_SCROLL_RIGHT:
g_object_get (priv->hadjustment, g_object_get (priv->hadjustment,
"lower", &lower,
"step-increment", &step, "step-increment", &step,
"value", &value, "value", &value,
"upper", &upper,
NULL); NULL);
break; break;
} }
@ -732,28 +728,16 @@ st_scroll_view_scroll_event (ClutterActor *self,
st_adjustment_set_value (priv->vadjustment, vvalue + delta_y); st_adjustment_set_value (priv->vadjustment, vvalue + delta_y);
break; break;
case CLUTTER_SCROLL_UP: case CLUTTER_SCROLL_UP:
if (value == lower) st_adjustment_set_value (priv->vadjustment, value - step);
return FALSE;
else
st_adjustment_set_value (priv->vadjustment, value - step);
break; break;
case CLUTTER_SCROLL_DOWN: case CLUTTER_SCROLL_DOWN:
if (value == upper) st_adjustment_set_value (priv->vadjustment, value + step);
return FALSE;
else
st_adjustment_set_value (priv->vadjustment, value + step);
break; break;
case CLUTTER_SCROLL_LEFT: case CLUTTER_SCROLL_LEFT:
if (value == lower) st_adjustment_set_value (priv->hadjustment, value - step);
return FALSE;
else
st_adjustment_set_value (priv->hadjustment, value - step);
break; break;
case CLUTTER_SCROLL_RIGHT: case CLUTTER_SCROLL_RIGHT:
if (value == upper) st_adjustment_set_value (priv->hadjustment, value + step);
return FALSE;
else
st_adjustment_set_value (priv->hadjustment, value + step);
break; break;
} }