From f025409cd37b546b33744458723c244330960622 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 19 Jun 2019 18:18:06 +0200 Subject: [PATCH] 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 --- lib/wibox/container/margin.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/wibox/container/margin.lua b/lib/wibox/container/margin.lua index 78d74cc1..71555237 100644 --- a/lib/wibox/container/margin.lua +++ b/lib/wibox/container/margin.lua @@ -44,7 +44,12 @@ function margin:layout(_, width, height) local w = self._private.right 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