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

Make display a lua setting

This commit is contained in:
Pavel Labath 2010-03-04 18:31:28 +01:00
parent 70d53b770f
commit fe9c0609cc
3 changed files with 13 additions and 19 deletions

View File

@ -308,9 +308,6 @@ struct _x11_stuff_s {
static int text_start_x, text_start_y; /* text start position in window */
static int text_width = 1, text_height = 1; /* initially 1 so no zero-sized window is created */
/* display to connect to */
static char *disp = NULL;
#endif /* BUILD_X11 */
/* struct that has all info to be shared between
@ -2246,7 +2243,6 @@ static void main_loop(void)
XFixesDestroyRegion(display, x11_stuff.region2);
XFixesDestroyRegion(display, x11_stuff.part);
#endif /* BUILD_XDAMAGE */
free_and_zero(disp);
}
#endif /* BUILD_X11 */
free_and_zero(overwrite_file);
@ -2662,7 +2658,7 @@ static void X11_initialisation(void)
if (x_initialised == YES) return;
state->pushboolean(true);
out_to_x.lua_set(*state);
init_X11(disp);
init_X11();
set_default_configurations_for_x();
x_initialised = YES;
#ifdef DEBUG
@ -2811,14 +2807,6 @@ char load_config_file(const char *f)
}
#ifdef BUILD_X11
CONF("display") {
if (!value || x_initialised == YES) {
CONF_ERR;
} else {
free_and_zero(disp);
disp = strdup(value);
}
}
CONF("background") {
fork_to_background = string_to_bool(value);
}
@ -3850,6 +3838,10 @@ void initialisation(int argc, char **argv) {
state->pushstring(optarg);
text_alignment.lua_set(*state);
break;
case 'X':
state->pushstring(optarg);
display_name.lua_set(*state);
break;
#ifdef OWN_WINDOW
case 'o':
@ -4051,10 +4043,6 @@ int main(int argc, char **argv)
case 'w':
window.window = strtol(optarg, 0, 0);
break;
case 'X':
free_and_zero(disp);
disp = strdup(optarg);
break;
#endif /* BUILD_X11 */
case '?':

View File

@ -75,9 +75,12 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop);
static Window find_subwindow(Window win, int w, int h);
/* X11 initializer */
void init_X11(const char *disp)
void init_X11()
{
if (!display) {
const std::string &dispstr = display_name.get(*state).c_str();
// passing NULL to XOpenDisplay should open the default display
const char *disp = dispstr.size() ? dispstr.c_str() : NULL;
if ((display = XOpenDisplay(disp)) == NULL) {
CRIT_ERR(NULL, NULL, "can't open display: %s", XDisplayName(disp));
}
@ -941,6 +944,8 @@ conky::simple_config_setting<alignment> text_alignment("alignment", NONE, false)
conky::simple_config_setting<bool> out_to_x("out_to_x", false, false);
conky::simple_config_setting<std::string> display_name("display", std::string(), false);
#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

@ -111,7 +111,7 @@ extern int workarea[4];
extern struct conky_window window;
extern char window_created;
void init_X11(const char*);
void init_X11();
void init_window(int width, int height, char **argv, int argc);
void destroy_window(void);
void create_gc(void);
@ -146,6 +146,7 @@ enum alignment {
extern conky::simple_config_setting<alignment> text_alignment;
extern conky::simple_config_setting<bool> out_to_x;
extern conky::simple_config_setting<std::string> display_name;
#ifdef OWN_WINDOW
extern conky::simple_config_setting<bool> own_window;