touchscreen: Fix kinetic and swipe scrolling outside of the list viewport.
There were some bugs, especially when the user scrolled above the list viewport. One bug made Rockbox completely unusable once triggered. Change-Id: I9bb4722ff4381db189058e9a19ea30b2c69e87d9
This commit is contained in:
parent
9b7edbf609
commit
2ffde90c69
1 changed files with 61 additions and 59 deletions
|
@ -732,7 +732,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
|
|||
short x, y;
|
||||
int action, adj_x, adj_y, line, line_height, list_start_item;
|
||||
bool recurse;
|
||||
static int last_y = -1;
|
||||
static bool initial_touch = true;
|
||||
static int last_y;
|
||||
|
||||
screen = SCREEN_MAIN;
|
||||
parent = list->parent[screen];
|
||||
|
@ -752,15 +753,17 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
|
|||
{
|
||||
case SCROLL_NONE:
|
||||
{
|
||||
if (last_y == -1)
|
||||
{ /* first run. register adj_y and re-run (will then take the else case) */
|
||||
last_y = adj_y;
|
||||
recurse = true;
|
||||
}
|
||||
else
|
||||
int click_loc;
|
||||
if (initial_touch)
|
||||
{
|
||||
int click_loc = get_click_location(list, x, y);
|
||||
/* on the first touch last_y has to be reset to avoid
|
||||
* glitches with touches from long ago */
|
||||
last_y = adj_y;
|
||||
initial_touch = false;
|
||||
}
|
||||
|
||||
line = 0; /* silence gcc 'used uninitialized' warning */
|
||||
click_loc = get_click_location(list, x, y);
|
||||
if (click_loc & LIST)
|
||||
{
|
||||
if(!skinlist_get_item(&screens[screen], list, adj_x, adj_y, &line))
|
||||
|
@ -793,13 +796,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 = -1;
|
||||
initial_touch = true;
|
||||
return ACTION_STD_CONTEXT;
|
||||
}
|
||||
}
|
||||
else if (action & BUTTON_REL)
|
||||
{
|
||||
last_y = -1;
|
||||
initial_touch = true;
|
||||
if (click_loc & LIST)
|
||||
{ /* release on list item enters it */
|
||||
gui_synclist_select_item(list, list_start_item + line);
|
||||
|
@ -814,7 +817,6 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
|
|||
return ACTION_STD_MENU;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCROLL_SWIPE:
|
||||
|
@ -842,7 +844,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
|
|||
scroll_mode = SCROLL_NONE;
|
||||
|
||||
if (scroll_mode == SCROLL_NONE)
|
||||
last_y = -1;
|
||||
initial_touch = true;
|
||||
break;
|
||||
}
|
||||
case SCROLL_KINETIC:
|
||||
|
@ -879,8 +881,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
|
|||
}
|
||||
}
|
||||
|
||||
/* register y position unless forcefully reset to 1- */
|
||||
if (last_y >= 0)
|
||||
/* register y position unless forcefully reset */
|
||||
if (!initial_touch)
|
||||
last_y = adj_y;
|
||||
|
||||
return recurse ? gui_synclist_do_touchscreen(list) : ACTION_REDRAW;
|
||||
|
|
Loading…
Reference in a new issue