diff --git a/awesomerc.lua.in b/awesomerc.lua.in
index 12cd522d..ef89235e 100644
--- a/awesomerc.lua.in
+++ b/awesomerc.lua.in
@@ -65,7 +65,7 @@ for s = 1, screen.count() do
tags[s] = {}
-- Create 9 tags per screen
for tagnumber = 1, 9 do
- tags[s][tagnumber] = tag.new({ name = tagnumber, layout = layouts[1] })
+ 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]:add(s)
@@ -77,51 +77,51 @@ end
-- {{{ Statusbar
-- Create a taglist widget
-mytaglist = widget.new({ type = "taglist", name = "mytaglist" })
-mytaglist:mouse_add(mouse.new({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
-mytaglist:mouse_add(mouse.new({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
-mytaglist:mouse_add(mouse.new({}, 3, function (object, tag) tag:view(not tag:isselected()) end))
-mytaglist:mouse_add(mouse.new({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
-mytaglist:mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
-mytaglist:mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
+mytaglist = widget({ type = "taglist", name = "mytaglist" })
+mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
+mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
+mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag:view(not tag:isselected()) end))
+mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
+mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
+mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
mytaglist.text_focus = " "
-- Create a tasklist widget
-mytasklist = widget.new({ type = "tasklist", name = "mytasklist" })
-mytasklist:mouse_add(mouse.new({ }, 1, function (object, c) c:focus_set(); c:raise() end))
-mytasklist:mouse_add(mouse.new({ }, 4, function () awful.client.focus(1) end))
-mytasklist:mouse_add(mouse.new({ }, 5, function () awful.client.focus(-1) end))
+mytasklist = widget({ type = "tasklist", name = "mytasklist" })
+mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
+mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focus(1) end))
+mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focus(-1) end))
mytasklist.text_focus = " "
-- Create a textbox widget
-mytextbox = widget.new({ type = "textbox", name = "mytextbox", align = "right" })
+mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
-- Set the default text in textbox
mytextbox.text = " awesome " .. AWESOME_VERSION .. " "
-mypromptbox = widget.new({ type = "textbox", name = "mypromptbox", align = "left" })
+mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
-- Create an iconbox widget
-myiconbox = widget.new({ type = "textbox", name = "myiconbox", align = "left" })
+myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
myiconbox.text = ""
-- Create a systray
-mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" })
+mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
-- Create an iconbox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox = {}
for s = 1, screen.count() do
- mylayoutbox[s] = widget.new({ type = "textbox", name = "mylayoutbox", align = "right" })
- mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end))
- mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end))
- mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end))
- mylayoutbox[s]:mouse_add(mouse.new({ }, 5, function () awful.layout.inc(layouts, -1) end))
+ mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
+ mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
+ mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
+ mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
+ mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
mylayoutbox[s].text = ""
end
-- Create a statusbar for each screen and add it
mystatusbar = {}
for s = 1, screen.count() do
- mystatusbar[s] = statusbar.new({ position = "top", name = "mystatusbar" .. s,
+ mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s,
fg = fg_normal, bg = bg_normal })
-- Add widgets to the statusbar - order matters
mystatusbar[s]:widget_add(mytaglist)
@@ -136,9 +136,9 @@ mystatusbar[screen.count()]:widget_add(mysystray)
-- }}}
-- {{{ Mouse bindings
-awesome.mouse_add(mouse.new({ }, 3, function () awful.spawn(terminal) end))
-awesome.mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
-awesome.mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
+awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
+awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
+awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
-- }}}
-- {{{ Key bindings
@@ -151,28 +151,28 @@ for s = 1, screen.count() do
end
for i = 1, keynumber do
- keybinding.new({ modkey }, i,
+ keybinding({ modkey }, i,
function ()
local screen = mouse.screen_get()
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end):add()
- keybinding.new({ modkey, "Control" }, i,
+ keybinding({ modkey, "Control" }, i,
function ()
local screen = mouse.screen_get()
if tags[screen][i] then
tags[screen][i]:view(not tags[screen][i]:isselected())
end
end):add()
- keybinding.new({ modkey, "Shift" }, i,
+ keybinding({ modkey, "Shift" }, i,
function ()
local screen = mouse.screen_get()
if tags[screen][i] then
awful.client.movetotag(tags[screen][i])
end
end):add()
- keybinding.new({ modkey, "Control", "Shift" }, i,
+ keybinding({ modkey, "Control", "Shift" }, i,
function ()
local screen = mouse.screen_get()
if tags[screen][i] then
@@ -181,47 +181,47 @@ for i = 1, keynumber do
end):add()
end
-keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
-keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
+keybinding({ modkey }, "Left", awful.tag.viewprev):add()
+keybinding({ modkey }, "Right", awful.tag.viewnext):add()
-- Standard program
-keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
+keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
-keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
-keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
+keybinding({ modkey, "Control" }, "r", awesome.restart):add()
+keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
-- Client manipulation
-keybinding.new({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
-keybinding.new({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
-keybinding.new({ modkey }, "k", function () awful.client.focus(-1); client.focus_get():raise() end):add()
-keybinding.new({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
-keybinding.new({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
-keybinding.new({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
-keybinding.new({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
-keybinding.new({ modkey, "Control" }, "space", awful.client.togglefloating):add()
-keybinding.new({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
-keybinding.new({ modkey }, "o", awful.client.movetoscreen):add()
+keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
+keybinding({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
+keybinding({ modkey }, "k", function () awful.client.focus(-1); client.focus_get():raise() end):add()
+keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
+keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
+keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
+keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
+keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
+keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
+keybinding({ modkey }, "o", awful.client.movetoscreen):add()
-- Layout manipulation
-keybinding.new({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
-keybinding.new({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
-keybinding.new({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
-keybinding.new({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
-keybinding.new({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
-keybinding.new({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
-keybinding.new({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
-keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
+keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
+keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
+keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
+keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
+keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
+keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
+keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
+keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
-- Prompt
-keybinding.new({ modkey }, "F1", function ()
+keybinding({ modkey }, "F1", function ()
awful.prompt({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.spawn, awful.completion.bash)
end):add()
-keybinding.new({ modkey }, "F4", function ()
+keybinding({ modkey }, "F4", function ()
awful.prompt({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.eval, awful.prompt.bash)
end):add()
--- Tabulous, tab manipulation
-keybinding.new({ modkey, "Control" }, "y", function ()
+keybinding({ modkey, "Control" }, "y", function ()
local tabbedview = tabulous.tabindex_get()
local nextclient = awful.client.next(1)
@@ -239,9 +239,9 @@ keybinding.new({ modkey, "Control" }, "y", function ()
end
end):add()
-keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
+keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
-keybinding.new({ modkey }, "y", function ()
+keybinding({ modkey }, "y", function ()
local tabbedview = tabulous.tabindex_get()
if tabbedview ~= nil then
@@ -251,8 +251,8 @@ keybinding.new({ modkey }, "y", function ()
end):add()
-- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
-keybinding.new({ modkey }, "t", awful.client.togglemarked):add()
-keybinding.new({ modkey, 'Shift' }, "t", function ()
+keybinding({ modkey }, "t", awful.client.togglemarked):add()
+keybinding({ modkey, 'Shift' }, "t", function ()
local tabbedview = tabulous.tabindex_get()
local clients = awful.client.getmarked()
@@ -268,7 +268,7 @@ keybinding.new({ modkey, 'Shift' }, "t", function ()
end):add()
for i = 1, keynumber do
- keybinding.new({ modkey, "Shift" }, "F" .. i,
+ keybinding({ modkey, "Shift" }, "F" .. i,
function ()
local screen = mouse.screen_get()
if tags[screen][i] then
@@ -316,9 +316,9 @@ end
-- Hook function to execute when a new client appears.
function hook_manage(c)
-- Add mouse bindings
- c:mouse_add(mouse.new({ }, 1, function (c) c:focus_set(); c:raise() end))
- c:mouse_add(mouse.new({ modkey }, 1, function (c) c:mouse_move() end))
- c:mouse_add(mouse.new({ modkey }, 3, function (c) c:mouse_resize() end))
+ c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
+ c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
+ c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
-- New client may not receive focus
-- if they're not focusable, so set border anyway.
c:border_set({ width = border_width, color = border_normal })
diff --git a/build-utils/fake-lua-src.lua b/build-utils/fake-lua-src.lua
index bb494b67..135459a1 100755
--- a/build-utils/fake-lua-src.lua
+++ b/build-utils/fake-lua-src.lua
@@ -70,10 +70,12 @@ for i, line in ipairs(ilines) do
else
local fctname, fctdef
_, _, fctname, fctdef = line:find("\"(.+)\", (.+) },?")
- if fctname and not fctname:find("^__") then
+ if fctname and (not fctname:find("^__") or fctname:find("^__call")) then
if function_doc[fctdef] then
+ fctname = "." .. fctname
+ fctname = fctname:gsub("^.__call", "")
print(function_doc[fctdef]:comment_translate())
- print("function " .. libname .. "." .. fctname .. "()")
+ print("function " .. libname .. fctname .. "()")
print("end");
else
print("This function is not yet documented.")
diff --git a/keybinding.c b/keybinding.c
index 333887ee..2c7c816b 100644
--- a/keybinding.c
+++ b/keybinding.c
@@ -184,22 +184,22 @@ luaA_keybinding_new(lua_State *L)
keybinding_t *k;
const char *key;
- /* arg 1 is key mod table */
- luaA_checktable(L, 1);
- /* arg 2 is key */
- key = luaL_checkstring(L, 2);
- /* arg 3 is cmd to run */
- luaA_checkfunction(L, 3);
+ /* arg 2 is key mod table */
+ luaA_checktable(L, 2);
+ /* arg 3 is key */
+ key = luaL_checkstring(L, 3);
+ /* arg 4 is cmd to run */
+ luaA_checkfunction(L, 4);
/* get the last arg as function */
k = p_new(keybinding_t, 1);
__luaA_keystore(k, key);
k->fct = luaL_ref(L, LUA_REGISTRYINDEX);
- len = lua_objlen(L, 1);
+ len = lua_objlen(L, 2);
for(i = 1; i <= len; i++)
{
- lua_rawgeti(L, 1, i);
+ lua_rawgeti(L, 2, i);
k->mod |= xutil_keymask_fromstr(luaL_checkstring(L, -1));
}
@@ -248,7 +248,7 @@ luaA_keybinding_tostring(lua_State *L)
const struct luaL_reg awesome_keybinding_methods[] =
{
- { "new", luaA_keybinding_new },
+ { "__call", luaA_keybinding_new },
{ NULL, NULL }
};
const struct luaL_reg awesome_keybinding_meta[] =
diff --git a/mouse.c b/mouse.c
index ab7b9a4e..38d3d9c2 100644
--- a/mouse.c
+++ b/mouse.c
@@ -1136,20 +1136,20 @@ luaA_mouse_new(lua_State *L)
int i, len;
button_t *button;
- luaA_checktable(L, 1);
+ luaA_checktable(L, 2);
/* arg 3 is mouse button */
- i = luaL_checknumber(L, 2);
+ i = luaL_checknumber(L, 3);
/* arg 4 is cmd to run */
- luaA_checkfunction(L, 3);
+ luaA_checkfunction(L, 4);
button = p_new(button_t, 1);
button->button = xutil_button_fromint(i);
button->fct = luaL_ref(L, LUA_REGISTRYINDEX);
- len = lua_objlen(L, 1);
+ len = lua_objlen(L, 2);
for(i = 1; i <= len; i++)
{
- lua_rawgeti(L, 1, i);
+ lua_rawgeti(L, 2, i);
button->mod |= xutil_keymask_fromstr(luaL_checkstring(L, -1));
}
@@ -1158,7 +1158,7 @@ luaA_mouse_new(lua_State *L)
const struct luaL_reg awesome_mouse_methods[] =
{
- { "new", luaA_mouse_new },
+ { "__call", luaA_mouse_new },
{ "screen_get", luaA_mouse_screen_get },
{ "coords_set", luaA_mouse_coords_set },
{ "coords_get", luaA_mouse_coords_get },
diff --git a/statusbar.c b/statusbar.c
index 653236c5..b5d9a465 100644
--- a/statusbar.c
+++ b/statusbar.c
@@ -538,37 +538,37 @@ luaA_statusbar_new(lua_State *L)
const char *buf;
size_t len;
- luaA_checktable(L, 1);
+ luaA_checktable(L, 2);
- if(!(buf = luaA_getopt_string(L, 1, "name", NULL)))
+ if(!(buf = luaA_getopt_string(L, 2, "name", NULL)))
luaL_error(L, "object statusbar must have a name");
sb = p_new(statusbar_t, 1);
sb->name = a_strdup(buf);
- if(!(buf = luaA_getopt_string(L, 1, "fg", NULL))
+ if(!(buf = luaA_getopt_string(L, 2, "fg", NULL))
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &sb->colors.fg))
sb->colors.fg = xcolor_copy(&globalconf.colors.fg);
- if(!(buf = luaA_getopt_string(L, 1, "bg", NULL))
+ if(!(buf = luaA_getopt_string(L, 2, "bg", NULL))
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &sb->colors.bg))
sb->colors.bg = xcolor_copy(&globalconf.colors.bg);
- buf = luaA_getopt_lstring(L, 1, "align", "left", &len);
+ buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
sb->align = draw_align_fromstr(buf, len);
- sb->width = luaA_getopt_number(L, 1, "width", 0);
+ sb->width = luaA_getopt_number(L, 2, "width", 0);
if(sb->width > 0)
sb->width_user = true;
- sb->height = luaA_getopt_number(L, 1, "height", 0);
+ sb->height = luaA_getopt_number(L, 2, "height", 0);
if(sb->height <= 0)
/* 1.5 as default factor, it fits nice but no one knows why */
sb->height = 1.5 * globalconf.font->height;
- buf = luaA_getopt_lstring(L, 1, "position", "top", &len);
+ buf = luaA_getopt_lstring(L, 2, "position", "top", &len);
sb->position = position_fromstr(buf, len);
return luaA_statusbar_userdata_new(L, sb);
@@ -603,7 +603,7 @@ luaA_statusbar_widget_get(lua_State *L)
const struct luaL_reg awesome_statusbar_methods[] =
{
- { "new", luaA_statusbar_new },
+ { "__call", luaA_statusbar_new },
{ NULL, NULL }
};
const struct luaL_reg awesome_statusbar_meta[] =
diff --git a/tag.c b/tag.c
index ea7be042..5fa327e0 100644
--- a/tag.c
+++ b/tag.c
@@ -314,15 +314,15 @@ luaA_tag_new(lua_State *L)
double mwfact;
layout_t *layout;
- luaA_checktable(L, 1);
+ luaA_checktable(L, 2);
- if(!(name = luaA_getopt_string(L, 1, "name", NULL)))
+ if(!(name = luaA_getopt_string(L, 2, "name", NULL)))
luaL_error(L, "object tag must have a name");
- mwfact = luaA_getopt_number(L, 1, "mwfact", 0.5);
- ncol = luaA_getopt_number(L, 1, "ncol", 1);
- nmaster = luaA_getopt_number(L, 1, "nmaster", 1);
- lay = luaA_getopt_string(L, 1, "layout", "tile");
+ mwfact = luaA_getopt_number(L, 2, "mwfact", 0.5);
+ ncol = luaA_getopt_number(L, 2, "ncol", 1);
+ nmaster = luaA_getopt_number(L, 2, "nmaster", 1);
+ lay = luaA_getopt_string(L, 2, "layout", "tile");
layout = name_func_lookup(lay, LayoutList);
@@ -560,7 +560,7 @@ luaA_tag_layout_set(lua_State *L)
const struct luaL_reg awesome_tag_methods[] =
{
- { "new", luaA_tag_new },
+ { "__call", luaA_tag_new },
{ "get", luaA_tag_get },
{ "geti", luaA_tag_geti },
{ NULL, NULL }
diff --git a/titlebar.c b/titlebar.c
index dff41537..33792203 100644
--- a/titlebar.c
+++ b/titlebar.c
@@ -298,38 +298,38 @@ luaA_titlebar_new(lua_State *L)
const char *buf;
size_t len;
- luaA_checktable(L, 1);
+ luaA_checktable(L, 2);
tb = p_new(titlebar_t, 1);
- buf = luaA_getopt_lstring(L, 1, "align", "left", &len);
+ buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
tb->align = draw_align_fromstr(buf, len);
- tb->width = luaA_getopt_number(L, 1, "width", 0);
- tb->height = luaA_getopt_number(L, 1, "height", 0);
+ tb->width = luaA_getopt_number(L, 2, "width", 0);
+ tb->height = luaA_getopt_number(L, 2, "height", 0);
if(tb->height <= 0)
/* 1.5 as default factor, it fits nice but no one knows why */
tb->height = 1.5 * globalconf.font->height;
- buf = luaA_getopt_lstring(L, 1, "position", "top", &len);
+ buf = luaA_getopt_lstring(L, 2, "position", "top", &len);
tb->position = position_fromstr(buf, len);
- if(!(buf = luaA_getopt_string(L, 1, "fg", NULL))
+ if(!(buf = luaA_getopt_string(L, 2, "fg", NULL))
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &tb->colors.fg))
tb->colors.fg = xcolor_copy(&globalconf.colors.fg);
- if(!(buf = luaA_getopt_string(L, 1, "bg", NULL))
+ if(!(buf = luaA_getopt_string(L, 2, "bg", NULL))
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &tb->colors.bg))
tb->colors.bg = xcolor_copy(&globalconf.colors.bg);
- if(!(buf = luaA_getopt_string(L, 1, "border_color", NULL))
+ if(!(buf = luaA_getopt_string(L, 2, "border_color", NULL))
|| !xcolor_new(globalconf.connection, globalconf.default_screen,
buf, &tb->border.color))
tb->border.color = xcolor_copy(&globalconf.colors.fg);
- tb->border.width = luaA_getopt_number(L, 1, "border_width", 0);
+ tb->border.width = luaA_getopt_number(L, 2, "border_width", 0);
return luaA_titlebar_userdata_new(globalconf.L, tb);
}
@@ -502,7 +502,7 @@ luaA_titlebar_tostring(lua_State *L)
const struct luaL_reg awesome_titlebar_methods[] =
{
- { "new", luaA_titlebar_new },
+ { "__call", luaA_titlebar_new },
{ NULL, NULL }
};
const struct luaL_reg awesome_titlebar_meta[] =
diff --git a/widget.c b/widget.c
index 9fa00f82..a8df7492 100644
--- a/widget.c
+++ b/widget.c
@@ -264,21 +264,21 @@ widget_invalidate_bywidget(widget_t *widget)
static int
luaA_widget_new(lua_State *L)
{
- const char *type, *buf;
+ const char *buf, *type;
widget_t *w = NULL;
widget_constructor_t *wc;
alignment_t align;
size_t len;
- luaA_checktable(L, 1);
+ luaA_checktable(L, 2);
- buf = luaA_getopt_lstring(L, 1, "align", "left", &len);
+ buf = luaA_getopt_lstring(L, 2, "align", "left", &len);
align = draw_align_fromstr(buf, len);
- if(!(buf = luaA_getopt_string(L, 1, "name", NULL)))
+ if(!(buf = luaA_getopt_string(L, 2, "name", NULL)))
luaL_error(L, "object widget must have a name");
- type = luaA_getopt_string(L, 1, "type", NULL);
+ type = luaA_getopt_string(L, 2, "type", NULL);
if((wc = name_func_lookup(type, WidgetList)))
w = wc(align);
@@ -422,14 +422,16 @@ luaA_widget_index(lua_State *L)
{
widget_t **widget = luaA_checkudata(L, 1, "widget");
- lua_getmetatable(L, 1); /* 1 */
- lua_pushvalue(L, 2); /* 2 */
- lua_rawget(L, -2); /* 2 */
- if (!lua_isnil(L, -1)) {
- lua_remove(L, -2); /* 1 */
+ lua_getmetatable(L, 1);
+ lua_pushvalue(L, 2);
+ lua_rawget(L, -2);
+ if (!lua_isnil(L, -1))
+ {
+ lua_remove(L, -2);
return 1;
}
lua_pop(L, 2);
+
return (*widget)->index ? (*widget)->index(L) : 0;
}
@@ -450,7 +452,7 @@ luaA_widget_newindex(lua_State *L)
const struct luaL_reg awesome_widget_methods[] =
{
- { "new", luaA_widget_new },
+ { "__call", luaA_widget_new },
{ NULL, NULL }
};
const struct luaL_reg awesome_widget_meta[] =