diff options
Diffstat (limited to 'dashboard.lua')
| -rw-r--r-- | dashboard.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dashboard.lua b/dashboard.lua index 95b3f79..8a89a02 100644 --- a/dashboard.lua +++ b/dashboard.lua @@ -34,6 +34,9 @@ local layout = { -- arrangement for the board yet. { widget = 'network', col = 14, row = 9, w = 3, h = 3 }, { widget = 'slackware', col = 12, row = 10, w = 2, h = 3 }, + -- Centred on the board. Twice as many rows as columns because cells are + -- about twice as wide as tall, so this span comes out square. + { widget = 'immich', col = 7.25, row = 3.5, w = 3.5, h = 7 }, } -- ========================================================================== @@ -162,6 +165,29 @@ local function draw(cr, sw, sh, colors) end end +-- Pointer events, handed to the widget whose cell is under the pointer, if it +-- defines mouse(event, rect). Coordinates are window-relative, and the window +-- is the whole surface, so they index the same grid the draw uses. +-- +-- Wrapped like the draw: a fault here must not take conky down. Returning true +-- tells conky the event was consumed. +function conky_mouse(event) + if conky_window == nil then return false end + local sw, sh = conky_window.width, conky_window.height + for _, entry in ipairs(layout) do + local r = rect_for(entry, sw, sh) + if event.x >= r.x and event.x < r.x + r.w + and event.y >= r.y and event.y < r.y + r.h then + local w = widget(entry.widget) + if not (w and w.mouse) then return false end + local ok, res = pcall(w.mouse, event, r) + if not ok then print('dashboard: mouse in ' .. entry.widget .. ': ' .. tostring(res)) end + return ok and res == true + end + end + return false +end + function conky_main() if conky_window == nil then return end local s = conky_surface() |
