summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-11-07 01:56:49 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-11-07 01:49:15 -0500
commit1d67f83c587cce30a9afa10f966cc04a86adb87b (patch)
tree8e8b1e7255c798405d8ad15d8d7e575c6bcc439e
parent13ac48562544eada909ee39a63d5b87afe51b219 (diff)
downloadrockbox-1d67f83c58.tar.gz
rockbox-1d67f83c58.zip
root_menu.c fix recent regression for shortcuts add resume for plugins
recent changes broke shortcuts when they originated from the root menu I mistakenly thought GO_TO_ROOT only happened at start and otherwise was GO_TO_PREVIOUS this commit also adds a few missing features for Start In Previous to resume the last plugin running at shutdown Additionally GO_TO_ROOT now overwrites the global last_screen so you can return to the main menu on next startup Change-Id: I86bf842616e25dc3d4f684ff9d476e6a5ba96b04
-rw-r--r--apps/open_plugin.c9
-rw-r--r--apps/root_menu.c38
2 files changed, 40 insertions, 7 deletions
diff --git a/apps/open_plugin.c b/apps/open_plugin.c
index d16502ecbe..f7f55d58cd 100644
--- a/apps/open_plugin.c
+++ b/apps/open_plugin.c
@@ -374,6 +374,15 @@ int open_plugin_run(const char *key)
void open_plugin_cache_flush(void)
{
logf("OP *cache flush*");
+ /* start_in_screen == 0 is 'Previous Screen' it is actually
+ * defined as (GO_TO_PREVIOUS = -2) + 2 for *Legacy?* reasons AFAICT */
+ if (global_settings.start_in_screen == 0 &&
+ global_status.last_screen == GO_TO_PLUGIN &&
+ open_plugin_entry.lang_id > OPEN_PLUGIN_LANG_INVALID)
+ {
+ /* flush the last item as LANG_PREVIOUS_SCREEN if the user wants to resume */
+ open_plugin_entry.lang_id = LANG_PREVIOUS_SCREEN;
+ }
op_update_dat(&open_plugin_entry, true);
}
diff --git a/apps/root_menu.c b/apps/root_menu.c
index f731531e16..16c45c1509 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -727,7 +727,7 @@ static int load_plugin_screen(char *key)
int ret = plugin_load(path, param);
- if (ret == PLUGIN_USB_CONNECTED)
+ if (ret == PLUGIN_USB_CONNECTED || ret == PLUGIN_ERROR)
ret_val = GO_TO_ROOT;
else if (ret == PLUGIN_GOTO_WPS)
ret_val = GO_TO_WPS;
@@ -735,13 +735,15 @@ static int load_plugin_screen(char *key)
continue;
else
{
- /* Prevents infinite loop with WPS & Plugins*/
+ /* Prevents infinite loop with WPS, Plugins, Previous Screen*/
if (ret == PLUGIN_OK && old_global == GO_TO_WPS && !audio_status())
ret_val = GO_TO_ROOT;
ret_val = GO_TO_PREVIOUS;
- last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous;
+ last_screen = (old_previous == next_screen || old_global == GO_TO_ROOT)
+ ? GO_TO_ROOT : old_previous;
+ if (last_screen == GO_TO_ROOT)
+ global_status.last_screen = GO_TO_ROOT;
}
-
/* ret_val != GO_TO_PLUGIN */
if (opret != OPEN_PLUGIN_NEEDS_FLUSHED || last_screen != GO_TO_WPS)
@@ -772,6 +774,29 @@ static int root_menu_setup_screens(void)
if (global_settings.start_in_screen == 0)
new_screen = (int)global_status.last_screen;
else new_screen = global_settings.start_in_screen - 2;
+ if (new_screen == GO_TO_PLUGIN)
+ {
+ if (global_status.last_screen == GO_TO_SHORTCUTMENU)
+ {
+ /* Can make this any value other than GO_TO_SHORTCUTMENU
+ otherwise it takes over on startup when the user wanted
+ the plugin at key - LANG_START_SCREEN */
+ global_status.last_screen = GO_TO_PLUGIN;
+ }
+ if(global_status.last_screen == GO_TO_SHORTCUTMENU ||
+ global_status.last_screen == GO_TO_PLUGIN)
+ {
+ if (global_settings.start_in_screen == 0)
+ { /* Start in: Previous Screen */
+ last_screen = GO_TO_PREVIOUS;
+ global_status.last_screen = GO_TO_ROOT;
+ /* since the plugin has GO_TO_PLUGIN as origin it
+ will just return GO_TO_PREVIOUS <=> GO_TO_PLUGIN in a loop
+ To allow exit after restart we check for GO_TO_ROOT
+ if so exit to ROOT after the plugin exits */
+ }
+ }
+ }
#if CONFIG_TUNER
add_event(PLAYBACK_EVENT_START_PLAYBACK, rootmenu_start_playback_callback);
#endif
@@ -841,7 +866,7 @@ void root_menu(void)
case GO_TO_ROOT:
if (last_screen != GO_TO_ROOT)
selected = get_selection(last_screen);
-
+ global_status.last_screen = GO_TO_ROOT; /* We've returned to ROOT */
/* When we are in the main menu we want the hardware BACK
* button to be handled by HOST instead of rockbox */
ignore_back_button_stub(true);
@@ -889,8 +914,7 @@ void root_menu(void)
case GO_TO_PLUGIN:
{
char *key;
- if (global_status.last_screen == GO_TO_SHORTCUTMENU &&
- last_screen != GO_TO_ROOT)
+ if (global_status.last_screen == GO_TO_SHORTCUTMENU)
{
shortcut_origin = last_screen;
key = ID2P(LANG_SHORTCUTS);