1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

fixed garbled graph colours on systems using less then 24 bit colour depth

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@121 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-08-21 03:29:05 +00:00
parent 62b51a2847
commit 3b184eeb1d
7 changed files with 62 additions and 106 deletions

View File

@ -109,3 +109,5 @@ William DiPlacido <bimbasaari at yahoo dot com>
Frequency from /proc/cpuinfo
Some other SETI stuff
zimba-tm <zimba-tm at users dot sourceforge dot net>
alignment none patch

View File

@ -1,7 +1,8 @@
# $Id$
2005-08-20
* Applied patch from zimba-tm, closes bug 1260225
* Applied patch from zimba-tm, closes patch 1260225
* Fixed ugly gradient bug. closes bug 1255608
2005-08-12
* Multiple unit additions and modifications

View File

@ -53,11 +53,6 @@ man_MANS = conky.1
LIBS = -lm -lpthread
if HAVE_HELP2MAN
conky.1: conky conky.x
help2man -h -h -v -V -i conky.x -o conky.1 -N ./conky
endif
# conky.1 is in EXTRA_DIST in case that someone doesn't have help2man
EXTRA_DIST = conkyrc.sample conky.1 conky.x \
app-admin/conky/conky-1.2.ebuild

View File

@ -144,9 +144,6 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
HAVE_HELP2MAN_FALSE = @HAVE_HELP2MAN_FALSE@
HAVE_HELP2MAN_TRUE = @HAVE_HELP2MAN_TRUE@
HELP2MAN = @HELP2MAN@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -669,9 +666,6 @@ uninstall-man: uninstall-man1
ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-info-am uninstall-man uninstall-man1
@HAVE_HELP2MAN_TRUE@conky.1: conky conky.x
@HAVE_HELP2MAN_TRUE@ help2man -h -h -v -V -i conky.x -o conky.1 -N ./conky
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

62
configure vendored
View File

@ -309,7 +309,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar BUILD_LINUX_TRUE BUILD_LINUX_FALSE BUILD_SOLARIS_TRUE BUILD_SOLARIS_FALSE BUILD_FREEBSD_TRUE BUILD_FREEBSD_FALSE BUILD_NETBSD_TRUE BUILD_NETBSD_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP BUILD_SETI_TRUE BUILD_SETI_FALSE BUILD_MPD_TRUE BUILD_MPD_FALSE BUILD_CAIRO_TRUE BUILD_CAIRO_FALSE CAIROCONFIG BUILD_METAR_TRUE BUILD_METAR_FALSE BUILD_MLDONKEY_TRUE BUILD_MLDONKEY_FALSE BUILD_X11_TRUE BUILD_X11_FALSE XFTCONFIG HELP2MAN HAVE_HELP2MAN_TRUE HAVE_HELP2MAN_FALSE X11_LIBS XFT_LIBS LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar BUILD_LINUX_TRUE BUILD_LINUX_FALSE BUILD_SOLARIS_TRUE BUILD_SOLARIS_FALSE BUILD_FREEBSD_TRUE BUILD_FREEBSD_FALSE BUILD_NETBSD_TRUE BUILD_NETBSD_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP BUILD_SETI_TRUE BUILD_SETI_FALSE BUILD_MPD_TRUE BUILD_MPD_FALSE BUILD_CAIRO_TRUE BUILD_CAIRO_FALSE CAIROCONFIG BUILD_METAR_TRUE BUILD_METAR_FALSE BUILD_MLDONKEY_TRUE BUILD_MLDONKEY_FALSE BUILD_X11_TRUE BUILD_X11_FALSE XFTCONFIG X11_LIBS XFT_LIBS LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@ -6212,56 +6212,6 @@ done
# Extract the first word of "help2man", so it can be a program name with args.
set dummy help2man; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_HELP2MAN+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
case $HELP2MAN in
[\\/]* | ?:[\\/]*)
ac_cv_path_HELP2MAN="$HELP2MAN" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_HELP2MAN="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
;;
esac
fi
HELP2MAN=$ac_cv_path_HELP2MAN
if test -n "$HELP2MAN"; then
echo "$as_me:$LINENO: result: $HELP2MAN" >&5
echo "${ECHO_T}$HELP2MAN" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test x$HELP2MAN != x; then
HAVE_HELP2MAN_TRUE=
HAVE_HELP2MAN_FALSE='#'
else
HAVE_HELP2MAN_TRUE='#'
HAVE_HELP2MAN_FALSE=
fi
if test x$WANT_SYSINFO = xyes; then
dah=no
@ -6759,13 +6709,6 @@ echo "$as_me: error: conditional \"BUILD_X11\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${HAVE_HELP2MAN_TRUE}" && test -z "${HAVE_HELP2MAN_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"HAVE_HELP2MAN\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
echo "$as_me: error: conditional \"HAVE_HELP2MAN\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
@ -7360,9 +7303,6 @@ s,@BUILD_MLDONKEY_FALSE@,$BUILD_MLDONKEY_FALSE,;t t
s,@BUILD_X11_TRUE@,$BUILD_X11_TRUE,;t t
s,@BUILD_X11_FALSE@,$BUILD_X11_FALSE,;t t
s,@XFTCONFIG@,$XFTCONFIG,;t t
s,@HELP2MAN@,$HELP2MAN,;t t
s,@HAVE_HELP2MAN_TRUE@,$HAVE_HELP2MAN_TRUE,;t t
s,@HAVE_HELP2MAN_FALSE@,$HAVE_HELP2MAN_FALSE,;t t
s,@X11_LIBS@,$X11_LIBS,;t t
s,@XFT_LIBS@,$XFT_LIBS,;t t
s,@LIBOBJS@,$LIBOBJS,;t t

