diff --git a/configure.ac b/configure.ac index bef332d..63a7617 100644 --- a/configure.ac +++ b/configure.ac @@ -103,6 +103,7 @@ AM_PROG_AR AX_FLAGS_WARN_ALL AX_APPEND_FLAG([-O2], [AM_CFLAGS]) AX_APPEND_FLAG([-funroll-loops], [AM_CFLAGS]) +AX_APPEND_FLAG([-pthread], [AM_CFLAGS]) AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])]) AC_SUBST(AM_CFLAGS) diff --git a/i3lock.c b/i3lock.c index 7ae20aa..925d2ac 100644 --- a/i3lock.c +++ b/i3lock.c @@ -8,6 +8,9 @@ */ #include +#include +#include + #include #include #include @@ -481,10 +484,9 @@ static void input_done(void) { return; } #endif - if (debug_mode) fprintf(stderr, "Authentication failure\n"); - + /* Get state of Caps and Num lock modifiers, to be displayed in * STATE_AUTH_WRONG state */ xkb_mod_index_t idx, num_mods; @@ -1560,7 +1562,7 @@ int main(int argc, char *argv[]) { errx(1, "bar-color is invalid, color must be given in 4-byte format: rrggbbaa\n"); } - else if (strcmp(longopts[longoptind].name, "bar-perioidic-step") == 0) { + else if (strcmp(longopts[longoptind].name, "bar-periodic-step") == 0) { int tmp = atoi(optarg); if (tmp > 0) bar_periodic_step = tmp; @@ -1811,8 +1813,17 @@ int main(int argc, char *argv[]) { * received up until now. ev will only pick up new events (when the X11 * file descriptor becomes readable). */ ev_invoke(main_loop, xcb_check, 0); + +// boy i sure hope this doesnt change in the future +#define NANOSECONDS_IN_SECOND 1000000000 if (show_clock || bar_enabled) { - start_time_redraw_tick(main_loop); + pthread_t draw_thread; + struct timespec ts; + double s; + double ns = modf(refresh_rate, &s); + ts.tv_sec = (time_t) s; + ts.tv_nsec = ns * NANOSECONDS_IN_SECOND; + (void) pthread_create(&draw_thread, NULL, start_time_redraw_tick, (void*) &ts); } ev_loop(main_loop, 0); diff --git a/unlock_indicator.c b/unlock_indicator.c index 5c3e20a..17690a1 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -133,9 +133,6 @@ extern xcb_screen_t *screen; * Local variables. ******************************************************************************/ -/* time stuff */ -static struct ev_periodic *time_redraw_tick; - /* Cache the screen’s visual, necessary for creating a Cairo context. */ static xcb_visualtype_t *vistype; @@ -940,19 +937,11 @@ void clear_indicator(void) { redraw_screen(); } -static void time_redraw_cb(struct ev_loop *loop, ev_periodic *w, int revents) { - redraw_screen(); -} - -void start_time_redraw_tick(struct ev_loop* main_loop) { - if (time_redraw_tick) { - ev_periodic_set(time_redraw_tick, 0., refresh_rate, 0); - ev_periodic_again(main_loop, time_redraw_tick); - } else { - if (!(time_redraw_tick = calloc(sizeof(struct ev_periodic), 1))) { - return; - } - ev_periodic_init(time_redraw_tick, time_redraw_cb, 0., refresh_rate, 0); - ev_periodic_start(main_loop, time_redraw_tick); +void* start_time_redraw_tick(void* arg) { + struct timespec *ts = (struct timespec *) arg; + while(1) { + nanosleep(ts, NULL); + redraw_screen(); } + return NULL; } diff --git a/unlock_indicator.h b/unlock_indicator.h index b26e4bd..9e12bbc 100644 --- a/unlock_indicator.h +++ b/unlock_indicator.h @@ -51,5 +51,5 @@ void init_colors_once(void); void redraw_screen(void); void clear_indicator(void); void start_time_redraw_timeout(void); -void start_time_redraw_tick(struct ev_loop*); +void* start_time_redraw_tick(void* arg); #endif