wibox.container.margin: Do not produce negative sizes

With draw_empty=false, :fit() can return 0,0. Then, when :layout() is
called, it will compute negative widths and heights. This can then cause
lots of problems later on.

Avoid this by having :layout() return nothing instead of producing
negative sizes.

Fixes: https://github.com/awesomeWM/awesome/issues/2799
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2019-06-19 18:18:06 +02:00
parent 99e81c097a
commit f025409cd3
1 changed files with 6 additions and 1 deletions

View File

@ -44,7 +44,12 @@ function margin:layout(_, width, height)
local w = self._private.right local w = self._private.right
local h = self._private.bottom local h = self._private.bottom
return { base.place_widget_at(self._private.widget, x, y, width - x - w, height - y - h) } local resulting_width = width - x - w
local resulting_height = height - y - h
if resulting_width > 0 and resulting_height > 0 then
return { base.place_widget_at(self._private.widget, x, y, resulting_width, resulting_height) }
end
end end
end end