mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 17:47:09 +00:00
Port out_to_x setting to lua-config
This commit is contained in:
parent
d22369333d
commit
12e98c7da5
@ -44,7 +44,7 @@ static void set_up_gradient(void)
|
||||
{
|
||||
int i;
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
colour_depth = DisplayPlanes(display, screen);
|
||||
} else
|
||||
#endif /* BUILD_X11 */
|
||||
|
69
src/conky.cc
69
src/conky.cc
@ -411,7 +411,7 @@ long global_text_lines;
|
||||
static int total_updates;
|
||||
static int updatereset;
|
||||
|
||||
static std::auto_ptr<lua::state> state;
|
||||
std::auto_ptr<lua::state> state;
|
||||
|
||||
void set_updatereset(int i)
|
||||
{
|
||||
@ -435,7 +435,7 @@ int calc_text_width(const char *s)
|
||||
size_t slen = strlen(s);
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if ((output_methods & TO_X) == 0) {
|
||||
if (not out_to_x.get(*state)) {
|
||||
#endif /* BUILD_X11 */
|
||||
return slen;
|
||||
#ifdef BUILD_X11
|
||||
@ -874,7 +874,7 @@ static int get_string_width_special(char *s, int special_index)
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return strlen(s);
|
||||
|
||||
p = strndup(s, text_buffer_size);
|
||||
@ -914,7 +914,7 @@ static void update_text_area(void)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
/* update text size if it isn't fixed */
|
||||
#ifdef OWN_WINDOW
|
||||
@ -1016,7 +1016,7 @@ static int text_size_updater(char *s, int special_index)
|
||||
int contain_SECRIT_MULTILINE_CHAR = 0;
|
||||
char *p;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return 0;
|
||||
/* get string widths and skip specials */
|
||||
p = s;
|
||||
@ -1095,7 +1095,7 @@ static int text_size_updater(char *s, int special_index)
|
||||
static inline void set_foreground_color(long c)
|
||||
{
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
#ifdef BUILD_ARGB
|
||||
if (have_argb_visual) {
|
||||
current_color = c | (own_window_argb_value << 24);
|
||||
@ -1163,7 +1163,7 @@ static void draw_string(const char *s)
|
||||
added = 0;
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
max = ((text_width - width_of_s) / get_string_width(" "));
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
@ -1186,7 +1186,7 @@ static void draw_string(const char *s)
|
||||
}
|
||||
}
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
if (text_width == maximum_width) {
|
||||
/* this means the text is probably pushing the limit,
|
||||
* so we'll chop it */
|
||||
@ -1199,7 +1199,7 @@ static void draw_string(const char *s)
|
||||
#endif /* BUILD_X11 */
|
||||
s = tmpstring2;
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
#ifdef BUILD_XFT
|
||||
if (use_xft) {
|
||||
XColor c;
|
||||
@ -1245,7 +1245,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
||||
int orig_special_index = special_index;
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
font_h = font_height();
|
||||
cur_y += font_ascent();
|
||||
}
|
||||
@ -1687,7 +1687,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
||||
}
|
||||
#endif /* BUILD_NCURSES */
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X)
|
||||
if (out_to_x.get(*state))
|
||||
cur_y += font_descent();
|
||||
#endif /* BUILD_X11 */
|
||||
if (recurse && *recurse) {
|
||||
@ -1700,7 +1700,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
||||
static int draw_line(char *s, int special_index)
|
||||
{
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
return draw_each_line_inner(s, special_index, -1);
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
@ -1720,7 +1720,7 @@ static void draw_text(void)
|
||||
#ifdef BUILD_LUA
|
||||
llua_draw_pre_hook();
|
||||
#endif /* BUILD_LUA */
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
cur_y = text_start_y;
|
||||
|
||||
/* draw borders */
|
||||
@ -1772,7 +1772,7 @@ static void draw_stuff(void)
|
||||
NORM_ERR("Can't append '%s' anymore", append_file);
|
||||
}
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
selected_font = 0;
|
||||
if (draw_shades && !draw_outline) {
|
||||
text_start_x++;
|
||||
@ -1810,7 +1810,7 @@ static void draw_stuff(void)
|
||||
draw_mode = FG;
|
||||
draw_text();
|
||||
#if defined(BUILD_X11) && defined(BUILD_XDBE)
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
xdbe_swap_buffers();
|
||||
}
|
||||
#endif /* BUILD_X11 && BUILD_XDBE */
|
||||
@ -1853,7 +1853,7 @@ static void update_text(void)
|
||||
#endif /* BUILD_IMLIB2 */
|
||||
generate_text();
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X)
|
||||
if (out_to_x.get(*state))
|
||||
clear_text(1);
|
||||
#endif /* BUILD_X11 */
|
||||
need_to_update = 1;
|
||||
@ -1912,7 +1912,7 @@ static void main_loop(void)
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
XFlush(display);
|
||||
|
||||
/* wait for X event or timeout */
|
||||
@ -2245,7 +2245,7 @@ static void main_loop(void)
|
||||
NORM_ERR("received SIGINT or SIGTERM to terminate. bye!");
|
||||
terminate = 1;
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
XDestroyRegion(x11_stuff.region);
|
||||
x11_stuff.region = NULL;
|
||||
#ifdef BUILD_XDAMAGE
|
||||
@ -2430,7 +2430,7 @@ void clean_up(void *memtofree1, void* memtofree2)
|
||||
llua_close();
|
||||
#endif /* BUILD_LUA */
|
||||
#ifdef BUILD_IMLIB2
|
||||
if (output_methods & TO_X)
|
||||
if (out_to_x.get(*state))
|
||||
cimlib_deinit();
|
||||
#endif /* BUILD_IMLIB2 */
|
||||
#ifdef BUILD_WEATHER_XOAP
|
||||
@ -2554,7 +2554,8 @@ static void set_default_configurations(void)
|
||||
#endif /* BUILD_XMMS2 */
|
||||
use_spacer = NO_SPACER;
|
||||
#ifdef BUILD_X11
|
||||
output_methods = TO_X;
|
||||
state->pushboolean(true);
|
||||
out_to_x.lua_set(*state);
|
||||
#else
|
||||
output_methods = TO_STDOUT;
|
||||
#endif
|
||||
@ -2678,7 +2679,8 @@ int x11_ioerror_handler(Display *d)
|
||||
static void X11_initialisation(void)
|
||||
{
|
||||
if (x_initialised == YES) return;
|
||||
output_methods |= TO_X;
|
||||
state->pushboolean(true);
|
||||
out_to_x.lua_set(*state);
|
||||
init_X11(disp);
|
||||
set_default_configurations_for_x();
|
||||
x_initialised = YES;
|
||||
@ -2695,7 +2697,7 @@ static int xargc = 0;
|
||||
|
||||
static void X11_create_window(void)
|
||||
{
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
#ifdef OWN_WINDOW
|
||||
init_window(own_window, text_width + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2,
|
||||
text_height + window.border_inner_margin * 2 + window.border_outer_margin * 2 + window.border_width * 2, set_transparent, background_colour,
|
||||
@ -2834,18 +2836,6 @@ char load_config_file(const char *f)
|
||||
}
|
||||
|
||||
#ifdef BUILD_X11
|
||||
CONF2("out_to_x") {
|
||||
/* don't listen if X is already initialised or
|
||||
* if we already know we don't want it */
|
||||
if(x_initialised != YES) {
|
||||
if (string_to_bool(value)) {
|
||||
output_methods &= TO_X;
|
||||
} else {
|
||||
output_methods &= ~TO_X;
|
||||
x_initialised = NEVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
CONF("display") {
|
||||
if (!value || x_initialised == YES) {
|
||||
CONF_ERR;
|
||||
@ -3416,7 +3406,7 @@ char load_config_file(const char *f)
|
||||
}
|
||||
CONF("text") {
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
X11_initialisation();
|
||||
}
|
||||
#endif
|
||||
@ -3576,7 +3566,7 @@ char load_config_file(const char *f)
|
||||
}
|
||||
#if defined(BUILD_NCURSES)
|
||||
#if defined(BUILD_X11)
|
||||
if ((output_methods & TO_X) && (output_methods & TO_NCURSES)) {
|
||||
if (out_to_x.get(*state) && (output_methods & TO_NCURSES)) {
|
||||
NORM_ERR("out_to_x and out_to_ncurses are incompatible, turning out_to_ncurses off");
|
||||
output_methods &= ~TO_NCURSES;
|
||||
endwin();
|
||||
@ -3756,7 +3746,7 @@ static void load_config_file_x11(const char *f)
|
||||
#endif
|
||||
CONF("text") {
|
||||
/* initialize BUILD_X11 if nothing BUILD_X11-related is mentioned before TEXT (and if BUILD_X11 is the default outputmethod) */
|
||||
if(output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
X11_initialisation();
|
||||
}
|
||||
}
|
||||
@ -3838,9 +3828,6 @@ static const char *getopt_string = "vVqdDs:t:u:i:hc:p:"
|
||||
#endif
|
||||
;
|
||||
|
||||
int printme(lua::state *, const char *str)
|
||||
{ fprintf(stderr, str); return 0;}
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "version", 0, NULL, 'V' },
|
||||
@ -4042,7 +4029,7 @@ void initialisation(int argc, char **argv) {
|
||||
|
||||
#ifdef BUILD_X11
|
||||
/* load font */
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
load_config_file_x11(current_config);
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "common.h" /* at least for struct dns_data */
|
||||
#include <sys/utsname.h> /* struct uname_s */
|
||||
#include <arpa/inet.h>
|
||||
#include <memory>
|
||||
#include "luamm.hh"
|
||||
|
||||
#if defined(HAS_MCHECK_H)
|
||||
#include <mcheck.h>
|
||||
@ -324,9 +326,6 @@ extern unsigned int max_user_text;
|
||||
/* path to config file */
|
||||
extern char *current_config;
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#define TO_X 1
|
||||
#endif /* BUILD_X11 */
|
||||
#define TO_STDOUT 2
|
||||
#define TO_STDERR 4
|
||||
#define OVERWRITE_FILE 8
|
||||
@ -358,4 +357,6 @@ void free_and_zero(T *&ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
extern std::auto_ptr<lua::state> state;
|
||||
|
||||
#endif /* _conky_h_ */
|
||||
|
@ -470,7 +470,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
#endif /* BUILD_X11 */
|
||||
END OBJ(color, 0)
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
|
||||
set_current_text_color(obj->data.l);
|
||||
}
|
||||
|
10
src/fonts.cc
10
src/fonts.cc
@ -48,7 +48,7 @@ void set_font(void)
|
||||
|
||||
void setup_fonts(void)
|
||||
{
|
||||
if ((output_methods & TO_X) == 0) {
|
||||
if (not out_to_x.get(*state)) {
|
||||
return;
|
||||
}
|
||||
#ifdef BUILD_XFT
|
||||
@ -66,7 +66,7 @@ void setup_fonts(void)
|
||||
|
||||
int add_font(const char *data_in)
|
||||
{
|
||||
if ((output_methods & TO_X) == 0) {
|
||||
if (not out_to_x.get(*state)) {
|
||||
return 0;
|
||||
}
|
||||
if (font_count > MAX_FONTS) {
|
||||
@ -100,7 +100,7 @@ int add_font(const char *data_in)
|
||||
|
||||
void set_first_font(const char *data_in)
|
||||
{
|
||||
if ((output_methods & TO_X) == 0) {
|
||||
if (not out_to_x.get(*state)) {
|
||||
return;
|
||||
}
|
||||
if (font_count < 0) {
|
||||
@ -123,7 +123,7 @@ void free_fonts(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if ((output_methods & TO_X) == 0) {
|
||||
if (not out_to_x.get(*state)) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i <= font_count; i++) {
|
||||
@ -161,7 +161,7 @@ void load_fonts(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
for (i = 0; i <= font_count; i++) {
|
||||
#ifdef BUILD_XFT
|
||||
|
@ -456,7 +456,7 @@ void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
|
||||
if (!lua_L) return;
|
||||
lua_newtable(lua_L);
|
||||
|
||||
if (output_methods & TO_X) {
|
||||
if (out_to_x.get(*state)) {
|
||||
#ifdef BUILD_LUA_EXTRAS
|
||||
llua_set_userdata("drawable", "Drawable", (void*)&window.drawable);
|
||||
llua_set_userdata("visual", "Visual", window.visual);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "logging.h"
|
||||
#include "specials.h"
|
||||
#include "text_object.h"
|
||||
#include "x11.h"
|
||||
#include <vector>
|
||||
|
||||
#define SCROLL_LEFT true
|
||||
@ -180,7 +181,7 @@ void print_scroll(struct text_object *obj, char *p, int p_max_size)
|
||||
}
|
||||
#ifdef BUILD_X11
|
||||
//reset color when scroll is finished
|
||||
if (output_methods & TO_X)
|
||||
if (out_to_x.get(*state))
|
||||
new_special(p + strlen(p), FG)->arg = sd->resetcolor;
|
||||
#endif
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ void new_gauge_in_x11(struct text_object *obj, char *buf, double usage)
|
||||
struct special_t *s = 0;
|
||||
struct gauge *g = (struct gauge *)obj->special_data;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!g)
|
||||
@ -305,7 +305,7 @@ void new_gauge(struct text_object *obj, char *p, int p_max_size, double usage)
|
||||
usage = MIN(g->scale, usage);
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X)
|
||||
if (out_to_x.get(*state))
|
||||
new_gauge_in_x11(obj, p, usage);
|
||||
else
|
||||
#endif /* BUILD_X11 */
|
||||
@ -318,7 +318,7 @@ void new_font(struct text_object *obj, char *p, int p_max_size)
|
||||
struct special_t *s;
|
||||
int tmp = selected_font;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!p_max_size)
|
||||
@ -372,7 +372,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
||||
struct special_t *s = 0;
|
||||
struct graph *g = (struct graph *)obj->special_data;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!g || !buf_max_size)
|
||||
@ -418,7 +418,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size, double val)
|
||||
|
||||
void new_hr(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!p_max_size)
|
||||
@ -453,7 +453,7 @@ void new_stippled_hr(struct text_object *obj, char *p, int p_max_size)
|
||||
struct special_t *s = 0;
|
||||
struct stippled_hr *sh = (struct stippled_hr *)obj->special_data;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!sh || !p_max_size)
|
||||
@ -469,7 +469,7 @@ void new_stippled_hr(struct text_object *obj, char *p, int p_max_size)
|
||||
void new_fg(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
#ifdef BUILD_X11
|
||||
if (output_methods & TO_X)
|
||||
if (out_to_x.get(*state))
|
||||
new_special(p, FG)->arg = obj->data.l;
|
||||
#endif /* BUILD_X11 */
|
||||
#ifdef BUILD_NCURSES
|
||||
@ -484,7 +484,7 @@ void new_fg(struct text_object *obj, char *p, int p_max_size)
|
||||
#ifdef BUILD_X11
|
||||
void new_bg(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!p_max_size)
|
||||
@ -526,7 +526,7 @@ static void new_bar_in_x11(struct text_object *obj, char *buf, double usage)
|
||||
struct special_t *s = 0;
|
||||
struct bar *b = (struct bar *)obj->special_data;
|
||||
|
||||
if ((output_methods & TO_X) == 0)
|
||||
if (not out_to_x.get(*state))
|
||||
return;
|
||||
|
||||
if (!b)
|
||||
@ -555,7 +555,7 @@ void new_bar(struct text_object *obj, char *p, int p_max_size, double usage)
|
||||
usage = MIN(b->scale, usage);
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if ((output_methods & TO_X))
|
||||
if (out_to_x.get(*state))
|
||||
new_bar_in_x11(obj, p, usage);
|
||||
else
|
||||
#endif /* BUILD_X11 */
|
||||
|
@ -927,3 +927,4 @@ conky::lua_traits<alignment>::Map conky::lua_traits<alignment>::map = {
|
||||
};
|
||||
conky::config_setting<alignment> text_alignment("alignment", conky::simple_accessors<alignment>(NONE, false));
|
||||
|
||||
conky::config_setting<bool> out_to_x("out_to_x", conky::simple_accessors<bool>(false, false));
|
||||
|
Loading…
Reference in New Issue
Block a user