diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index f954268..72d71a7 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -486,6 +486,7 @@ bool option_screen(const struct settings_list *setting, temp_var = oldvalue = *(bool*)setting->setting?1:0; } else return false; /* only int/bools can go here */ + push_current_screen(SCREEN_OPTIONSELECT); gui_synclist_init(&lists, value_setting_get_name_cb, (void*)setting, false, 1, parent); if (setting->lang_id == -1) @@ -566,6 +567,7 @@ bool option_screen(const struct settings_list *setting, if (function == sound_get_fn(SOUND_VOLUME)) global_status.last_volume_change = current_tick; } + pop_current_screen(); return false; } diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index f03043d..5973d01 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -317,6 +317,9 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente * - an action taken while pressing the enter button, * then release the enter button*/ bool can_quit = false; + + push_current_screen(SCREEN_QUICKSCREEN); + FOR_NB_SCREENS(i) { screens[i].set_viewport(NULL); @@ -369,6 +372,7 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente viewportmanager_theme_undo(i, true); } + pop_current_screen(); return changed; } diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 3037a95..10f106f 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c @@ -780,7 +780,7 @@ static __attribute__((noinline)) void skin_render_playlistviewer(struct playlist int cur_pos, start_item, max; int nb_lines = viewport_get_nb_lines(viewer->vp); #if CONFIG_TUNER - if (current_screen() == GO_TO_FM) + if (get_current_screen() == SCREEN_FM) { cur_pos = radio_current_preset(); start_item = cur_pos + viewer->start_offset; diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 3aa7947..a5e9169 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -1730,37 +1730,7 @@ const char *get_token_value(struct gui_wps *gwps, case SKIN_TOKEN_CURRENT_SCREEN: { - int curr_screen = current_screen(); - -#ifdef HAVE_RECORDING - /* override current_screen() for recording screen since it may - * be entered from the radio screen */ - if (in_recording_screen()) - curr_screen = GO_TO_RECSCREEN; -#endif - - switch (curr_screen) - { - case GO_TO_WPS: - curr_screen = 2; - break; -#ifdef HAVE_RECORDING - case GO_TO_RECSCREEN: - curr_screen = 3; - break; -#endif -#if CONFIG_TUNER - case GO_TO_FM: - curr_screen = 4; - break; -#endif - case GO_TO_PLAYLIST_VIEWER: - curr_screen = 5; - break; - default: /* lists */ - curr_screen = 1; - break; - } + int curr_screen = get_current_screen(); if (intval) { *intval = curr_screen; diff --git a/apps/misc.c b/apps/misc.c index b027215..6845a8f 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -1021,3 +1021,19 @@ int clamp_value_wrap(int value, int max, int min) } #endif #endif +#define MAX_SCREEN_DEPTH 64 +static enum current_screen current_screen[MAX_SCREEN_DEPTH] = {SCREEN_UNKNOWN}; +static int current_screen_top = 0; +void push_current_screen(enum current_screen screen) +{ + current_screen[current_screen_top++] = screen; +} +void pop_current_screen(void) +{ + current_screen_top--; +} +enum current_screen get_current_screen(void) +{ + return current_screen[current_screen_top?current_screen_top-1:0]; +} + diff --git a/apps/misc.h b/apps/misc.h index 1022af4..9efba84 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -100,4 +100,23 @@ int clamp_value_wrap(int value, int max, int min); #endif #endif +enum current_screen { + SCREEN_UNKNOWN = 0, + SCREEN_MAINMENU, + SCREEN_FILEBROWSER, + SCREEN_DATABASEBROWSER, + SCREEN_PLUGINBROWSER, + SCREEN_WPS, + SCREEN_FM, + SCREEN_RECORDING, + SCREEN_QUICKSCREEN, + SCREEN_PITCHSCREEN, + SCREEN_PLAYLISTVIEWER, + SCREEN_OPTIONSELECT +}; +void push_current_screen(enum current_screen screen); +void pop_current_screen(void); +enum current_screen get_current_screen(void); + + #endif /* MISC_H */ diff --git a/apps/radio/radio.c b/apps/radio/radio.c index 5c0b884..51b0be0 100644 --- a/apps/radio/radio.c +++ b/apps/radio/radio.c @@ -403,6 +403,7 @@ void radio_screen(void) #endif /* change status to "in screen" */ + push_current_screen(SCREEN_FM); in_screen = true; if(radio_preset_count() <= 0) @@ -868,6 +869,7 @@ void radio_screen(void) cpu_idle_mode(false); #endif fms_fix_displays(FMS_EXIT); + pop_current_screen(); in_screen = false; } /* radio_screen */ diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index b4f7d25..67ea81f 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -1108,6 +1108,7 @@ bool recording_screen(bool no_source) struct audio_recording_options rec_options; rec_status = RCSTAT_IN_RECSCREEN; + push_current_screen(SCREEN_RECORDING); #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \ && !defined(SIMULATOR) @@ -2089,7 +2090,7 @@ rec_abort: #endif settings_save(); - + pop_current_screen(); return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; } /* recording_screen */ diff --git a/apps/root_menu.c b/apps/root_menu.c index 76c081f..b851b61 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -151,6 +151,7 @@ static int browser(void* param) #endif strcpy(folder, last_folder); } + push_current_screen(SCREEN_FILEBROWSER); break; #ifdef HAVE_TAGCACHE case GO_TO_DBBROWSER: @@ -246,12 +247,14 @@ static int browser(void* param) filter = SHOW_ID3DB; tc->dirlevel = last_db_dirlevel; tc->selected_item = last_db_selection; + push_current_screen(SCREEN_DATABASEBROWSER); break; #endif } browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL); ret_val = rockbox_browse(&browse); + pop_current_screen(); switch ((intptr_t)param) { case GO_TO_FILEBROWSER: @@ -285,6 +288,7 @@ static int wpsscrn(void* param) { int ret_val = GO_TO_PREVIOUS; (void)param; + push_current_screen(SCREEN_WPS); if (audio_status()) { talk_shutup(); @@ -306,6 +310,7 @@ static int wpsscrn(void* param) { splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); } + pop_current_screen(); return ret_val; } #if CONFIG_TUNER @@ -578,15 +583,12 @@ void previous_music_is_wps(void) previous_music = GO_TO_WPS; } -int current_screen(void) -{ - return next_screen; -} - void root_menu(void) { int previous_browser = GO_TO_FILEBROWSER; int selected = 0; + + push_current_screen(SCREEN_UNKNOWN); if (global_settings.start_in_screen == 0) next_screen = (int)global_status.last_screen; diff --git a/apps/root_menu.h b/apps/root_menu.h index 3d18d18..2ffdced 100644 --- a/apps/root_menu.h +++ b/apps/root_menu.h @@ -64,6 +64,4 @@ extern const struct menu_item_ex root_menu_; extern void previous_music_is_wps(void); -extern int current_screen(void); - #endif /* __ROOT_MENU_H__ */