diff --git a/lib/wibox/container/margin.lua b/lib/wibox/container/margin.lua index 78d74cc1a..715552376 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 diff --git a/lib/wibox/hierarchy.lua b/lib/wibox/hierarchy.lua index a5edddfad..7dbeb73a0 100644 --- a/lib/wibox/hierarchy.lua +++ b/lib/wibox/hierarchy.lua @@ -304,8 +304,8 @@ end --- Does the given cairo context have an empty clip (aka "no drawing possible")? local function empty_clip(cr) - local _, _, width, height = cr:clip_extents() - return width == 0 or height == 0 + local x1, y1, x2, y2 = cr:clip_extents() + return x2 - x1 == 0 or y2 - y1 == 0 end --- Draw a hierarchy to some cairo context. diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index dc8bf5ff0..d3958b2d8 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -397,6 +397,8 @@ end -- @treturn table An opaque object that can be returned from `:layout()`. -- @staticfct wibox.widget.base.place_widget_via_matrix function base.place_widget_via_matrix(widget, mat, width, height) + assert(width >= 0, "A widget's width cannot be negative: " .. tostring(width)) + assert(height >= 0, "A widget's height cannot be negative: " .. tostring(height)) return { _widget = widget, _width = width,