Eliminate skin updates in between activities

1) Adds way to pop activity without refreshing the skin at
the same time.

Activities are sometimes popped in immediate succession,
or one activity is popped before another one is pushed right
away. This can lead to the UI appearing glitchy, due to an
activity only appearing for a split-second, which is especially
noticeable with complex skins that change the dimensions
of the UI viewport depending on the current activity

To fix this, prevent superfluous skin updates

* when switching between:
- WPS and browser
- WPS and Playlist Catalogue
- WPS and playlist
- WPS and Settings/System/Plugins

* when accessing Track Info or when displaying
bookmarks using the context menu on the WPS

* when switching from QuickScreen to Shortcuts Menu

2) The playlist viewer activity was pushed & popped
redundantly by playlist_view.

----
NB:
Behavior has remained unchanged in all instances of the
code where pop_current_activity() has been replaced by
pop_current_activity(ACTIVITY_REFRESH_NOW).

Change-Id: I56b517b8c9dba823a9fed3a3f558d7469dcea9fd
This commit is contained in:
Christian Soffke 2022-11-27 01:15:14 +01:00
parent 90d1ac0448
commit dfd9c10589
18 changed files with 119 additions and 32 deletions

View file

@ -1122,7 +1122,7 @@ int bookmark_load_menu(void)
}
}
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
return ret;
}
@ -1143,7 +1143,7 @@ bool bookmark_mrb_load()
ret = play_bookmark(bookmark);
}
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
return ret;
}

View file

@ -574,7 +574,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_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
return false;
}

View file

@ -406,10 +406,13 @@ static int gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter
{ /* stop scrolling before exiting */
for (int j = 0; j < QUICKSCREEN_ITEM_COUNT; j++)
screens[i].scroll_stop_viewport(&vps[i][j]);
viewportmanager_theme_undo(i, true);
viewportmanager_theme_undo(i, !(ret & QUICKSCREEN_GOTO_SHORTCUTS_MENU));
}
pop_current_activity();
if (ret & QUICKSCREEN_GOTO_SHORTCUTS_MENU) /* Eliminate flashing of parent during */
pop_current_activity(ACTIVITY_REFRESH_DEFERRED); /* transition to Shortcuts */
else
pop_current_activity(ACTIVITY_REFRESH_NOW);
return ret;
}

View file

@ -315,5 +315,5 @@ void gui_usb_screen_run(bool early_usb)
viewportmanager_theme_undo(i, false);
}
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
}

View file

@ -138,6 +138,8 @@ int save_playlist_screen(struct playlist_info* playlist)
static int playlist_view_(void)
{
playlist_viewer_ex(NULL, NULL);
FOR_NB_SCREENS(i) /* Playlist Viewer defers skin updates when popping its activity */
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
return 0;
}
MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST),

View file

@ -304,7 +304,7 @@ int time_screen(void* ignored)
#endif
ret = do_menu(&time_menu, NULL, menu, false);
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
/* see comments above in the button callback */
if (!menu_was_pressed && ret == GO_TO_PREVIOUS)
return 0;

View file

@ -1579,13 +1579,14 @@ void push_current_activity(enum current_activity screen)
}
}
void pop_current_activity(void)
void pop_current_activity(enum activity_refresh refresh)
{
current_activity_top--;
FOR_NB_SCREENS(i)
{
skinlist_set_cfg(i, NULL);
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
if (ACTIVITY_REFRESH_NOW == refresh)
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
}
}
enum current_activity get_current_activity(void)

View file

@ -214,8 +214,14 @@ struct mp3entry;
int id3_get_replaygain_mode(const struct mp3entry *id3);
void replaygain_update(void);
enum activity_refresh
{
ACTIVITY_REFRESH_DEFERRED = 0,
ACTIVITY_REFRESH_NOW,
};
void push_current_activity(enum current_activity screen);
void pop_current_activity(void);
void pop_current_activity(enum activity_refresh refresh);
enum current_activity get_current_activity(void);
/* format a sound value like: -1.05 dB */

View file

