mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Last fixes:
- round usage values - fix graph colors on 16-bit displays git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@245 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
46ac6b392a
commit
5856598c6b
11
src/common.c
11
src/common.c
@ -245,3 +245,14 @@ void update_stuff()
|
|||||||
last_fs_update = current_update_time;
|
last_fs_update = current_update_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int round_to_int(float f)
|
||||||
|
{
|
||||||
|
int intval = (int)f;
|
||||||
|
double delta = f - intval;
|
||||||
|
if (!(delta < 0.5)) {
|
||||||
|
++intval;
|
||||||
|
}
|
||||||
|
|
||||||
|
return intval;
|
||||||
|
}
|
||||||
|
34
src/conky.c
34
src/conky.c
@ -524,13 +524,34 @@ inline void graph_append(struct special_t *graph, double f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short colour_depth = 0;
|
||||||
|
void set_up_gradient();
|
||||||
|
|
||||||
|
/* adjust color values depending on color depth*/
|
||||||
|
static unsigned int adjust_colors(unsigned int color)
|
||||||
|
{
|
||||||
|
double r, g, b;
|
||||||
|
if (colour_depth == 0) {
|
||||||
|
set_up_gradient();
|
||||||
|
}
|
||||||
|
if (colour_depth == 16) {
|
||||||
|
r = (color & 0xff0000) >> 16;
|
||||||
|
g = (color & 0xff00) >> 8;
|
||||||
|
b = color & 0xff;
|
||||||
|
color = (int)(r / 0xff * 0x1f) << 11;
|
||||||
|
color |= (int)(g / 0xff * 0x3f) << 5;
|
||||||
|
color |= (int)(b / 0xff * 0x1f);
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
static void new_graph(char *buf, int w, int h, unsigned int first_colour, unsigned int second_colour, double i, int scale, int append)
|
static void new_graph(char *buf, int w, int h, unsigned int first_colour, unsigned int second_colour, double i, int scale, int append)
|
||||||
{
|
{
|
||||||
struct special_t *s = new_special(buf, GRAPH);
|
struct special_t *s = new_special(buf, GRAPH);
|
||||||
s->width = w;
|
s->width = w;
|
||||||
s->height = h;
|
s->height = h;
|
||||||
s->first_colour = first_colour;
|
s->first_colour = adjust_colors(first_colour);
|
||||||
s->last_colour = second_colour;
|
s->last_colour = adjust_colors(second_colour);
|
||||||
if (scale != 0) {
|
if (scale != 0) {
|
||||||
s->scaled = 0;
|
s->scaled = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -1907,23 +1928,23 @@ static void generate_text()
|
|||||||
}
|
}
|
||||||
if (!use_spacer)
|
if (!use_spacer)
|
||||||
snprintf(p, n, "%*d", pad_percents,
|
snprintf(p, n, "%*d", pad_percents,
|
||||||
(int) (cur->cpu_usage[obj->data.cpu_index] *
|
(int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
|
||||||
100.0));
|
100.0));
|
||||||
else
|
else
|
||||||
snprintf(p, 4, "%*d ",
|
snprintf(p, 4, "%*d ",
|
||||||
pad_percents,
|
pad_percents,
|
||||||
(int) (cur->cpu_usage[obj->data.cpu_index] *
|
(int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
|
||||||
100.0));
|
100.0));
|
||||||
}
|
}
|
||||||
OBJ(cpubar) {
|
OBJ(cpubar) {
|
||||||
new_bar(p, obj->a,
|
new_bar(p, obj->a,
|
||||||
obj->b,
|
obj->b,
|
||||||
(int) (cur->cpu_usage[obj->data.cpu_index] * 255.0));
|
(int) round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
|
||||||
}
|
}
|
||||||
OBJ(cpugraph) {
|
OBJ(cpugraph) {
|
||||||
new_graph(p, obj->a,
|
new_graph(p, obj->a,
|
||||||
obj->b, obj->c, obj->d,
|
obj->b, obj->c, obj->d,
|
||||||
(unsigned int) (cur->cpu_usage[obj->data.cpu_index] *
|
(unsigned int) round_to_int(cur->cpu_usage[obj->data.cpu_index] *
|
||||||
100), 100, 1);
|
100), 100, 1);
|
||||||
}
|
}
|
||||||
OBJ(color) {
|
OBJ(color) {
|
||||||
@ -3327,7 +3348,6 @@ static void draw_string(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
long redmask, greenmask, bluemask;
|
long redmask, greenmask, bluemask;
|
||||||
short colour_depth = 0;
|
|
||||||
|
|
||||||
void set_up_gradient()
|
void set_up_gradient()
|
||||||
{
|
{
|
||||||
|
@ -272,6 +272,8 @@ struct net_stat *get_net_stat(const char *dev);
|
|||||||
|
|
||||||
void update_stuff();
|
void update_stuff();
|
||||||
|
|
||||||
|
int round_to_int(float f);
|
||||||
|
|
||||||
#define SET_NEED(a) need_mask |= 1 << (a)
|
#define SET_NEED(a) need_mask |= 1 << (a)
|
||||||
extern unsigned long long need_mask;
|
extern unsigned long long need_mask;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user