summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-08-29 21:15:34 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-08-29 21:15:34 +0100
commitc11ed99cb453af968493018e1b83606423d9b9a0 (patch)
tree937d185d1087e08b3af50d24150cb532c118559a /apps
parent6322e66219baba3fea7f4ec3cc622674f2f340f3 (diff)
bugfix: redraw yes/no screen after a full skin update
This fixes a bug reported on IRC: 1. Set 'bookmark on stop' to 'ask' 2. Play a track from the file browser 3. Stop playback, yes/no screen briefly flashes then disappears. The screen still handles input correctly but the prompt will not be displayed on the LCD. Long story short, get_action() can cause the skin engine to do a full redraw which cleared the screen and erased the prompt. There is a special event, GUI_EVENT_NEED_UI_UPDATE, which the list code uses to avoid precisely this problem. Hooking up a handler for this event and redrawing the yes/no prompt fixes the bug. Change-Id: If3c26655540c13b488b3a11bd46e1d60d4111469
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/yesno.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c
index 4098d630d0..a79b8ae644 100644
--- a/apps/gui/yesno.c
+++ b/apps/gui/yesno.c
@@ -28,6 +28,7 @@
#include "talk.h"
#include "settings.h"
#include "viewport.h"
+#include "appevents.h"
struct gui_yesno
@@ -142,6 +143,16 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
return(true);
}
+static void gui_yesno_ui_update(unsigned short id, void *event_data, void *user_data)
+{
+ (void)id;
+ (void)event_data;
+
+ struct gui_yesno* yn = (struct gui_yesno*)user_data;
+ FOR_NB_SCREENS(i)
+ gui_yesno_draw(&yn[i]);
+}
+
enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
const struct text_message * yes_message,
const struct text_message * no_message)
@@ -166,7 +177,7 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
#ifdef HAVE_TOUCHSCREEN
/* switch to point mode because that's more intuitive */
- enum touchscreen_mode tsm = touchscreen_get_mode();
+ enum touchscreen_mode old_mode = touchscreen_get_mode();
touchscreen_set_mode(TOUCHSCREEN_POINT);
#endif
@@ -174,6 +185,10 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
action_wait_for_release();
button_clear_queue();
+ /* hook into UI update events to avoid the dialog disappearing
+ * in case the skin decides to do a full refresh */
+ add_event_ex(GUI_EVENT_NEED_UI_UPDATE, false, gui_yesno_ui_update, &yn[0]);
+
while (result==-1)
{
/* Repeat the question every 5secs (more or less) */
@@ -218,22 +233,14 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
continue;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED) {
-#ifdef HAVE_TOUCHSCREEN
- /* restore old touchscreen mode */
- touchscreen_set_mode(tsm);
-#endif
- return YESNO_USB;
+ result = YESNO_USB;
+ goto exit;
}
result = YESNO_NO;
}
}
-#ifdef HAVE_TOUCHSCREEN
- /* restore old touchscreen mode */
- touchscreen_set_mode(tsm);
-#endif
-
FOR_NB_SCREENS(i)
result_displayed=gui_yesno_draw_result(&(yn[i]), result);
@@ -252,7 +259,12 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
viewportmanager_theme_undo(i, true);
}
- return(result);
+ exit:
+ remove_event_ex(GUI_EVENT_NEED_UI_UPDATE, gui_yesno_ui_update, &yn[0]);
+#ifdef HAVE_TOUCHSCREEN
+ touchscreen_set_mode(old_mode);
+#endif
+ return result;
}