Merge pull request #2658 from psychon/delayed_call_run_now
Add and use gears.timer.run_delayed_calls_now()
This commit is contained in:
commit
fd38e2fb5c
|
@ -227,12 +227,17 @@ function timer.weak_start_new(timeout, callback)
|
|||
end
|
||||
|
||||
local delayed_calls = {}
|
||||
capi.awesome.connect_signal("refresh", function()
|
||||
|
||||
--- Run all pending delayed calls now. This function should best not be used at
|
||||
-- all, because it means that less batching happens and the delayed calls run
|
||||
-- prematurely.
|
||||
-- @function gears.timer.run_delayed_calls_now
|
||||
function timer.run_delayed_calls_now()
|
||||
for _, callback in ipairs(delayed_calls) do
|
||||
protected_call(unpack(callback))
|
||||
end
|
||||
delayed_calls = {}
|
||||
end)
|
||||
end
|
||||
|
||||
--- Call the given function at the end of the current main loop iteration
|
||||
-- @tparam function callback The function that should be called
|
||||
|
@ -243,6 +248,8 @@ function timer.delayed_call(callback, ...)
|
|||
table.insert(delayed_calls, { callback, ... })
|
||||
end
|
||||
|
||||
capi.awesome.connect_signal("refresh", timer.run_delayed_calls_now)
|
||||
|
||||
function timer.mt.__call(_, ...)
|
||||
return timer.new(...)
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ local p = awful.popup { --DOC_HIDE
|
|||
placement = awful.placement.centered, --DOC_HIDE
|
||||
} --DOC_HIDE
|
||||
p:_apply_size_now() --DOC_HIDE
|
||||
awesome.emit_signal("refresh") --DOC_HIDE
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE
|
||||
p._drawable._do_redraw() --DOC_HIDE
|
||||
|
||||
--DOC_HIDE Necessary as the widgets are drawn later
|
||||
|
|
|
@ -111,7 +111,7 @@ local p10 = awful.popup {
|
|||
shape = gears.shape.infobubble,
|
||||
}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
p10:bind_to_widget(mytextclock)
|
||||
|
||||
-- The titlebar
|
||||
|
|
|
@ -13,7 +13,7 @@ local args = loadfile(file_path)() or {}
|
|||
|
||||
-- Emulate the event loop for 5 iterations
|
||||
for _ = 1, 5 do
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
-- Draw the result
|
||||
|
@ -172,7 +172,7 @@ end
|
|||
|
||||
-- Emulate the event loop for another 5 iterations
|
||||
for _ = 1, 5 do
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
for _, d in ipairs(drawin.get()) do
|
||||
|
|
|
@ -13,7 +13,7 @@ local wibox = require("wibox")
|
|||
width = 100, height = 44, x = 100, y = 10, visible = true, bg = "#00000000"
|
||||
}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
for _, side in ipairs{ "top_left", "bottom_left", "top_right", "bottom_right"} do
|
||||
local tt = awful.tooltip {
|
||||
|
@ -27,4 +27,4 @@ end
|
|||
|
||||
mouse.coords{x=125, y= 35}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -13,7 +13,7 @@ local wibox = require("wibox")
|
|||
width = 100, height = 44, x = 100, y = 10, visible = true, bg = "#00000000"
|
||||
}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
for _, side in ipairs{ "left", "right", "bottom", "top" } do
|
||||
local tt = awful.tooltip {
|
||||
|
@ -27,4 +27,4 @@ end
|
|||
|
||||
mouse.coords{x=125, y= 35}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -8,7 +8,7 @@ local beautiful = require("beautiful")
|
|||
|
||||
-- mouse.coords{x=50, y= 10}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
local x_offset = 0
|
||||
|
||||
|
@ -20,13 +20,13 @@ for _, color in ipairs{ "#ff0000", "#00ff00", "#0000ff", "#00ffff" } do
|
|||
border_color = color,
|
||||
}
|
||||
tt.bg = beautiful.bg_normal
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt:show()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt.wibox.x = x_offset
|
||||
x_offset = x_offset + 640/5
|
||||
end
|
||||
|
||||
mouse.coords{x=125, y= 0}
|
||||
-- mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -8,7 +8,7 @@ local beautiful = require("beautiful")
|
|||
|
||||
-- mouse.coords{x=50, y= 10}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
local x_offset = 0
|
||||
|
||||
|
@ -20,13 +20,13 @@ for _, width in ipairs{ 1,2,4,6 } do
|
|||
border_color = beautiful.border_color,
|
||||
}
|
||||
tt.bg = beautiful.bg_normal
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt:show()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt.wibox.x = x_offset
|
||||
x_offset = x_offset + 640/5
|
||||
end
|
||||
|
||||
mouse.coords{x=125, y= 0}
|
||||
-- mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -8,7 +8,7 @@ local beautiful = require("beautiful")
|
|||
|
||||
-- mouse.coords{x=50, y= 10}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
local x_offset = 0
|
||||
|
||||
|
@ -20,13 +20,13 @@ for _, width in ipairs{ 1,2,4,6 } do
|
|||
border_color = beautiful.border_color,
|
||||
}
|
||||
tt.bg = beautiful.bg_normal
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt:show()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt.wibox.x = x_offset
|
||||
x_offset = x_offset + 640/5
|
||||
end
|
||||
|
||||
mouse.coords{x=125, y= 0}
|
||||
-- mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -8,7 +8,7 @@ local beautiful = require("beautiful")
|
|||
|
||||
-- mouse.coords{x=50, y= 10}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
local x_offset = 0
|
||||
|
||||
|
@ -20,13 +20,13 @@ for _, width in ipairs{ 1,2,4,6 } do
|
|||
border_color = beautiful.border_color,
|
||||
}
|
||||
tt.bg = beautiful.bg_normal
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt:show()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt.wibox.x = x_offset
|
||||
x_offset = x_offset + 640/5
|
||||
end
|
||||
|
||||
mouse.coords{x=125, y= 0}
|
||||
-- mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -8,7 +8,7 @@ local beautiful = require("beautiful")
|
|||
|
||||
-- mouse.coords{x=50, y= 10}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
local x_offset = 0
|
||||
|
||||
|
@ -20,13 +20,13 @@ for _, width in ipairs{ 1,2,4,6 } do
|
|||
border_color = beautiful.border_color,
|
||||
}
|
||||
tt.bg = beautiful.bg_normal
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt:show()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt.wibox.x = x_offset
|
||||
x_offset = x_offset + 640/5
|
||||
end
|
||||
|
||||
mouse.coords{x=125, y= 0}
|
||||
-- mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -11,7 +11,7 @@ mouse.coords{x=50, y= 10}
|
|||
|
||||
local wb = wibox {width = 100, height = 44, x = 50, y = 25, visible = true}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
local tt = awful.tooltip {
|
||||
text = "A tooltip!",
|
||||
objects = {wb},
|
||||
|
@ -20,4 +20,4 @@ tt.bg = beautiful.bg_normal
|
|||
|
||||
mouse.coords{x=75, y= 35}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -11,7 +11,7 @@ mouse.coords{x=50, y= 10}
|
|||
|
||||
local wb = wibox {width = 100, height = 44, x = 50, y = 25, visible = true}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
local tt = awful.tooltip {
|
||||
text = "A tooltip!",
|
||||
objects = {wb},
|
||||
|
@ -21,4 +21,4 @@ tt.bg = beautiful.bg_normal
|
|||
|
||||
mouse.coords{x=75, y= 35}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -11,7 +11,7 @@ local wibox = require("wibox")
|
|||
|
||||
local wb = wibox {width = 100, height = 44, x = 100, y = 50, visible = true}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
for _, side in ipairs{ "left", "right", "bottom", "top" } do
|
||||
local tt = awful.tooltip {
|
||||
|
@ -26,4 +26,4 @@ end
|
|||
|
||||
mouse.coords{x=125, y= 75}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -11,7 +11,7 @@ local wibox = require("wibox")
|
|||
|
||||
local wb = wibox {width = 100, height = 44, x = 100, y = 50, visible = true}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
for _, side in ipairs{ "left", "right", "bottom", "top" } do
|
||||
local tt = awful.tooltip {
|
||||
|
@ -26,4 +26,4 @@ end
|
|||
|
||||
mouse.coords{x=125, y= 75}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -11,7 +11,7 @@ local wibox = require("wibox")
|
|||
|
||||
local wb = wibox {width = 100, height = 44, x = 100, y = 50, visible = true}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
for _, side in ipairs{ "left", "right", "bottom", "top" } do
|
||||
local tt = awful.tooltip {
|
||||
|
@ -26,4 +26,4 @@ end
|
|||
|
||||
mouse.coords{x=125, y= 75}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -11,7 +11,7 @@ local wibox = require("wibox")
|
|||
|
||||
local wb = wibox {width = 100, height = 44, x = 100, y = 50, visible = true}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
for _, side in ipairs{ "left", "right", "bottom", "top" } do
|
||||
local tt = awful.tooltip {
|
||||
|
@ -25,4 +25,4 @@ end
|
|||
|
||||
mouse.coords{x=125, y= 75}
|
||||
mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -9,7 +9,7 @@ local gears = {shape = require("gears.shape")}
|
|||
|
||||
-- mouse.coords{x=50, y= 10}
|
||||
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
||||
local x_offset = 0
|
||||
|
||||
|
@ -22,13 +22,13 @@ for _, shape in ipairs{ "rounded_rect", "rounded_bar", "octogon", "infobubble"}
|
|||
border_color = beautiful.border_color,
|
||||
}
|
||||
tt.bg = beautiful.bg_normal
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt:show()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
tt.wibox.x = x_offset
|
||||
x_offset = x_offset + 640/5
|
||||
end
|
||||
|
||||
mouse.coords{x=125, y= 0}
|
||||
-- mouse.push_history()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
|
|
|
@ -15,7 +15,7 @@ local wb = awful.wibar { position = "top" } --DOC_HIDE
|
|||
wb:setup { layout = wibox.layout.align.horizontal, --DOC_HIDE
|
||||
nil, nil, mytextclock} --DOC_HIDE
|
||||
|
||||
awesome.emit_signal("refresh") --DOC_HIDE the hierarchy is async
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE the hierarchy is async
|
||||
|
||||
local myclock_t = awful.tooltip {
|
||||
objects = { mytextclock },
|
||||
|
@ -24,7 +24,7 @@ awesome.emit_signal("refresh") --DOC_HIDE the hierarchy is async
|
|||
end,
|
||||
}
|
||||
|
||||
awesome.emit_signal("refresh") --DOC_HIDE
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE
|
||||
|
||||
mouse.coords{x=250, y= 10} --DOC_HIDE
|
||||
mouse.push_history() --DOC_HIDE
|
||||
|
|
|
@ -15,7 +15,7 @@ local wb = awful.wibar { position = "top" } --DOC_HIDE
|
|||
wb:setup { layout = wibox.layout.align.horizontal, --DOC_HIDE
|
||||
nil, nil, mytextclock} --DOC_HIDE
|
||||
|
||||
awesome.emit_signal("refresh") --DOC_HIDE the hierarchy is async
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE the hierarchy is async
|
||||
|
||||
local myclock_t = awful.tooltip { }
|
||||
--DOC_NEWLINE
|
||||
|
@ -25,7 +25,7 @@ awesome.emit_signal("refresh") --DOC_HIDE the hierarchy is async
|
|||
myclock_t.text = os.date("Today is %A %B %d %Y\nThe time is %T")
|
||||
end)
|
||||
|
||||
awesome.emit_signal("refresh") --DOC_HIDE
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE
|
||||
|
||||
mouse.coords{x=250, y= 10} --DOC_HIDE
|
||||
mouse.push_history() --DOC_HIDE
|
||||
|
|
|
@ -24,7 +24,7 @@ local awful = {keygrabber = require("awful.keygrabber"), --DOC_HIDE
|
|||
}
|
||||
|
||||
--DOC_HIDE Trigger the keybinging
|
||||
awesome.emit_signal("refresh") --DOC_HIDE `export_keybindings` is async
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE `export_keybindings` is async
|
||||
root.fake_input("key_press", "Alt_L")--DOC_HIDE
|
||||
root.fake_input("key_press", "Tab")--DOC_HIDE
|
||||
root.fake_input("key_release", "Tab")--DOC_HIDE
|
||||
|
|
|
@ -27,7 +27,7 @@ awful.keygrabber {
|
|||
--DOC_NEWLINE
|
||||
-- The following will **NOT** trigger the keygrabbing because it isn't exported
|
||||
-- to the root (global) keys. Adding `export_keybindings` would solve that
|
||||
awesome.emit_signal("refresh") --DOC_HIDE `root_keybindings` is async
|
||||
require("gears.timer").run_delayed_calls_now() --DOC_HIDE `root_keybindings` is async
|
||||
root._execute_keybinding({"Mod4", "Shift"}, "i")
|
||||
assert(#keybinding_works == 0)
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ local container = wibox.widget {
|
|||
|
||||
-- Emulate the event loop for 10 iterations
|
||||
for _ = 1, 10 do
|
||||
awesome:emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
-- Get the example fallback size (the tests can return a size if the want)
|
||||
|
|
|
@ -99,7 +99,7 @@ local widget, w, h = loadfile(file_path)(generic_widget, generic_before_after)
|
|||
|
||||
-- Emulate the event loop for 10 iterations
|
||||
for _ = 1, 10 do
|
||||
awesome:emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
-- Save to the output file
|
||||
|
|
|
@ -13,7 +13,7 @@ image_type = image_type or "svg"
|
|||
|
||||
-- Emulate the event loop for 10 iterations
|
||||
for _ = 1, 10 do
|
||||
awesome:emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
-- Get the example fallback size (the tests can return a size if the want)
|
||||
|
|
|
@ -41,7 +41,7 @@ do
|
|||
end
|
||||
|
||||
local function do_pending_repaint()
|
||||
awesome.emit_signal("refresh")
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
local function create_and_draw_wibox()
|
||||
|
|
|
@ -7,8 +7,8 @@ local create_wibox = require("_wibox_helper").create_wibox
|
|||
local wibox = require("wibox")
|
||||
|
||||
local prepare_for_collect = nil
|
||||
local function emit_refresh()
|
||||
awesome.emit_signal("refresh")
|
||||
local function run_delayed_calls()
|
||||
require("gears.timer").run_delayed_calls_now()
|
||||
end
|
||||
|
||||
-- Make the layoutbox in the default config GC'able
|
||||
|
@ -18,7 +18,7 @@ for s in screen do
|
|||
s.mywibox = nil
|
||||
s.mylayoutbox = nil
|
||||
end
|
||||
emit_refresh()
|
||||
run_delayed_calls()
|
||||
|
||||
-- Test if some objects can be garbage collected
|
||||
local function collectable(a, b, c, d, e, f, g, h, last)
|
||||
|
@ -66,19 +66,19 @@ collectable(wibox.widget.textclock())
|
|||
collectable(awful.widget.layoutbox(1))
|
||||
|
||||
-- Some widgets do things via timer.delayed_call
|
||||
prepare_for_collect = emit_refresh
|
||||
prepare_for_collect = run_delayed_calls
|
||||
collectable(tooltip_delayed())
|
||||
|
||||
prepare_for_collect = emit_refresh
|
||||
prepare_for_collect = run_delayed_calls
|
||||
collectable(tooltip_now())
|
||||
|
||||
prepare_for_collect = emit_refresh
|
||||
prepare_for_collect = run_delayed_calls
|
||||
collectable(awful.widget.taglist{screen=1, filter=awful.widget.taglist.filter.all})
|
||||
|
||||
prepare_for_collect = emit_refresh
|
||||
prepare_for_collect = run_delayed_calls
|
||||
collectable(awful.widget.tasklist{screen=1, filter=awful.widget.tasklist.filter.currenttags})
|
||||
|
||||
prepare_for_collect = emit_refresh
|
||||
prepare_for_collect = run_delayed_calls
|
||||
collectable(create_wibox())
|
||||
|
||||
runner.run_steps({ function() return true end })
|
||||
|
|
Loading…
Reference in New Issue