diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-08-29 21:15:34 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-08-29 21:15:34 +0100 |
commit | c11ed99cb453af968493018e1b83606423d9b9a0 (patch) | |
tree | 937d185d1087e08b3af50d24150cb532c118559a | |
parent | 6322e66219baba3fea7f4ec3cc622674f2f340f3 (diff) | |
download | rockbox-c11ed99cb453af968493018e1b83606423d9b9a0.tar.gz rockbox-c11ed99cb453af968493018e1b83606423d9b9a0.zip |
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
-rw-r--r-- | apps/gui/yesno.c | 36 |
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 @@ | |||
28 | #include "talk.h" | 28 | #include "talk.h" |
29 | #include "settings.h" | 29 | #include "settings.h" |
30 | #include "viewport.h" | 30 | #include "viewport.h" |
31 | #include "appevents.h" | ||
31 | 32 | ||
32 | 33 | ||
33 | struct gui_yesno | 34 | struct gui_yesno |
@@ -142,6 +143,16 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) | |||
142 | return(true); | 143 | return(true); |
143 | } | 144 | } |
144 | 145 | ||
146 | static void gui_yesno_ui_update(unsigned short id, void *event_data, void *user_data) | ||
147 | { | ||
148 | (void)id; | ||
149 | (void)event_data; | ||
150 | |||
151 | struct gui_yesno* yn = (struct gui_yesno*)user_data; | ||
152 | FOR_NB_SCREENS(i) | ||
153 | gui_yesno_draw(&yn[i]); | ||
154 | } | ||
155 | |||
145 | enum yesno_res gui_syncyesno_run(const struct text_message * main_message, | 156 | enum yesno_res gui_syncyesno_run(const struct text_message * main_message, |
146 | const struct text_message * yes_message, | 157 | const struct text_message * yes_message, |
147 | const struct text_message * no_message) | 158 | const struct text_message * no_message) |
@@ -166,7 +177,7 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, | |||
166 | 177 | ||
167 | #ifdef HAVE_TOUCHSCREEN | 178 | #ifdef HAVE_TOUCHSCREEN |
168 | /* switch to point mode because that's more intuitive */ | 179 | /* switch to point mode because that's more intuitive */ |
169 | enum touchscreen_mode tsm = touchscreen_get_mode(); | 180 | enum touchscreen_mode old_mode = touchscreen_get_mode(); |
170 | touchscreen_set_mode(TOUCHSCREEN_POINT); | 181 | touchscreen_set_mode(TOUCHSCREEN_POINT); |
171 | #endif | 182 | #endif |
172 | 183 | ||
@@ -174,6 +185,10 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, | |||
174 | action_wait_for_release(); | 185 | action_wait_for_release(); |
175 | button_clear_queue(); | 186 | button_clear_queue(); |
176 | 187 | ||
188 | /* hook into UI update events to avoid the dialog disappearing | ||
189 | * in case the skin decides to do a full refresh */ | ||
190 | add_event_ex(GUI_EVENT_NEED_UI_UPDATE, false, gui_yesno_ui_update, &yn[0]); | ||
191 | |||
177 | while (result==-1) | 192 | while (result==-1) |
178 | { | 193 | { |
179 | /* Repeat the question every 5secs (more or less) */ | 194 | /* Repeat the question every 5secs (more or less) */ |
@@ -218,22 +233,14 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, | |||
218 | continue; | 233 | continue; |
219 | default: | 234 | default: |
220 | if(default_event_handler(button) == SYS_USB_CONNECTED) { | 235 | if(default_event_handler(button) == SYS_USB_CONNECTED) { |
221 | #ifdef HAVE_TOUCHSCREEN | 236 | result = YESNO_USB; |
222 | /* restore old touchscreen mode */ | 237 | goto exit; |
223 | touchscreen_set_mode(tsm); | ||
224 | #endif | ||
225 | return YESNO_USB; | ||
226 | } | 238 | } |
227 | 239 | ||
228 | result = YESNO_NO; | 240 | result = YESNO_NO; |
229 | } | 241 | } |
230 | } | 242 | } |
231 | 243 | ||
232 | #ifdef HAVE_TOUCHSCREEN | ||
233 | /* restore old touchscreen mode */ | ||
234 | touchscreen_set_mode(tsm); | ||
235 | #endif | ||
236 | |||
237 | FOR_NB_SCREENS(i) | 244 | FOR_NB_SCREENS(i) |
238 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); | 245 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); |
239 | 246 | ||
@@ -252,7 +259,12 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, | |||
252 | viewportmanager_theme_undo(i, true); | 259 | viewportmanager_theme_undo(i, true); |
253 | } | 260 | } |
254 | 261 | ||
255 | return(result); | 262 | exit: |
263 | remove_event_ex(GUI_EVENT_NEED_UI_UPDATE, gui_yesno_ui_update, &yn[0]); | ||
264 | #ifdef HAVE_TOUCHSCREEN | ||
265 | touchscreen_set_mode(old_mode); | ||
266 | #endif | ||
267 | return result; | ||
256 | } | 268 | } |
257 | 269 | ||
258 | 270 | ||