Index: apps/misc.h =================================================================== --- apps/misc.h (revision 29279) +++ apps/misc.h (working copy) @@ -101,4 +101,22 @@ #endif #endif +enum current_screen { + SCREEN_UNKNONW = 0, + SCREEN_MAINMENU, + SCREEN_FILEBROWSER, + SCREEN_DATABASEBROWSER, + SCREEN_PLUGINBROWSER, + SCREEN_WPS, + SCREEN_FM, + SCREEN_RECORDING, + SCREEN_QUICKSCREEN, + SCREEN_PITCHSCREEN, + SCREEN_PLAYLISTVIEWER +}; +void push_current_screen(enum current_screen screen); +void pop_current_screen(void); +enum current_screen get_current_screen(void); + + #endif /* MISC_H */ Index: apps/gui/skin_engine/skin_tokens.c =================================================================== --- apps/gui/skin_engine/skin_tokens.c (revision 29279) +++ apps/gui/skin_engine/skin_tokens.c (working copy) @@ -1725,37 +1725,7 @@ 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; Index: apps/gui/quickscreen.c =================================================================== --- apps/gui/quickscreen.c (revision 29279) +++ apps/gui/quickscreen.c (working copy) @@ -313,6 +313,9 @@ * - 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); @@ -365,6 +368,7 @@ viewportmanager_theme_undo(i, true); } + pop_current_screen(); return changed; } Index: apps/root_menu.c =================================================================== --- apps/root_menu.c (revision 29279) +++ apps/root_menu.c (working copy) @@ -151,6 +151,7 @@ #endif strcpy(folder, last_folder); } + push_current_screen(SCREEN_FILEBROWSER); break; #ifdef HAVE_TAGCACHE case GO_TO_DBBROWSER: @@ -246,12 +247,14 @@ 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: @@ -577,15 +580,12 @@ 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_UNKNONW); if (global_settings.start_in_screen == 0) next_screen = (int)global_status.last_screen; Index: apps/root_menu.h =================================================================== --- apps/root_menu.h (revision 29279) +++ apps/root_menu.h (working copy) @@ -64,6 +64,4 @@ extern void previous_music_is_wps(void); -extern int current_screen(void); - #endif /* __ROOT_MENU_H__ */ Index: apps/misc.c =================================================================== --- apps/misc.c (revision 29279) +++ apps/misc.c (working copy) @@ -1015,3 +1015,19 @@ } #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]; +} +