Get rid of the color name, and generate a #RGBA value on the fly if needed.
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
924078c898
commit
46ea7c45aa
2
client.c
2
client.c
|
@ -1280,7 +1280,7 @@ luaA_client_index(lua_State *L)
|
||||||
lua_pushnumber(L, (*c)->border);
|
lua_pushnumber(L, (*c)->border);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_COLOR:
|
case A_TK_BORDER_COLOR:
|
||||||
lua_pushstring(L, (*c)->border_color.name);
|
luaA_pushcolor(L, &(*c)->border_color);
|
||||||
break;
|
break;
|
||||||
case A_TK_COORDS:
|
case A_TK_COORDS:
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
|
@ -427,8 +427,8 @@ draw_setup_cairo_color_source(draw_context_t *ctx, area_t rect,
|
||||||
const xcolor_t *pcolor_end)
|
const xcolor_t *pcolor_end)
|
||||||
{
|
{
|
||||||
cairo_pattern_t *pat = NULL;
|
cairo_pattern_t *pat = NULL;
|
||||||
bool has_center = pcolor_center->name[0] != '\0';
|
bool has_center = pcolor_center->initialized;
|
||||||
bool has_end = pcolor_end->name[0] != '\0';
|
bool has_end = pcolor_end->initialized;
|
||||||
|
|
||||||
/* no need for a real pattern: */
|
/* no need for a real pattern: */
|
||||||
if(!has_end && !has_center)
|
if(!has_end && !has_center)
|
||||||
|
@ -1151,7 +1151,7 @@ xcolor_init(xcolor_t *color, xcb_connection_t *conn, int phys_screen,
|
||||||
color->green = hexa_color->green;
|
color->green = hexa_color->green;
|
||||||
color->blue = hexa_color->blue;
|
color->blue = hexa_color->blue;
|
||||||
color->alpha = alpha;
|
color->alpha = alpha;
|
||||||
a_strcpy(color->name, sizeof(color->name), colstr);
|
color->initialized = true;
|
||||||
p_delete(&hexa_color);
|
p_delete(&hexa_color);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1173,7 @@ xcolor_init(xcolor_t *color, xcb_connection_t *conn, int phys_screen,
|
||||||
color->blue = named_color->visual_blue;
|
color->blue = named_color->visual_blue;
|
||||||
color->alpha = 0xffff;
|
color->alpha = 0xffff;
|
||||||
color->alpha = alpha;
|
color->alpha = alpha;
|
||||||
a_strcpy(color->name, sizeof(color->name), colstr);
|
color->initialized = true;
|
||||||
p_delete(&named_color);
|
p_delete(&named_color);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,7 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Color name */
|
unsigned initialized : 1;
|
||||||
char name[32];
|
|
||||||
uint32_t pixel;
|
uint32_t pixel;
|
||||||
uint16_t red;
|
uint16_t red;
|
||||||
uint16_t green;
|
uint16_t green;
|
||||||
|
|
10
lua.c
10
lua.c
|
@ -653,3 +653,13 @@ luaA_on_timer(EV_P_ ev_timer *w, int revents)
|
||||||
{
|
{
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.timer, 0);
|
luaA_dofunction(globalconf.L, globalconf.hooks.timer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
luaA_pushcolor(lua_State *L, const xcolor_t *c)
|
||||||
|
{
|
||||||
|
uint8_t r = (unsigned)c->red * 0xff / 0xffff;
|
||||||
|
uint8_t g = (unsigned)c->green * 0xff / 0xffff;
|
||||||
|
uint8_t b = (unsigned)c->blue * 0xff / 0xffff;
|
||||||
|
uint8_t a = (unsigned)c->alpha * 0xff / 0xffff;
|
||||||
|
lua_pushfstring(L, "#%02x%02x%02x%02x", r, g, b, a);
|
||||||
|
}
|
||||||
|
|
2
lua.h
2
lua.h
|
@ -27,6 +27,7 @@
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
#include "common/draw.h"
|
||||||
|
|
||||||
/** Object types */
|
/** Object types */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -194,6 +195,7 @@ void luaA_pushpointer(lua_State *, void *, awesome_type_t);
|
||||||
void luaA_cs_init(void);
|
void luaA_cs_init(void);
|
||||||
void luaA_cs_cleanup(void);
|
void luaA_cs_cleanup(void);
|
||||||
void luaA_on_timer(EV_P_ ev_timer *w, int revents);
|
void luaA_on_timer(EV_P_ ev_timer *w, int revents);
|
||||||
|
void luaA_pushcolor(lua_State *, const xcolor_t *c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
|
@ -516,10 +516,10 @@ luaA_statusbar_index(lua_State *L)
|
||||||
lua_pushstring(L, draw_align_tostr((*statusbar)->align));
|
lua_pushstring(L, draw_align_tostr((*statusbar)->align));
|
||||||
break;
|
break;
|
||||||
case A_TK_FG:
|
case A_TK_FG:
|
||||||
lua_pushstring(L, (*statusbar)->colors.fg.name);
|
luaA_pushcolor(L, &(*statusbar)->colors.fg);
|
||||||
break;
|
break;
|
||||||
case A_TK_BG:
|
case A_TK_BG:
|
||||||
lua_pushstring(L, (*statusbar)->colors.bg.name);
|
luaA_pushcolor(L, &(*statusbar)->colors.bg);
|
||||||
break;
|
break;
|
||||||
case A_TK_POSITION:
|
case A_TK_POSITION:
|
||||||
lua_pushstring(L, position_tostr((*statusbar)->position));
|
lua_pushstring(L, position_tostr((*statusbar)->position));
|
||||||
|
|
|
@ -538,13 +538,13 @@ luaA_titlebar_index(lua_State *L)
|
||||||
lua_pushnumber(L, (*titlebar)->border.width);
|
lua_pushnumber(L, (*titlebar)->border.width);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_COLOR:
|
case A_TK_BORDER_COLOR:
|
||||||
lua_pushstring(L, (*titlebar)->border.color.name);
|
luaA_pushcolor(L, &(*titlebar)->border.color);
|
||||||
break;
|
break;
|
||||||
case A_TK_FG:
|
case A_TK_FG:
|
||||||
lua_pushstring(L, (*titlebar)->colors.fg.name);
|
luaA_pushcolor(L, &(*titlebar)->colors.fg);
|
||||||
break;
|
break;
|
||||||
case A_TK_BG:
|
case A_TK_BG:
|
||||||
lua_pushstring(L, (*titlebar)->colors.bg.name);
|
luaA_pushcolor(L, &(*titlebar)->colors.bg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -443,10 +443,10 @@ luaA_graph_index(lua_State *L, awesome_token_t token)
|
||||||
lua_pushnumber(L, d->width);
|
lua_pushnumber(L, d->width);
|
||||||
break;
|
break;
|
||||||
case A_TK_BORDER_COLOR:
|
case A_TK_BORDER_COLOR:
|
||||||
lua_pushstring(L, d->border_color.name);
|
luaA_pushcolor(L, &d->border_color);
|
||||||
break;
|
break;
|
||||||
case A_TK_BG:
|
case A_TK_BG:
|
||||||
lua_pushstring(L, d->bg.name);
|
luaA_pushcolor(L, &d->bg);
|
||||||
break;
|
break;
|
||||||
case A_TK_GROW:
|
case A_TK_GROW:
|
||||||
switch(d->grow)
|
switch(d->grow)
|
||||||
|
|
Loading…
Reference in New Issue