Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve transition between plugin and WPS

Eliminate flashing when plugins are launched
from WPS, by not enabling the SBS, and by
deferring other lcd updates.

Also prevents flashing root menu activity when
returning from plugins.

Change-Id: I7d761867027f2275c4ab8e16ada3107c7ba0be6e

+109 -40
+69 -27
apps/gui/wps.c
··· 63 63 #include "wps.h" 64 64 #include "statusbar-skinned.h" 65 65 #include "skin_engine/wps_internals.h" 66 + #include "open_plugin.h" 66 67 67 68 #define RESTORE_WPS_INSTANTLY 0l 68 69 #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) ··· 514 515 } 515 516 #endif 516 517 517 - static void gwps_leave_wps(void) 518 + static void gwps_leave_wps(bool theme_enabled) 518 519 { 519 520 FOR_NB_SCREENS(i) 520 521 { 521 522 struct gui_wps *gwps = skin_get_gwps(WPS, i); 522 523 gwps->display->scroll_stop(); 524 + if (theme_enabled) 525 + { 523 526 #ifdef HAVE_BACKDROP_IMAGE 524 - skin_backdrop_show(sb_get_backdrop(i)); 527 + skin_backdrop_show(sb_get_backdrop(i)); 525 528 #endif 526 - viewportmanager_theme_undo(i, skin_has_sbs(gwps)); 529 + viewportmanager_theme_undo(i, skin_has_sbs(gwps)); 530 + } 527 531 } 528 532 529 533 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) ··· 539 543 540 544 /* 541 545 * display the wps on entering or restoring */ 542 - static void gwps_enter_wps(void) 546 + static void gwps_enter_wps(bool theme_enabled) 543 547 { 544 548 struct gui_wps *gwps; 545 549 struct screen *display; ··· 548 552 gwps = skin_get_gwps(WPS, i); 549 553 display = gwps->display; 550 554 display->scroll_stop(); 551 - viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL); 555 + if (theme_enabled) 556 + viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL); 552 557 553 558 /* Update the values in the first (default) viewport - in case the user 554 559 has modified the statusbar or colour settings */ ··· 609 614 * b) return with a value evaluated by root_menu.c, in this case the wps 610 615 * is really left, and root_menu will handle the next screen 611 616 * 612 - * In either way, call gwps_leave_wps(), in order to restore the correct 617 + * In either way, call gwps_leave_wps(true), in order to restore the correct 613 618 * "main screen" backdrops and statusbars 614 619 */ 615 620 long gui_wps_show(void) ··· 632 637 633 638 while ( 1 ) 634 639 { 640 + bool theme_enabled = true; 635 641 bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; 636 642 637 643 /* did someone else (i.e power thread) change audio pause mode? */ ··· 693 699 case ACTION_WPS_CONTEXT: 694 700 { 695 701 bool hotkey = button == ACTION_WPS_HOTKEY; 696 - gwps_leave_wps(); 697 - int retval = onplay(state->id3->path, 702 + 703 + #ifdef HAVE_HOTKEY 704 + if (hotkey && global_settings.hotkey_wps == HOTKEY_PLUGIN) 705 + { 706 + /* leave WPS without re-enabling theme */ 707 + theme_enabled = false; 708 + gwps_leave_wps(theme_enabled); 709 + onplay(state->id3->path, 698 710 FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); 699 - /* if music is stopped in the context menu we want to exit the wps */ 700 - if (retval == ONPLAY_MAINMENU 701 - || !audio_status()) 702 - return GO_TO_ROOT; 703 - else if (retval == ONPLAY_PLAYLIST) 704 - return GO_TO_PLAYLIST_VIEWER; 705 - else if (retval == ONPLAY_PLUGIN) 706 - return GO_TO_PLUGIN; 711 + if (!audio_status()) 712 + { 713 + /* re-enable theme since we're returning to SBS */ 714 + FOR_NB_SCREENS(i) 715 + { 716 + struct gui_wps *gwps = skin_get_gwps(WPS, i); 717 + #ifdef HAVE_BACKDROP_IMAGE 718 + skin_backdrop_show(sb_get_backdrop(i)); 719 + #endif 720 + viewportmanager_theme_undo(i, skin_has_sbs(gwps)); 721 + } 722 + return GO_TO_ROOT; 723 + } 724 + } 725 + else 726 + #endif 727 + { 728 + gwps_leave_wps(true); 729 + int retval = onplay(state->id3->path, 730 + FILE_ATTR_AUDIO, CONTEXT_WPS, hotkey); 731 + /* if music is stopped in the context menu we want to exit the wps */ 732 + if (retval == ONPLAY_MAINMENU 733 + || !audio_status()) 734 + return GO_TO_ROOT; 735 + else if (retval == ONPLAY_PLAYLIST) 736 + return GO_TO_PLAYLIST_VIEWER; 737 + else if (retval == ONPLAY_PLUGIN) 738 + { 739 + FOR_NB_SCREENS(i) 740 + { 741 + struct gui_wps *gwps = skin_get_gwps(WPS, i); 742 + viewportmanager_theme_enable(i, skin_has_sbs(gwps), NULL); 743 + } 744 + theme_enabled = false; 745 + open_plugin_run(ID2P(LANG_OPEN_PLUGIN_SET_WPS_CONTEXT_PLUGIN)); 746 + } 747 + } 748 + 707 749 restore = true; 708 750 } 709 751 break; 710 752 711 753 case ACTION_WPS_BROWSE: 712 - gwps_leave_wps(); 754 + gwps_leave_wps(true); 713 755 return GO_TO_PREVIOUS_BROWSER; 714 756 break; 715 757 ··· 852 894 break; 853 895 /* menu key functions */ 854 896 case ACTION_WPS_MENU: 855 - gwps_leave_wps(); 897 + gwps_leave_wps(true); 856 898 return GO_TO_ROOT; 857 899 break; 858 900 ··· 860 902 #ifdef HAVE_QUICKSCREEN 861 903 case ACTION_WPS_QUICKSCREEN: 862 904 { 863 - gwps_leave_wps(); 905 + gwps_leave_wps(true); 864 906 bool enter_shortcuts_menu = global_settings.shortcuts_replaces_qs; 865 907 if (!enter_shortcuts_menu) 866 908 { ··· 889 931 #ifdef HAVE_PITCHCONTROL 890 932 case ACTION_WPS_PITCHSCREEN: 891 933 { 892 - gwps_leave_wps(); 934 + gwps_leave_wps(true); 893 935 if (1 == gui_syncpitchscreen_run()) 894 936 return GO_TO_ROOT; 895 937 restore = true; ··· 917 959 break; 918 960 919 961 case ACTION_WPS_LIST_BOOKMARKS: 920 - gwps_leave_wps(); 962 + gwps_leave_wps(true); 921 963 if (bookmark_load_menu() == BOOKMARK_USB_CONNECTED) 922 964 { 923 965 return GO_TO_ROOT; ··· 926 968 break; 927 969 928 970 case ACTION_WPS_CREATE_BOOKMARK: 929 - gwps_leave_wps(); 971 + gwps_leave_wps(true); 930 972 bookmark_create_menu(); 931 973 restore = true; 932 974 break; 933 975 934 976 case ACTION_WPS_ID3SCREEN: 935 977 { 936 - gwps_leave_wps(); 978 + gwps_leave_wps(true); 937 979 if (browse_id3(audio_current_track(), 938 980 playlist_get_display_index(), 939 981 playlist_amount())) ··· 956 998 break; 957 999 #endif 958 1000 case ACTION_WPS_VIEW_PLAYLIST: 959 - gwps_leave_wps(); 1001 + gwps_leave_wps(true); 960 1002 return GO_TO_PLAYLIST_VIEWER; 961 1003 break; 962 1004 default: ··· 965 1007 case SYS_USB_CONNECTED: 966 1008 case SYS_CALL_INCOMING: 967 1009 case BUTTON_MULTIMEDIA_STOP: 968 - gwps_leave_wps(); 1010 + gwps_leave_wps(true); 969 1011 return GO_TO_ROOT; 970 1012 } 971 1013 update = true; ··· 1003 1045 sb_skin_set_update_delay(0); 1004 1046 skin_request_full_update(WPS); 1005 1047 update = true; 1006 - gwps_enter_wps(); 1048 + gwps_enter_wps(theme_enabled); 1007 1049 } 1008 1050 else 1009 1051 { ··· 1038 1080 #ifdef AB_REPEAT_ENABLE 1039 1081 ab_reset_markers(); 1040 1082 #endif 1041 - gwps_leave_wps(); 1083 + gwps_leave_wps(true); 1042 1084 #ifdef HAVE_RECORDING 1043 1085 if (button == ACTION_WPS_REC) 1044 1086 return GO_TO_RECSCREEN;
+7
apps/misc.c
··· 1579 1579 } 1580 1580 } 1581 1581 1582 + void push_activity_without_refresh(enum current_activity screen) 1583 + { 1584 + current_activity[current_activity_top++] = screen; 1585 + FOR_NB_SCREENS(i) 1586 + skinlist_set_cfg(i, NULL); 1587 + } 1588 + 1582 1589 void pop_current_activity(enum activity_refresh refresh) 1583 1590 { 1584 1591 current_activity_top--;
+1
apps/misc.h
··· 221 221 }; 222 222 223 223 void push_current_activity(enum current_activity screen); 224 + void push_activity_without_refresh(enum current_activity screen); 224 225 void pop_current_activity(enum activity_refresh refresh); 225 226 enum current_activity get_current_activity(void); 226 227
+9 -7
apps/playlist_viewer.c
··· 143 143 static bool update_playlist(bool force); 144 144 static enum pv_onplay_result onplay_menu(int index); 145 145 146 - static void close_playlist_viewer(void); 146 + static void close_playlist_viewer(bool pop_activity); 147 147 148 148 static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, 149 149 int names_buffer_size) ··· 525 525 static enum pv_onplay_result open_with(const struct playlist_entry *current_track) 526 526 { 527 527 char selected_track[MAX_PATH]; 528 - close_playlist_viewer(); 528 + close_playlist_viewer(false); /* don't pop activity yet – relevant for plugin_load */ 529 529 530 530 strmemccpy(selected_track, current_track->name, sizeof(selected_track)); 531 531 532 532 int plugin_return = filetype_list_viewers(selected_track); 533 + pop_current_activity(ACTIVITY_REFRESH_DEFERRED); 533 534 534 535 switch (plugin_return) 535 536 { ··· 547 548 static enum pv_onplay_result open_pictureflow(const struct playlist_entry *current_track) 548 549 { 549 550 char selected_track[MAX_PATH]; 550 - close_playlist_viewer(); 551 + close_playlist_viewer(false); /* don't pop activity yet – relevant for plugin_load */ 551 552 552 553 strmemccpy(selected_track, current_track->name, sizeof(selected_track)); 553 - 554 554 int plugin_return = filetype_load_plugin((void *)"pictureflow", selected_track); 555 + pop_current_activity(ACTIVITY_REFRESH_DEFERRED); 555 556 556 557 switch (plugin_return) 557 558 { ··· 1092 1093 } 1093 1094 1094 1095 exit: 1095 - close_playlist_viewer(); 1096 + close_playlist_viewer(true); 1096 1097 return ret; 1097 1098 } 1098 1099 1099 - static void close_playlist_viewer(void) 1100 + static void close_playlist_viewer(bool pop_activity) 1100 1101 { 1101 1102 talk_shutup(); 1102 - pop_current_activity(ACTIVITY_REFRESH_DEFERRED); 1103 + if (pop_activity) 1104 + pop_current_activity(ACTIVITY_REFRESH_DEFERRED); 1103 1105 if (viewer.playlist) 1104 1106 { 1105 1107 if (viewer.initial_selection)
+14 -3
apps/plugin.c
··· 894 894 *(p_hdr->api) = &rockbox_api; 895 895 lcd_set_viewport(NULL); 896 896 lcd_clear_display(); 897 - lcd_update(); 898 897 899 898 #ifdef HAVE_REMOTE_LCD 900 899 lcd_remote_set_viewport(NULL); 901 900 lcd_remote_clear_display(); 902 901 lcd_remote_update(); 903 902 #endif 904 - push_current_activity(ACTIVITY_PLUGIN); 903 + if (get_current_activity() == ACTIVITY_WPS) 904 + push_activity_without_refresh(ACTIVITY_PLUGIN); 905 + else 906 + push_current_activity(ACTIVITY_PLUGIN); 905 907 /* some plugins assume the entry cache doesn't move and save pointers to it 906 908 * they should be fixed properly instead of this lock */ 907 909 tree_lock_cache(tree_get_context()); ··· 922 924 int rc = p_hdr->entry_point(parameter); 923 925 924 926 tree_unlock_cache(tree_get_context()); 925 - pop_current_activity(ACTIVITY_REFRESH_NOW); 927 + 928 + pop_current_activity(ACTIVITY_REFRESH_DEFERRED); 929 + int curr_activity = get_current_activity(); 930 + if ((curr_activity != ACTIVITY_PLAYLISTVIEWER) && 931 + (curr_activity != ACTIVITY_WPS) && 932 + (rc != PLUGIN_GOTO_WPS)) 933 + { 934 + FOR_NB_SCREENS(i) 935 + skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL); 936 + } 926 937 927 938 if (!pfn_tsr_exit) 928 939 { /* close handle if plugin is no tsr one */
+9 -3
apps/root_menu.c
··· 708 708 709 709 if (activity != ACTIVITY_UNKNOWN) 710 710 { 711 - if (ret_val == GO_TO_WPS 712 - || ret_val == GO_TO_PREVIOUS_MUSIC) 711 + if (ret_val == GO_TO_PLUGIN 712 + || ret_val == GO_TO_WPS 713 + || ret_val == GO_TO_PREVIOUS_MUSIC 714 + || ret_val == GO_TO_PREVIOUS_BROWSER 715 + || ret_val == GO_TO_FILEBROWSER) 713 716 { 714 717 pop_current_activity(ACTIVITY_REFRESH_DEFERRED); 715 718 } ··· 986 989 } 987 990 } 988 991 989 - next_screen = load_plugin_screen(key); 992 + 993 + push_activity_without_refresh(ACTIVITY_UNKNOWN); /* prevent plugin_load */ 994 + next_screen = load_plugin_screen(key); /* from flashing root */ 995 + pop_current_activity(ACTIVITY_REFRESH_DEFERRED); /* menu activity */ 990 996 991 997 if (next_screen == GO_TO_PREVIOUS) 992 998 {