Merge pull request #2800 from psychon/fix_negative_sizes
Fix negative sizes with the margin container
This commit is contained in:
commit
0857a8fef8
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue