Index: apps/gui/gwps-common.c
===================================================================
--- apps/gui/gwps-common.c (Revision 20571)
+++ apps/gui/gwps-common.c (Arbeitskopie)
@@ -356,7 +356,7 @@
{
gwps->state->id3 = id3 = audio_current_track();

- if (cuesheet_is_enabled() && id3->cuesheet_type
+ if (cuesheet_is_enabled() && id3 && id3->cuesheet_type
&& strcmp(id3->path, curr_cue->audio_filename))
{
/* the current cuesheet isn't the right one any more */
@@ -375,7 +375,7 @@
}
}

- if (cuesheet_is_enabled() && id3->cuesheet_type
+ if (cuesheet_is_enabled() && id3 && id3->cuesheet_type
&& (id3->elapsed < curr_cue->curr_track->offset
|| (curr_cue->curr_track_idx < curr_cue->track_count - 1
&& id3->elapsed >= (curr_cue->curr_track+1)->offset)))
@@ -1873,6 +1873,15 @@
}
}

+static void reset_sublines(struct wps_data *data)
+{
+ int i;
+ for (i = 0; i <= data->num_lines; i++)
+ {
+ data->lines[i].curr_subline = SUBLINE_RESET;
+ }
+}
+
bool gui_wps_redraw(struct gui_wps *gwps,
int ffwd_offset,
unsigned refresh_mode)
@@ -1913,18 +1922,64 @@

#endif

+#ifdef HAVE_BACKLIGHT
+ if (global_settings.caption_backlight)
+ {
+ /* turn on backlight n seconds before track ends, and turn it off n
+ seconds into the new track. n == backlight_timeout, or 5s */
+ int n = global_settings.backlight_timeout * 1000;
+
+ if ( n < 1000 )
+ n = 5000; /* use 5s if backlight is always on or off */
+
+ if (((id3->elapsed < 1000) ||
+ ((id3->length - id3->elapsed) < (unsigned)n)) &&
+ (state->paused == false))
+ backlight_on();
+ }
+#endif
+#ifdef HAVE_REMOTE_LCD
+ if (global_settings.remote_caption_backlight)
+ {
+ /* turn on remote backlight n seconds before track ends, and turn it
+ off n seconds into the new track. n == remote_backlight_timeout,
+ or 5s */
+ int n = global_settings.remote_backlight_timeout * 1000;
+
+ if ( n < 1000 )
+ n = 5000; /* use 5s if backlight is always on or off */
+
+ if (((id3->elapsed < 1000) ||
+ ((id3->length - id3->elapsed) < (unsigned)n)) &&
+ (state->paused == false))
+ remote_backlight_on();
+ }
+#endif
+
+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+ if (!lcd_active()
+#ifdef HAVE_REMOTE_LCD
+ /* currently, all remotes are readable without backlight */
+ && (display->screen_type == SCREEN_MAIN)
+#endif
+ )
+ {
+ /* lcd inactive, updates won't be visible, so just return */
+ /* reset sublines to avoid fast subline changing when backlight is
+ * on again */
+ reset_sublines(data);
+ return true;
+ }
+#endif
+
/* reset to first subline if refresh all flag is set */
if (refresh_mode == WPS_REFRESH_ALL)
{
display->set_viewport(&data->viewports[0].vp);
display->clear_viewport();
-
- for (i = 0; i <= data->num_lines; i++)
- {
- data->lines[i].curr_subline = SUBLINE_RESET;
- }
+ reset_sublines(data);
}
-
+
#ifdef HAVE_LCD_CHARCELLS
for (i = 0; i < 8; i++)
{
@@ -2085,38 +2140,5 @@

display->update();

-#ifdef HAVE_BACKLIGHT
- if (global_settings.caption_backlight)
- {
- /* turn on backlight n seconds before track ends, and turn it off n
- seconds into the new track. n == backlight_timeout, or 5s */
- int n = global_settings.backlight_timeout * 1000;
-
- if ( n < 1000 )
- n = 5000; /* use 5s if backlight is always on or off */
-
- if (((id3->elapsed < 1000) ||
- ((id3->length - id3->elapsed) < (unsigned)n)) &&
- (state->paused == false))
- backlight_on();
- }
-#endif
-#ifdef HAVE_REMOTE_LCD
- if (global_settings.remote_caption_backlight)
- {
- /* turn on remote backlight n seconds before track ends, and turn it
- off n seconds into the new track. n == remote_backlight_timeout,
- or 5s */
- int n = global_settings.remote_backlight_timeout * 1000;
-
- if ( n < 1000 )
- n = 5000; /* use 5s if backlight is always on or off */
-
- if (((id3->elapsed < 1000) ||
- ((id3->length - id3->elapsed) < (unsigned)n)) &&
- (state->paused == false))
- remote_backlight_on();
- }
-#endif
return true;
}
Index: apps/gui/gwps.c
===================================================================
--- apps/gui/gwps.c (Revision 20571)
+++ apps/gui/gwps.c (Arbeitskopie)
@@ -175,6 +175,13 @@
#endif
}

+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+static void wps_lcd_activation_hook(void)
+{
+ queue_post(&button_queue, SYS_LCD_ACTIVATED, 0);
+}
+#endif
+
static void gwps_fix_statusbars(void)
{
#ifdef HAVE_LCD_BITMAP
@@ -212,6 +219,9 @@
show_remote_main_backdrop();
#endif
viewportmanager_set_statusbar(oldbars);
+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+ lcd_activation_set_hook(NULL);
+#endif
}

void gwps_draw_statusbars(void)
@@ -651,6 +661,7 @@
case ACTION_REDRAW: /* yes are locked, just redraw */
restore = true;
break;
+ case SYS_LCD_ACTIVATED:
case ACTION_NONE: /* Timeout */
update_track = true;
ffwd_rew(button); /* hopefully fix the ffw/rwd bug */
@@ -685,13 +696,16 @@
((restoretimer == RESTORE_WPS_INSTANTLY) ||
TIME_AFTER(current_tick, restoretimer)))
{
- restore = false;
- restoretimer = RESTORE_WPS_INSTANTLY;
FOR_NB_SCREENS(i)
{
screens[i].stop_scroll();
gui_wps_display(&gui_wps[i]);
}
+ restore = false;
+ restoretimer = RESTORE_WPS_INSTANTLY;
+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+ lcd_activation_set_hook(wps_lcd_activation_hook);
+#endif
}

if (exit) {
Index: apps/misc.c
===================================================================
--- apps/misc.c (Revision 20571)
+++ apps/misc.c (Arbeitskopie)
@@ -615,6 +615,8 @@
iap_handlepkt();
return SYS_IAP_HANDLEPKT;
#endif
+ case SYS_LCD_ACTIVATED:
+ return SYS_LCD_ACTIVATED;
}
return 0;
}
Index: firmware/export/kernel.h
===================================================================
--- firmware/export/kernel.h (Revision 20571)
+++ firmware/export/kernel.h (Arbeitskopie)
@@ -82,6 +82,7 @@
#define SYS_CAR_ADAPTER_RESUME MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 0)
#define SYS_IAP_PERIODIC MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 1)
#define SYS_IAP_HANDLEPKT MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 2)
+#define SYS_LCD_ACTIVATED MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 3)

#define IS_SYSEVENT(ev) ((ev & SYS_EVENT) == SYS_EVENT)