From 4269934588bcfc1a1c4a65d472c318b1367f03ea Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 17 Apr 2012 13:52:21 +0200 Subject: touchscreen/lists: fix two regressions * fix potential stack overflow through recursion * fix using using the scrollbar during active kinetic scrolling animation Change-Id: Iaf124970a60d3f0c2ee7919ac278f2d6ac329e47 --- apps/gui/bitmap/list.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'apps/gui/bitmap') 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; -- cgit v1.1