1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-29 01:58:26 +00:00

Made downspeedgraph and upspeedgraph use same scaling

This commit is contained in:
donutAnees 2024-07-21 02:58:02 +05:30 committed by Brenden Matthews
parent ac25fcce8b
commit 82bfeba9bf
8 changed files with 27 additions and 12 deletions

View File

@ -352,7 +352,7 @@ void print_no_update(struct text_object *obj, char *p,
#ifdef BUILD_GUI
void scan_loadgraph_arg(struct text_object *obj, const char *arg) {
scan_graph(obj, arg, 0);
scan_graph(obj, arg, 0, FALSE);
}
double loadgraphval(struct text_object *obj) {

View File

@ -729,7 +729,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
#ifdef BUILD_GUI
END OBJ(cpugraph, &update_cpu_usage) get_cpu_count();
SCAN_CPU(arg, obj->data.i);
scan_graph(obj, arg, 1);
scan_graph(obj, arg, 1, FALSE);
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
obj->callbacks.graphval = &cpu_barval;
obj->callbacks.free = &free_cpu;
@ -1241,9 +1241,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(memwithbuffersbar, &update_meminfo) scan_bar(obj, arg, 1);
obj->callbacks.barval = &mem_with_buffers_barval;
#ifdef BUILD_GUI
END OBJ(memgraph, &update_meminfo) scan_graph(obj, arg, 1);
END OBJ(memgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE);
obj->callbacks.graphval = &mem_barval;
END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1);
END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE);
obj->callbacks.graphval = &mem_with_buffers_barval;
#endif /* BUILD_GUI*/
#ifdef HAVE_SOME_SOUNDCARD_H
@ -1825,7 +1825,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
"lua_graph needs arguments: <function name> [height],[width] [gradient "
"colour 1] [gradient colour 2] [scale] [-t] [-l]") auto [buf, skip] =
scan_command(arg);
scan_graph(obj, arg + skip, 100);
scan_graph(obj, arg + skip, 100, FALSE);
if (buf != nullptr) {
obj->data.s = buf;
} else {
@ -1968,7 +1968,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(apcupsd_loadbar, &update_apcupsd) scan_bar(obj, arg, 100);
obj->callbacks.barval = &apcupsd_loadbarval;
#ifdef BUILD_GUI
END OBJ(apcupsd_loadgraph, &update_apcupsd) scan_graph(obj, arg, 100);
END OBJ(apcupsd_loadgraph, &update_apcupsd) scan_graph(obj, arg, 100, FALSE);
obj->callbacks.graphval = &apcupsd_loadbarval;
END OBJ(apcupsd_loadgauge, &update_apcupsd) scan_gauge(obj, arg, 100);
obj->callbacks.gaugeval = &apcupsd_loadbarval;

View File

@ -173,7 +173,7 @@ void print_diskio_write(struct text_object *obj, char *p,
#ifdef BUILD_GUI
void parse_diskiograph_arg(struct text_object *obj, const char *arg) {
auto [buf, skip] = scan_command(arg);
scan_graph(obj, arg + skip, 0);
scan_graph(obj, arg + skip, 0, FALSE);
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
free_and_zero(buf);

View File

@ -275,7 +275,7 @@ void scan_exec_arg(struct text_object *obj, const char *arg,
cmd = scan_gauge(obj, cmd, 100);
} else if ((execflag & EF_GRAPH) != 0u) {
auto [buf, skip] = scan_command(cmd);
scan_graph(obj, cmd + skip, 100);
scan_graph(obj, cmd + skip, 100, FALSE);
cmd = buf;
if (cmd == nullptr) {
NORM_ERR("error parsing arguments to execgraph object");

View File

@ -334,7 +334,7 @@ void parse_net_stat_graph_arg(struct text_object *obj, const char *arg,
void *free_at_crash) {
/* scan arguments and get interface name back */
auto [buf, skip] = scan_command(arg);
scan_graph(obj, arg + skip, 0);
scan_graph(obj, arg + skip, 0, TRUE);
// default to DEFAULTNETDEV
if (buf != nullptr) {

View File

@ -458,7 +458,7 @@ int set_nvidia_query(struct text_object *obj, const char *arg,
break;
case text_node_t::GRAPH: {
auto [buf, skip] = scan_command(arg);
scan_graph(obj, arg + skip, 100);
scan_graph(obj, arg + skip, 100, FALSE);
arg = buf;
} break;
case text_node_t::GAUGE:

View File

@ -50,6 +50,7 @@ struct special_node *specials = nullptr;
int special_count;
int graph_count = 0;
double maxspeedval = 1e-47; /* The maximum value among the speed graphs */
std::map<int, double *> graphs;
@ -106,6 +107,7 @@ struct graph {
Colour first_colour, last_colour;
double scale;
char tempgrad;
char speedgraph; /* If the current graph is a speed graph */
};
struct stippled_hr {
@ -249,7 +251,7 @@ std::pair<char *, size_t> scan_command(const char *s) {
* @param[in] defscale default scale if no scale argument given
* @return whether parsing was successful
**/
bool scan_graph(struct text_object *obj, const char *argstr, double defscale) {
bool scan_graph(struct text_object *obj, const char *argstr, double defscale, char speedGraph) {
char first_colour_name[1024] = {'\0'};
char last_colour_name[1024] = {'\0'};
@ -267,6 +269,10 @@ bool scan_graph(struct text_object *obj, const char *argstr, double defscale) {
g->scale = defscale;
g->tempgrad = FALSE;
if (speedGraph) {
g->speedgraph = TRUE;
}
if (argstr == nullptr) return false;
/* set tempgrad to true if '-t' specified.
@ -486,6 +492,10 @@ static void graph_append(struct special_node *graph, double f, char showaslog) {
if (graph->scaled != 0) {
graph->scale =
*std::max_element(graph->graph + 0, graph->graph + graph->graph_width);
if (graph->speedgraph) {
maxspeedval = graph->scale < maxspeedval ? maxspeedval : graph->scale;
graph->scale = maxspeedval;
}
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 */
@ -610,6 +620,10 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size,
}
#endif
if (g->speedgraph) {
s->speedgraph = TRUE;
}
if (store_graph_data_explicitly.get(*state)) {
if (s->graph) { s->graph = retrieve_graph(g->id, s->graph_width); }

View File

@ -80,6 +80,7 @@ struct special_node {
Colour last_colour;
short font_added;
char tempgrad;
char speedgraph;
struct special_node *next;
};
@ -97,7 +98,7 @@ const char *scan_gauge(struct text_object *, const char *, double);
#ifdef BUILD_GUI
void scan_font(struct text_object *, const char *);
std::pair<char *, size_t> scan_command(const char *);
bool scan_graph(struct text_object *, const char *, double);
bool scan_graph(struct text_object *, const char *, double, char);
void scan_tab(struct text_object *, const char *);
void scan_stippled_hr(struct text_object *, const char *);