1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
local awful = require("awful")
local wibox = require("wibox")
local beautiful = require("beautiful")
local gears = require("gears")
-- TODO more args
-- TODO use tooltip theme vars
function create_wibox_tooltip(parent, widget)
local p = {
parent = parent,
popup = awful.popup {
widget = wibox.container.margin (
widget,
beautiful.margin_leftright, beautiful.margin_leftright,
beautiful.margin_topbottom, beautiful.margin_topbottom
),
ontop = true,
visible = false,
preferred_positions = "bottom",
preferred_anchors = "middle",
}
}
-- hover timer
p.timer = gears.timer {
timeout = 1,
single_shot = true,
callback = function()
p.popup:move_next_to(mouse.current_widget_geometry)
p.popup.visible = true
end,
}
-- signal functions
p._mouse_enter = function()
p.timer:again()
end
p._mouse_leave = function()
p.timer:stop()
p.popup.visible = false
end
p.connect_signals = function()
p.parent:connect_signal("mouse::enter", p._mouse_enter)
p.parent:connect_signal("mouse::leave", p._mouse_leave)
end
p.disconnect_signals = function()
p.parent:disconnect_signal("mouse::enter", p._mouse_enter)
p.parent:disconnect_signal("mouse::leave", p._mouse_leave)
end
p.connect_signals()
return p
end
return create_wibox_tooltip
|