Fix spawn callbacks
Spawn callbacks were never invoked when no startup-notification-rules were given. This commit fixes the code so that "startup done" callbacks are also called when no rules were given. Fixes: https://github.com/awesomeWM/awesome/issues/1218 Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
005e1b3ff0
commit
f9cdc98c73
|
@ -106,8 +106,8 @@ function spawn.spawn(cmd, sn_rules, callback)
|
|||
enable_sn = not not enable_sn -- Force into a boolean.
|
||||
local pid, snid = capi.awesome.spawn(cmd, enable_sn)
|
||||
-- The snid will be nil in case of failure
|
||||
if snid and type(sn_rules) == "table" then
|
||||
sn_rules = sn_rules or {}
|
||||
if snid then
|
||||
sn_rules = type(sn_rules) ~= "boolean" and sn_rules or {}
|
||||
spawn.snid_buffer[snid] = { sn_rules, { callback } }
|
||||
end
|
||||
return pid, snid
|
||||
|
|
|
@ -79,25 +79,25 @@ local function init()
|
|||
end
|
||||
|
||||
-- Hack needed for awesome's Startup Notification machinery
|
||||
local function get_snid(sn_rules)
|
||||
local success, snid = spawn({ "/bin/true" }, sn_rules)
|
||||
local function get_snid(sn_rules, callback)
|
||||
local success, snid = spawn({ "/bin/true" }, sn_rules, callback)
|
||||
assert(success)
|
||||
assert(snid)
|
||||
return snid
|
||||
end
|
||||
|
||||
return function(class, title, sn_rules)
|
||||
return function(class, title, sn_rules, callback)
|
||||
class = class or "test_app"
|
||||
title = title or "Awesome test client"
|
||||
|
||||
init()
|
||||
local snid = sn_rules and get_snid(sn_rules) or ""
|
||||
local snid = (sn_rules or callback) and get_snid(sn_rules, callback) or ""
|
||||
local data = class .. "\n" .. title .. "\n" .. snid .. "\n"
|
||||
local success, msg = pipe:write_all(data)
|
||||
assert(success, msg)
|
||||
|
||||
-- TODO: Fix the API of this function
|
||||
return true, sn_rules and snid or nil
|
||||
return true, (sn_rules or callback) and snid or nil
|
||||
end
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -12,8 +12,13 @@ client.connect_signal("manage", function(c)
|
|||
tostring(c.machine) .. " ~= " .. tostring(awesome.hostname))
|
||||
end)
|
||||
|
||||
|
||||
local ret, snid
|
||||
local num_callbacks = 0
|
||||
local function callback(c)
|
||||
assert(c.startup_id == snid)
|
||||
num_callbacks = num_callbacks + 1
|
||||
end
|
||||
|
||||
local steps = {
|
||||
function(count)
|
||||
if count == 1 then
|
||||
|
@ -38,7 +43,20 @@ local steps = {
|
|||
assert(c_snid == nil, "c.startup_snid should be nil!")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
function(count)
|
||||
if count == 1 then
|
||||
manage_called = false
|
||||
ret, snid = test_client("baz", "barz", false, callback)
|
||||
elseif manage_called then
|
||||
assert(ret)
|
||||
assert(snid)
|
||||
assert(snid == c_snid)
|
||||
assert(num_callbacks == 1, num_callbacks)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
runner.run_steps(steps)
|
||||
|
|
Loading…
Reference in New Issue