After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 672413 - st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-03-19 20:32 UTC by Florian Müllner
Modified: 2012-04-24 18:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events (3.30 KB, patch)
2012-03-19 20:32 UTC, Florian Müllner
needs-work Details | Review
st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events (3.26 KB, patch)
2012-03-19 23:18 UTC, Florian Müllner
committed Details | Review
st: Clean up scroll event code (4.55 KB, patch)
2012-03-19 23:39 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2012-03-19 20:32:31 UTC
See patch.
Comment 1 Florian Müllner 2012-03-19 20:32:35 UTC
Created attachment 210115 [details] [review]
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.
Comment 2 Owen Taylor 2012-03-19 22:23:41 UTC
Review of attachment 210115 [details] [review]:

::: src/st/st-scroll-bar.c
@@ +466,3 @@
+                                      &delta_x, &delta_y);
+      if (value == lower || value == upper)
+        return FALSE;

I know it matches what was there before but this has no point and seems quite wrong to me that we'd mark the event handled until the scroll region hits the end then stop handling the event and let the parent handle it.

The only thing I can think of is that the code is trying to handle the case of a not-scrollable scrolled area and let the event pass through to a parent scrollable area, but that seems really fiddly to me. upper isn't even right since what the range of an adjustment is:

 MAX (priv->lower, priv->upper - priv->page_size)

so in one direction the current code is just busted. Just rely on the clamping in st_adjustment_set_value() I think.

@@ +467,3 @@
+      if (value == lower || value == upper)
+        return FALSE;
+      else if (delta_x > delta_y)

Need to be comparing fabs(delta) right?

::: src/st/st-scroll-view.c
@@ +699,3 @@
+      clutter_event_get_scroll_delta ((ClutterEvent *)event,
+                                      &delta_x, &delta_y);
+      g_object_get (delta_x > delta_y ? priv->hadjustment : priv->vadjustment,

also missing a fabs. 

You could possible do 'adjustment = ; delta = ;' to avoid the duplicated calls to g_object_get() and st_adjustment_set_value(), etc, but maybe it would be better to scroll the hadjustment the delta_x and the vadjusment by the delta_y? Is only one supposed to be non-zero?
Comment 3 Florian Müllner 2012-03-19 23:18:56 UTC
Created attachment 210123 [details] [review]
st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events

(In reply to comment #2)
> I know it matches what was there before but this has no point and seems quite
> wrong to me that we'd mark the event handled until the scroll region hits the
> end then stop handling the event and let the parent handle it.
> 
> The only thing I can think of is that the code is trying to handle the case of
> a not-scrollable scrolled area and let the event pass through to a parent
> scrollable area, but that seems really fiddly to me. upper isn't even right
> since what the range of an adjustment is:
> 
>  MAX (priv->lower, priv->upper - priv->page_size)

Ugh, you are of course right.


> Just rely on the clamping in st_adjustment_set_value() I think.

Makes sense to me.


> @@ +467,3 @@
> +      if (value == lower || value == upper)
> +        return FALSE;
> +      else if (delta_x > delta_y)
> 
> Need to be comparing fabs(delta) right?

Right, fixed.


> ::: src/st/st-scroll-view.c
> @@ +699,3 @@
> +      clutter_event_get_scroll_delta ((ClutterEvent *)event,
> +                                      &delta_x, &delta_y);
> +      g_object_get (delta_x > delta_y ? priv->hadjustment : priv->vadjustment,
> 
> also missing a fabs. 
> [...] but maybe it would be better to scroll the hadjustment the delta_x
> and the vadjusment by the delta_y? Is only one supposed to be non-zero?

That sounds like the nicer solution to me. I would assume that both values may be non-zero, but I don't see how it would hurt if that's not the case ...
Comment 4 Owen Taylor 2012-03-19 23:22:32 UTC
Review of attachment 210123 [details] [review]:

Looks good, one whitespace issue

::: src/st/st-scroll-bar.c
@@ +466,3 @@
+      clutter_event_get_scroll_delta ((ClutterEvent *)event,
+                                      &delta_x, &delta_y);
+      if (fabs (delta_x) > fabs(delta_y))

missing space in fabs(delta_y)
Comment 5 Florian Müllner 2012-03-19 23:39:45 UTC
Created attachment 210125 [details] [review]
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.
Comment 6 Florian Müllner 2012-03-19 23:40:56 UTC
Comment on attachment 210123 [details] [review]
st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events

Attachment 210123 [details] pushed as a7d4c7d - st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
Comment 7 Jasper St. Pierre (not reading bugmail) 2012-04-24 18:31:02 UTC
Review of attachment 210125 [details] [review]:

Is this still necessary?
Comment 8 Florian Müllner 2012-04-24 18:39:10 UTC
(In reply to comment #7)
> Is this still necessary?

It is a cleanup, so not strictly necessary. Still nice to have IMHO though (e.g. nothing has changed here since the patch was written).
Comment 9 Jasper St. Pierre (not reading bugmail) 2012-04-24 18:40:12 UTC
Review of attachment 210125 [details] [review]:

Go for it, then.
Comment 10 Florian Müllner 2012-04-24 18:50:34 UTC
Attachment 210125 [details] pushed as 700c060 - st: Clean up scroll event code