antognolli pushed a commit to branch master.
commit 74710bbd81a26f888b0d19c012a95da8440ac2c9
Author: Rafael Antognolli <[email protected]>
Date: Wed Jun 5 19:14:59 2013 -0300
elm/scrollable: Avoid division by zero during scroll.
When several mouse move events arrive with the same timestamps, the
calculation done to get an average of movement will try to divide things
by zero. This fix will make it ignore this calculation and just go back
to assuming that there's only one last move event.
Such behavior can happen on wayland backend, when using the X11 backend
for Weston, since it will process several X events in one loop iteration
and send all of them with the same timestamp.
---
src/lib/elm_interface_scrollable.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/lib/elm_interface_scrollable.c
b/src/lib/elm_interface_scrollable.c
index 9810c8c..94c4307 100644
--- a/src/lib/elm_interface_scrollable.c
+++ b/src/lib/elm_interface_scrollable.c
@@ -2898,21 +2898,24 @@ _elm_scroll_hold_animator(void *data)
dxsum /= (double)i;
dysum /= (double)i;
dtsum /= (double)i;
- xsum /= (double)i;
- ysum /= (double)i;
- tadd = tnow - sid->down.history[0].timestamp +
_elm_config->scroll_smooth_future_time;
- tadd = tadd - (maxdt / 2);
+ if (dtsum > 0)
+ {
+ xsum /= (double)i;
+ ysum /= (double)i;
+ tadd = tnow - sid->down.history[0].timestamp +
_elm_config->scroll_smooth_future_time;
+ tadd = tadd - (maxdt / 2);
#define WEIGHT(n, o, v) n = (((double)o * (1.0 - v)) + ((double)n * v))
- WEIGHT(tadd, sid->down.hist.tadd,
_elm_config->scroll_smooth_history_weight);
- WEIGHT(dxsum, sid->down.hist.dxsum,
_elm_config->scroll_smooth_history_weight);
- WEIGHT(dysum, sid->down.hist.dysum,
_elm_config->scroll_smooth_history_weight);
- fx = basex + xsum + ((dxsum * tadd) / dtsum);
- fy = basey + ysum + ((dysum * tadd) / dtsum);
- sid->down.hist.tadd = tadd;
- sid->down.hist.dxsum = dxsum;
- sid->down.hist.dysum = dysum;
- WEIGHT(fx, sid->down.hold_x, _elm_config->scroll_smooth_amount);
- WEIGHT(fy, sid->down.hold_y, _elm_config->scroll_smooth_amount);
+ WEIGHT(tadd, sid->down.hist.tadd,
_elm_config->scroll_smooth_history_weight);
+ WEIGHT(dxsum, sid->down.hist.dxsum,
_elm_config->scroll_smooth_history_weight);
+ WEIGHT(dysum, sid->down.hist.dysum,
_elm_config->scroll_smooth_history_weight);
+ fx = basex + xsum + ((dxsum * tadd) / dtsum);
+ fy = basey + ysum + ((dysum * tadd) / dtsum);
+ sid->down.hist.tadd = tadd;
+ sid->down.hist.dxsum = dxsum;
+ sid->down.hist.dysum = dysum;
+ WEIGHT(fx, sid->down.hold_x,
_elm_config->scroll_smooth_amount);
+ WEIGHT(fy, sid->down.hold_y,
_elm_config->scroll_smooth_amount);
+ }
}
}
--
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j