diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/list.c | 31 | ||||
-rw-r--r-- | apps/gui/usb_screen.c | 11 |
2 files changed, 23 insertions, 19 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c index 5368636896..256cf45c40 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -60,12 +60,8 @@ static bool list_is_dirty(struct gui_synclist *list) | |||
60 | 60 | ||
61 | static void list_force_reinit(unsigned short id, void *param, void *last_dirty_tick) | 61 | static void list_force_reinit(unsigned short id, void *param, void *last_dirty_tick) |
62 | { | 62 | { |
63 | (void)id; | ||
63 | (void)param; | 64 | (void)param; |
64 | if (id == SYS_EVENT_USB_INSERTED) /* Disable the skin redraw callback -- Data may not be valid after USB unplug*/ | ||
65 | { | ||
66 | current_lists = NULL; | ||
67 | return; | ||
68 | } | ||
69 | *(int *)last_dirty_tick = current_tick; | 65 | *(int *)last_dirty_tick = current_tick; |
70 | } | 66 | } |
71 | 67 | ||
@@ -73,7 +69,6 @@ void list_init(void) | |||
73 | { | 69 | { |
74 | last_dirty_tick = current_tick; | 70 | last_dirty_tick = current_tick; |
75 | add_event_ex(GUI_EVENT_THEME_CHANGED, false, list_force_reinit, &last_dirty_tick); | 71 | add_event_ex(GUI_EVENT_THEME_CHANGED, false, list_force_reinit, &last_dirty_tick); |
76 | add_event_ex(SYS_EVENT_USB_INSERTED, false, list_force_reinit, NULL); | ||
77 | } | 72 | } |
78 | 73 | ||
79 | static void list_init_viewports(struct gui_synclist *list) | 74 | static void list_init_viewports(struct gui_synclist *list) |
@@ -166,7 +161,6 @@ void gui_synclist_init(struct gui_synclist * gui_list, | |||
166 | gui_list->nb_items = 0; | 161 | gui_list->nb_items = 0; |
167 | gui_list->selected_item = 0; | 162 | gui_list->selected_item = 0; |
168 | gui_synclist_init_display_settings(gui_list); | 163 | gui_synclist_init_display_settings(gui_list); |
169 | |||
170 | #ifdef HAVE_TOUCHSCREEN | 164 | #ifdef HAVE_TOUCHSCREEN |
171 | gui_list->y_pos = 0; | 165 | gui_list->y_pos = 0; |
172 | #endif | 166 | #endif |
@@ -592,15 +586,19 @@ bool gui_synclist_keyclick_callback(int action, void* data) | |||
592 | * loop. | 586 | * loop. |
593 | * | 587 | * |
594 | * The GUI_EVENT_NEED_UI_UPDATE event is registered for in list_do_action_timeout() | 588 | * The GUI_EVENT_NEED_UI_UPDATE event is registered for in list_do_action_timeout() |
595 | * and unregistered in gui_synclict_do_button(). This is done because | 589 | * as a oneshot and current_lists updated. later current_lists is set to NULL |
596 | * if something is using the list UI they *must* be calling those | 590 | * in gui_synclist_do_button() effectively disabling the callback. |
591 | * This is done because if something is using the list UI they *must* be calling those | ||
597 | * two functions in the correct order or the list wont work. | 592 | * two functions in the correct order or the list wont work. |
598 | */ | 593 | */ |
599 | static bool ui_update_event_registered = false; | 594 | |
600 | static void _lists_uiviewport_update_callback(unsigned short id, void *data) | 595 | static void _lists_uiviewport_update_callback(unsigned short id, |
596 | void *data, void *userdata) | ||
601 | { | 597 | { |
602 | (void)id; | 598 | (void)id; |
603 | (void)data; | 599 | (void)data; |
600 | (void)userdata; | ||
601 | |||
604 | if (current_lists) | 602 | if (current_lists) |
605 | gui_synclist_draw(current_lists); | 603 | gui_synclist_draw(current_lists); |
606 | } | 604 | } |
@@ -774,13 +772,8 @@ int list_do_action_timeout(struct gui_synclist *lists, int timeout) | |||
774 | /* Returns the lowest of timeout or the delay until a postponed | 772 | /* Returns the lowest of timeout or the delay until a postponed |
775 | scheduled announcement is due (if any). */ | 773 | scheduled announcement is due (if any). */ |
776 | { | 774 | { |
777 | if (lists != current_lists) | 775 | add_event_ex(GUI_EVENT_NEED_UI_UPDATE, true, _lists_uiviewport_update_callback, NULL); |
778 | { | 776 | current_lists = lists; |
779 | if (!ui_update_event_registered) | ||
780 | ui_update_event_registered = | ||
781 | add_event(GUI_EVENT_NEED_UI_UPDATE, _lists_uiviewport_update_callback); | ||
782 | current_lists = lists; | ||
783 | } | ||
784 | if(lists->scheduled_talk_tick) | 777 | if(lists->scheduled_talk_tick) |
785 | { | 778 | { |
786 | long delay = lists->scheduled_talk_tick -current_tick +1; | 779 | long delay = lists->scheduled_talk_tick -current_tick +1; |
@@ -949,7 +942,9 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
949 | old_line_count = simplelist_line_count; | 942 | old_line_count = simplelist_line_count; |
950 | } | 943 | } |
951 | else if(default_event_handler(action) == SYS_USB_CONNECTED) | 944 | else if(default_event_handler(action) == SYS_USB_CONNECTED) |
945 | { | ||
952 | return true; | 946 | return true; |
947 | } | ||
953 | } | 948 | } |
954 | talk_shutup(); | 949 | talk_shutup(); |
955 | 950 | ||
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c index fb59f820b6..8a3510ea15 100644 --- a/apps/gui/usb_screen.c +++ b/apps/gui/usb_screen.c | |||
@@ -243,7 +243,13 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) | |||
243 | 243 | ||
244 | void gui_usb_screen_run(bool early_usb) | 244 | void gui_usb_screen_run(bool early_usb) |
245 | { | 245 | { |
246 | (void) early_usb; | 246 | #ifdef SIMULATOR /* the sim allows toggling USB fast enough to overflow viewportmanagers stack */ |
247 | static bool in_usb_screen = false; | ||
248 | if (in_usb_screen) | ||
249 | return; | ||
250 | in_usb_screen = true; | ||
251 | #endif | ||
252 | |||
247 | struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS]; | 253 | struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS]; |
248 | #if defined HAVE_TOUCHSCREEN | 254 | #if defined HAVE_TOUCHSCREEN |
249 | enum touchscreen_mode old_mode = touchscreen_get_mode(); | 255 | enum touchscreen_mode old_mode = touchscreen_get_mode(); |
@@ -334,4 +340,7 @@ void gui_usb_screen_run(bool early_usb) | |||
334 | } | 340 | } |
335 | 341 | ||
336 | pop_current_activity(); | 342 | pop_current_activity(); |
343 | #ifdef SIMULATOR | ||
344 | in_usb_screen = false; | ||
345 | #endif | ||
337 | } | 346 | } |