all repos — tint2 @ 4b9ee685acd89b1c7e01d28cb15284d1f193d687

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Update timers correctly after suspend
o9000 mrovi9000@gmail.com
commit

4b9ee685acd89b1c7e01d28cb15284d1f193d687

parent

cfc43685a4a0511098dca132d42b44d099bd50c8

1 files changed, 17 insertions(+), 7 deletions(-)

jump to
M src/util/timer.csrc/util/timer.c

@@ -82,6 +82,16 @@ multi_timeouts = NULL;

} } +int gettime(struct timespec *tp) +{ + // CLOCK_BOOTTIME under Linux is the same as CLOCK_MONOTONIC under *BSD. +#ifdef CLOCK_BOOTTIME + return clock_gettime(CLOCK_BOOTTIME, tp); +#else + return clock_gettime(CLOCK_MONOTONIC, tp); +#endif +} + // Implementation notes for timeouts // // The timeouts are kept in a GSList sorted by their expiration time.

@@ -124,7 +134,7 @@ if (timeout_list) {

timeout *t = timeout_list->data; struct timespec cur_time; struct timespec next_timeout2 = {.tv_sec = next_timeout.tv_sec, .tv_nsec = next_timeout.tv_usec * 1000}; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); if (timespec_subtract(&next_timeout2, &t->timeout_expires, &cur_time)) { next_timeout.tv_sec = 0; next_timeout.tv_usec = 0;

@@ -141,7 +151,7 @@ {

struct timespec cur_time; timeout *t; while (timeout_list) { - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); t = timeout_list->data; if (compare_timespecs(&t->timeout_expires, &cur_time) <= 0) { // it's time for the callback function

@@ -187,7 +197,7 @@ t->interval_msec = interval_msec;

t->_callback = _callback; t->arg = arg; struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); t->timeout_expires = add_msec_to_timespec(cur_time, value_msec); int can_align = 0;

@@ -343,7 +353,7 @@ int interval = calc_multi_timeout_interval(mth);

int next_timeout_msec = interval; struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); GSList *it = mth->timeout_list; struct timespec diff_time;

@@ -368,7 +378,7 @@ void callback_multi_timeout(void *arg)

{ multi_timeout_handler *mth = arg; struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); GSList *it = mth->timeout_list; while (it) { timeout *t = it->data;

@@ -407,7 +417,7 @@ stop_timeout(mth->parent_timeout);

free(mth); struct timespec cur_time, diff_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); timespec_subtract(&diff_time, &t->timeout_expires, &cur_time); int msec_to_expiration = diff_time.tv_sec * 1000 + diff_time.tv_nsec / 1000000; add_timeout_intern(msec_to_expiration,

@@ -438,7 +448,7 @@

double get_time() { struct timespec cur_time; - clock_gettime(CLOCK_MONOTONIC, &cur_time); + gettime(&cur_time); return cur_time.tv_sec + cur_time.tv_nsec * 1.0e-9; }