summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-02-15 18:37:06 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-02-15 18:43:27 +0000
commit0646de4f66ecf54b59a0054e08f11f13d46e2b25 (patch)
treee8ca5ab88684de74faa52afd14f9eb60a3a459fd
parentf02cb1cb0dbb3e269430a1d65784a14b9cf636e8 (diff)
elm - scroller wheel accel - limit to avoid over/underflow
limit wheell accel multiplier to 100,000 ... this way sane values of wheel_event->z will not overflow. also up intermediate coors to long longs and clamp to be sure.
-rw-r--r--src/lib/elementary/elm_interface_scrollable.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/lib/elementary/elm_interface_scrollable.c b/src/lib/elementary/elm_interface_scrollable.c
index f03ae31e63..4968332738 100644
--- a/src/lib/elementary/elm_interface_scrollable.c
+++ b/src/lib/elementary/elm_interface_scrollable.c
@@ -2052,10 +2052,11 @@ _scroll_wheel_post_event_cb(void *data, Evas *e EINA_UNUSED)
2052 2052
2053 Evas_Coord x = 0, y = 0, vw = 0, vh = 0, cw = 0, ch = 0; 2053 Evas_Coord x = 0, y = 0, vw = 0, vh = 0, cw = 0, ch = 0;
2054 int pagenumber_h = 0, pagenumber_v = 0; 2054 int pagenumber_h = 0, pagenumber_v = 0;
2055 int mx = 0, my = 0, minx = 0, miny = 0; 2055 int mx = 0, my = 0, minx = 0, miny = 0, panw = 0, panh = 0;
2056 Eina_Bool hold = EINA_FALSE; 2056 Eina_Bool hold = EINA_FALSE;
2057 Evas_Coord pwx, pwy; 2057 Evas_Coord pwx, pwy;
2058 double t; 2058 double t;
2059 long long lx, ly;
2059 int direction; 2060 int direction;
2060 2061
2061 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, EINA_TRUE); 2062 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, EINA_TRUE);
@@ -2075,6 +2076,7 @@ _scroll_wheel_post_event_cb(void *data, Evas *e EINA_UNUSED)
2075 if (sid->scrollto.y.animator) y = sid->scrollto.y.end; 2076 if (sid->scrollto.y.animator) y = sid->scrollto.y.end;
2076 elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my); 2077 elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
2077 elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny); 2078 elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
2079 elm_pan_content_size_get(sid->pan_obj, &panw, &panh);
2078 if (x < minx) x = minx; 2080 if (x < minx) x = minx;
2079 if (x > mx) x = mx; 2081 if (x > mx) x = mx;
2080 if (y < miny) y = miny; 2082 if (y < miny) y = miny;
@@ -2109,7 +2111,7 @@ _scroll_wheel_post_event_cb(void *data, Evas *e EINA_UNUSED)
2109 elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch); 2111 elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
2110 if (!_paging_is_enabled(sid)) 2112 if (!_paging_is_enabled(sid))
2111 { 2113 {
2112 int d = ev->z; 2114 long long d = ev->z;
2113 double delta_t = (double)(ev->timestamp - sid->last_wheel) / 1000.0; 2115 double delta_t = (double)(ev->timestamp - sid->last_wheel) / 1000.0;
2114 double mul; 2116 double mul;
2115 2117
@@ -2117,31 +2119,40 @@ _scroll_wheel_post_event_cb(void *data, Evas *e EINA_UNUSED)
2117 if (delta_t > 0.2) delta_t = 0.2; 2119 if (delta_t > 0.2) delta_t = 0.2;
2118 mul = 1.0 + (_elm_config->scroll_accel_factor * ((0.2 - delta_t) / 0.2)); 2120 mul = 1.0 + (_elm_config->scroll_accel_factor * ((0.2 - delta_t) / 0.2));
2119 mul = mul * (1.0 + (0.15 * sid->last_wheel_mul)); 2121 mul = mul * (1.0 + (0.15 * sid->last_wheel_mul));
2122 if (d > 1000) d = 1000;
2123 else if (d < -1000) d = -1000;
2124 if (mul > 100000.0) mul = 100000.0;
2120 d *= mul; 2125 d *= mul;
2121 sid->last_wheel = ev->timestamp; 2126 sid->last_wheel = ev->timestamp;
2122 sid->last_wheel_mul = mul; 2127 sid->last_wheel_mul = mul;
2128 lx = x;
2129 ly = y;
2123 2130
2124 if (!direction) 2131 if (!direction)
2125 { 2132 {
2126 if ((ch > vh) || (cw <= vw)) 2133 if ((ch > vh) || (cw <= vw))
2127 y += d * sid->step.y; 2134 ly += d * (long long)sid->step.y;
2128 else 2135 else
2129 { 2136 {
2130 x += d * sid->step.x; 2137 lx += d * (long long)sid->step.x;
2131 direction = 1; 2138 direction = 1;
2132 } 2139 }
2133 } 2140 }
2134 else 2141 else
2135 { 2142 {
2136 if ((cw > vw) || (ch <= vh)) 2143 if ((cw > vw) || (ch <= vh))
2137 x += d * sid->step.x; 2144 lx += d * (long long)sid->step.x;
2138 else 2145 else
2139 { 2146 {
2140 y += d * sid->step.y; 2147 ly += d * (long long)sid->step.y;
2141 direction = 0; 2148 direction = 0;
2142 } 2149 }
2143 } 2150 }
2144 _scroll_wheel_post_event_go(sid, x, y); 2151 if (ly < (0 - panh)) ly = 0 - panh;
2152 else if (ly > (my + panh)) ly = my + panh;
2153 if (lx < (0 - panw)) lx = 0 - panw;
2154 else if (lx > (mx + panw)) lx = mx + panw;
2155 _scroll_wheel_post_event_go(sid, lx, ly);
2145 } 2156 }
2146 else 2157 else
2147 { 2158 {