diff --git a/lib/awful/titlebar.lua.in b/lib/awful/titlebar.lua.in index d00b94f4..4022cdae 100644 --- a/lib/awful/titlebar.lua.in +++ b/lib/awful/titlebar.lua.in @@ -48,7 +48,7 @@ function add(c, args) local tb = capi.wibox(args) - local title = capi.widget({ type = "textbox", name = "title", align = "flex" }) + local title = capi.widget({ type = "textbox", align = "flex" }) title.text = " " .. util.escape(c.name) .. " " -- Redirect relevant events to the client the titlebar belongs to @@ -61,7 +61,7 @@ function add(c, args) title:buttons(bts) function title.mouse_enter(s) hooks.user.call('mouse_enter', c) end - local appicon = capi.widget({ type = "imagebox", name = "appicon", align = "left" }) + local appicon = capi.widget({ type = "imagebox", align = "left" }) appicon.image = c.icon -- Also redirect events for appicon (So the entire titlebar behaves consistently) @@ -70,13 +70,13 @@ function add(c, args) local closef if theme.titlebar_close_button_focus then - closef = widget.button({ name = "closef", align = "right", + closef = widget.button({ align = "right", image = theme.titlebar_close_button_focus }) end local close if theme.titlebar_close_button_normal then - close = widget.button({ name = "close", align = "right", + close = widget.button({ align = "right", image = theme.titlebar_close_button_normal }) end @@ -107,7 +107,8 @@ function add(c, args) end end - tb.widgets = { appicon, title, closef, close } + tb.widgets = { appicon = appicon, title = title, + closef = closef, close = close } c.titlebar = tb @@ -121,21 +122,13 @@ end function update(c, prop) if c.titlebar and data[c] then local widgets = c.titlebar.widgets - local title, close, closef - for k, v in pairs(widgets) do - if v.name == "title" then title = v - elseif v.name == "close" then close = v - elseif v.name == "closef" then closef = v - elseif v.name == "appicon" then appicon = v end - if title and close and closef and appicon then break end - end if prop == "name" then - if title then - title.text = " " .. util.escape(c.name) .. " " + if widgets.title then + widgets.title.text = " " .. util.escape(c.name) .. " " end elseif prop == "icon" then - if appicon then - appicon.image = c.icon + if widgets.appicon then + widgets.appicon.image = c.icon end elseif prop == "geometry" then if data[c].width then @@ -152,13 +145,13 @@ function update(c, prop) if capi.client.focus == c then c.titlebar.fg = data[c].fg_focus c.titlebar.bg = data[c].bg_focus - if closef then closef.visible = true end - if close then close.visible = false end + if widgets.closef then widgets.closef.visible = true end + if widgets.close then widgets.close.visible = false end else c.titlebar.fg = data[c].fg c.titlebar.bg = data[c].bg - if closef then closef.visible = false end - if close then close.visible = true end + if widgets.closef then widgets.closef.visible = false end + if widgets.close then widgets.close.visible = true end end end end diff --git a/lib/awful/widget.lua.in b/lib/awful/widget.lua.in index 8e21c1fd..acaca8e4 100644 --- a/lib/awful/widget.lua.in +++ b/lib/awful/widget.lua.in @@ -40,7 +40,7 @@ local function taglist_update (screen, w, label, buttons, data) -- Add more widgets if len < #tags then for i = len + 1, #tags do - w[i] = capi.widget({ type = "textbox", name = "taglist" .. i }) + w[i] = capi.widget({ type = "textbox" }) end -- Remove widgets elseif len > #tags then @@ -189,8 +189,8 @@ local function tasklist_update(w, buttons, label, data) -- Add more widgets if len < #clients then for i = len * 2 + 1, #clients * 2, 2 do - w[i] = capi.widget({ type = "imagebox", name = "tasklist_icon" .. i, align = "flex" }) - w[i + 1] = capi.widget({ type = "textbox", name = "tasklist_text" .. i, align = "flex" }) + w[i] = capi.widget({ type = "imagebox", align = "flex" }) + w[i + 1] = capi.widget({ type = "textbox", align = "flex" }) end -- Remove widgets elseif len > #clients then diff --git a/lib/invaders.lua.in b/lib/invaders.lua.in index ee652210..5ac4e054 100644 --- a/lib/invaders.lua.in +++ b/lib/invaders.lua.in @@ -69,7 +69,7 @@ function player.new () y = gamedata.field.y + gamedata.field.h - (16 + 5) }) p.screen = 1 - w = widget({ type = "imagebox", name = "player" }) + w = widget({ type = "imagebox" }) w.image = image("@AWESOME_ICON_PATH@/invaders/player.png") p.widgets = w @@ -180,8 +180,7 @@ function enemies.new (t) x = gamedata.field.x, y = gamedata.field.y }) e.screen = 1 - w = widget({ type = "imagebox", - name = "enemy"..t }) + w = widget({ type = "imagebox" }) w.image = gamedata.enemies[t] e.widgets = w @@ -385,8 +384,7 @@ function game.highscore_show () y = gamedata.field.y + math.floor(gamedata.field.h / 2) - 55 }) gamedata.highscore.window.screen = 1 - gamedata.highscore.table = widget({ type = "textbox", - name = "highscore" }) + gamedata.highscore.table = widget({ type = "textbox" }) gamedata.highscore.window.widgets = gamedata.highscore.table gamedata.highscore.table.text = " Highscores:\n" @@ -453,8 +451,7 @@ function game.highscore (score) y = gamedata.field.y + math.floor(gamedata.field.h / 2) }) gamedata.highscore.window.screen = 1 - gamedata.namebox = widget({ type = "textbox", - name = "foobar" }) + gamedata.namebox = widget({ type = "textbox" }) gamedata.namebox.text = " Name: |" gamedata.highscore.window.widgets = gamedata.namebox @@ -511,12 +508,10 @@ function run(args) gamedata.field.north.screen = 1 gamedata.field.status = widget({ type = "textbox", - name = "status", align = "right" }) gamedata.field.status.text = gamedata.score.." | "..gamedata.round .. " " gamedata.field.caption = widget({ type = "textbox", - name = "caption", align = "left" }) gamedata.field.caption.text = " Awesome Invaders" diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in index db688d52..1b9afce3 100644 --- a/lib/naughty.lua.in +++ b/lib/naughty.lua.in @@ -200,7 +200,7 @@ function notify(args) end -- create textbox - local textbox = widget({ type = "textbox", name = "text", align = "flex" }) + local textbox = widget({ type = "textbox", align = "flex" }) textbox:buttons({ button({ }, 1, run), button({ }, 3, die) }) textbox.text = string.format('%s%s', font, title, text) @@ -209,7 +209,7 @@ function notify(args) -- create iconbox local iconbox = nil if icon then - iconbox = widget({ type = "imagebox", name = "icon", align = "left" }) + iconbox = widget({ type = "imagebox", align = "left" }) iconbox:buttons({ button({ }, 1, run), button({ }, 3, die) }) local img = image(icon) @@ -222,8 +222,7 @@ function notify(args) end -- create container wibox - notification.box = wibox({ name = "not" .. notification.idx, - position = "floating", + notification.box = wibox({ position = "floating", fg = fg, bg = bg, border_color = config.border_color, diff --git a/structs.h b/structs.h index a7ea8635..d4a9cc04 100644 --- a/structs.h +++ b/structs.h @@ -105,8 +105,6 @@ struct widget_t { /** Ref count */ int refcount; - /** widget_t name */ - char *name; /** Widget type is constructor */ widget_constructor_t *type; /** Widget destructor */ diff --git a/widget.c b/widget.c index ac712330..e4c8da6b 100644 --- a/widget.c +++ b/widget.c @@ -48,7 +48,6 @@ widget_delete(widget_t **widget) button_array_wipe(&(*widget)->buttons); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*widget)->mouse_enter); luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*widget)->mouse_leave); - p_delete(&(*widget)->name); p_delete(widget); } @@ -365,7 +364,7 @@ widget_invalidate_bywidget(widget_t *widget) * \param L The Lua VM state. * * \luastack - * \lparam A table with at least a name and a type value. Optional attributes + * \lparam A table with at least a type value. Optional attributes * are: align. * \lreturn A brand new widget. */ @@ -383,8 +382,6 @@ luaA_widget_new(lua_State *L) buf = luaA_getopt_lstring(L, 2, "align", "left", &len); align = draw_align_fromstr(buf, len); - buf = luaA_getopt_string(L, 2, "name", NULL); - type = luaA_getopt_string(L, 2, "type", NULL); if((wc = name_func_lookup(type, WidgetList))) @@ -402,8 +399,6 @@ luaA_widget_new(lua_State *L) w->mouse_enter = w->mouse_leave = LUA_REFNIL; - w->name = a_strdup(buf); - return luaA_widget_userdata_new(L, w); } @@ -435,7 +430,6 @@ luaA_widget_buttons(lua_State *L) * \return The number of elements pushed on stack. * \luastack * \lfield visible The widget visibility. - * \lfield name The widget name. * \lfield mouse_enter A function to execute when the mouse enter the widget. * \lfield mouse_leave A function to execute when the mouse leave the widget. */ @@ -455,12 +449,6 @@ luaA_widget_index(lua_State *L) case A_TK_VISIBLE: lua_pushboolean(L, (*widget)->isvisible); return 1; - case A_TK_NAME: - if((*widget)->name) - lua_pushstring(L, (*widget)->name); - else - lua_pushnil(L); - return 1; case A_TK_MOUSE_ENTER: if((*widget)->mouse_enter != LUA_REFNIL) lua_rawgeti(L, LUA_REGISTRYINDEX, (*widget)->mouse_enter);