tag: use index for nmaster

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-01 14:17:07 +02:00
parent ef7379c983
commit d328904d30
3 changed files with 14 additions and 45 deletions

View File

@ -22,6 +22,7 @@ image
left left
line line
mwfact mwfact
nmaster
on on
plot_data_add plot_data_add
plot_properties_set plot_properties_set

View File

@ -197,7 +197,7 @@ end
function P.tag.setnmaster(nmaster) function P.tag.setnmaster(nmaster)
local t = P.tag.selected() local t = P.tag.selected()
if t then if t then
t:nmaster_set(nmaster) t.nmaster = nmaster
end end
end end
@ -206,7 +206,7 @@ end
function P.tag.incnmaster(add) function P.tag.incnmaster(add)
local t = P.tag.selected() local t = P.tag.selected()
if t then if t then
t:nmaster_set(t:nmaster_get() + add) t.nmaster = t.nmaster + add
end end
end end

54
tag.c
View File

@ -245,7 +245,6 @@ luaA_tag_add(lua_State *L)
} }
} }
(*tag)->screen = screen;
tag_append_to_screen(*tag, screen); tag_append_to_screen(*tag, screen);
return 0; return 0;
} }
@ -379,46 +378,6 @@ luaA_tag_ncol_get(lua_State *L)
return 1; return 1;
} }
/** Set the number of master windows. This is used in various layouts to
* determine how many windows are in the master area.
* \param L The Lua VM state.
*
* \luastack
* \lvalue A tag.
* \lparam The number of master windows.
*/
static int
luaA_tag_nmaster_set(lua_State *L)
{
tag_t **tag = luaA_checkudata(L, 1, "tag");
int nmaster = luaL_checknumber(L, 2);
if(nmaster >= 0)
{
(*tag)->nmaster = nmaster;
globalconf.screens[(*tag)->screen].need_arrange = true;
}
else
luaL_error(L, "bad value, must be greater than 0");
return 0;
}
/** Get the number of master windows of the tag.
* \param L The Lua VM state.
*
* \luastack
* \lvalue A tag.
* \lreturn The number of master windows.
*/
static int
luaA_tag_nmaster_get(lua_State *L)
{
tag_t **tag = luaA_checkudata(L, 1, "tag");
lua_pushnumber(L, (*tag)->nmaster);
return 1;
}
/** Get the tag name. /** Get the tag name.
* \param L The Lua VM state. * \param L The Lua VM state.
* *
@ -524,6 +483,9 @@ luaA_tag_index(lua_State *L)
case A_TK_MWFACT: case A_TK_MWFACT:
lua_pushnumber(L, (*tag)->mwfact); lua_pushnumber(L, (*tag)->mwfact);
break; break;
case A_TK_NMASTER:
lua_pushnumber(L, (*tag)->nmaster);
break;
default: default:
return 0; return 0;
} }
@ -542,6 +504,7 @@ luaA_tag_newindex(lua_State *L)
tag_t **tag = luaA_checkudata(L, 1, "tag"); tag_t **tag = luaA_checkudata(L, 1, "tag");
const char *attr = luaL_checklstring(L, 2, &len); const char *attr = luaL_checklstring(L, 2, &len);
double d; double d;
int i;
switch(a_tokenize(attr, len)) switch(a_tokenize(attr, len))
{ {
@ -555,6 +518,13 @@ luaA_tag_newindex(lua_State *L)
else else
luaL_error(L, "bad value, must be between 0 and 1"); luaL_error(L, "bad value, must be between 0 and 1");
break; break;
case A_TK_NMASTER:
i = luaL_checknumber(L, 3);
if(i >= 0)
(*tag)->nmaster = i;
else
luaL_error(L, "bad value, must be greater than 0");
break;
default: default:
return 0; return 0;
} }
@ -578,8 +548,6 @@ const struct luaL_reg awesome_tag_meta[] =
{ "add", luaA_tag_add }, { "add", luaA_tag_add },
{ "ncol_set", luaA_tag_ncol_set }, { "ncol_set", luaA_tag_ncol_set },
{ "ncol_get", luaA_tag_ncol_get }, { "ncol_get", luaA_tag_ncol_get },
{ "nmaster_set", luaA_tag_nmaster_set },
{ "nmaster_get", luaA_tag_nmaster_get },
{ "name_get", luaA_tag_name_get }, { "name_get", luaA_tag_name_get },
{ "name_set", luaA_tag_name_set }, { "name_set", luaA_tag_name_set },
{ "layout_get", luaA_tag_layout_get }, { "layout_get", luaA_tag_layout_get },