Merge pull request #1026 from Elv13/misc_fixes

Misc fixes
This commit is contained in:
Emmanuel Lepage Vallée 2016-08-02 14:03:07 -04:00 committed by GitHub
commit b470f8dfcf
4 changed files with 48 additions and 6 deletions

View File

@ -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.

View File

@ -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 {}

View File

@ -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

View File

@ -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 })