Skip to content

Commit

Permalink
wibox.container.margin: Do not produce negative sizes
Browse files Browse the repository at this point in the history
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: awesomeWM#2799
Signed-off-by: Uli Schlachter <[email protected]>
  • Loading branch information
psychon committed Jun 19, 2019
1 parent 99e81c0 commit f025409
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/wibox/container/margin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f025409

Please sign in to comment.