client: merge border_set into index

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-01 20:07:21 +02:00
parent 2b1101daee
commit b9e8307f60
3 changed files with 26 additions and 35 deletions

View File

@ -284,25 +284,25 @@ end
-- Hook function to execute when focusing a client. -- Hook function to execute when focusing a client.
function hook_focus(c) function hook_focus(c)
if not awful.client.ismarked(c) then if not awful.client.ismarked(c) then
c:border_set({ width = border_width, color = border_focus }) c.border_color = border_focus
end end
end end
-- Hook function to execute when unfocusing a client. -- Hook function to execute when unfocusing a client.
function hook_unfocus(c) function hook_unfocus(c)
if not awful.client.ismarked(c) then if not awful.client.ismarked(c) then
c:border_set({ width = border_width, color = border_normal }) c.border_color = border_normal
end end
end end
-- Hook function to execute when marking a client -- Hook function to execute when marking a client
function hook_marked(c) function hook_marked(c)
c:border_set({ width = border_width, color = border_marked }) c.border_color = border_marked
end end
-- Hook function to execute when unmarking a client -- Hook function to execute when unmarking a client
function hook_unmarked(c) function hook_unmarked(c)
c:border_set({ width = border_width, color = border_focus }) c.border_color = border_focus
end end
-- Hook function to execute when the mouse is over a client. -- Hook function to execute when the mouse is over a client.
@ -321,7 +321,8 @@ function hook_manage(c)
c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end)) c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
-- New client may not receive focus -- New client may not receive focus
-- if they're not focusable, so set border anyway. -- if they're not focusable, so set border anyway.
c:border_set({ width = border_width, color = border_normal }) c.border_width = border_width
c.border_color = border_normal
c:focus_set() c:focus_set()
if floatings[c.name:lower()] then if floatings[c.name:lower()] then
c.floating = true c.floating = true

View File

@ -969,34 +969,6 @@ client_setborder(client_t *c, int width)
globalconf.screens[c->screen].need_arrange = true; globalconf.screens[c->screen].need_arrange = true;
} }
/** Set the client border width and color.
* \param L The Lua VM state.
* \luastack
* \lvalue A client.
* \lparam A table with `width' key for the border width in pixel and `color' key
* for the border color.
*/
static int
luaA_client_border_set(lua_State *L)
{
client_t **c = luaA_checkudata(L, 1, "client");
int width = luaA_getopt_number(L, 2, "width", (*c)->border);
const char *colorstr = luaA_getopt_string(L, 2, "color", NULL);
xcolor_t color;
client_setborder(*c, width);
if(colorstr
&& xcolor_new(globalconf.connection, (*c)->phys_screen, colorstr, &color))
{
xcb_change_window_attributes(globalconf.connection, (*c)->win, XCB_CW_BORDER_PIXEL,
&color.pixel);
xcolor_wipe(&color);
}
return 0;
}
/** Move the client to another screen. /** Move the client to another screen.
* \param L The Lua VM state. * \param L The Lua VM state.
* \luastack * \luastack
@ -1327,6 +1299,7 @@ luaA_client_newindex(lua_State *L)
const char *buf = luaL_checklstring(L, 2, &len); const char *buf = luaL_checklstring(L, 2, &len);
bool b; bool b;
double d; double d;
xcolor_t color;
switch(a_tokenize(buf, len)) switch(a_tokenize(buf, len))
{ {
@ -1360,10 +1333,22 @@ luaA_client_newindex(lua_State *L)
client_setfloating(*c, luaA_checkboolean(L, 3)); client_setfloating(*c, luaA_checkboolean(L, 3));
break; break;
case A_TK_HONORSIZEHINTS: case A_TK_HONORSIZEHINTS:
(*c)->honorsizehints = true; (*c)->honorsizehints = luaA_checkboolean(L, 3);
if(client_isvisible(*c, (*c)->screen)) if(client_isvisible(*c, (*c)->screen))
globalconf.screens[(*c)->screen].need_arrange = true; globalconf.screens[(*c)->screen].need_arrange = true;
break; break;
case A_TK_BORDER_WIDTH:
client_setborder(*c, luaL_checknumber(L, 3));
break;
case A_TK_BORDER_COLOR:
if((buf = luaL_checkstring(L, 3))
&& xcolor_new(globalconf.connection, (*c)->phys_screen, buf, &color))
{
xcolor_wipe(&(*c)->border_color);
(*c)->border_color = color;
xcb_change_window_attributes(globalconf.connection, (*c)->win, XCB_CW_BORDER_PIXEL, &color.pixel);
}
break;
default: default:
return 0; return 0;
} }
@ -1402,6 +1387,11 @@ luaA_client_index(lua_State *L)
case A_TK_HONORSIZEHINTS: case A_TK_HONORSIZEHINTS:
lua_pushboolean(L, (*c)->honorsizehints); lua_pushboolean(L, (*c)->honorsizehints);
break; break;
case A_TK_BORDER_WIDTH:
lua_pushnumber(L, (*c)->border);
break;
case A_TK_BORDER_COLOR:
lua_pushstring(L, (*c)->border_color.name);
default: default:
return 0; return 0;
} }
@ -1423,7 +1413,6 @@ const struct luaL_reg awesome_client_meta[] =
{ "titlebar_get", luaA_client_titlebar_get }, { "titlebar_get", luaA_client_titlebar_get },
{ "screen_set", luaA_client_screen_set }, { "screen_set", luaA_client_screen_set },
{ "screen_get", luaA_client_screen_get }, { "screen_get", luaA_client_screen_get },
{ "border_set", luaA_client_border_set },
{ "tag", luaA_client_tag }, { "tag", luaA_client_tag },
{ "istagged", luaA_client_istagged }, { "istagged", luaA_client_istagged },
{ "coords_get", luaA_client_coords_get }, { "coords_get", luaA_client_coords_get },

View File

@ -250,6 +250,7 @@ struct client_t
/** Respect resize hints */ /** Respect resize hints */
bool honorsizehints; bool honorsizehints;
int border, oldborder; int border, oldborder;
xcolor_t border_color;
/** True if the client does not want any border */ /** True if the client does not want any border */
bool noborder; bool noborder;
/** Has urgency hint */ /** Has urgency hint */