draw: really copy colors
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
b63f768f00
commit
3ebca2181c
|
@ -205,7 +205,23 @@ static inline void
|
||||||
xcolor_wipe(xcolor_t *color)
|
xcolor_wipe(xcolor_t *color)
|
||||||
{
|
{
|
||||||
if(color)
|
if(color)
|
||||||
|
{
|
||||||
p_delete(&color->name);
|
p_delete(&color->name);
|
||||||
|
p_clear(color, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline xcolor_t
|
||||||
|
xcolor_copy(xcolor_t *color)
|
||||||
|
{
|
||||||
|
xcolor_t c;
|
||||||
|
|
||||||
|
assert(color);
|
||||||
|
|
||||||
|
c = *color;
|
||||||
|
c.name = a_strdup(color->name);
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool xcolor_new(xcb_connection_t *, int, const char *, xcolor_t *);
|
bool xcolor_new(xcb_connection_t *, int, const char *, xcolor_t *);
|
||||||
|
|
|
@ -547,12 +547,12 @@ luaA_statusbar_new(lua_State *L)
|
||||||
if(!(buf = luaA_getopt_string(L, 1, "fg", NULL))
|
if(!(buf = luaA_getopt_string(L, 1, "fg", NULL))
|
||||||
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
buf, &sb->colors.fg))
|
buf, &sb->colors.fg))
|
||||||
sb->colors.fg = globalconf.colors.fg;
|
sb->colors.fg = xcolor_copy(&globalconf.colors.fg);
|
||||||
|
|
||||||
if(!(buf = luaA_getopt_string(L, 1, "bg", NULL))
|
if(!(buf = luaA_getopt_string(L, 1, "bg", NULL))
|
||||||
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
buf, &sb->colors.bg))
|
buf, &sb->colors.bg))
|
||||||
sb->colors.bg = globalconf.colors.bg;
|
sb->colors.bg = xcolor_copy(&globalconf.colors.bg);
|
||||||
|
|
||||||
buf = luaA_getopt_lstring(L, 1, "align", "left", &len);
|
buf = luaA_getopt_lstring(L, 1, "align", "left", &len);
|
||||||
sb->align = draw_align_fromstr(buf, len);
|
sb->align = draw_align_fromstr(buf, len);
|
||||||
|
|
|
@ -317,17 +317,17 @@ luaA_titlebar_new(lua_State *L)
|
||||||
if(!(buf = luaA_getopt_string(L, -1, "fg", NULL))
|
if(!(buf = luaA_getopt_string(L, -1, "fg", NULL))
|
||||||
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
buf, &tb->colors.fg))
|
buf, &tb->colors.fg))
|
||||||
tb->colors.fg = globalconf.colors.fg;
|
tb->colors.fg = xcolor_copy(&globalconf.colors.fg);
|
||||||
|
|
||||||
if(!(buf = luaA_getopt_string(L, -1, "bg", NULL))
|
if(!(buf = luaA_getopt_string(L, -1, "bg", NULL))
|
||||||
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
buf, &tb->colors.bg))
|
buf, &tb->colors.bg))
|
||||||
tb->colors.bg = globalconf.colors.bg;
|
tb->colors.bg = xcolor_copy(&globalconf.colors.bg);
|
||||||
|
|
||||||
if(!(buf = luaA_getopt_string(L, -1, "border_color", NULL))
|
if(!(buf = luaA_getopt_string(L, -1, "border_color", NULL))
|
||||||
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
|
||||||
buf, &tb->border.color))
|
buf, &tb->border.color))
|
||||||
tb->border.color = globalconf.colors.fg;
|
tb->border.color = xcolor_copy(&globalconf.colors.fg);
|
||||||
|
|
||||||
tb->border.width = luaA_getopt_number(L, 1, "border_width", 0);
|
tb->border.width = luaA_getopt_number(L, 1, "border_width", 0);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ graph_plot_add(graph_data_t *d, const char *title)
|
||||||
plot->values = p_new(float, d->size);
|
plot->values = p_new(float, d->size);
|
||||||
plot->lines = p_new(int, d->size);
|
plot->lines = p_new(int, d->size);
|
||||||
plot->max_value = 100.0;
|
plot->max_value = 100.0;
|
||||||
plot->color_start = globalconf.colors.fg;
|
plot->color_start = xcolor_copy(&globalconf.colors.fg);
|
||||||
plot->vertical_gradient = true;
|
plot->vertical_gradient = true;
|
||||||
|
|
||||||
plot_list_append(&d->plots, plot);
|
plot_list_append(&d->plots, plot);
|
||||||
|
@ -596,8 +596,8 @@ graph_new(alignment_t align)
|
||||||
d->draw_from = p_new(int, d->size);
|
d->draw_from = p_new(int, d->size);
|
||||||
d->draw_to = p_new(int, d->size);
|
d->draw_to = p_new(int, d->size);
|
||||||
|
|
||||||
d->bg = globalconf.colors.bg;
|
d->bg = xcolor_copy(&globalconf.colors.bg);
|
||||||
d->border_color = globalconf.colors.fg;
|
d->border_color = xcolor_copy(&globalconf.colors.fg);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,10 +103,10 @@ progressbar_bar_add(progressbar_data_t *d, const char *title)
|
||||||
bar_t *bar = p_new(bar_t, 1);
|
bar_t *bar = p_new(bar_t, 1);
|
||||||
|
|
||||||
bar->title = a_strdup(title);
|
bar->title = a_strdup(title);
|
||||||
bar->fg = globalconf.colors.fg;
|
bar->fg = xcolor_copy(&globalconf.colors.fg);
|
||||||
bar->fg_off = globalconf.colors.bg;
|
bar->fg_off = xcolor_copy(&globalconf.colors.bg);
|
||||||
bar->bg = globalconf.colors.bg;
|
bar->bg = xcolor_copy(&globalconf.colors.bg);
|
||||||
bar->border_color = globalconf.colors.fg;
|
bar->border_color = xcolor_copy(&globalconf.colors.fg);
|
||||||
bar->max_value = 100.0;
|
bar->max_value = 100.0;
|
||||||
|
|
||||||
/* append the bar in the list */
|
/* append the bar in the list */
|
||||||
|
|
Loading…
Reference in New Issue