From 951cb1ac7e34347f54dc968e68371d5c334abc5e Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 23 Oct 2011 20:51:55 +0200 Subject: [PATCH] Fix graph updating for large (>512pix) graphs (sf.net #3253656) apparently, this was actually a feature as someone made it deliberately act that way. However, I agree with the bug reporter that it is strange so I remove it. --- src/conky.cc | 6 +----- src/specials.cc | 17 ++++------------- src/specials.h | 3 --- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 1f2e5920..657977cd 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -1580,11 +1580,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) cur_x + i + 1, by + h, cur_x + i + 1, round_to_int((double)by + h - current->graph[j] * (h - 1) / current->scale)); - if ((w - i) / ((float) (w - 2) / - (current->graph_width)) > j - && j < MAX_GRAPH_DEPTH - 3) { - j++; - } + j++; } free_and_zero(tmpcolour); if (h > cur_y_add diff --git a/src/specials.cc b/src/specials.cc index 900a2eca..08497f3c 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -392,13 +392,13 @@ 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--) { + for (i = graph->width - 1; i > 0; i--) { graph->graph[i] = graph->graph[i - 1]; } graph->graph[0] = f; /* add new data */ if(graph->scaled) { - graph->scale = *std::max_element(graph->graph + 0, graph->graph + graph->graph_width); + graph->scale = *std::max_element(graph->graph + 0, graph->graph + graph->width); if(graph->scale < 1e-47) { /* avoid NaN's when the graph is all-zero (e.g. before the first update) * there is nothing magical about 1e-47 here */ @@ -422,14 +422,8 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val) s->width = g->width; if (s->graph == NULL) { - if (s->width > 0 && s->width < MAX_GRAPH_DEPTH) { - // subtract 2 for the box - s->graph_width = s->width /* - 2 */; - } else { - s->graph_width = MAX_GRAPH_DEPTH - 2; - } - s->graph = (double*)malloc(s->graph_width * sizeof(double)); - memset(s->graph, 0, s->graph_width * sizeof(double)); + s->graph = (double*)malloc(s->width * sizeof(double)); + memset(s->graph, 0, s->width * sizeof(double)); s->scale = 100; } s->height = g->height; @@ -445,9 +439,6 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val) s->show_scale = 1; } s->tempgrad = g->tempgrad; - /* if (s->width) { - s->graph_width = s->width - 2; // subtract 2 for rectangle around - } */ #ifdef MATH if (g->flags & SF_SHOWLOG) { s->scale = log10(s->scale + 1); diff --git a/src/specials.h b/src/specials.h index d5f5c967..96a054c9 100644 --- a/src/specials.h +++ b/src/specials.h @@ -34,8 +34,6 @@ #define SPECIAL_CHAR '\x01' -#define MAX_GRAPH_DEPTH 512 - // don't use spaces in LOGGRAPH or NORMGRAPH if you change them #define LOGGRAPH "-l" #define TEMPGRAD "-t" @@ -67,7 +65,6 @@ struct special_t { double *graph; double scale; /* maximum value */ short show_scale; - int graph_width; int scaled; /* auto adjust maximum */ unsigned long first_colour; // for graph gradient unsigned long last_colour;