dock: Track workarea changes

This commit is contained in:
Emmanuel Lepage Vallee 2016-07-06 22:22:41 -04:00
parent 0618a8d18c
commit 687e21dcdc
1 changed files with 15 additions and 0 deletions

View File

@ -22,6 +22,8 @@ local default_shape = function(cr, width, height) shape.partially_rounded_rect(
local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{} local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{}
local max_size = {height={},width={}} local max_size = {height={},width={}}
local docks = setmetatable({}, {__mode="k"})
-- Compute the optimal maxmimum size -- Compute the optimal maxmimum size
local function get_max_size(data,screen) local function get_max_size(data,screen)
local dir = "left" local dir = "left"
@ -101,6 +103,10 @@ local function get_wibox(data, screen)
honor_workarea = false, honor_workarea = false,
}) })
-- Make sure it is resized
docks[screen] = docks[screen] or setmetatable({}, {__mode="v"})
table.insert(docks[capi.screen[screen]], data)
return w return w
end end
@ -162,5 +168,14 @@ local function new(args)
return ret return ret
end end
-- Resize the docks when the stuts (wibars, docked client) change
capi.screen.connect_signal("property::workarea", function(s)
docks[s] = docks[s] or setmetatable({}, {__mode="v"})
for _, v in ipairs(docks[s]) do
adapt_size(v, v._internal.w.width, v._internal.w.height, s)
end
end)
return setmetatable(module, { __call = function(_, ...) return new(...) end }) return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 4; replace-tabs on; -- kate: space-indent on; indent-width 4; replace-tabs on;