1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 21:49:07 +00:00

Make use_xft a lua setting

This commit is contained in:
Pavel Labath 2010-04-21 19:33:39 +02:00
parent 88064ef8db
commit 927394505c
5 changed files with 23 additions and 34 deletions

View File

@ -431,7 +431,7 @@ int calc_text_width(const char *s)
#ifdef BUILD_X11
}
#ifdef BUILD_XFT
if (use_xft) {
if (use_xft.get(*state)) {
XGlyphInfo gi;
if (utf8_mode) {
@ -1191,7 +1191,7 @@ static void draw_string(const char *s)
#ifdef BUILD_X11
if (out_to_x.get(*state)) {
#ifdef BUILD_XFT
if (use_xft) {
if (use_xft.get(*state)) {
XColor c;
XftColor c2;
@ -2185,7 +2185,7 @@ static void main_loop(void)
#endif
XSetRegion(display, window.gc, x11_stuff.region);
#ifdef BUILD_XFT
if (use_xft) {
if (use_xft.get(*state)) {
XftDrawSetClip(window.xftdraw, x11_stuff.region);
}
#endif
@ -2925,9 +2925,6 @@ char load_config_file(const char *f)
}
#ifdef BUILD_X11
#ifdef BUILD_XFT
CONF("use_xft") {
use_xft = string_to_bool(value);
}
CONF("font") {
if (value) {
set_first_font(value);
@ -2939,13 +2936,8 @@ char load_config_file(const char *f)
}
}
CONF("xftfont") {
if (use_xft) {
if (use_xft.get(*state)) {
#else
CONF("use_xft") {
if (string_to_bool(value)) {
NORM_ERR("Xft not enabled at compile time");
}
}
CONF("xftfont") {
/* xftfont silently ignored when no Xft */
}

View File

@ -39,7 +39,7 @@ char fontloaded = 0;
void set_font(void)
{
#ifdef BUILD_XFT
if (use_xft) return;
if (use_xft.get(*state)) return;
#endif /* BUILD_XFT */
if (font_count > -1 && fonts[selected_font].font) {
XSetFont(display, window.gc, fonts[selected_font].font->fid);
@ -52,7 +52,7 @@ void setup_fonts(void)
return;
}
#ifdef BUILD_XFT
if (use_xft) {
if (use_xft.get(*state)) {
if (window.xftdraw) {
XftDrawDestroy(window.xftdraw);
window.xftdraw = 0;
@ -128,7 +128,7 @@ void free_fonts(void)
}
for (i = 0; i <= font_count; i++) {
#ifdef BUILD_XFT
if (use_xft) {
if (use_xft.get(*state)) {
/*
* Do we not need to close fonts with Xft? Unsure. Not freeing the
* fonts seems to incur a slight memory leak, but it also prevents
@ -166,11 +166,10 @@ void load_fonts(void)
for (i = 0; i <= font_count; i++) {
#ifdef BUILD_XFT
/* load Xft font */
if (use_xft && fonts[i].xftfont) {
continue;
} else if (use_xft) {
fonts[i].xftfont = XftFontOpenName(display, screen,
fonts[i].name);
if (use_xft.get(*state)) {
if(not fonts[i].xftfont)
fonts[i].xftfont = XftFontOpenName(display, screen, fonts[i].name);
if (fonts[i].xftfont) {
continue;
}
@ -181,12 +180,7 @@ void load_fonts(void)
continue;
}
NORM_ERR("can't load Xft font '%s'", "courier-12");
if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) {
CRIT_ERR(NULL, NULL, "can't load font '%s'", "fixed");
}
use_xft = 0;
CRIT_ERR(NULL, NULL, "can't load Xft font '%s'", "courier-12");
continue;
}

View File

@ -47,13 +47,13 @@ struct font_list {
#ifdef BUILD_XFT
#define font_height() (use_xft ? (fonts[selected_font].xftfont->ascent + \
#define font_height() (use_xft.get(*state) ? (fonts[selected_font].xftfont->ascent + \
fonts[selected_font].xftfont->descent) \
: (fonts[selected_font].font->max_bounds.ascent + \
fonts[selected_font].font->max_bounds.descent))
#define font_ascent() (use_xft ? fonts[selected_font].xftfont->ascent \
#define font_ascent() (use_xft.get(*state) ? fonts[selected_font].xftfont->ascent \
: fonts[selected_font].font->max_bounds.ascent)
#define font_descent() (use_xft ? fonts[selected_font].xftfont->descent \
#define font_descent() (use_xft.get(*state) ? fonts[selected_font].xftfont->descent \
: fonts[selected_font].font->max_bounds.descent)
#else

View File

@ -44,7 +44,6 @@
#ifdef BUILD_XFT
#include <X11/Xft/Xft.h>
int use_xft = 0;
#endif
#ifdef BUILD_XDBE
@ -206,6 +205,10 @@ priv::colour_setting default_color("default_color", 0xffffff);
priv::colour_setting default_shade_color("default_shade_color", 0x000000);
priv::colour_setting default_outline_color("default_outline_color", 0x000000);
#ifdef BUILD_XFT
conky::simple_config_setting<bool> use_xft("use_xft", false, false);
#endif
#ifdef OWN_WINDOW
conky::simple_config_setting<bool> own_window("own_window", false, false);
conky::simple_config_setting<bool> set_transparent("own_window_transparent", false, false);

View File

@ -93,10 +93,6 @@ struct conky_window {
extern int use_xdbe;
#endif
#ifdef BUILD_XFT
extern int use_xft;
#endif
#if defined(BUILD_ARGB) && defined(OWN_WINDOW)
/* true if use_argb_visual=true and argb visual was found*/
extern bool have_argb_visual;
@ -188,6 +184,10 @@ extern priv::colour_setting default_color;
extern priv::colour_setting default_shade_color;
extern priv::colour_setting default_outline_color;
#ifdef BUILD_XFT
extern conky::simple_config_setting<bool> use_xft;
#endif
#ifdef OWN_WINDOW
extern conky::simple_config_setting<bool> own_window;
extern conky::simple_config_setting<bool> set_transparent;