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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-03-05 20:00:43 +01:00
parent 4a42ed0d44
commit 2a57d944ba
1 changed files with 3 additions and 0 deletions

View File

@ -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