From a4dadde33553847bcf754e11c85457c83c81da20 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 19 Jun 2019 18:23:08 +0200 Subject: [PATCH] Fix wibox.hierarchy's empty_clip() This function checks if a given cairo context has an empty clip. It was written with the assumption that cairo_clip_extents() produces the x, y, width, height of the clip extents. However, that function actually produces x1, y1, x2, y2, where (x1, y1) and (x2, y2) are the corners of the rectangles. Due to the way the function is written, it will return non-zero numbers when there is a translation (cr:translate()). Thus, this function worked basically never. Fix this by checking if both points have the same X- or Y-coordinate. Signed-off-by: Uli Schlachter --- lib/wibox/hierarchy.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wibox/hierarchy.lua b/lib/wibox/hierarchy.lua index a5edddfa..7dbeb73a 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.