summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/root_menu.c98
1 files changed, 48 insertions, 50 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 674f20ead2..7e28cf8a29 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -187,11 +187,6 @@ static int browser(void* param)
187 break; 187 break;
188#endif 188#endif
189 } 189 }
190 /* hopefully only happens trying to go back into the WPS
191 from plugins, if music is stopped... */
192 if ((ret_val == GO_TO_PREVIOUS) && (last_screen == (intptr_t)param))
193 ret_val = GO_TO_ROOT;
194
195 return ret_val; 190 return ret_val;
196} 191}
197 192
@@ -232,8 +227,6 @@ static int wpsscrn(void* param)
232 else 227 else
233 { 228 {
234 gui_syncsplash(HZ*2, str(LANG_NOTHING_TO_RESUME)); 229 gui_syncsplash(HZ*2, str(LANG_NOTHING_TO_RESUME));
235 if (last_screen == GO_TO_WPS)
236 ret_val = GO_TO_ROOT;
237 } 230 }
238#if LCD_DEPTH > 1 231#if LCD_DEPTH > 1
239 show_main_backdrop(); 232 show_main_backdrop();
@@ -388,46 +381,65 @@ static int get_selection(int last_screen)
388 return 0; 381 return 0;
389} 382}
390 383
384static inline int load_screen(int screen)
385{
386 /* set the global_status.last_screen before entering,
387 if we dont we will always return to the wrong screen on boot */
388 int old_previous = last_screen;
389 int ret_val;
390 if (screen <= GO_TO_ROOT)
391 return screen;
392 if (screen == old_previous)
393 old_previous = GO_TO_ROOT;
394 global_status.last_screen = (char)screen;
395 status_save();
396 action_signalscreenchange();
397 last_screen = screen;
398 ret_val = items[screen].function(items[screen].param);
399 if (ret_val == GO_TO_PREVIOUS)
400 last_screen = old_previous;
401 return ret_val;
402}
403
391void root_menu(void) 404void root_menu(void)
392{ 405{
393 int previous_browser = GO_TO_FILEBROWSER; 406 int previous_browser = GO_TO_FILEBROWSER;
394 int previous_music = GO_TO_WPS; 407 int previous_music = GO_TO_WPS;
395 int ret_val = GO_TO_ROOT; 408 int next_screen = GO_TO_ROOT;
396 int this_screen = GO_TO_ROOT;
397 int selected = 0; 409 int selected = 0;
398 410
399 if (global_settings.start_in_screen == 0) 411 if (global_settings.start_in_screen == 0)
400 ret_val = (int)global_status.last_screen; 412 next_screen = (int)global_status.last_screen;
401 else ret_val = global_settings.start_in_screen - 2; 413 else next_screen = global_settings.start_in_screen - 2;
402 414
403#ifdef HAVE_RTC_ALARM 415#ifdef HAVE_RTC_ALARM
404 if ( rtc_check_alarm_started(true) ) 416 if ( rtc_check_alarm_started(true) )
405 { 417 {
406 rtc_enable_alarm(false); 418 rtc_enable_alarm(false);
407 ret_val = GO_TO_WPS; 419 next_screen = GO_TO_WPS;
408#if CONFIG_TUNER 420#if CONFIG_TUNER
409 if (global_settings.alarm_wake_up_screen == ALARM_START_FM) 421 if (global_settings.alarm_wake_up_screen == ALARM_START_FM)
410 ret_val = GO_TO_FM; 422 next_screen = GO_TO_FM;
411#endif 423#endif
412#ifdef HAVE_RECORDING 424#ifdef HAVE_RECORDING
413 if (global_settings.alarm_wake_up_screen == ALARM_START_REC) 425 if (global_settings.alarm_wake_up_screen == ALARM_START_REC)
414 { 426 {
415 recording_start_automatic = true; 427 recording_start_automatic = true;
416 ret_val = GO_TO_RECSCREEN; 428 next_screen = GO_TO_RECSCREEN;
417 } 429 }
418#endif 430#endif
419 } 431 }
420#endif /* HAVE_RTC_ALARM */ 432#endif /* HAVE_RTC_ALARM */
421 433
422#ifdef HAVE_HEADPHONE_DETECTION 434#ifdef HAVE_HEADPHONE_DETECTION
423 if (ret_val == GO_TO_WPS && 435 if (next_screen == GO_TO_WPS &&
424 (global_settings.unplug_autoresume && !headphones_inserted() )) 436 (global_settings.unplug_autoresume && !headphones_inserted() ))
425 ret_val = GO_TO_ROOT; 437 next_screen = GO_TO_ROOT;
426#endif 438#endif
427 439
428 while (true) 440 while (true)
429 { 441 {
430 switch (ret_val) 442 switch (next_screen)
431 { 443 {
432 case MENU_ATTACHED_USB: 444 case MENU_ATTACHED_USB:
433 case MENU_SELECTED_EXIT: 445 case MENU_SELECTED_EXIT:
@@ -436,53 +448,39 @@ void root_menu(void)
436 case GO_TO_ROOT: 448 case GO_TO_ROOT:
437 if (last_screen != GO_TO_ROOT) 449 if (last_screen != GO_TO_ROOT)
438 selected = get_selection(last_screen); 450 selected = get_selection(last_screen);
439 ret_val = do_menu(&root_menu_, &selected); 451 next_screen = do_menu(&root_menu_, &selected);
440 if (ret_val <= GO_TO_ROOT) 452 if (next_screen != GO_TO_PREVIOUS)
441 { 453 last_screen = GO_TO_ROOT;
442 if (ret_val == GO_TO_PREVIOUS)
443 {
444 ret_val = last_screen;
445 last_screen = GO_TO_ROOT;
446 }
447 continue;
448 }
449 last_screen = GO_TO_ROOT;
450 break; 454 break;
451 455
452 case GO_TO_PREVIOUS: 456 case GO_TO_PREVIOUS:
453 ret_val = last_screen; 457 next_screen = last_screen;
454 continue;
455 break; 458 break;
456 459
457 case GO_TO_PREVIOUS_BROWSER: 460 case GO_TO_PREVIOUS_BROWSER:
458 ret_val = previous_browser; 461 next_screen = previous_browser;
459 break; 462 break;
460 463
461 case GO_TO_PREVIOUS_MUSIC: 464 case GO_TO_PREVIOUS_MUSIC:
462 ret_val = previous_music; 465 next_screen = previous_music;
463 break; 466 break;
464 } 467
465 this_screen = ret_val; 468 default:
466 /* set the global_status.last_screen before entering, 469 if (next_screen == GO_TO_FILEBROWSER
467 if we dont we will always return to the wrong screen on boot */
468 global_status.last_screen = (char)this_screen;
469 if (this_screen == GO_TO_FILEBROWSER
470#ifdef HAVE_TAGCACHE 470#ifdef HAVE_TAGCACHE
471 || this_screen == GO_TO_DBBROWSER 471 || next_screen == GO_TO_DBBROWSER
472#endif 472#endif
473 ) 473 )
474 previous_browser = this_screen; 474 previous_browser = next_screen;
475 if (this_screen == GO_TO_WPS 475 if (next_screen == GO_TO_WPS
476#ifdef CONFIG_TUNER 476#ifdef CONFIG_TUNER
477 || this_screen == GO_TO_FM 477 || next_screen == GO_TO_FM
478#endif 478#endif
479 ) 479 )
480 previous_music = this_screen; 480 previous_music = next_screen;
481 status_save(); 481 next_screen = load_screen(next_screen);
482 action_signalscreenchange(); 482 break;
483 ret_val = items[this_screen].function(items[this_screen].param); 483 } /* switch() */
484 if (ret_val != GO_TO_PREVIOUS)
485 last_screen = this_screen;
486 } 484 }
487 return; 485 return;
488} 486}