mirror of
https://github.com/Raymo111/i3lock-color.git
synced 2025-02-24 16:06:26 -05:00
fix that annoying refresh bug
This commit is contained in:
parent
d623b5b904
commit
e69147d860
4 changed files with 23 additions and 22 deletions
|
@ -103,6 +103,7 @@ AM_PROG_AR
|
||||||
AX_FLAGS_WARN_ALL
|
AX_FLAGS_WARN_ALL
|
||||||
AX_APPEND_FLAG([-O2], [AM_CFLAGS])
|
AX_APPEND_FLAG([-O2], [AM_CFLAGS])
|
||||||
AX_APPEND_FLAG([-funroll-loops], [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])])
|
AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
|
||||||
AC_SUBST(AM_CFLAGS)
|
AC_SUBST(AM_CFLAGS)
|
||||||
|
|
||||||
|
|
17
i3lock.c
17
i3lock.c
|
@ -8,6 +8,9 @@
|
||||||
*/
|
*/
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -481,7 +484,6 @@ static void input_done(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (debug_mode)
|
if (debug_mode)
|
||||||
fprintf(stderr, "Authentication failure\n");
|
fprintf(stderr, "Authentication failure\n");
|
||||||
|
|
||||||
|
@ -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");
|
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);
|
int tmp = atoi(optarg);
|
||||||
if (tmp > 0)
|
if (tmp > 0)
|
||||||
bar_periodic_step = tmp;
|
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
|
* received up until now. ev will only pick up new events (when the X11
|
||||||
* file descriptor becomes readable). */
|
* file descriptor becomes readable). */
|
||||||
ev_invoke(main_loop, xcb_check, 0);
|
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) {
|
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);
|
ev_loop(main_loop, 0);
|
||||||
|
|
||||||
|
|
|
@ -133,9 +133,6 @@ extern xcb_screen_t *screen;
|
||||||
* Local variables.
|
* Local variables.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* time stuff */
|
|
||||||
static struct ev_periodic *time_redraw_tick;
|
|
||||||
|
|
||||||
/* Cache the screen’s visual, necessary for creating a Cairo context. */
|
/* Cache the screen’s visual, necessary for creating a Cairo context. */
|
||||||
static xcb_visualtype_t *vistype;
|
static xcb_visualtype_t *vistype;
|
||||||
|
|
||||||
|
@ -940,19 +937,11 @@ void clear_indicator(void) {
|
||||||
redraw_screen();
|
redraw_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void time_redraw_cb(struct ev_loop *loop, ev_periodic *w, int revents) {
|
void* start_time_redraw_tick(void* arg) {
|
||||||
|
struct timespec *ts = (struct timespec *) arg;
|
||||||
|
while(1) {
|
||||||
|
nanosleep(ts, NULL);
|
||||||
redraw_screen();
|
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);
|
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,5 +51,5 @@ void init_colors_once(void);
|
||||||
void redraw_screen(void);
|
void redraw_screen(void);
|
||||||
void clear_indicator(void);
|
void clear_indicator(void);
|
||||||
void start_time_redraw_timeout(void);
|
void start_time_redraw_timeout(void);
|
||||||
void start_time_redraw_tick(struct ev_loop*);
|
void* start_time_redraw_tick(void* arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue