From d328904d30634f41d79042ff2a3b59e5bed43815 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 1 Jul 2008 14:17:07 +0200 Subject: [PATCH] tag: use index for nmaster Signed-off-by: Julien Danjou --- common/tokenize.gperf | 1 + lib/awful.lua | 4 ++-- tag.c | 54 +++++++++---------------------------------- 3 files changed, 14 insertions(+), 45 deletions(-) diff --git a/common/tokenize.gperf b/common/tokenize.gperf index 27de170e3..eb457886f 100644 --- a/common/tokenize.gperf +++ b/common/tokenize.gperf @@ -22,6 +22,7 @@ image left line mwfact +nmaster on plot_data_add plot_properties_set diff --git a/lib/awful.lua b/lib/awful.lua index ad51b84f6..f98c64b8a 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -197,7 +197,7 @@ end function P.tag.setnmaster(nmaster) local t = P.tag.selected() if t then - t:nmaster_set(nmaster) + t.nmaster = nmaster end end @@ -206,7 +206,7 @@ end function P.tag.incnmaster(add) local t = P.tag.selected() if t then - t:nmaster_set(t:nmaster_get() + add) + t.nmaster = t.nmaster + add end end diff --git a/tag.c b/tag.c index 10c67f88a..252cf7b23 100644 --- a/tag.c +++ b/tag.c @@ -245,7 +245,6 @@ luaA_tag_add(lua_State *L) } } - (*tag)->screen = screen; tag_append_to_screen(*tag, screen); return 0; } @@ -379,46 +378,6 @@ luaA_tag_ncol_get(lua_State *L) 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. * \param L The Lua VM state. * @@ -524,6 +483,9 @@ luaA_tag_index(lua_State *L) case A_TK_MWFACT: lua_pushnumber(L, (*tag)->mwfact); break; + case A_TK_NMASTER: + lua_pushnumber(L, (*tag)->nmaster); + break; default: return 0; } @@ -542,6 +504,7 @@ luaA_tag_newindex(lua_State *L) tag_t **tag = luaA_checkudata(L, 1, "tag"); const char *attr = luaL_checklstring(L, 2, &len); double d; + int i; switch(a_tokenize(attr, len)) { @@ -555,6 +518,13 @@ luaA_tag_newindex(lua_State *L) else luaL_error(L, "bad value, must be between 0 and 1"); 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: return 0; } @@ -578,8 +548,6 @@ const struct luaL_reg awesome_tag_meta[] = { "add", luaA_tag_add }, { "ncol_set", luaA_tag_ncol_set }, { "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_set", luaA_tag_name_set }, { "layout_get", luaA_tag_layout_get },