Timer: rename timeout -> timer

This commit is contained in:
o9000 2017-12-29 13:10:47 +01:00
parent c064ec70ed
commit e5380f8e29
10 changed files with 67 additions and 74 deletions

View file

@ -41,7 +41,7 @@ struct BatteryState battery_state;
gboolean battery_enabled;
gboolean battery_tooltip_enabled;
int percentage_hide;
static Timer battery_timeout;
static Timer battery_timer;
#define BATTERY_BUF_SIZE 256
static char buf_bat_line1[BATTERY_BUF_SIZE];
@ -76,7 +76,7 @@ void default_battery()
percentage_hide = 101;
battery_low_cmd_sent = FALSE;
battery_full_cmd_sent = FALSE;
INIT_TIMER(battery_timeout);
INIT_TIMER(battery_timer);
bat1_has_font = FALSE;
bat1_font_desc = NULL;
bat1_format = NULL;
@ -127,7 +127,7 @@ void cleanup_battery()
ac_connected_cmd = NULL;
free(ac_disconnected_cmd);
ac_disconnected_cmd = NULL;
destroy_timer(&battery_timeout);
destroy_timer(&battery_timer);
battery_found = FALSE;
battery_os_free();
@ -225,7 +225,7 @@ void init_battery()
battery_found = battery_os_init();
change_timer(&battery_timeout, true, 10, 30000, update_battery_tick, 0);
change_timer(&battery_timer, true, 10, 30000, update_battery_tick, 0);
update_battery();
}

View file

