mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Adjust LED update interval according to need
Add new routine compute_redraw_interval, which returns the appropriate interval in milliseconds for updating the LED panel, namely 100ms if there are any downloads, 1000 if the clock is enabled (with a TODO noted to check whether the date format includes seconds), or 0 otherwise to indicate that the LED paanel need not be updated Use the new compute_redraw_interval routine in draw_leds and redraw_leds. This fixes bug 973, "LED indicators wake system up every 100ms".
This commit is contained in:
parent
bbee237ff0
commit
3433c9d0f6
@ -31,8 +31,6 @@
|
|||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
#include "viewer/timer.h"
|
#include "viewer/timer.h"
|
||||||
|
|
||||||
#define LEDS_REFRESH_DELAY ((milliseconds_T) 100)
|
|
||||||
|
|
||||||
/* Current leds allocation:
|
/* Current leds allocation:
|
||||||
* 0 - SSL connection indicator
|
* 0 - SSL connection indicator
|
||||||
* 1 - Insert-mode indicator
|
* 1 - Insert-mode indicator
|
||||||
@ -187,6 +185,21 @@ draw_clock(struct terminal *term, int xpos, int ypos, struct color_pair *color)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static milliseconds_T
|
||||||
|
compute_redraw_interval(void)
|
||||||
|
{
|
||||||
|
if (are_there_downloads())
|
||||||
|
return 100;
|
||||||
|
|
||||||
|
/* TODO: Check whether the time format includes seconds. If not,
|
||||||
|
* return milliseconds to next minute. */
|
||||||
|
|
||||||
|
if (get_leds_clock_enable())
|
||||||
|
return 1000;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
draw_leds(struct session *ses)
|
draw_leds(struct session *ses)
|
||||||
{
|
{
|
||||||
@ -238,8 +251,12 @@ draw_leds(struct session *ses)
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
/* Redraw each 100ms. */
|
/* Redraw each 100ms. */
|
||||||
if (!drawing && redraw_timer == TIMER_ID_UNDEF)
|
if (!drawing && redraw_timer == TIMER_ID_UNDEF) {
|
||||||
install_timer(&redraw_timer, LEDS_REFRESH_DELAY, redraw_leds, NULL);
|
milliseconds_T delay = compute_redraw_interval();
|
||||||
|
|
||||||
|
if (delay)
|
||||||
|
install_timer(&redraw_timer, delay, redraw_leds, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine if leds redrawing is necessary. Returns non-zero if so. */
|
/* Determine if leds redrawing is necessary. Returns non-zero if so. */
|
||||||
@ -302,15 +319,18 @@ static void
|
|||||||
redraw_leds(void *xxx)
|
redraw_leds(void *xxx)
|
||||||
{
|
{
|
||||||
struct terminal *term;
|
struct terminal *term;
|
||||||
|
milliseconds_T delay;
|
||||||
|
|
||||||
|
redraw_timer = TIMER_ID_UNDEF;
|
||||||
|
|
||||||
if (!get_leds_panel_enable()
|
if (!get_leds_panel_enable()
|
||||||
&& get_opt_int("ui.timer.enable", NULL) != 2) {
|
&& get_opt_int("ui.timer.enable", NULL) != 2) {
|
||||||
redraw_timer = TIMER_ID_UNDEF;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
install_timer(&redraw_timer, LEDS_REFRESH_DELAY, redraw_leds, NULL);
|
delay = compute_redraw_interval();
|
||||||
/* The expired timer ID has now been erased. */
|
if (delay)
|
||||||
|
install_timer(&redraw_timer, delay, redraw_leds, NULL);
|
||||||
|
|
||||||
if (drawing) return;
|
if (drawing) return;
|
||||||
drawing = 1;
|
drawing = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user