From dfd9c10589d25a966c7e2e4dedab57c59a1987fd Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Sun, 27 Nov 2022 01:15:14 +0100 Subject: [PATCH] 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 --- apps/bookmark.c | 4 +-- apps/gui/option_select.c | 2 +- apps/gui/quickscreen.c | 7 ++++-- apps/gui/usb_screen.c | 2 +- apps/menus/playlist_menu.c | 2 ++ apps/menus/time_menu.c | 2 +- apps/misc.c | 5 ++-- apps/misc.h | 8 +++++- apps/onplay.c | 33 ++++++++++++++++++++++--- apps/playlist_viewer.c | 11 +++++++-- apps/plugin.c | 2 +- apps/plugins/pitch_screen.c | 2 +- apps/radio/radio.c | 2 +- apps/recorder/recording.c | 2 +- apps/root_menu.c | 49 +++++++++++++++++++++++++++++++------ apps/screens.c | 2 +- apps/shortcuts.c | 5 +++- apps/tree.c | 11 +++++++-- 18 files changed, 119 insertions(+), 32 deletions(-) diff --git a/apps/bookmark.c b/apps/bookmark.c index 68c10b36e7..64a4b9f761 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -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; } diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index ca16b5b05f..918335d6cd 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -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; } diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 141eb1a16b..1f32dca544 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -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; } diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c index 31321ec005..05e60067e0 100644 --- a/apps/gui/usb_screen.c +++ b/apps/gui/usb_screen.c @@ -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); } diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c index 89c93edc2e..981ec74798 100644 --- a/apps/menus/playlist_menu.c +++ b/apps/menus/playlist_menu.c @@ -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), diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index e37e2b5637..b44d47ff8b 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c @@ -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; diff --git a/apps/misc.c b/apps/misc.c index 950662d19a..7da3c57c73 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -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) diff --git a/apps/misc.h b/apps/misc.h index af520a7fd1..4f4527f686 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -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 */ diff --git a/apps/onplay.c b/apps/onplay.c index f2dbf8b3bf..7ea6b9035b 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -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) { diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 4abd3ee1c5..90a47c35ea 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -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) diff --git a/apps/plugin.c b/apps/plugin.c index 128b52ea2d..b8897c95ee 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -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 */ diff --git a/apps/plugins/pitch_screen.c b/apps/plugins/pitch_screen.c index e24e0240a2..76e7fa9775 100644 --- a/apps/plugins/pitch_screen.c +++ b/apps/plugins/pitch_screen.c @@ -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) diff --git a/apps/radio/radio.c b/apps/radio/radio.c index bf8ad865dd..a02d4429fa 100644 --- a/apps/radio/radio.c +++ b/apps/radio/radio.c @@ -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 */ diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 6c52adf5d3..374583cc21 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -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 */ diff --git a/apps/root_menu.c b/apps/root_menu.c index 80b5be1d36..3553b794fa 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -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; } diff --git a/apps/screens.c b/apps/screens.c index db24e534c1..2ffdf68023 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -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; } diff --git a/apps/shortcuts.c b/apps/shortcuts.c index e52e38eb06..98edcf653e 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c @@ -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; diff --git a/apps/tree.c b/apps/tree.c index fa745319a9..3684e395a1 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -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; }