window: add border_color property

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-10-02 16:42:31 +02:00
parent cdd888d6cf
commit 2b5bb2c34c
6 changed files with 30 additions and 67 deletions

View File

@ -1622,20 +1622,6 @@ luaA_client_set_urgent(lua_State *L, client_t *c)
return 0;
}
static int
luaA_client_set_border_color(lua_State *L, client_t *c)
{
size_t len;
const char *buf;
if((buf = luaL_checklstring(L, -1, &len))
&& xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
{
xwindow_set_border_color(c->window, &c->border_color);
luaA_object_emit_signal(L, -3, "property::border_color", 0);
}
return 0;
}
static int
luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
{
@ -1679,7 +1665,6 @@ LUA_OBJECT_EXPORT_PROPERTY(client, client_t, size_hints_honor, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_horizontal, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_width, lua_pushnumber)
LUA_OBJECT_EXPORT_PROPERTY(client, client_t, border_color, luaA_pushxcolor)
static int
luaA_client_get_content(lua_State *L, client_t *c)
@ -2119,10 +2104,6 @@ client_class_setup(lua_State *L)
(lua_class_propfunc_t) luaA_client_set_border_width,
(lua_class_propfunc_t) luaA_client_get_border_width,
(lua_class_propfunc_t) luaA_client_set_border_width);
luaA_class_add_property(&client_class, A_TK_BORDER_COLOR,
(lua_class_propfunc_t) luaA_client_set_border_color,
(lua_class_propfunc_t) luaA_client_get_border_color,
(lua_class_propfunc_t) luaA_client_set_border_color);
luaA_class_add_property(&client_class, A_TK_URGENT,
(lua_class_propfunc_t) luaA_client_set_urgent,
(lua_class_propfunc_t) luaA_client_get_urgent,

View File

@ -81,7 +81,6 @@ struct client_t
} geometries;
/** Border width and pre-fullscreen border width */
int border_width, border_width_fs;
xcolor_t border_color;
/** True if the client is sticky */
bool sticky;
/** Has urgency hint */

View File

@ -347,20 +347,6 @@ wibox_refresh_pixmap_partial(wibox_t *wibox,
w, h);
}
/** Set a wibox border color.
* \param L The Lua VM state.
* \param udx The wibox to change border width.
* \param color The border color.
*/
static void
wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
{
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
xwindow_set_border_color(w->window, &w->border_color);
w->border_color = *color;
luaA_object_emit_signal(L, udx, "property::border_color", 0);
}
/** Set wibox orientation.
* \param L The Lua VM state.
* \param udx The wibox to change orientation.
@ -767,11 +753,7 @@ wibox_attach(lua_State *L, int udx, screen_t *s)
/** Create a new wibox.
* \param L The Lua VM state.
*
* \luastack
* \lparam A table with optionally defined values:
* fg, bg, border_width, border_color, ontop, width and height.
* \lreturn A brand new wibox.
* \return The number of elements pushed on stack.
*/
static int
luaA_wibox_new(lua_State *L)
@ -786,9 +768,6 @@ luaA_wibox_new(lua_State *L)
if(!w->ctx.bg.initialized)
w->ctx.bg = globalconf.colors.bg;
if(!w->border_color.initialized)
w->border_color = globalconf.colors.bg;
w->visible = true;
if(!w->opacity)
@ -878,7 +857,6 @@ LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, ontop, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, cursor, lua_pushstring)
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, visible, lua_pushboolean)
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_width, lua_pushnumber)
LUA_OBJECT_EXPORT_PROPERTY(wibox, wibox_t, border_color, luaA_pushxcolor)
static int
luaA_wibox_set_x(lua_State *L, wibox_t *wibox)
@ -1152,23 +1130,6 @@ luaA_wibox_get_orientation(lua_State *L, wibox_t *wibox)
return 1;
}
/** Set the wibox border color.
* \param L The Lua VM state.
* \param wibox The wibox object.
* \return The number of elements pushed on stack.
*/
static int
luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
{
size_t len;
const char *buf = luaL_checklstring(L, -1, &len);
if(buf)
if(xcolor_init_reply(xcolor_init_unchecked(&wibox->border_color, buf, len)))
if(wibox->window)
wibox_set_border_color(L, -3, &wibox->border_color);
return 0;
}
/** Set the wibox visibility.
* \param L The Lua VM state.
* \param wibox The wibox object.
@ -1303,10 +1264,6 @@ wibox_class_setup(lua_State *L)
(lua_class_propfunc_t) luaA_wibox_set_visible,
(lua_class_propfunc_t) luaA_wibox_get_visible,
(lua_class_propfunc_t) luaA_wibox_set_visible);
luaA_class_add_property(&wibox_class, A_TK_BORDER_COLOR,
(lua_class_propfunc_t) luaA_wibox_set_border_color,
(lua_class_propfunc_t) luaA_wibox_get_border_color,
(lua_class_propfunc_t) luaA_wibox_set_border_color);
luaA_class_add_property(&wibox_class, A_TK_BORDER_WIDTH,
(lua_class_propfunc_t) luaA_wibox_set_border_width,
(lua_class_propfunc_t) luaA_wibox_get_border_width,

View File

@ -55,8 +55,6 @@ struct wibox_t
area_t geometry;
/** The window border width */
uint16_t border_width;
/** The window border color */
xcolor_t border_color;
/** Draw context */
draw_context_t ctx;
/** Orientation */

View File

@ -127,7 +127,29 @@ luaA_window_get_opacity(lua_State *L, window_t *window)
return 0;
}
/** Set the window border color.
* \param L The Lua VM state.
* \param window The window object.
* \return The number of elements pushed on stack.
*/
static int
luaA_window_set_border_color(lua_State *L, window_t *window)
{
size_t len;
const char *color_name = luaL_checklstring(L, -1, &len);
if(color_name &&
xcolor_init_reply(xcolor_init_unchecked(&window->border_color, color_name, len)))
{
xwindow_set_border_color(window->window, &window->border_color);
luaA_object_emit_signal(L, -3, "property::border_color", 0);
}
return 0;
}
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, window, lua_pushnumber)
LUA_OBJECT_EXPORT_PROPERTY(window, window_t, border_color, luaA_pushxcolor)
void
window_class_setup(lua_State *L)
@ -157,6 +179,10 @@ window_class_setup(lua_State *L)
(lua_class_propfunc_t) luaA_window_set_opacity,
(lua_class_propfunc_t) luaA_window_get_opacity,
(lua_class_propfunc_t) luaA_window_set_opacity);
luaA_class_add_property(&window_class, A_TK_BORDER_COLOR,
(lua_class_propfunc_t) luaA_window_set_border_color,
(lua_class_propfunc_t) luaA_window_get_border_color,
(lua_class_propfunc_t) luaA_window_set_border_color);
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -37,7 +37,9 @@
/** Client logical screen */ \
screen_t *screen; \
/** Button bindings */ \
button_array_t buttons;
button_array_t buttons; \
/** Border color */ \
xcolor_t border_color;
/** Window structure */
typedef struct