@ -144,6 +144,15 @@ static bool clipboard_clip(struct clipboard *clip, const char *path,
/* interface function. */
/* ----------------------------------------------------------------------- */
static int bookmark_load_menu_wrapper(void)
{
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */
pop_current_activity(ACTIVITY_REFRESH_DEFERRED); /* when called from ctxt menu */
return bookmark_load_menu();
}
static int bookmark_menu_callback(int action,
const struct menu_item_ex *this_item,
struct gui_synclist *this_list);
@ -153,7 +162,7 @@ MENUITEM_FUNCTION(bookmark_create_menu_item, 0,
bookmark_menu_callback, Icon_Bookmark);
MENUITEM_FUNCTION(bookmark_load_menu_item, 0,
ID2P(LANG_BOOKMARK_MENU_LIST),
bookmark_load_menu, NULL,
bookmark_load_menu_wrapper, NULL,
bookmark_menu_callback, Icon_Bookmark);
MAKE_ONPLAYMENU(bookmark_menu, ID2P(LANG_BOOKMARK_MENU),
bookmark_menu_callback, Icon_Bookmark,
@ -462,7 +471,18 @@ static bool save_playlist(void)
return false;
}
extern struct menu_item_ex view_cur_playlist; /* from playlist_menu.c */
static int wps_view_cur_playlist(void)
{
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */
pop_current_activity(ACTIVITY_REFRESH_DEFERRED); /* when called from ctxt menu */
playlist_viewer_ex(NULL, NULL);
return 0;
}
MENUITEM_FUNCTION(wps_view_cur_playlist_item, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
wps_view_cur_playlist, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(search_playlist_item, 0, ID2P(LANG_SEARCH_IN_PLAYLIST),
search_playlist, NULL, NULL, Icon_Playlist);
MENUITEM_FUNCTION(playlist_save_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST),
@ -473,7 +493,7 @@ MENUITEM_FUNCTION(playing_time_item, 0, ID2P(LANG_PLAYING_TIME),
playing_time, NULL, NULL, Icon_Playlist);
MAKE_ONPLAYMENU( wps_playlist_menu, ID2P(LANG_PLAYLIST),
NULL, Icon_Playlist,
&view_cur_playlist, &search_playlist_item,
&wps_view_cur_playlist_item, &search_playlist_item,
&playlist_save_item, &reshuffle_item, &playing_time_item
);
@ -1499,6 +1519,9 @@ MENUITEM_FUNCTION(view_cue_item, 0, ID2P(LANG_BROWSE_CUESHEET),
static int browse_id3_wrapper(void)
{
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */
pop_current_activity(ACTIVITY_REFRESH_DEFERRED); /* when called from ctxt menu */
if (browse_id3(audio_current_track(),
playlist_get_display_index(),
playlist_amount()))
@ -1954,7 +1977,9 @@ int onplay(char* file, int attr, int from, bool hotkey)
else
menu = &tree_onplay_menu;
menu_selection = do_menu(menu, NULL, NULL, false);
pop_current_activity();
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* Activity may have been */
pop_current_activity(ACTIVITY_REFRESH_NOW); /* popped already by menu item */
switch (menu_selection)
{

View file

@ -1015,7 +1015,14 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
case ACTION_STD_QUICKSCREEN:
if (!global_settings.shortcuts_replaces_qs)
{
quick_screen_quick(button);
if (quick_screen_quick(button) ==
QUICKSCREEN_GOTO_SHORTCUTS_MENU) /* currently disabled */
{
/* QuickScreen defers skin updates when popping its activity
to switch to Shortcuts Menu, so make up for that here: */
FOR_NB_SCREENS(i)
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
}
update_playlist(true);
prepare_lists(&playlist_lists);
}
@ -1092,7 +1099,7 @@ exit:
static void close_playlist_viewer(void)
{
talk_shutup();
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_DEFERRED);
if (viewer.playlist)
{
if (viewer.initial_selection)

View file

@ -919,7 +919,7 @@ int plugin_load(const char* plugin, const void* parameter)
int rc = p_hdr->entry_point(parameter);
tree_unlock_cache(tree_get_context());
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
if (!pfn_tsr_exit)
{ /* close handle if plugin is no tsr one */

View file

@ -1109,7 +1109,7 @@ int gui_syncpitchscreen_run(void)
}
//rb->pcmbuf_set_low_latency(false);
//pop_current_activity();
//pop_current_activity(ACTIVITY_REFRESH_NOW);
/* Clean up */
FOR_NB_SCREENS(i)

View file

@ -729,7 +729,7 @@ void radio_screen(void)
cpu_idle_mode(false);
#endif
fms_fix_displays(FMS_EXIT);
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
in_screen = false;
} /* radio_screen */

View file

@ -1844,7 +1844,7 @@ rec_abort:
#endif
settings_save();
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
} /* recording_screen */

View file

@ -276,7 +276,14 @@ static int browser(void* param)
browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL);
ret_val = rockbox_browse(&browse);
pop_current_activity();
if (ret_val == GO_TO_WPS
|| ret_val == GO_TO_PREVIOUS_MUSIC
|| ret_val == GO_TO_PLUGIN)
pop_current_activity(ACTIVITY_REFRESH_DEFERRED);
else
pop_current_activity(ACTIVITY_REFRESH_NOW);
switch ((intptr_t)param)
{
case GO_TO_FILEBROWSER:
@ -336,7 +343,23 @@ static int wpsscrn(void* param)
{
splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME));
}
pop_current_activity();
if (ret_val == GO_TO_PLAYLIST_VIEWER
|| ret_val == GO_TO_PLUGIN
|| ret_val == GO_TO_WPS
|| ret_val == GO_TO_PREVIOUS_MUSIC
|| ret_val == GO_TO_PREVIOUS_BROWSER
|| (ret_val == GO_TO_PREVIOUS
&& (last_screen == GO_TO_MAINMENU /* Settings */
|| last_screen == GO_TO_BROWSEPLUGINS
|| last_screen == GO_TO_SYSTEM_SCREEN
|| last_screen == GO_TO_PLAYLISTS_SCREEN)))
{
pop_current_activity(ACTIVITY_REFRESH_DEFERRED);
}
else
pop_current_activity(ACTIVITY_REFRESH_NOW);
return ret_val;
}
#if CONFIG_TUNER
@ -370,10 +393,14 @@ static int playlist_view_catalog(void * param)
(void)param;
push_current_activity(ACTIVITY_PLAYLISTBROWSER);
bool item_was_selected = catalog_view_playlists();
pop_current_activity();
if (item_was_selected)
{
pop_current_activity(ACTIVITY_REFRESH_DEFERRED);
return GO_TO_WPS;
return GO_TO_PREVIOUS;
}
pop_current_activity(ACTIVITY_REFRESH_NOW);
return GO_TO_ROOT;
}
static int playlist_view(void * param)
@ -381,9 +408,7 @@ static int playlist_view(void * param)
(void)param;
int val;
push_current_activity(ACTIVITY_PLAYLISTVIEWER);
val = playlist_viewer();
pop_current_activity();
switch (val)
{
case PLAYLIST_VIEWER_MAINMENU:
@ -682,7 +707,15 @@ static inline int load_screen(int screen)
ret_val = items[screen].function(items[screen].param);
if (activity != ACTIVITY_UNKNOWN)
pop_current_activity();
{
if (ret_val == GO_TO_WPS
|| ret_val == GO_TO_PREVIOUS_MUSIC)
{
pop_current_activity(ACTIVITY_REFRESH_DEFERRED);
}
else
pop_current_activity(ACTIVITY_REFRESH_NOW);
}
last_screen = screen;
if (ret_val == GO_TO_PREVIOUS)
@ -708,7 +741,7 @@ static int load_context_screen(int selection)
if (context_menu)
retval = do_menu(context_menu, NULL, NULL, false);
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
return retval;
}

View file

@ -733,7 +733,7 @@ bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_a
}
}
pop_current_activity();
pop_current_activity(ACTIVITY_REFRESH_NOW);
return ret;
}

View file

@ -718,7 +718,10 @@ int do_shortcut_menu(void *ignored)
}
}
}
pop_current_activity();
if (GO_TO_PLUGIN == done)
pop_current_activity(ACTIVITY_REFRESH_DEFERRED);
else
pop_current_activity(ACTIVITY_REFRESH_NOW);
--buflib_move_lock;
return done;

View file

@ -763,7 +763,7 @@ static int dirbrowse(void)
else if (ret == QUICKSCREEN_GOTO_SHORTCUTS_MENU)
enter_shortcuts_menu = true;
}
if (enter_shortcuts_menu && *tc.dirfilter < NUM_FILTER_MODES)
{
int last_screen = global_status.last_screen;
@ -774,7 +774,14 @@ static int dirbrowse(void)
else
return shortcut_ret;
}
else if (enter_shortcuts_menu) /* currently disabled */
{
/* QuickScreen defers skin updates, popping its activity, when
switching to Shortcuts Menu, so make up for that here: */
FOR_NB_SCREENS(i)
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
}
restore = true;
break;
}