A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

gui: Remove "enum list_wrap" from list action functions

Removing the "list_wrap" argument is actually pretty easy.
In practice, almost all lists are using LIST_WRAP_UNLESS_HELD
behavior so we can make that the default. A couple of lists
disable wraparound with LIST_WRAP_OFF; this is now achieved
by setting the list "wraparound" flag to false when setting
up the list. LIST_WRAP_ON was unused and is of questionable
value, so it has been removed entirely.

This makes list wraparound behavior a property of the list,
controlled solely by the "wraparound" flag. The result is a
simpler list API and implementation, without changing the
behavior of any lists.

Change-Id: Ib55d17519e6d92fc95ae17b84ab0aaf4233bcb5a

+53 -86
+1 -2
apps/bookmark.c
··· 793 793 refresh = false; 794 794 } 795 795 796 - list_do_action(CONTEXT_BOOKMARKSCREEN, HZ / 2, 797 - &list, &action, LIST_WRAP_UNLESS_HELD); 796 + list_do_action(CONTEXT_BOOKMARKSCREEN, HZ / 2, &list, &action); 798 797 item = gui_synclist_get_sel_pos(&list) / 2; 799 798 800 799 if (bookmarks->show_dont_resume)
+1 -1
apps/cuesheet.c
··· 481 481 { 482 482 gui_synclist_draw(&lists); 483 483 action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 484 - if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) 484 + if (gui_synclist_do_button(&lists, &action)) 485 485 continue; 486 486 switch (action) 487 487 {
+13 -26
apps/gui/list.c
··· 595 595 gui_synclist_draw(current_lists); 596 596 } 597 597 598 - bool gui_synclist_do_button(struct gui_synclist * lists, 599 - int *actionptr, enum list_wrap wrap) 598 + bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr) 600 599 { 601 600 int action = *actionptr; 602 601 static bool pgleft_allow_cancel = false; ··· 642 641 643 642 /* Disable the skin redraw callback */ 644 643 current_lists = NULL; 645 - switch (wrap) 646 - { 647 - case LIST_WRAP_ON: 648 - lists->limit_scroll = !lists->wraparound; 649 - break; 650 - case LIST_WRAP_OFF: 651 - lists->limit_scroll = true; 652 - break; 653 - case LIST_WRAP_UNLESS_HELD: 654 - if (action == ACTION_STD_PREVREPEAT || 655 - action == ACTION_STD_NEXTREPEAT || 656 - action == ACTION_LISTTREE_PGUP || 657 - action == ACTION_LISTTREE_PGDOWN) 658 - lists->limit_scroll = true; 659 - else 660 - lists->limit_scroll = !lists->wraparound; 661 - break; 662 - }; 644 + 645 + /* Prevent list wraparound by repeating actions */ 646 + if (action == ACTION_STD_PREVREPEAT || 647 + action == ACTION_STD_NEXTREPEAT || 648 + action == ACTION_LISTTREE_PGUP || 649 + action == ACTION_LISTTREE_PGDOWN) 650 + lists->limit_scroll = true; 651 + else 652 + lists->limit_scroll = !lists->wraparound; 663 653 664 654 switch (action) 665 655 { ··· 795 785 } 796 786 797 787 bool list_do_action(int context, int timeout, 798 - struct gui_synclist *lists, int *action, 799 - enum list_wrap wrap) 788 + struct gui_synclist *lists, int *action) 800 789 /* Combines the get_action() (with possibly overridden timeout) and 801 790 gui_synclist_do_button() calls. Returns the list action from 802 791 do_button, and places the action from get_action in *action. */ ··· 804 793 timeout = list_do_action_timeout(lists, timeout); 805 794 keyclick_set_callback(gui_synclist_keyclick_callback, lists); 806 795 *action = get_action(context, timeout); 807 - return gui_synclist_do_button(lists, action, wrap); 796 + return gui_synclist_do_button(lists, action); 808 797 } 809 798 810 799 bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, ··· 871 860 struct gui_synclist lists; 872 861 int action, old_line_count = simplelist_line_count; 873 862 list_get_name *getname; 874 - int wrap = global_settings.list_wraparound ? LIST_WRAP_UNLESS_HELD : LIST_WRAP_OFF; 875 863 if (info->get_name) 876 864 getname = info->get_name; 877 865 else ··· 914 902 915 903 while(1) 916 904 { 917 - list_do_action(CONTEXT_LIST, info->timeout, 918 - &lists, &action, wrap); 905 + list_do_action(CONTEXT_LIST, info->timeout, &lists, &action); 919 906 920 907 /* We must yield in this case or no other thread can run */ 921 908 if (info->timeout == TIMEOUT_NOBLOCK)
+2 -11
apps/gui/list.h
··· 30 30 31 31 #define SCROLLBAR_WIDTH global_settings.scrollbar_width 32 32 33 - enum list_wrap { 34 - LIST_WRAP_ON = 0, 35 - LIST_WRAP_OFF, 36 - LIST_WRAP_UNLESS_HELD, 37 - }; 38 - 39 33 enum synclist_cursor 40 34 { 41 35 SYNCLIST_CURSOR_NOSTYLE = 0, ··· 238 232 * returns true if the action was handled. 239 233 * NOTE: *action may be changed regardless of return value 240 234 */ 241 - extern bool gui_synclist_do_button(struct gui_synclist * lists, 242 - int *action, 243 - enum list_wrap); 235 + extern bool gui_synclist_do_button(struct gui_synclist * lists, int *action); 244 236 #if !defined(PLUGIN) 245 237 struct listitem_viewport_cfg { 246 238 struct wps_data *data; ··· 283 275 list_do_action_timeout) with the gui_synclist_do_button call, for 284 276 convenience. */ 285 277 extern bool list_do_action(int context, int timeout, 286 - struct gui_synclist *lists, int *action, 287 - enum list_wrap wrap); 278 + struct gui_synclist *lists, int *action); 288 279 289 280 290 281 /** Simplelist implementation.
+6 -2
apps/gui/option_select.c
··· 511 511 gui_synclist_speak_item(&lists); 512 512 while (!done) 513 513 { 514 + /* override user wraparound setting; used mainly by EQ settings. 515 + * Not sure this is justified? */ 516 + if (!allow_wrap) 517 + lists.wraparound = false; 518 + 514 519 if (list_do_action(CONTEXT_LIST, HZ, /* HZ so the status bar redraws */ 515 - &lists, &action, 516 - allow_wrap? LIST_WRAP_UNLESS_HELD: LIST_WRAP_OFF)) 520 + &lists, &action)) 517 521 { 518 522 /* setting changed */ 519 523 selected = gui_synclist_get_sel_pos(&lists);
+1 -1
apps/menu.c
··· 450 450 action = new_action; 451 451 } 452 452 453 - if (LIKELY(gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))) 453 + if (LIKELY(gui_synclist_do_button(&lists, &action))) 454 454 continue; 455 455 #ifdef HAVE_QUICKSCREEN 456 456 else if (action == ACTION_STD_QUICKSCREEN)
+1 -2
apps/onplay.c
··· 429 429 gui_synclist_draw(&pt_lists); 430 430 gui_synclist_speak_item(&pt_lists); 431 431 while (true) { 432 - if (list_do_action(CONTEXT_LIST, HZ/2, 433 - &pt_lists, &key, LIST_WRAP_UNLESS_HELD) == 0 432 + if (list_do_action(CONTEXT_LIST, HZ/2, &pt_lists, &key) == 0 434 433 && key!=ACTION_NONE && key!=ACTION_UNKNOWN) 435 434 { 436 435 talk_force_shutup();
+2 -4
apps/playlist_viewer.c
··· 844 844 } 845 845 846 846 /* Timeout so we can determine if play status has changed */ 847 - bool res = list_do_action(CONTEXT_TREE, HZ/2, 848 - &playlist_lists, &button, LIST_WRAP_UNLESS_HELD); 847 + bool res = list_do_action(CONTEXT_TREE, HZ/2, &playlist_lists, &button); 849 848 /* during moving, another redraw is going to be needed, 850 849 * since viewer.selected_track is updated too late (after the first draw) 851 850 * drawing the moving item needs it */ ··· 1131 1130 gui_synclist_speak_item(&playlist_lists); 1132 1131 while (!exit) 1133 1132 { 1134 - if (list_do_action(CONTEXT_LIST, HZ/4, 1135 - &playlist_lists, &button, LIST_WRAP_UNLESS_HELD)) 1133 + if (list_do_action(CONTEXT_LIST, HZ/4, &playlist_lists, &button)) 1136 1134 continue; 1137 1135 switch (button) 1138 1136 {
+3 -4
apps/plugin.h
··· 157 157 #define PLUGIN_MAGIC 0x526F634B /* RocK */ 158 158 159 159 /* increase this every time the api struct changes */ 160 - #define PLUGIN_API_VERSION 253 160 + #define PLUGIN_API_VERSION 254 161 161 162 162 /* update this to latest version if a change to the api struct breaks 163 163 backwards compatibility (and please take the opportunity to sort in any 164 164 new function which are "waiting" at the end of the function table) */ 165 - #define PLUGIN_MIN_API_VERSION 253 165 + #define PLUGIN_MIN_API_VERSION 254 166 166 167 167 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ 168 168 ··· 373 373 int item_number); 374 374 void (*gui_synclist_add_item)(struct gui_synclist * lists); 375 375 void (*gui_synclist_del_item)(struct gui_synclist * lists); 376 - bool (*gui_synclist_do_button)(struct gui_synclist * lists, 377 - int *action, enum list_wrap wrap); 376 + bool (*gui_synclist_do_button)(struct gui_synclist * lists, int *action); 378 377 void (*gui_synclist_set_title)(struct gui_synclist *lists, const char* title, 379 378 enum themable_icons icon); 380 379 enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message,
+1 -1
apps/plugins/calendar.c
··· 964 964 while (!exit) 965 965 { 966 966 button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); 967 - rb->gui_synclist_do_button(&gui_memos, &button, LIST_WRAP_UNLESS_HELD); 967 + rb->gui_synclist_do_button(&gui_memos, &button); 968 968 969 969 switch (button) 970 970 {
+1 -2
apps/plugins/chessbox/chessbox_pgn.c
··· 686 686 while (true) { 687 687 curr_selection = rb->gui_synclist_get_sel_pos(&games_list); 688 688 button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 689 - if (rb->gui_synclist_do_button(&games_list,&button,LIST_WRAP_OFF)){ 689 + if (rb->gui_synclist_do_button(&games_list, &button)) 690 690 continue; 691 - } 692 691 switch (button) { 693 692 case ACTION_STD_OK: 694 693 return get_game_info(curr_selection, first_game);
+1 -1
apps/plugins/keybox.c
··· 567 567 { 568 568 rb->gui_synclist_draw(&kb_list); 569 569 button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); 570 - if (rb->gui_synclist_do_button(&kb_list, &button, LIST_WRAP_UNLESS_HELD)) 570 + if (rb->gui_synclist_do_button(&kb_list, &button)) 571 571 continue; 572 572 573 573 switch (button)
+1 -1
apps/plugins/keyremap.c
··· 2054 2054 redraw = true; 2055 2055 2056 2056 ret = menu_action_cb(&action, selected_item, &exit, &lists); 2057 - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) 2057 + if (rb->gui_synclist_do_button(&lists, &action)) 2058 2058 continue; 2059 2059 selected_item = rb->gui_synclist_get_sel_pos(&lists); 2060 2060
+1 -2
apps/plugins/lrcplayer.c
··· 2078 2078 while (!exit) 2079 2079 { 2080 2080 button = rb->get_action(CONTEXT_TREE, TIMEOUT_BLOCK); 2081 - if (rb->gui_synclist_do_button(&gui_editor, &button, 2082 - LIST_WRAP_UNLESS_HELD)) 2081 + if (rb->gui_synclist_do_button(&gui_editor, &button)) 2083 2082 continue; 2084 2083 2085 2084 switch (button)
+1 -1
apps/plugins/main_menu_config.c
··· 188 188 { 189 189 cur_sel = rb->gui_synclist_get_sel_pos(&list); 190 190 action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 191 - if (rb->gui_synclist_do_button(&list,&action,LIST_WRAP_UNLESS_HELD)) 191 + if (rb->gui_synclist_do_button(&list, &action)) 192 192 continue; 193 193 194 194 switch (action)
+2 -2
apps/plugins/open_plugins.c
··· 681 681 { 682 682 action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 683 683 684 - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) 684 + if (rb->gui_synclist_do_button(&lists, &action)) 685 685 continue; 686 686 selected_item = rb->gui_synclist_get_sel_pos(&lists); 687 687 switch (action) ··· 864 864 { 865 865 action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 866 866 867 - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) 867 + if (rb->gui_synclist_do_button(&lists, &action)) 868 868 continue; 869 869 selection = rb->gui_synclist_get_sel_pos(&lists); 870 870 switch (action)
+1 -1
apps/plugins/properties.c
··· 397 397 { 398 398 button = rb->get_action(CONTEXT_LIST, HZ); 399 399 /* HZ so the status bar redraws corectly */ 400 - if (rb->gui_synclist_do_button(&properties_lists,&button,LIST_WRAP_UNLESS_HELD)) 400 + if (rb->gui_synclist_do_button(&properties_lists, &button)) 401 401 continue; 402 402 switch(button) 403 403 {
+3 -3
apps/plugins/puzzles/rockbox.c
··· 2458 2458 { 2459 2459 rb->gui_synclist_draw(&list); 2460 2460 int button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); 2461 - if(rb->gui_synclist_do_button(&list, &button, LIST_WRAP_UNLESS_HELD)) 2461 + if(rb->gui_synclist_do_button(&list, &button)) 2462 2462 continue; 2463 2463 switch(button) 2464 2464 { ··· 2672 2672 { 2673 2673 rb->gui_synclist_draw(&list); 2674 2674 int button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); 2675 - if(rb->gui_synclist_do_button(&list, &button, LIST_WRAP_UNLESS_HELD)) 2675 + if(rb->gui_synclist_do_button(&list, &button)) 2676 2676 continue; 2677 2677 switch(button) 2678 2678 { ··· 2757 2757 { 2758 2758 rb->gui_synclist_draw(&list); 2759 2759 int button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); 2760 - if(rb->gui_synclist_do_button(&list, &button, LIST_WRAP_UNLESS_HELD)) 2760 + if(rb->gui_synclist_do_button(&list, &button)) 2761 2761 continue; 2762 2762 switch(button) 2763 2763 {
+1 -1
apps/plugins/random_folder_advance_config.c
··· 317 317 { 318 318 rb->gui_synclist_draw(&lists); 319 319 button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 320 - if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD)) 320 + if (rb->gui_synclist_do_button(&lists, &button)) 321 321 continue; 322 322 selection = rb->gui_synclist_get_sel_pos(&lists); 323 323 switch (button)
+1 -1
apps/plugins/rb_info.c
··· 557 557 else 558 558 redraw = true; 559 559 ret = menu_action_cb(&action, selected_item, &exit, &lists); 560 - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) 560 + if (rb->gui_synclist_do_button(&lists, &action)) 561 561 continue; 562 562 selected_item = rb->gui_synclist_get_sel_pos(&lists); 563 563 }
+1 -1
apps/plugins/shopper.c
··· 315 315 rb->gui_synclist_draw(&lists); 316 316 cur_sel = rb->gui_synclist_get_sel_pos(&lists); 317 317 button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 318 - if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD)) 318 + if (rb->gui_synclist_do_button(&lists, &button)) 319 319 continue; 320 320 switch (button) 321 321 {
+1 -6
apps/plugins/shortcuts/shortcuts_view.c
··· 59 59 /* user input */ 60 60 button = rb->get_action(CONTEXT_LIST, HZ); 61 61 /* HZ so the status bar redraws corectly */ 62 - if (rb->gui_synclist_do_button(gui_sc, &button, 63 - LIST_WRAP_UNLESS_HELD)) { 64 - /* automatic handling of user input. 65 - * _UNLESS_HELD can be _ON or _OFF also 66 - * selection changed, so redraw */ 62 + if (rb->gui_synclist_do_button(gui_sc, &button)) 67 63 continue; 68 - } 69 64 switch (button) { /* process the user input */ 70 65 case ACTION_STD_OK: 71 66 return SCLA_SELECT;
+1 -1
apps/plugins/text_editor.c
··· 394 394 rb->gui_synclist_draw(&lists); 395 395 cur_sel = rb->gui_synclist_get_sel_pos(&lists); 396 396 button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 397 - if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD)) 397 + if (rb->gui_synclist_do_button(&lists, &button)) 398 398 continue; 399 399 switch (button) 400 400 {
+1 -2
apps/radio/presets.c
··· 490 490 while (result == 0) 491 491 { 492 492 gui_synclist_draw(&lists); 493 - list_do_action(CONTEXT_STD, TIMEOUT_BLOCK, 494 - &lists, &action, LIST_WRAP_UNLESS_HELD); 493 + list_do_action(CONTEXT_STD, TIMEOUT_BLOCK, &lists, &action); 495 494 switch (action) 496 495 { 497 496 case ACTION_STD_MENU:
+1 -1
apps/recorder/recording.c
··· 1265 1265 } 1266 1266 1267 1267 /* let list handle the button */ 1268 - gui_synclist_do_button(&lists, &button, LIST_WRAP_UNLESS_HELD); 1268 + gui_synclist_do_button(&lists, &button); 1269 1269 1270 1270 1271 1271 switch(button)
+2 -4
apps/screens.c
··· 714 714 gui_synclist_draw(&id3_lists); 715 715 gui_synclist_speak_item(&id3_lists); 716 716 while (true) { 717 - if(!list_do_action(CONTEXT_LIST,HZ/2, 718 - &id3_lists, &key,LIST_WRAP_UNLESS_HELD) 717 + if(!list_do_action(CONTEXT_LIST,HZ/2, &id3_lists, &key) 719 718 && key!=ACTION_NONE && key!=ACTION_UNKNOWN) 720 719 { 721 720 if (key == ACTION_STD_OK || key == ACTION_STD_CANCEL) ··· 793 792 say_runtime = false; 794 793 } 795 794 gui_synclist_draw(&lists); 796 - list_do_action(CONTEXT_STD, HZ, 797 - &lists, &action, LIST_WRAP_UNLESS_HELD); 795 + list_do_action(CONTEXT_STD, HZ, &lists, &action); 798 796 if(action == ACTION_STD_CANCEL) 799 797 break; 800 798 if(action == ACTION_STD_OK) {
+1 -1
apps/tree.c
··· 649 649 button = get_action(CONTEXT_TREE|ALLOW_SOFTLOCK, 650 650 list_do_action_timeout(&tree_lists, HZ/2)); 651 651 oldbutton = button; 652 - gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD); 652 + gui_synclist_do_button(&tree_lists, &button); 653 653 tc.selected_item = gui_synclist_get_sel_pos(&tree_lists); 654 654 switch ( button ) { 655 655 case ACTION_STD_OK:
+1 -1
docs/PLUGIN_API
··· 669 669 \param lists 670 670 \description 671 671 672 - bool gui_synclist_do_button(struct gui_synclist * lists, unsigned *action, enum list_wrap wrap) 672 + bool gui_synclist_do_button(struct gui_synclist * lists, unsigned *action) 673 673 \group list 674 674 \param lists 675 675 \param action