From 41feec02a5fede3cdb51cb9bd2be5c65ef82c0d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 30 Jul 2016 17:12:20 -0400 Subject: [PATCH 1/4] widget.base: Fix the root get_children_by_id() widget. If the wibox root widget had an id, it was added to the properties, but not the get_children_by_id() table --- lib/wibox/widget/base.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 07a72fb5b..2ed69066c 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -495,6 +495,8 @@ function base.widget:setup(args) if id then -- Avoid being dropped by wibox metatable -> drawin rawset(self, id, w) + ids[id] = ids[id] or {} + table.insert(ids[id], 1, w) end if rawget(self, "_private") then @@ -522,6 +524,11 @@ function base.make_widget_declarative(args) local mt = getmetatable(w) or {} local orig_string = tostring(w) + -- Add the main id (if any) + if id then + ids[id] = ids[id] or {} + table.insert(ids[id], 1, w) + end if rawget(w, "_private") then w._private.by_id = ids From facf676b1367e6915235a45ce3e7ef11790b0411 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 1 Aug 2016 15:29:02 -0400 Subject: [PATCH 2/4] screen: Fix potential nil index This looks like a copy-paste error. --- lib/awful/screen.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 162628cfa..253bd7bec 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -230,7 +230,11 @@ end -- present currently. function screen.focused(args) args = args or screen.default_focused_args or {} - return get_screen(args.client and capi.client.screen or capi.mouse.screen) + return get_screen( + (args.client and args.client.screen) or + (capi.client.focus and capi.client.focus.screen) or + capi.mouse.screen + ) end --- Get a placement bounding geometry. From 220dc4c5e5b14194899bb7074d881f6f1c9e4e64 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 1 Aug 2016 15:35:00 -0400 Subject: [PATCH 3/4] doc: Document titlebar arguments. It was reported as incomplete on IRC. --- lib/awful/titlebar.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/awful/titlebar.lua b/lib/awful/titlebar.lua index f63a75e7f..13bcc272a 100644 --- a/lib/awful/titlebar.lua +++ b/lib/awful/titlebar.lua @@ -64,11 +64,18 @@ end --- Get a client's titlebar -- @class function --- @param c The client for which a titlebar is wanted. --- @param[opt] args A table with extra arguments for the titlebar. The --- "size" is the height of the titlebar. Available "position" values are top, --- left, right and bottom. Additionally, the foreground and background colors --- can be configured via e.g. "bg_normal" and "bg_focus". +-- @tparam client c The client for which a titlebar is wanted. +-- @tparam[opt={}] table args A table with extra arguments for the titlebar. +-- @tparam[opt=font.height*1.5] number args.size The height of the titlebar. +-- @tparam[opt=top] string args.position" values are `top`, +-- `left`, `right` and `bottom`. +-- @tparam[opt=top] string args.bg_normal +-- @tparam[opt=top] string args.bg_focus +-- @tparam[opt=top] string args.bgimage_normal +-- @tparam[opt=top] string args.bgimage_focus +-- @tparam[opt=top] string args.fg_normal +-- @tparam[opt=top] string args.fg_focus +-- @tparam[opt=top] string args.font -- @name titlebar local function new(c, args) args = args or {} From 3587de5721131b95cde560e9f10d4eb6caff5647 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 1 Aug 2016 16:02:58 -0400 Subject: [PATCH 4/4] tests: Test the declarative widget system on wiboxes --- tests/test-miss-handlers.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test-miss-handlers.lua b/tests/test-miss-handlers.lua index 46cfad2cd..8a8948183 100644 --- a/tests/test-miss-handlers.lua +++ b/tests/test-miss-handlers.lua @@ -44,4 +44,28 @@ assert(w.foo == "bar") screen[1].clients = 42 assert(screen[1].clients ~= 42) +-- Test the wibox declarative widget system (drawin proxy) + +local w2 = wibox { + visible = true, + wisth = 100, + height = 100 +} + +w2:setup{ + { + text = "Awesomeness!", + id = "main_textbox", + widget = wibox.widget.textbox, + }, + id = "main_background", + widget = wibox.container.background +} + +assert(w2.main_background) +assert(w2:get_children_by_id("main_background")[1]) +assert(w2:get_children_by_id("main_textbox")[1]) +assert(w2.main_background.main_textbox) +assert(w2.main_background == w2:get_children_by_id("main_background")[1]) + require("_runner").run_steps({ function() return true end })