1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

Make border_{inner,outer}_margin a lua setting

This commit is contained in:
Pavel Labath 2010-04-22 21:59:12 +02:00
parent 00e91d8c31
commit 96c966b7a6
4 changed files with 34 additions and 39 deletions

View File

@ -979,8 +979,8 @@ static void update_text_area(void)
x += workarea[0];
y += workarea[1];
long border_total = window.border_inner_margin
+ window.border_outer_margin + window.border_width;
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
text_start_x = text_start_y = border_total;
window.x = x - border_total;
window.y = y - border_total;
@ -1740,11 +1740,12 @@ static void draw_text(void)
CapButt, JoinMiter);
}
int inner_margin = border_inner_margin.get(*state);
XDrawRectangle(display, window.drawable, window.gc,
text_start_x - window.border_inner_margin - window.border_width,
text_start_y - window.border_inner_margin - window.border_width,
text_width + window.border_inner_margin * 2 + window.border_width * 2,
text_height + window.border_inner_margin * 2 + window.border_width * 2);
text_start_x - inner_margin - window.border_width,
text_start_y - inner_margin - window.border_width,
text_width + inner_margin * 2 + window.border_width * 2,
text_height + inner_margin * 2 + window.border_width * 2);
}
/* draw text */
@ -1840,8 +1841,8 @@ static void clear_text(int exposures)
#endif
if (display && window.window) { // make sure these are !null
/* there is some extra space for borders and outlines */
long border_total = window.border_inner_margin
+ window.border_outer_margin + window.border_width;
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
XClearArea(display, window.window, text_start_x - border_total,
text_start_y - border_total, text_width + 2*border_total,
@ -1964,8 +1965,8 @@ static void main_loop(void)
update_text_area();
#if defined(OWN_WINDOW) || defined(BUILD_XDBE)
long border_total = window.border_inner_margin
+ window.border_outer_margin + window.border_width;
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
#endif
#ifdef OWN_WINDOW
if (own_window.get(*state)) {
@ -2110,8 +2111,10 @@ static void main_loop(void)
}
}
text_width = window.width - window.border_inner_margin * 2 - window.border_outer_margin * 2 - window.border_width * 2;
text_height = window.height - window.border_inner_margin * 2 - window.border_outer_margin * 2 - window.border_width * 2;
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
text_width = window.width - 2*border_total;
text_height = window.height - 2*border_total;
if (text_width > maximum_width
&& maximum_width > 0) {
text_width = maximum_width;
@ -2205,8 +2208,8 @@ static void main_loop(void)
if (use_xdbe) {
XRectangle r;
long border_total = window.border_inner_margin
+ window.border_outer_margin + window.border_width;
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
r.x = text_start_x - border_total;
r.y = text_start_y - border_total;
r.width = text_width + 2*border_total;
@ -2363,8 +2366,8 @@ static void reload_config(void)
#ifdef BUILD_X11
void clean_up_x11() {
if(window_created == 1) {
long border_total = window.border_inner_margin
+ window.border_outer_margin + window.border_width;
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
XClearArea(display, window.window, text_start_x - border_total,
text_start_y - border_total, text_width + 2*border_total,
text_height + 2*border_total, 0);
@ -2564,8 +2567,6 @@ static void set_default_configurations(void)
minimum_height = 5;
maximum_width = 0;
stippled_borders = 0;
window.border_inner_margin = 3;
window.border_outer_margin = 1;
window.border_width = 1;
#endif /* BUILD_X11 */
@ -2618,8 +2619,9 @@ static bool append_works(const char *path)
static void X11_create_window(void)
{
if (out_to_x.get(*state)) {
init_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,
long border_total = border_inner_margin.get(*state)
+ border_outer_margin.get(*state) + window.border_width;
init_window(text_width + 2*border_total, text_height + 2*border_total,
argv_copy, argc_copy);
setup_fonts();
load_fonts();
@ -2751,22 +2753,6 @@ char load_config_file(const char *f)
// start the whole if-then-else-if cascade
if (false) {}
#ifdef BUILD_X11
CONF("border_inner_margin") {
if (value) {
window.border_inner_margin = strtol(value, 0, 0);
if (window.border_inner_margin < 0) window.border_inner_margin = 0;
} else {
CONF_ERR;
}
}
CONF("border_outer_margin") {
if (value) {
window.border_outer_margin = strtol(value, 0, 0);
if (window.border_outer_margin < 0) window.border_outer_margin = 0;
} else {
CONF_ERR;
}
}
CONF("border_width") {
if (value) {
window.border_width = strtol(value, 0, 0);

View File

@ -465,8 +465,8 @@ void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
llua_set_number("width", window.width);
llua_set_number("height", window.height);
llua_set_number("border_inner_margin", window.border_inner_margin);
llua_set_number("border_outer_margin", window.border_outer_margin);
llua_set_number("border_inner_margin", border_inner_margin.get(*state));
llua_set_number("border_outer_margin", border_outer_margin.get(*state));
llua_set_number("border_width", window.border_width);
llua_set_number("text_start_x", text_start_x);

View File

@ -205,6 +205,12 @@ 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);
conky::range_config_setting<int> border_inner_margin("border_inner_margin", 0,
std::numeric_limits<int>::max(), 3, true);
conky::range_config_setting<int> border_outer_margin("border_outer_margin", 0,
std::numeric_limits<int>::max(), 1, true);
#ifdef BUILD_XFT
conky::simple_config_setting<bool> use_xft("use_xft", false, false);
#endif

View File

@ -72,7 +72,7 @@ struct conky_window {
Visual *visual;
Colormap colourmap;
GC gc;
long border_inner_margin, border_outer_margin, border_width;
long border_width;
#ifdef BUILD_XDBE
XdbeBackBuffer back_buffer;
@ -184,6 +184,9 @@ extern priv::colour_setting default_color;
extern priv::colour_setting default_shade_color;
extern priv::colour_setting default_outline_color;
extern conky::range_config_setting<int> border_inner_margin;
extern conky::range_config_setting<int> border_outer_margin;
#ifdef BUILD_XFT
extern conky::simple_config_setting<bool> use_xft;
#endif