diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2012-04-17 13:52:21 +0200 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2012-04-17 17:19:31 +0200 |
| commit | 4269934588bcfc1a1c4a65d472c318b1367f03ea (patch) | |
| tree | 7161cd598bfecd1ca5be97a48599453077915642 /apps/gui/bitmap | |
| parent | 3f4be750248b5e163297cd34958077eb872b10f4 (diff) | |
| download | rockbox-4269934588bcfc1a1c4a65d472c318b1367f03ea.zip rockbox-4269934588bcfc1a1c4a65d472c318b1367f03ea.tar.gz rockbox-4269934588bcfc1a1c4a65d472c318b1367f03ea.tar.bz2 rockbox-4269934588bcfc1a1c4a65d472c318b1367f03ea.tar.xz | |
touchscreen/lists: fix two regressions
* fix potential stack overflow through recursion
* fix using using the scrollbar during active kinetic scrolling animation
Change-Id: Iaf124970a60d3f0c2ee7919ac278f2d6ac329e47
Diffstat (limited to 'apps/gui/bitmap')
| -rw-r--r-- | apps/gui/bitmap/list.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index e1acecd..0581050 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -706,7 +706,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) short x, y; int action, adj_y, line, line_height, list_start_item; bool recurse; - static int last_y; + static int last_y = -1; screen = SCREEN_MAIN; parent = list->parent[screen]; @@ -725,7 +725,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) { case SCROLL_NONE: { - if (!last_y) + if (last_y == -1) { /* first run. register adj_y and re-run (will then take the else case) */ last_y = adj_y; recurse = true; @@ -763,13 +763,13 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) gui_synclist_select_item(list, list_start_item + line); /* don't sent context repeatedly */ action_wait_for_release(); - last_y = 0; + last_y = -1; return ACTION_STD_CONTEXT; } } else if (action & BUTTON_REL) { - last_y = 0; + last_y = -1; if (click_loc & LIST) { /* release on list item enters it */ gui_synclist_select_item(list, list_start_item + line); @@ -808,7 +808,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) scroll_mode = SCROLL_NONE; if (scroll_mode == SCROLL_NONE) - last_y = 0; + last_y = -1; break; } case SCROLL_KINETIC: @@ -819,7 +819,10 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) if (!is_kinetic_over()) { /* a) the user touched the screen (manual cancellation) */ kinetic_force_stop(); - scroll_mode = SCROLL_SWIPE; + if (get_click_location(list, x, y) & SCROLLBAR) + scroll_mode = SCROLL_BAR; + else + scroll_mode = SCROLL_SWIPE; } else { /* b) kinetic scrolling stopped on its own */ @@ -841,8 +844,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) } } - /* register y position unless forcefully reset to 0 */ - if (last_y) + /* register y position unless forcefully reset to 1- */ + if (last_y >= 0) last_y = adj_y; return recurse ? gui_synclist_do_touchscreen(list) : ACTION_REDRAW; |