From 2b5bb2c34c2fe25cea3c7743e6f9d6468caf0874 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 2 Oct 2009 16:42:31 +0200 Subject: [PATCH] window: add border_color property Signed-off-by: Julien Danjou --- objects/client.c | 19 ------------------- objects/client.h | 1 - objects/wibox.c | 45 +-------------------------------------------- objects/wibox.h | 2 -- objects/window.c | 26 ++++++++++++++++++++++++++ objects/window.h | 4 +++- 6 files changed, 30 insertions(+), 67 deletions(-) diff --git a/objects/client.c b/objects/client.c index 33f9ba2dd..1fd39c889 100644 --- a/objects/client.c +++ b/objects/client.c @@ -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, diff --git a/objects/client.h b/objects/client.h index 1510f6f15..edf06d373 100644 --- a/objects/client.h +++ b/objects/client.h @@ -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 */ diff --git a/objects/wibox.c b/objects/wibox.c index 28a3e6bec..b286c38b2 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -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, diff --git a/objects/wibox.h b/objects/wibox.h index 19e094d8c..1134006ff 100644 --- a/objects/wibox.h +++ b/objects/wibox.h @@ -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 */ diff --git a/objects/window.c b/objects/window.c index 3f19e397d..d4c699f3a 100644 --- a/objects/window.c +++ b/objects/window.c @@ -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 diff --git a/objects/window.h b/objects/window.h index ddff9ebda..3a93ae5f7 100644 --- a/objects/window.h +++ b/objects/window.h @@ -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