@ -51,7 +51,7 @@ static char buf_time[256];
static char buf_date[256];
static char buf_tooltip[512];
int clock_enabled;
static Timer clock_timeout;
static Timer clock_timer;
void clock_init_fonts();
char *clock_get_tooltip(void *obj);
@ -65,7 +65,7 @@ void default_clock()
time1_timezone = NULL;
time2_format = NULL;
time2_timezone = NULL;
INIT_TIMER(clock_timeout);
INIT_TIMER(clock_timer);
time_tooltip_format = NULL;
time_tooltip_timezone = NULL;
clock_lclick_command = NULL;
@ -110,7 +110,7 @@ void cleanup_clock()
clock_uwheel_command = NULL;
free(clock_dwheel_command);
clock_dwheel_command = NULL;
destroy_timer(&clock_timeout);
destroy_timer(&clock_timer);
}
struct tm *clock_gettime_for_tz(const char *timezone)
@ -154,7 +154,7 @@ void update_clocks_sec(void *arg)
{
gettimeofday(&time_clock, 0);
update_clocks();
change_timer(&clock_timeout, true, ms_until_second_change(&time_clock), 0, update_clocks_sec, 0);
change_timer(&clock_timer, true, ms_until_second_change(&time_clock), 0, update_clocks_sec, 0);
}
void update_clocks_min(void *arg)
@ -166,7 +166,7 @@ void update_clocks_min(void *arg)
if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60 || (time1_format && !buf_time[0]) || (time2_format && !buf_date[0]))
update_clocks();
old_sec = time_clock.tv_sec;
change_timer(&clock_timeout, true, ms_until_second_change(&time_clock), 0, update_clocks_min, 0);
change_timer(&clock_timer, true, ms_until_second_change(&time_clock), 0, update_clocks_min, 0);
}
gboolean time_format_needs_sec_ticks(char *time_format)
@ -215,7 +215,7 @@ void init_clock_panel(void *p)
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
}
if (!clock_timeout.enabled_) {
if (!clock_timer.enabled_) {
if (time_format_needs_sec_ticks(time1_format) || time_format_needs_sec_ticks(time2_format)) {
update_clocks_sec(NULL);
} else {

View file

@ -145,7 +145,7 @@ void cleanup_panel()
if (p->main_win)
XDestroyWindow(server.display, p->main_win);
p->main_win = 0;
destroy_timer(&p->autohide_timeout);
destroy_timer(&p->autohide_timer);
cleanup_freespace(p);
}
@ -207,7 +207,7 @@ void init_panel()
panels = calloc(num_panels, sizeof(Panel));
for (int i = 0; i < num_panels; i++) {
memcpy(&panels[i], &panel_config, sizeof(Panel));
INIT_TIMER(panels[i].autohide_timeout);
INIT_TIMER(panels[i].autohide_timer);
}
fprintf(stderr,
@ -1061,15 +1061,15 @@ Button *click_button(Panel *panel, int x, int y)
return NULL;
}
void stop_autohide_timeout(Panel *p)
void stop_autohide_timer(Panel *p)
{
stop_timer(&p->autohide_timeout);
stop_timer(&p->autohide_timer);
}
void autohide_show(void *p)
{
Panel *panel = (Panel *)p;
stop_autohide_timeout(panel);
stop_autohide_timer(panel);
panel->is_hidden = 0;
XMapSubwindows(server.display, panel->main_win); // systray windows
set_panel_window_geometry(panel);
@ -1081,7 +1081,7 @@ void autohide_show(void *p)
void autohide_hide(void *p)
{
Panel *panel = (Panel *)p;
stop_autohide_timeout(panel);
stop_autohide_timer(panel);
set_panel_layer(panel, panel_layer);
panel->is_hidden = TRUE;
XUnmapSubwindows(server.display, panel->main_win); // systray windows
@ -1093,7 +1093,7 @@ void autohide_trigger_show(Panel *p)
{
if (!p)
return;
change_timer(&p->autohide_timeout, true, panel_autohide_show_timeout, 0, autohide_show, p);
change_timer(&p->autohide_timer, true, panel_autohide_show_timeout, 0, autohide_show, p);
}
void autohide_trigger_hide(Panel *p)
@ -1108,7 +1108,7 @@ void autohide_trigger_hide(Panel *p)
if (child)
return; // mouse over one of the system tray icons
change_timer(&p->autohide_timeout, true, panel_autohide_hide_timeout, 0, autohide_hide, p);
change_timer(&p->autohide_timer, true, panel_autohide_hide_timeout, 0, autohide_hide, p);
}
void shrink_panel(Panel *panel)

View file

@ -144,7 +144,7 @@ typedef struct Panel {
gboolean is_hidden;
int hidden_width, hidden_height;
Pixmap hidden_pixmap;
Timer autohide_timeout;
Timer autohide_timer;
} Panel;
extern Panel panel_config;

View file

@ -730,8 +730,8 @@ gboolean add_icon(Window win)
traywin->pid = pid;
traywin->name = name;
traywin->chrono = chrono;
INIT_TIMER(traywin->render_timeout);
INIT_TIMER(traywin->resize_timeout);
INIT_TIMER(traywin->render_timer);
INIT_TIMER(traywin->resize_timer);
chrono++;
show(&systray.area);
@ -942,8 +942,8 @@ void remove_icon(TrayWindow *traywin)
XDestroyWindow(server.display, traywin->parent);
XSync(server.display, False);
XSetErrorHandler(old);
destroy_timer(&traywin->render_timeout);
destroy_timer(&traywin->resize_timeout);
destroy_timer(&traywin->render_timer);
destroy_timer(&traywin->resize_timer);
free(traywin->name);
if (traywin->image) {
imlib_context_set_image(traywin->image);
@ -1057,8 +1057,8 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e)
if (traywin->bad_size_counter < min_bad_resize_events) {
systray_resize_icon(traywin);
} else {
if (!traywin->resize_timeout.enabled_)
change_timer(&traywin->resize_timeout, true, fast_resize_period, 0, systray_resize_icon, traywin);
if (!traywin->resize_timer.enabled_)
change_timer(&traywin->resize_timer, true, fast_resize_period, 0, systray_resize_icon, traywin);
}
} else {
if (traywin->bad_size_counter == max_bad_resize_events) {
@ -1072,13 +1072,13 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e)
// FIXME Normally we should force the icon to resize fill_color to the size we resized it to when we
// embedded it.
// However this triggers a resize loop in new versions of GTK, which we must avoid.
if (!traywin->resize_timeout.enabled_)
change_timer(&traywin->resize_timeout, true, slow_resize_period, 0, systray_resize_icon, traywin);
if (!traywin->resize_timer.enabled_)
change_timer(&traywin->resize_timer, true, slow_resize_period, 0, systray_resize_icon, traywin);
return;
}
} else {
// Correct size
stop_timer(&traywin->resize_timeout);
stop_timer(&traywin->resize_timer);
}
// Resize and redraw the systray
@ -1135,8 +1135,8 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e)
if (traywin->bad_size_counter < min_bad_resize_events) {
systray_resize_icon(traywin);
} else {
if (!traywin->resize_timeout.enabled_)
change_timer(&traywin->resize_timeout, true, fast_resize_period, 0, systray_resize_icon, traywin);
if (!traywin->resize_timer.enabled_)
change_timer(&traywin->resize_timer, true, fast_resize_period, 0, systray_resize_icon, traywin);
}
} else {
if (traywin->bad_size_counter == max_bad_resize_events) {
@ -1149,13 +1149,13 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e)
// Delayed resize
// FIXME Normally we should force the icon to resize to the size we resized it to when we embedded it.
// However this triggers a resize loop in some versions of GTK, which we must avoid.
if (!traywin->resize_timeout.enabled_)
change_timer(&traywin->resize_timeout, true, slow_resize_period, 0, systray_resize_icon, traywin);
if (!traywin->resize_timer.enabled_)
change_timer(&traywin->resize_timer, true, slow_resize_period, 0, systray_resize_icon, traywin);
return;
}
} else {
// Correct size
stop_timer(&traywin->resize_timeout);
stop_timer(&traywin->resize_timer);
}
// Resize and redraw the systray
@ -1222,7 +1222,7 @@ void systray_render_icon_composited(void *t)
if (compare_timespecs(&earliest_render, &now) > 0) {
traywin->num_fast_renders++;
if (traywin->num_fast_renders > max_fast_refreshes) {
change_timer(&traywin->render_timeout, true, min_refresh_period, 0, systray_render_icon_composited, traywin);
change_timer(&traywin->render_timer, true, min_refresh_period, 0, systray_render_icon_composited, traywin);
if (systray_profile)
fprintf(stderr,
YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n",
@ -1241,7 +1241,7 @@ void systray_render_icon_composited(void *t)
if (traywin->width == 0 || traywin->height == 0) {
// reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu)
change_timer(&traywin->render_timeout, true, min_refresh_period, 0, systray_render_icon_composited, traywin);
change_timer(&traywin->render_timer, true, min_refresh_period, 0, systray_render_icon_composited, traywin);
if (systray_profile)
fprintf(stderr,
YELLOW "[%f] %s:%d win = %lu (%s) delaying rendering" RESET "\n",
@ -1253,9 +1253,7 @@ void systray_render_icon_composited(void *t)
return;
}
if (traywin->render_timeout.enabled_) {
stop_timer(&traywin->render_timeout);
}
stop_timer(&traywin->render_timer);
// good systray icons support 32 bit depth, but some icons are still 24 bit.
// We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and
@ -1418,8 +1416,7 @@ void systray_render_icon(void *t)
// __LINE__,
// traywin->win,
// traywin->name);
stop_timer(&traywin->render_timeout);
change_timer(&traywin->render_timeout, true, min_refresh_period, 0, systray_render_icon, traywin);
change_timer(&traywin->render_timer, true, min_refresh_period, 0, systray_render_icon, traywin);
return;
}
@ -1442,17 +1439,13 @@ void systray_render_icon(void *t)
unsigned int width, height, depth;
Window root;
if (!XGetGeometry(server.display, traywin->win, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) {
stop_timer(&traywin->render_timeout);
if (!traywin->render_timeout.enabled_)
change_timer(&traywin->render_timeout, true, min_refresh_period, 0, systray_render_icon, traywin);
change_timer(&traywin->render_timer, true, min_refresh_period, 0, systray_render_icon, traywin);
systray_render_icon_from_image(traywin);
XSetErrorHandler(old);
return;
} else {
if (xpos != 0 || ypos != 0 || width != traywin->width || height != traywin->height) {
stop_timer(&traywin->render_timeout);
if (!traywin->render_timeout.enabled_)
change_timer(&traywin->render_timeout, true, min_refresh_period, 0, systray_render_icon, traywin);
change_timer(&traywin->render_timer, true, min_refresh_period, 0, systray_render_icon, traywin);
systray_render_icon_from_image(traywin);
if (systray_profile)
fprintf(stderr,

View file

@ -56,11 +56,11 @@ typedef struct {
// Members used for rendering
struct timespec time_last_render;
int num_fast_renders;
Timer render_timeout;
Timer render_timer;
// Members used for resizing
int bad_size_counter;
struct timespec time_last_resize;
Timer resize_timeout;
Timer resize_timer;
// Icon contents if we are compositing the icon, otherwise null
Imlib_Image image;
// XDamage

View file

@ -31,9 +31,9 @@ static int x, y, width, height;
static gboolean just_shown;
// the next functions are helper functions for tooltip handling
void start_show_timeout();
void start_hide_timeout();
void stop_tooltip_timeout();
void start_show_timer();
void start_hide_timer();
void stop_tooltip_timer();
void tooltip_init_fonts();
@ -44,8 +44,8 @@ void default_tooltip()
// give the tooltip some reasonable default values
memset(&g_tooltip, 0, sizeof(Tooltip));
INIT_TIMER(g_tooltip.timeout);
INIT_TIMER(g_tooltip.update_timeout);
INIT_TIMER(g_tooltip.visibility_timer);
INIT_TIMER(g_tooltip.update_timer);
g_tooltip.font_color.rgb[0] = 1;
g_tooltip.font_color.rgb[1] = 1;
@ -56,9 +56,9 @@ void default_tooltip()
void cleanup_tooltip()
{
stop_tooltip_timeout();
destroy_timer(&g_tooltip.timeout);
destroy_timer(&g_tooltip.update_timeout);
stop_tooltip_timer();
destroy_timer(&g_tooltip.visibility_timer);
destroy_timer(&g_tooltip.update_timer);
tooltip_hide(NULL);
tooltip_update_contents_for(NULL);
if (g_tooltip.window)
@ -125,9 +125,9 @@ void tooltip_trigger_show(Area *area, Panel *p, XEvent *e)
if (g_tooltip.mapped && g_tooltip.area != area) {
tooltip_update_contents_for(area);
tooltip_update();
stop_tooltip_timeout();
stop_tooltip_timer();
} else if (!g_tooltip.mapped) {
start_show_timeout();
start_show_timer();
}
}
@ -310,10 +310,10 @@ void tooltip_trigger_hide()
{
if (g_tooltip.mapped) {
tooltip_update_contents_for(NULL);
start_hide_timeout();
start_hide_timer();
} else {
// tooltip not visible yet, but maybe a timeout is still pending
stop_tooltip_timeout();
// tooltip not visible yet, but maybe a timer is still pending
stop_tooltip_timer();
}
}
@ -327,19 +327,19 @@ void tooltip_hide(void *arg)
g_tooltip.area = NULL;
}
void start_show_timeout()
void start_show_timer()
{
change_timer(&g_tooltip.timeout, true, g_tooltip.show_timeout_msec, 0, tooltip_show, 0);
change_timer(&g_tooltip.visibility_timer, true, g_tooltip.show_timeout_msec, 0, tooltip_show, 0);
}
void start_hide_timeout()
void start_hide_timer()
{
change_timer(&g_tooltip.timeout, true, g_tooltip.hide_timeout_msec, 0, tooltip_hide, 0);
change_timer(&g_tooltip.visibility_timer, true, g_tooltip.hide_timeout_msec, 0, tooltip_hide, 0);
}
void stop_tooltip_timeout()
void stop_tooltip_timer()
{
stop_timer(&g_tooltip.timeout);
stop_timer(&g_tooltip.visibility_timer);
}
void tooltip_update_contents_timeout(void *arg)
@ -360,7 +360,7 @@ void tooltip_update_contents_for(Area *area)
if (g_tooltip.image)
cairo_surface_reference(g_tooltip.image);
else
change_timer(&g_tooltip.update_timeout, true, 300, 0, tooltip_update_contents_timeout, NULL);
change_timer(&g_tooltip.update_timer, true, 300, 0, tooltip_update_contents_timeout, NULL);
}
g_tooltip.area = area;
}

View file

@ -36,8 +36,8 @@ typedef struct {
PangoFontDescription *font_desc;
Color font_color;
Background *bg;
Timer timeout;
Timer update_timeout;
Timer visibility_timer;
Timer update_timer;
cairo_surface_t *image;
} Tooltip;

View file

@ -1239,7 +1239,7 @@ TEST(change_timer_simple_other_inside_callback)
ASSERT_EQUAL(triggered_other, 0);
}
TEST(add_change_two_timeout_simple_inside_callback)
TEST(add_change_two_timer_simple_inside_callback)
{
u_int64_t origin = MOCK_ORIGIN;
TimeoutContainer container;
@ -1460,7 +1460,7 @@ TEST(change_timer_multi_other_inside_callback)
ASSERT_EQUAL(triggered_other, 0);
}
TEST(add_change_two_timeout_multi_inside_callback)
TEST(add_change_two_timer_multi_inside_callback)
{
u_int64_t origin = MOCK_ORIGIN;
TimeoutContainer container;
@ -1651,7 +1651,7 @@ TEST(get_duration_to_next_timer_expiration_simple_multi)
ASSERT_EQUAL(timeval_to_ms(get_duration_to_next_timer_expiration()), 40);
}
TEST(cleanup_timeout_simple)
TEST(cleanup_timers_simple)
{
u_int64_t origin = MOCK_ORIGIN;
int triggered = 0;

View file

@ -62,7 +62,7 @@ void stop_timer(Timer *timer);
// Do not free the pointer; it is harmless to change its contents.
struct timeval *get_duration_to_next_timer_expiration();
// Callback of all expired timeouts
// Trigger all expired timers, and reschedule them if they are periodic timers
void handle_expired_timers();
// Time helper functions.