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 | |
parent | 3f4be750248b5e163297cd34958077eb872b10f4 (diff) | |
download | rockbox-4269934588bcfc1a1c4a65d472c318b1367f03ea.tar.gz rockbox-4269934588bcfc1a1c4a65d472c318b1367f03ea.zip |
touchscreen/lists: fix two regressions
* fix potential stack overflow through recursion
* fix using using the scrollbar during active kinetic scrolling animation
Change-Id: Iaf124970a60d3f0c2ee7919ac278f2d6ac329e47
-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 e1acecd218..0581050091 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) | |||
706 | short x, y; | 706 | short x, y; |
707 | int action, adj_y, line, line_height, list_start_item; | 707 | int action, adj_y, line, line_height, list_start_item; |
708 | bool recurse; | 708 | bool recurse; |
709 | static int last_y; | 709 | static int last_y = -1; |
710 | 710 | ||
711 | screen = SCREEN_MAIN; | 711 | screen = SCREEN_MAIN; |
712 | parent = list->parent[screen]; | 712 | parent = list->parent[screen]; |
@@ -725,7 +725,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) | |||
725 | { | 725 | { |
726 | case SCROLL_NONE: | 726 | case SCROLL_NONE: |
727 | { | 727 | { |
728 | if (!last_y) | 728 | if (last_y == -1) |
729 | { /* first run. register adj_y and re-run (will then take the else case) */ | 729 | { /* first run. register adj_y and re-run (will then take the else case) */ |
730 | last_y = adj_y; | 730 | last_y = adj_y; |
731 | recurse = true; | 731 | recurse = true; |
@@ -763,13 +763,13 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) | |||
763 | gui_synclist_select_item(list, list_start_item + line); | 763 | gui_synclist_select_item(list, list_start_item + line); |
764 | /* don't sent context repeatedly */ | 764 | /* don't sent context repeatedly */ |
765 | action_wait_for_release(); | 765 | action_wait_for_release(); |
766 | last_y = 0; | 766 | last_y = -1; |
767 | return ACTION_STD_CONTEXT; | 767 | return ACTION_STD_CONTEXT; |
768 | } | 768 | } |
769 | } | 769 | } |
770 | else if (action & BUTTON_REL) | 770 | else if (action & BUTTON_REL) |
771 | { | 771 | { |
772 | last_y = 0; | 772 | last_y = -1; |
773 | if (click_loc & LIST) | 773 | if (click_loc & LIST) |
774 | { /* release on list item enters it */ | 774 | { /* release on list item enters it */ |
775 | gui_synclist_select_item(list, list_start_item + line); | 775 | gui_synclist_select_item(list, list_start_item + line); |
@@ -808,7 +808,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) | |||
808 | scroll_mode = SCROLL_NONE; | 808 | scroll_mode = SCROLL_NONE; |
809 | 809 | ||
810 | if (scroll_mode == SCROLL_NONE) | 810 | if (scroll_mode == SCROLL_NONE) |
811 | last_y = 0; | 811 | last_y = -1; |
812 | break; | 812 | break; |
813 | } | 813 | } |
814 | case SCROLL_KINETIC: | 814 | case SCROLL_KINETIC: |
@@ -819,7 +819,10 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) | |||
819 | if (!is_kinetic_over()) | 819 | if (!is_kinetic_over()) |
820 | { /* a) the user touched the screen (manual cancellation) */ | 820 | { /* a) the user touched the screen (manual cancellation) */ |
821 | kinetic_force_stop(); | 821 | kinetic_force_stop(); |
822 | scroll_mode = SCROLL_SWIPE; | 822 | if (get_click_location(list, x, y) & SCROLLBAR) |
823 | scroll_mode = SCROLL_BAR; | ||
824 | else | ||
825 | scroll_mode = SCROLL_SWIPE; | ||
823 | } | 826 | } |
824 | else | 827 | else |
825 | { /* b) kinetic scrolling stopped on its own */ | 828 | { /* b) kinetic scrolling stopped on its own */ |
@@ -841,8 +844,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) | |||
841 | } | 844 | } |
842 | } | 845 | } |
843 | 846 | ||
844 | /* register y position unless forcefully reset to 0 */ | 847 | /* register y position unless forcefully reset to 1- */ |
845 | if (last_y) | 848 | if (last_y >= 0) |
846 | last_y = adj_y; | 849 | last_y = adj_y; |
847 | 850 | ||
848 | return recurse ? gui_synclist_do_touchscreen(list) : ACTION_REDRAW; | 851 | return recurse ? gui_synclist_do_touchscreen(list) : ACTION_REDRAW; |