tag: remove mwfact_{get,set}, use {new,}index
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f750124d5c
commit
ef7379c983
|
@ -67,7 +67,7 @@ for s = 1, screen.count() do
|
|||
for tagnumber = 1, 9 do
|
||||
tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
|
||||
-- Add tags to screen one by one
|
||||
tags[s][tagnumber]:mwfact_set(0.618033988769)
|
||||
tags[s][tagnumber].mwfact = 0.618033988769
|
||||
tags[s][tagnumber]:add(s)
|
||||
end
|
||||
-- I'm sure you want to see at least one tag.
|
||||
|
|
|
@ -21,6 +21,7 @@ height
|
|||
image
|
||||
left
|
||||
line
|
||||
mwfact
|
||||
on
|
||||
plot_data_add
|
||||
plot_properties_set
|
||||
|
|
|
@ -179,7 +179,7 @@ end
|
|||
function P.tag.setmwfact(mwfact)
|
||||
local t = P.tag.selected()
|
||||
if t then
|
||||
t:mwfact_set(mwfact)
|
||||
t.mwfact = mwfact
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -188,7 +188,7 @@ end
|
|||
function P.tag.incmwfact(add)
|
||||
local t = P.tag.selected()
|
||||
if t then
|
||||
t:mwfact_set(t:mwfact_get() + add)
|
||||
t.mwfact = t.mwfact + add
|
||||
end
|
||||
end
|
||||
|
||||
|
|
64
tag.c
64
tag.c
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include "layoutgen.h"
|
||||
|
||||
#define TAG_SCREEN_UNDEF (-1)
|
||||
|
||||
extern awesome_t globalconf;
|
||||
|
||||
DO_LUA_NEW(extern, tag_t, tag, "tag", tag_ref)
|
||||
|
@ -69,6 +71,9 @@ tag_new(const char *name, layout_t *layout, double mwfact, int nmaster, int ncol
|
|||
a_iso2utf8(name, &tag->name);
|
||||
tag->layout = layout;
|
||||
|
||||
/* to avoid error */
|
||||
tag->screen = TAG_SCREEN_UNDEF;
|
||||
|
||||
tag->mwfact = mwfact;
|
||||
if(tag->mwfact <= 0 || tag->mwfact >= 1)
|
||||
tag->mwfact = 0.5;
|
||||
|
@ -175,7 +180,8 @@ tags_get_current(int screen)
|
|||
static void
|
||||
tag_view_only(tag_t *target)
|
||||
{
|
||||
if (target) {
|
||||
if (target)
|
||||
{
|
||||
tag_array_t *tags = &globalconf.screens[target->screen].tags;
|
||||
|
||||
for(int i = 0; i < tags->len; i++)
|
||||
|
@ -333,46 +339,6 @@ luaA_tag_new(lua_State *L)
|
|||
return luaA_tag_userdata_new(L, tag);
|
||||
}
|
||||
|
||||
/** Set the tag master width factor. This value is used in various layouts to
|
||||
* determine the size of the master window.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lvalue A tag.
|
||||
* \lparam The master width ratio value, between 0 and 1.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_mwfact_set(lua_State *L)
|
||||
{
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
double mwfact = luaL_checknumber(L, 2);
|
||||
|
||||
if(mwfact < 1 && mwfact > 0)
|
||||
{
|
||||
(*tag)->mwfact = mwfact;
|
||||
globalconf.screens[(*tag)->screen].need_arrange = true;
|
||||
}
|
||||
else
|
||||
luaL_error(L, "bad value, must be between 0 and 1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get the tag master width factor.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lvalue A tag.
|
||||
* \lreturn The master width ratio value.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_mwfact_get(lua_State *L)
|
||||
{
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
lua_pushnumber(L, (*tag)->mwfact);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Set the number of columns. This is used in various layouts to set the number
|
||||
* of columns used to display non-master windows.
|
||||
* \param L The Lua VM state.
|
||||
|
@ -555,6 +521,9 @@ luaA_tag_index(lua_State *L)
|
|||
case A_TK_SELECTED:
|
||||
lua_pushboolean(L, (*tag)->selected);
|
||||
break;
|
||||
case A_TK_MWFACT:
|
||||
lua_pushnumber(L, (*tag)->mwfact);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -572,16 +541,27 @@ luaA_tag_newindex(lua_State *L)
|
|||
size_t len;
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
const char *attr = luaL_checklstring(L, 2, &len);
|
||||
double d;
|
||||
|
||||
switch(a_tokenize(attr, len))
|
||||
{
|
||||
case A_TK_SELECTED:
|
||||
tag_view(*tag, luaA_checkboolean(L, 3));
|
||||
return 0;
|
||||
case A_TK_MWFACT:
|
||||
d = luaL_checknumber(L, 3);
|
||||
if(d > 0 && d < 1)
|
||||
(*tag)->mwfact = d;
|
||||
else
|
||||
luaL_error(L, "bad value, must be between 0 and 1");
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if((*tag)->screen != TAG_SCREEN_UNDEF)
|
||||
globalconf.screens[(*tag)->screen].need_arrange = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -596,8 +576,6 @@ const struct luaL_reg awesome_tag_methods[] =
|
|||
const struct luaL_reg awesome_tag_meta[] =
|
||||
{
|
||||
{ "add", luaA_tag_add },
|
||||
{ "mwfact_set", luaA_tag_mwfact_set },
|
||||
{ "mwfact_get", luaA_tag_mwfact_get },
|
||||
{ "ncol_set", luaA_tag_ncol_set },
|
||||
{ "ncol_get", luaA_tag_ncol_get },
|
||||
{ "nmaster_set", luaA_tag_nmaster_set },
|
||||
|
|
Loading…
Reference in New Issue