touchscreen: Fix menu callbacks in touchscreen pointing mode

Touchscreen events get translated into standard actions only after
the call to gui_synclist_do_button(). The menu callback doesn't get
a chance to see the real action if it is called before do_button.

Moving the do_button call up could potentially break callbacks that
want to intercept actions before they hit the list code. Therefore
we need to manually handle touch events first, and pass the action
to do_button afterward.

Fixes a bug where exiting a plugin in touchscreen point mode always
goes to the games list because the callback wasn't invoked properly.

Change-Id: I3b74a16d68a111935fba2157c15fa188f15446e9
This commit is contained in:
Aidan MacDonald 2022-04-20 21:01:07 +01:00 committed by Solomon Peachy
parent fd4a10719d
commit 306caa2754

View file

@ -434,6 +434,13 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
/* query audio status to see if it changed */ /* query audio status to see if it changed */
redraw_lists = query_audio_status(&old_audio_status); redraw_lists = query_audio_status(&old_audio_status);
#ifdef HAVE_TOUCHSCREEN
/* need to translate touch actions *first* so the menu callback has
* a chance to intercept before it hits the list's do_button. */
if (action == ACTION_TOUCHSCREEN)
action = gui_synclist_do_touchscreen(&lists);
#endif
if (menu_callback) if (menu_callback)
{ {
int new_action = menu_callback(action, menu, &lists); int new_action = menu_callback(action, menu, &lists);