View File

@ -286,9 +286,6 @@ dnl
dnl Check help2man
dnl
AC_PATH_PROG(HELP2MAN, help2man)
AM_CONDITIONAL(HAVE_HELP2MAN, test x$HELP2MAN != x)
dnl
dnl Check sysinfo()
dnl

87
conky.c
View File

@ -525,7 +525,7 @@ static const char *scan_graph(const char *args, int *w, int *h, unsigned int *fi
if (sscanf(args, "%d,%d %x %x", h, w, first_colour, last_colour) < 4) {
*w = 0;
*h = 25;
if (sscanf(args, "%*s %x %x", first_colour, last_colour) < 2) {
if (sscanf(args, "%*s %x %x", first_colour, last_colour) < 3) {
*w = 0;
*h = 25;
if (sscanf(args, "%x %x", first_colour, last_colour) < 2) {
@ -2625,7 +2625,6 @@ static void set_font()
screen),
DefaultColormap(display,
screen));
} else
#endif
{
@ -2873,17 +2872,44 @@ static void draw_string(const char *s)
memcpy(tmpstring1, s, TEXT_BUFFER_SIZE);
}
long redmask, greenmask, bluemask;
short colour_depth = 0;
void set_up_gradient()
{
colour_depth = DisplayPlanes(display, screen);
if (colour_depth != 24 && colour_depth != 16) {
ERR("using non-standard colour depth, gradients may look like a lolly-pop");
}
int i;
redmask = 0;
greenmask = 0;
bluemask = 0;
for(i = (colour_depth / 3)-1; i>=0; i--) {
redmask |= 1 << i;
greenmask |= 1 << i;
bluemask |= 1 << i;
}
if (colour_depth%3 == 1) {
greenmask |= 1 << (colour_depth / 3);
}
redmask = redmask << (2*colour_depth / 3 + colour_depth%3);
greenmask = greenmask << (colour_depth / 3);
}
inline unsigned long do_gradient(unsigned long first_colour, unsigned long last_colour) { /* this function returns the next colour between two colours for a gradient */
int tmp_color = 0;
int red1, green1, blue1; // first colour
int red2, green2, blue2; // second colour
int red3 = 0, green3 = 0, blue3 = 0; // difference
red1 = (first_colour & 0xff0000) >> 16;
green1 = (first_colour & 0xff00) >> 8;
blue1 = first_colour & 0xff;
red2 = (last_colour & 0xff0000) >> 16;
green2 = (last_colour & 0xff00) >> 8;
blue2 = last_colour & 0xff;
short redshift = (2*colour_depth / 3 + colour_depth%3);
short greenshift = (colour_depth / 3);
red1 = (first_colour & redmask) >> redshift;
green1 = (first_colour & greenmask) >> greenshift;
blue1 = first_colour & bluemask;
red2 = (last_colour & redmask) >> redshift;
green2 = (last_colour & greenmask) >> greenshift;
blue2 = last_colour & bluemask;
if (red1 > red2) {
red3 = -1;
}
@ -2914,29 +2940,34 @@ inline unsigned long do_gradient(unsigned long first_colour, unsigned long last_
if (blue1 < 0) {
blue1 = 0;
}
if (red1 > 0xff) {
red1 = 0xff;
if (red1 > bluemask) {
red1 = bluemask;
}
if (green1 > 0xff) {
green1 = 0xff;
if (green1 > bluemask) {
green1 = bluemask;
}
if (blue1 > 0xff) {
blue1 = 0xff;
if (blue1 > bluemask) {
blue1 = bluemask;
}
tmp_color = (red1 << 16) | (green1 << 8) | blue1;
tmp_color = (red1 << redshift) | (green1 << greenshift) | blue1;
return tmp_color;
}
inline unsigned long gradient_max(unsigned long first_colour, unsigned long last_colour) { /* this function returns the max diff for a gradient */
if (colour_depth == 0) {
set_up_gradient();
}
int red1, green1, blue1; // first colour
int red2, green2, blue2; // second colour
long redshift = (2*colour_depth / 3 + colour_depth%3);
long greenshift = (colour_depth / 3);
int red3 = 0, green3 = 0, blue3 = 0; // difference
red1 = (first_colour & 0xff0000) >> 16;
green1 = (first_colour & 0xff00) >> 8;
blue1 = first_colour & 0xff;
red2 = (last_colour & 0xff0000) >> 16;
green2 = (last_colour & 0xff00) >> 8;
blue2 = last_colour & 0xff;
red1 = (first_colour & redmask) >> redshift;
green1 = (first_colour & greenmask) >> greenshift;
blue1 = first_colour & bluemask;
red2 = (last_colour & redmask) >> redshift;
green2 = (last_colour & greenmask) >> greenshift;
blue2 = last_colour & bluemask;
red3 = abs(red1 - red2);
green3 = abs(green1 - green2);
blue3 = abs(blue1 - blue2);
@ -3114,11 +3145,7 @@ static void draw_line(char *s)
gradient_update--;
}
}
if (i /
((float) (w - 3) /
(specials
[special_index].
graph_width)) > j) {
if (i / ((float) (w - 3) / (specials[special_index].graph_width)) > j) {
j++;
}
XDrawLine(display, window.drawable, window.gc, cur_x + i + 2, by + h, cur_x + i + 2, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale); /* this is mugfugly, but it works */
@ -3184,11 +3211,11 @@ static void draw_line(char *s)
case ALIGNR:
{
int pos_x = text_width - gap_x - get_string_width(p) - border_margin*2 - 1;
int pos_x = text_width + gap_x - get_string_width(p) /*- border_margin*2 - 1*/;
/*printf("pos_x %i text_start_x %i text_width %i cur_x %i get_string_width(p) %i gap_x %i specials[special_index].arg %i border_margin %i border_width %i\n", pos_x, text_start_x, text_width, cur_x, get_string_width(p), gap_x, specials[special_index].arg, border_margin, border_width);*/
if (pos_x > specials[special_index].arg) {
w = pos_x - specials[special_index].arg;
}
if (pos_x > specials[special_index].arg && pos_x > cur_x) {
cur_x = pos_x - specials[special_index].arg;
}
}
break;