diff options
author | Tim Keller <tjkeller.xyz> | 2025-04-12 14:34:55 -0500 |
---|---|---|
committer | Tim Keller <tjkeller.xyz> | 2025-04-12 14:34:55 -0500 |
commit | 39f8a32b96c86a442c6cdc4aae7a870a5f65b45f (patch) | |
tree | 301b6b623f80838de954c8afdd0d19cb2665f11a /lib | |
parent | 3ab998e85b7eb487d129530c5ec437259e305c81 (diff) | |
download | awesome-39f8a32b96c86a442c6cdc4aae7a870a5f65b45f.tar.xz awesome-39f8a32b96c86a442c6cdc4aae7a870a5f65b45f.zip |
cleanup and tasklist tooltip + wibox tooltip lib
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wiboxtooltip.lua | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/wiboxtooltip.lua b/lib/wiboxtooltip.lua new file mode 100644 index 0000000..c101f92 --- /dev/null +++ b/lib/wiboxtooltip.lua @@ -0,0 +1,56 @@ +local awful = require("awful") +local wibox = require("wibox") +local beautiful = require("beautiful") +local gears = require("gears") + +local margin_leftright = beautiful.xresources.apply_dpi(5) +local margin_topbottom = beautiful.xresources.apply_dpi(3) + +-- 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, + margin_leftright, margin_leftright, + margin_topbottom, 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 |