|
@ -88,12 +88,12 @@ extern float refresh_rate; |
|
|
extern bool show_clock; |
|
|
extern bool show_clock; |
|
|
extern bool always_show_clock; |
|
|
extern bool always_show_clock; |
|
|
extern bool show_indicator; |
|
|
extern bool show_indicator; |
|
|
extern int verif_align; |
|
|
extern int verif_align; |
|
|
extern int wrong_align; |
|
|
extern int wrong_align; |
|
|
extern int time_align; |
|
|
extern int time_align; |
|
|
extern int date_align; |
|
|
extern int date_align; |
|
|
extern int layout_align; |
|
|
extern int layout_align; |
|
|
extern int modif_align; |
|
|
extern int modif_align; |
|
|
extern char time_format[32]; |
|
|
extern char time_format[32]; |
|
|
extern char date_format[32]; |
|
|
extern char date_format[32]; |
|
|
extern char *fonts[5]; |
|
|
extern char *fonts[5]; |
|
@ -166,7 +166,7 @@ rgba_t bshl16; |
|
|
rgba_t sep16; |
|
|
rgba_t sep16; |
|
|
rgba_t bar16; |
|
|
rgba_t bar16; |
|
|
// just rgb
|
|
|
// just rgb
|
|
|
rgb_t rgb16; |
|
|
rgb_t rgb16; |
|
|
|
|
|
|
|
|
// experimental bar stuff
|
|
|
// experimental bar stuff
|
|
|
|
|
|
|
|
@ -203,20 +203,18 @@ static cairo_font_face_t *font_faces[5] = { |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
static double scaling_factor(void) { |
|
|
static double scaling_factor(void) { |
|
|
const int dpi = (double) screen->height_in_pixels * 25.4 / |
|
|
const int dpi = (double)screen->height_in_pixels * 25.4 / |
|
|
(double) screen->height_in_millimeters; |
|
|
(double)screen->height_in_millimeters; |
|
|
return (dpi / 96.0); |
|
|
return (dpi / 96.0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static cairo_font_face_t *get_font_face(int which) { |
|
|
static cairo_font_face_t *get_font_face(int which) { |
|
|
if (font_faces[which]) { |
|
|
if (font_faces[which]) { |
|
|
return font_faces[which]; |
|
|
return font_faces[which]; |
|
|
} |
|
|
} |
|
|
const unsigned char* face_name = (const unsigned char*) fonts[which]; |
|
|
const unsigned char *face_name = (const unsigned char *)fonts[which]; |
|
|
FcResult result; |
|
|
FcResult result; |
|
|
/*
|
|
|
/*
|
|
|
* Loads the default config. |
|
|
* Loads the default config. |
|
|
* On successive calls, does no work and just returns true. |
|
|
* On successive calls, does no work and just returns true. |
|
|
*/ |
|
|
*/ |
|
@ -271,7 +269,8 @@ static cairo_font_face_t *get_font_face(int which) { |
|
|
* Draws the given text onto the cairo context |
|
|
* Draws the given text onto the cairo context |
|
|
*/ |
|
|
*/ |
|
|
static void draw_text(cairo_t *ctx, text_t text) { |
|
|
static void draw_text(cairo_t *ctx, text_t text) { |
|
|
if (!text.show) return; |
|
|
if (!text.show) |
|
|
|
|
|
return; |
|
|
cairo_text_extents_t extents; |
|
|
cairo_text_extents_t extents; |
|
|
|
|
|
|
|
|
cairo_set_font_face(ctx, text.font); |
|
|
cairo_set_font_face(ctx, text.font); |
|
@ -281,12 +280,12 @@ static void draw_text(cairo_t *ctx, text_t text) { |
|
|
|
|
|
|
|
|
double x; |
|
|
double x; |
|
|
|
|
|
|
|
|
switch(text.align) { |
|
|
switch (text.align) { |
|
|
case 1: |
|
|
case 1: |
|
|
x = text.x; |
|
|
x = text.x; |
|
|
break; |
|
|
break; |
|
|
case 2: |
|
|
case 2: |
|
|
x= text.x - (extents.width + extents.x_bearing); |
|
|
x = text.x - (extents.width + extents.x_bearing); |
|
|
break; |
|
|
break; |
|
|
case 0: |
|
|
case 0: |
|
|
default: |
|
|
default: |
|
@ -307,7 +306,7 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
// ideally it'd intelligently span both monitors
|
|
|
// ideally it'd intelligently span both monitors
|
|
|
double width, height; |
|
|
double width, height; |
|
|
double back_x = 0, back_y = 0, back_x2 = 0, back_y2 = 0, back_width = 0, back_height = 0; |
|
|
double back_x = 0, back_y = 0, back_x2 = 0, back_y2 = 0, back_width = 0, back_height = 0; |
|
|
for(int i = 0; i < num_bars; ++i) { |
|
|
for (int i = 0; i < num_bars; ++i) { |
|
|
double cur_bar_height = bar_heights[i]; |
|
|
double cur_bar_height = bar_heights[i]; |
|
|
|
|
|
|
|
|
if (cur_bar_height > 0) { |
|
|
if (cur_bar_height > 0) { |
|
@ -339,8 +338,7 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
y = i * bar_width; |
|
|
y = i * bar_width; |
|
|
if (bar_reversed) { |
|
|
if (bar_reversed) { |
|
|
x -= width; |
|
|
x -= width; |
|
|
} |
|
|
} else if (bar_bidirectional) { |
|
|
else if (bar_bidirectional) { |
|
|
|
|
|
width = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height * 2); |
|
|
width = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height * 2); |
|
|
x = bar_offset - (width / 2) + (bar_base_height / 2); |
|
|
x = bar_offset - (width / 2) + (bar_base_height / 2); |
|
|
} |
|
|
} |
|
@ -351,8 +349,7 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
y = bar_offset; |
|
|
y = bar_offset; |
|
|
if (bar_reversed) { |
|
|
if (bar_reversed) { |
|
|
y -= height; |
|
|
y -= height; |
|
|
} |
|
|
} else if (bar_bidirectional) { |
|
|
else if (bar_bidirectional) { |
|
|
|
|
|
height = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height * 2); |
|
|
height = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height * 2); |
|
|
y = bar_offset - (height / 2) + (bar_base_height / 2); |
|
|
y = bar_offset - (height / 2) + (bar_base_height / 2); |
|
|
} |
|
|
} |
|
@ -365,9 +362,8 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
back_width = bar_base_height - cur_bar_height; |
|
|
back_width = bar_base_height - cur_bar_height; |
|
|
back_height = height; |
|
|
back_height = height; |
|
|
if (bar_reversed) { |
|
|
if (bar_reversed) { |
|
|
back_x = bar_offset - bar_base_height; |
|
|
back_x = bar_offset - bar_base_height; |
|
|
} |
|
|
} else if (bar_bidirectional) { |
|
|
else if (bar_bidirectional) { |
|
|
|
|
|
back_x = bar_offset; |
|
|
back_x = bar_offset; |
|
|
back_y2 = y; |
|
|
back_y2 = y; |
|
|
back_width = (bar_base_height - (cur_bar_height * 2)) / 2; |
|
|
back_width = (bar_base_height - (cur_bar_height * 2)) / 2; |
|
@ -380,12 +376,11 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
back_height = bar_base_height - cur_bar_height; |
|
|
back_height = bar_base_height - cur_bar_height; |
|
|
if (bar_reversed) { |
|
|
if (bar_reversed) { |
|
|
back_y = bar_offset - bar_base_height; |
|
|
back_y = bar_offset - bar_base_height; |
|
|
} |
|
|
} else if (bar_bidirectional) { |
|
|
else if (bar_bidirectional) { |
|
|
|
|
|
back_x2 = x; |
|
|
back_x2 = x; |
|
|
back_y = bar_offset; |
|
|
back_y = bar_offset; |
|
|
back_height = (bar_base_height - (cur_bar_height * 2)) / 2; |
|
|
back_height = (bar_base_height - (cur_bar_height * 2)) / 2; |
|
|
back_y2= bar_offset + (cur_bar_height * 2) + back_height; |
|
|
back_y2 = bar_offset + (cur_bar_height * 2) + back_height; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -405,8 +400,7 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (cur_bar_height > 0 && cur_bar_height < bar_base_height && ((bar_bidirectional && ((cur_bar_height * 2) < bar_base_height)) |
|
|
if (cur_bar_height > 0 && cur_bar_height < bar_base_height && ((bar_bidirectional && ((cur_bar_height * 2) < bar_base_height)) || (!bar_bidirectional && (cur_bar_height < bar_base_height)))) { |
|
|
|| (!bar_bidirectional && (cur_bar_height < bar_base_height)))) { |
|
|
|
|
|
cairo_rectangle(ctx, back_x, back_y, back_width, back_height); |
|
|
cairo_rectangle(ctx, back_x, back_y, back_width, back_height); |
|
|
cairo_fill(ctx); |
|
|
cairo_fill(ctx); |
|
|
if (bar_bidirectional) { |
|
|
if (bar_bidirectional) { |
|
@ -415,13 +409,12 @@ static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
for(int i = 0; i < num_bars; ++i) { |
|
|
for (int i = 0; i < num_bars; ++i) { |
|
|
if (bar_heights[i] > 0) |
|
|
if (bar_heights[i] > 0) |
|
|
bar_heights[i] -= bar_periodic_step; |
|
|
bar_heights[i] -= bar_periodic_step; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
|
|
static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
|
|
if (unlock_indicator && |
|
|
if (unlock_indicator && |
|
|
(unlock_state >= STATE_KEY_PRESSED || auth_state > STATE_AUTH_IDLE || show_indicator)) { |
|
|
(unlock_state >= STATE_KEY_PRESSED || auth_state > STATE_AUTH_IDLE || show_indicator)) { |
|
@ -456,20 +449,20 @@ static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
|
|
case STATE_AUTH_LOCK: |
|
|
case STATE_AUTH_LOCK: |
|
|
cairo_set_source_rgba(ctx, ringver16.red, ringver16.green, ringver16.blue, ringver16.alpha); |
|
|
cairo_set_source_rgba(ctx, ringver16.red, ringver16.green, ringver16.blue, ringver16.alpha); |
|
|
if (internal_line_source == 1) { |
|
|
if (internal_line_source == 1) { |
|
|
line16.red = ringver16.red; |
|
|
line16.red = ringver16.red; |
|
|
line16.green = ringver16.green; |
|
|
line16.green = ringver16.green; |
|
|
line16.blue = ringver16.blue; |
|
|
line16.blue = ringver16.blue; |
|
|
line16.alpha = ringver16.alpha; |
|
|
line16.alpha = ringver16.alpha; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case STATE_AUTH_WRONG: |
|
|
case STATE_AUTH_WRONG: |
|
|
case STATE_I3LOCK_LOCK_FAILED: |
|
|
case STATE_I3LOCK_LOCK_FAILED: |
|
|
cairo_set_source_rgba(ctx, ringwrong16.red, ringwrong16.green, ringwrong16.blue, ringwrong16.alpha); |
|
|
cairo_set_source_rgba(ctx, ringwrong16.red, ringwrong16.green, ringwrong16.blue, ringwrong16.alpha); |
|
|
if (internal_line_source == 1) { |
|
|
if (internal_line_source == 1) { |
|
|
line16.red = ringwrong16.red; |
|
|
line16.red = ringwrong16.red; |
|
|
line16.green = ringwrong16.green; |
|
|
line16.green = ringwrong16.green; |
|
|
line16.blue = ringwrong16.blue; |
|
|
line16.blue = ringwrong16.blue; |
|
|
line16.alpha = ringwrong16.alpha; |
|
|
line16.alpha = ringwrong16.alpha; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case STATE_AUTH_IDLE: |
|
|
case STATE_AUTH_IDLE: |
|
@ -485,17 +478,17 @@ static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
|
|
} |
|
|
} |
|
|
cairo_set_source_rgba(ctx, ring16.red, ring16.green, ring16.blue, ring16.alpha); |
|
|
cairo_set_source_rgba(ctx, ring16.red, ring16.green, ring16.blue, ring16.alpha); |
|
|
if (internal_line_source == 1) { |
|
|
if (internal_line_source == 1) { |
|
|
line16.red = ring16.red; |
|
|
line16.red = ring16.red; |
|
|
line16.green = ring16.green; |
|
|
line16.green = ring16.green; |
|
|
line16.blue = ring16.blue; |
|
|
line16.blue = ring16.blue; |
|
|
line16.alpha = ring16.alpha; |
|
|
line16.alpha = ring16.alpha; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
cairo_stroke(ctx); |
|
|
cairo_stroke(ctx); |
|
|
|
|
|
|
|
|
/* Draw an inner separator line. */ |
|
|
/* Draw an inner separator line. */ |
|
|
if (internal_line_source != 2) { //pretty sure this only needs drawn if it's being drawn over the inside?
|
|
|
if (internal_line_source != 2) { //pretty sure this only needs drawn if it's being drawn over the inside?
|
|
|
cairo_set_source_rgba(ctx, line16.red, line16.green, line16.blue, line16.alpha); |
|
|
cairo_set_source_rgba(ctx, line16.red, line16.green, line16.blue, line16.alpha); |
|
|
cairo_set_line_width(ctx, 2.0); |
|
|
cairo_set_line_width(ctx, 2.0); |
|
|
cairo_arc(ctx, ind_x, ind_y, BUTTON_RADIUS - 5, 0, 2 * M_PI); |
|
|
cairo_arc(ctx, ind_x, ind_y, BUTTON_RADIUS - 5, 0, 2 * M_PI); |
|
@ -551,13 +544,13 @@ static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
|
|
(strtol(colorstring_tmparr[3], NULL, 16))}; |
|
|
(strtol(colorstring_tmparr[3], NULL, 16))}; |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
static void set_color(char* dest, const char* src, int offset) { |
|
|
static void set_color(char *dest, const char *src, int offset) { |
|
|
dest[0] = src[offset]; |
|
|
dest[0] = src[offset]; |
|
|
dest[1] = src[offset + 1]; |
|
|
dest[1] = src[offset + 1]; |
|
|
dest[2] = '\0'; |
|
|
dest[2] = '\0'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void colorgen(rgba_str_t* tmp, const char* src, rgba_t* dest) { |
|
|
static void colorgen(rgba_str_t *tmp, const char *src, rgba_t *dest) { |
|
|
set_color(tmp->red, src, 0); |
|
|
set_color(tmp->red, src, 0); |
|
|
set_color(tmp->green, src, 2); |
|
|
set_color(tmp->green, src, 2); |
|
|
set_color(tmp->blue, src, 4); |
|
|
set_color(tmp->blue, src, 4); |
|
@ -569,7 +562,7 @@ static void colorgen(rgba_str_t* tmp, const char* src, rgba_t* dest) { |
|
|
dest->alpha = strtol(tmp->alpha, NULL, 16) / 255.0; |
|
|
dest->alpha = strtol(tmp->alpha, NULL, 16) / 255.0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void colorgen_rgb(rgb_str_t* tmp, const char* src, rgb_t* dest) { |
|
|
static void colorgen_rgb(rgb_str_t *tmp, const char *src, rgb_t *dest) { |
|
|
set_color(tmp->red, src, 0); |
|
|
set_color(tmp->red, src, 0); |
|
|
set_color(tmp->green, src, 2); |
|
|
set_color(tmp->green, src, 2); |
|
|
set_color(tmp->blue, src, 4); |
|
|
set_color(tmp->blue, src, 4); |
|
@ -581,7 +574,7 @@ static void colorgen_rgb(rgb_str_t* tmp, const char* src, rgb_t* dest) { |
|
|
|
|
|
|
|
|
void init_colors_once(void) { |
|
|
void init_colors_once(void) { |
|
|
rgba_str_t tmp; |
|
|
rgba_str_t tmp; |
|
|
rgb_str_t tmp_rgb; |
|
|
rgb_str_t tmp_rgb; |
|
|
|
|
|
|
|
|
/* build indicator color arrays */ |
|
|
/* build indicator color arrays */ |
|
|
colorgen(&tmp, insidevercolor, &insidever16); |
|
|
colorgen(&tmp, insidevercolor, &insidever16); |
|
@ -625,7 +618,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
cairo_surface_t *output = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, resolution[0], resolution[1]); |
|
|
cairo_surface_t *output = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, resolution[0], resolution[1]); |
|
|
cairo_t *ctx = cairo_create(output); |
|
|
cairo_t *ctx = cairo_create(output); |
|
|
|
|
|
|
|
|
// cairo_set_font_face(ctx, get_font_face(0));
|
|
|
// cairo_set_font_face(ctx, get_font_face(0));
|
|
|
|
|
|
|
|
|
cairo_surface_t *xcb_output = cairo_xcb_surface_create(conn, bg_pixmap, vistype, resolution[0], resolution[1]); |
|
|
cairo_surface_t *xcb_output = cairo_xcb_surface_create(conn, bg_pixmap, vistype, resolution[0], resolution[1]); |
|
|
cairo_t *xcb_ctx = cairo_create(xcb_output); |
|
|
cairo_t *xcb_ctx = cairo_create(xcb_output); |
|
@ -634,7 +627,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
if (blur_img) { |
|
|
if (blur_img) { |
|
|
cairo_set_source_surface(xcb_ctx, blur_img, 0, 0); |
|
|
cairo_set_source_surface(xcb_ctx, blur_img, 0, 0); |
|
|
cairo_paint(xcb_ctx); |
|
|
cairo_paint(xcb_ctx); |
|
|
} else { // img can no longer be non-NULL if blur_img is not null
|
|
|
} else { // img can no longer be non-NULL if blur_img is not null
|
|
|
if (!tile) { |
|
|
if (!tile) { |
|
|
cairo_set_source_surface(xcb_ctx, img, 0, 0); |
|
|
cairo_set_source_surface(xcb_ctx, img, 0, 0); |
|
|
cairo_paint(xcb_ctx); |
|
|
cairo_paint(xcb_ctx); |
|
@ -686,7 +679,6 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
|
|
|
|
|
|
if (unlock_indicator && |
|
|
if (unlock_indicator && |
|
|
(unlock_state >= STATE_KEY_PRESSED || auth_state > STATE_AUTH_IDLE || show_indicator)) { |
|
|
(unlock_state >= STATE_KEY_PRESSED || auth_state > STATE_AUTH_IDLE || show_indicator)) { |
|
|
|
|
|
|
|
|
switch (auth_state) { |
|
|
switch (auth_state) { |
|
|
case STATE_AUTH_VERIFY: |
|
|
case STATE_AUTH_VERIFY: |
|
|
status_text.show = true; |
|
|
status_text.show = true; |
|
@ -769,7 +761,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
|
|
|
|
|
|
if (show_clock && (!status_text.show || always_show_clock)) { |
|
|
if (show_clock && (!status_text.show || always_show_clock)) { |
|
|
time_t rawtime; |
|
|
time_t rawtime; |
|
|
struct tm* timeinfo; |
|
|
struct tm *timeinfo; |
|
|
time(&rawtime); |
|
|
time(&rawtime); |
|
|
timeinfo = localtime(&rawtime); |
|
|
timeinfo = localtime(&rawtime); |
|
|
|
|
|
|
|
@ -807,14 +799,18 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
int te_x_err; |
|
|
int te_x_err; |
|
|
int te_y_err; |
|
|
int te_y_err; |
|
|
// variable mapping for evaluating the clock position expression
|
|
|
// variable mapping for evaluating the clock position expression
|
|
|
te_variable vars[] = { |
|
|
te_variable vars[] = |
|
|
{"w", &w}, {"h", &h}, |
|
|
{{"w", &w}, |
|
|
{"x", &screen_x}, {"y", &screen_y}, |
|
|
{"h", &h}, |
|
|
{"ix", &ix}, {"iy", &iy}, |
|
|
{"x", &screen_x}, |
|
|
{"tx", &tx}, {"ty", &ty}, |
|
|
{"y", &screen_y}, |
|
|
{"dx", &dx}, {"dy", &dy}, |
|
|
{"ix", &ix}, |
|
|
{"r", &radius} |
|
|
{"iy", &iy}, |
|
|
}; |
|
|
{"tx", &tx}, |
|
|
|
|
|
{"ty", &ty}, |
|
|
|
|
|
{"dx", &dx}, |
|
|
|
|
|
{"dy", &dy}, |
|
|
|
|
|
{"r", &radius}}; |
|
|
#define NUM_VARS 11 |
|
|
#define NUM_VARS 11 |
|
|
|
|
|
|
|
|
te_expr *te_ind_x_expr = te_compile(ind_x_expr, vars, NUM_VARS, &te_x_err); |
|
|
te_expr *te_ind_x_expr = te_compile(ind_x_expr, vars, NUM_VARS, &te_x_err); |
|
@ -851,8 +847,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
iy = 0; |
|
|
iy = 0; |
|
|
ix = te_eval(te_ind_x_expr); |
|
|
ix = te_eval(te_ind_x_expr); |
|
|
iy = te_eval(te_ind_y_expr); |
|
|
iy = te_eval(te_ind_y_expr); |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
ix = xr_resolutions[screen_number].x + (xr_resolutions[screen_number].width / 2); |
|
|
ix = xr_resolutions[screen_number].x + (xr_resolutions[screen_number].width / 2); |
|
|
iy = xr_resolutions[screen_number].y + (xr_resolutions[screen_number].height / 2); |
|
|
iy = xr_resolutions[screen_number].y + (xr_resolutions[screen_number].height / 2); |
|
|
} |
|
|
} |
|
@ -965,19 +960,21 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { |
|
|
// maybe see about doing ((double) rand() / RAND_MAX) * num_bars
|
|
|
// maybe see about doing ((double) rand() / RAND_MAX) * num_bars
|
|
|
int index = rand() % num_bars; |
|
|
int index = rand() % num_bars; |
|
|
bar_heights[index] = max_bar_height; |
|
|
bar_heights[index] = max_bar_height; |
|
|
for(int i = 0; i < ((max_bar_height / bar_step) + 1); ++i) { |
|
|
for (int i = 0; i < ((max_bar_height / bar_step) + 1); ++i) { |
|
|
int low_ind = index - i; |
|
|
int low_ind = index - i; |
|
|
while (low_ind < 0) { |
|
|
while (low_ind < 0) { |
|
|
low_ind += num_bars; |
|
|
low_ind += num_bars; |
|
|
} |
|
|
} |
|
|
int high_ind = (index + i) % num_bars; |
|
|
int high_ind = (index + i) % num_bars; |
|
|
int tmp_height = max_bar_height - (bar_step * i); |
|
|
int tmp_height = max_bar_height - (bar_step * i); |
|
|
if (tmp_height < 0) tmp_height = 0; |
|
|
if (tmp_height < 0) |
|
|
|
|
|
tmp_height = 0; |
|
|
if (bar_heights[low_ind] < tmp_height) |
|
|
if (bar_heights[low_ind] < tmp_height) |
|
|
bar_heights[low_ind] = tmp_height; |
|
|
bar_heights[low_ind] = tmp_height; |
|
|
if (bar_heights[high_ind] < tmp_height) |
|
|
if (bar_heights[high_ind] < tmp_height) |
|
|
bar_heights[high_ind] = tmp_height; |
|
|
bar_heights[high_ind] = tmp_height; |
|
|
if (tmp_height == 0) break; |
|
|
if (tmp_height == 0) |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
draw_bar(ctx, x, y, bar_offset); |
|
|
draw_bar(ctx, x, y, bar_offset); |
|
@ -1028,9 +1025,9 @@ void clear_indicator(void) { |
|
|
redraw_screen(); |
|
|
redraw_screen(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void* start_time_redraw_tick_pthread(void* arg) { |
|
|
void *start_time_redraw_tick_pthread(void *arg) { |
|
|
struct timespec *ts = (struct timespec *) arg; |
|
|
struct timespec *ts = (struct timespec *)arg; |
|
|
while(1) { |
|
|
while (1) { |
|
|
nanosleep(ts, NULL); |
|
|
nanosleep(ts, NULL); |
|
|
redraw_screen(); |
|
|
redraw_screen(); |
|
|
} |
|
|
} |
|
@ -1041,13 +1038,13 @@ static void time_redraw_cb(struct ev_loop *loop, ev_periodic *w, int revents) { |
|
|
redraw_screen(); |
|
|
redraw_screen(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void start_time_redraw_tick(struct ev_loop* main_loop) { |
|
|
void start_time_redraw_tick(struct ev_loop *main_loop) { |
|
|
if (time_redraw_tick) { |
|
|
if (time_redraw_tick) { |
|
|
ev_periodic_set(time_redraw_tick, 0., refresh_rate, 0); |
|
|
ev_periodic_set(time_redraw_tick, 0., refresh_rate, 0); |
|
|
ev_periodic_again(main_loop, time_redraw_tick); |
|
|
ev_periodic_again(main_loop, time_redraw_tick); |
|
|
} else { |
|
|
} else { |
|
|
if (!(time_redraw_tick = calloc(sizeof(struct ev_periodic), 1))) { |
|
|
if (!(time_redraw_tick = calloc(sizeof(struct ev_periodic), 1))) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
ev_periodic_init(time_redraw_tick, time_redraw_cb, 0., refresh_rate, 0); |
|
|
ev_periodic_init(time_redraw_tick, time_redraw_cb, 0., refresh_rate, 0); |
|
|
ev_periodic_start(main_loop, time_redraw_tick); |
|
|
ev_periodic_start(main_loop, time_redraw_tick); |
|
|