From 2a57d944bae73066f53169239c0fdb3ef6f666bf Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 5 Mar 2017 20:00:43 +0100 Subject: [PATCH] gears.geometry: Fix rectangle intersection computation Previously, when gears.geometry.rectangle.get_intersection() was called with two non-intersecting rectangles, it would return a negative width/height. Signed-off-by: Uli Schlachter --- lib/gears/geometry.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/gears/geometry.lua b/lib/gears/geometry.lua index a5144356..70628888 100644 --- a/lib/gears/geometry.lua +++ b/lib/gears/geometry.lua @@ -176,6 +176,9 @@ function gears.geometry.rectangle.get_intersection(a, b) g.y = math.max(a.y, b.y) g.width = math.min(a.x + a.width, b.x + b.width) - g.x g.height = math.min(a.y + a.height, b.y + b.height) - g.y + if g.width <= 0 or g.height <= 0 then + g.width, g.height = 0, 0 + end return g end