panel: Allow widgets to request faster update rate for animations
This commit is contained in:
parent
a5cb666d6a
commit
ace54766fe
16
apps/panel.c
16
apps/panel.c
@ -693,7 +693,7 @@ static int widget_draw_generic(struct PanelWidget * this, gfx_context_t * ctx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int widget_update_generic(struct PanelWidget * this) {
|
||||
static int widget_update_generic(struct PanelWidget * this, int * force_updates) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -741,11 +741,12 @@ static void widgets_layout(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void update_periodic_widgets(void) {
|
||||
static void update_periodic_widgets(int * force_updates) {
|
||||
*force_updates = 0;
|
||||
int needs_layout = 0;
|
||||
foreach(widget_node, widgets_enabled) {
|
||||
struct PanelWidget * widget = widget_node->value;
|
||||
needs_layout |= widget->update(widget);
|
||||
needs_layout |= widget->update(widget, force_updates);
|
||||
}
|
||||
if (needs_layout) widgets_layout();
|
||||
redraw();
|
||||
@ -871,7 +872,8 @@ int main (int argc, char ** argv) {
|
||||
}
|
||||
|
||||
/* Lay out the widgets */
|
||||
update_periodic_widgets();
|
||||
int force_updates = 0;
|
||||
update_periodic_widgets(&force_updates);
|
||||
widgets_layout();
|
||||
|
||||
/* Subscribe to window updates */
|
||||
@ -891,7 +893,7 @@ int main (int argc, char ** argv) {
|
||||
|
||||
while (_continue) {
|
||||
|
||||
int index = fswait2(1,fds,200);
|
||||
int index = fswait2(1,fds,force_updates ? 50 : 200); /* ~20 fps? */
|
||||
|
||||
if (index == 0) {
|
||||
/* Respond to Yutani events */
|
||||
@ -941,13 +943,13 @@ int main (int argc, char ** argv) {
|
||||
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
if (now.tv_sec != last_tick) {
|
||||
if (now.tv_sec != last_tick || force_updates) {
|
||||
last_tick = now.tv_sec;
|
||||
waitpid(-1, NULL, WNOHANG);
|
||||
update_periodic_widgets();
|
||||
if (was_tabbing) {
|
||||
redraw_alttab();
|
||||
}
|
||||
update_periodic_widgets(&force_updates);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ struct PanelWidget {
|
||||
int (*enter)(struct PanelWidget *, struct yutani_msg_window_mouse_event *);
|
||||
int (*move)(struct PanelWidget *, struct yutani_msg_window_mouse_event *);
|
||||
int (*draw)(struct PanelWidget *, gfx_context_t * ctx);
|
||||
int (*update)(struct PanelWidget *);
|
||||
int (*update)(struct PanelWidget *, int *force_updates);
|
||||
int (*onkey)(struct PanelWidget *, struct yutani_msg_key_event *);
|
||||
};
|
||||
|
||||
|
@ -81,9 +81,10 @@ static int widget_click_clock(struct PanelWidget * this, struct yutani_msg_windo
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int widget_update_clock(struct PanelWidget * this) {
|
||||
static int widget_update_clock(struct PanelWidget * this, int * force_updates) {
|
||||
if (clockmenu && clockmenu->window) {
|
||||
menu_force_redraw(clockmenu);
|
||||
*force_updates = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ static int widget_click_date(struct PanelWidget * this, struct yutani_msg_window
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int widget_update_date(struct PanelWidget * this) {
|
||||
static int widget_update_date(struct PanelWidget * this, int * force_updates) {
|
||||
int width_before = date_widget_width;
|
||||
update_date_widget();
|
||||
this->width = date_widget_width;
|
||||
|
@ -94,7 +94,7 @@ _netif_next:
|
||||
netstat_count++;
|
||||
}
|
||||
|
||||
static int widget_update_network(struct PanelWidget * this) {
|
||||
static int widget_update_network(struct PanelWidget * this, int * force_updates) {
|
||||
network_status = 0;
|
||||
netstat_count = 0;
|
||||
|
||||
|
@ -29,7 +29,7 @@ static hashmap_t * weather_icons = NULL;
|
||||
static sprite_t * weather_icon = NULL;
|
||||
static int widgets_weather_enabled = 0;
|
||||
|
||||
static int widget_update_weather(struct PanelWidget * this) {
|
||||
static int widget_update_weather(struct PanelWidget * this, int * force_updates) {
|
||||
FILE * f = fopen("/tmp/weather-parsed.conf","r");
|
||||
if (!f) {
|
||||
weather_status_valid = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user