mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 20:44:56 +00:00
Fix some minor graph related bugs.
This commit is contained in:
parent
d03df4a367
commit
35a72f5a95
36
src/conky.c
36
src/conky.c
@ -6116,23 +6116,43 @@ static void draw_line(char *s)
|
||||
if (specials[special_index].last_colour != 0
|
||||
|| specials[special_index].first_colour != 0) {
|
||||
if (specials[special_index].tempgrad) {
|
||||
#ifdef DEBUG_lol
|
||||
assert(
|
||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
||||
(w - 2) / (float)specials[special_index].graph_scale)
|
||||
< w - 1
|
||||
);
|
||||
assert(
|
||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
||||
(w - 2) / (float)specials[special_index].graph_scale)
|
||||
> -1
|
||||
);
|
||||
if (specials[special_index].graph[j] == specials[special_index].graph_scale) {
|
||||
assert(
|
||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
||||
(w - 2) / (float)specials[special_index].graph_scale)
|
||||
== 0
|
||||
);
|
||||
}
|
||||
#endif /* DEBUG_lol */
|
||||
XSetForeground(display, window.gc, tmpcolour[
|
||||
(int)((float)(w - 1) - specials[special_index].graph[j] *
|
||||
(w - 2) / (float)specials[special_index].graph_scale) - 1]);
|
||||
(int)((float)(w - 2) - specials[special_index].graph[j] *
|
||||
(w - 2) / (float)specials[special_index].graph_scale)
|
||||
]);
|
||||
} else {
|
||||
XSetForeground(display, window.gc, tmpcolour[colour_idx++]);
|
||||
}
|
||||
}
|
||||
/* this is mugfugly, but it works */
|
||||
XDrawLine(display, window.drawable, window.gc,
|
||||
cur_x + i + 1, by + h, cur_x + i + 1,
|
||||
by + h - specials[special_index].graph[j] *
|
||||
(h - 1) / specials[special_index].graph_scale);
|
||||
if ((w - i) / ((float) (w - 2) /
|
||||
(specials[special_index].graph_width)) > j
|
||||
(specials[special_index].graph_width)) > j
|
||||
&& j < MAX_GRAPH_DEPTH - 3) {
|
||||
j++;
|
||||
}
|
||||
/* this is mugfugly, but it works */
|
||||
XDrawLine(display, window.drawable, window.gc,
|
||||
cur_x + i + 1, by + h, cur_x + i + 1,
|
||||
by + h - specials[special_index].graph[j] *
|
||||
(h - 1) / specials[special_index].graph_scale);
|
||||
}
|
||||
if (tmpcolour) free(tmpcolour);
|
||||
if (h > cur_y_add
|
||||
|
@ -288,11 +288,15 @@ static void graph_append(struct special_t *graph, double f, char showaslog)
|
||||
/* shift all the data by 1 */
|
||||
for (i = graph->graph_width - 1; i > 0; i--) {
|
||||
graph->graph[i] = graph->graph[i - 1];
|
||||
if (graph->scaled && graph->graph[i] > graph->graph_scale) {
|
||||
if (graph->scaled && graph->graph[i - 1] > graph->graph_scale) {
|
||||
/* check if we need to update the scale */
|
||||
graph->graph_scale = graph->graph[i];
|
||||
graph->graph_scale = graph->graph[i - 1];
|
||||
}
|
||||
}
|
||||
if (graph->scaled && graph->graph[graph->graph_width] > graph->graph_scale) {
|
||||
/* check if we need to update the scale */
|
||||
graph->graph_scale = graph->graph[graph->graph_width];
|
||||
}
|
||||
}
|
||||
|
||||
void new_graph(char *buf, int w, int h, unsigned int first_colour,
|
||||
|
Loading…
Reference in New Issue
Block a user