From f60abed1d0340ca41bff145595a651c0c14579a9 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 24 Jun 2019 17:10:50 -0400 Subject: [PATCH] gears.geometry: Add a function to compare 2 rectangles. The next step will be to find all the places where this is duplicated. --- lib/gears/geometry.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/gears/geometry.lua b/lib/gears/geometry.lua index 364aedf96..0ad73234f 100644 --- a/lib/gears/geometry.lua +++ b/lib/gears/geometry.lua @@ -151,6 +151,20 @@ function gears.geometry.rectangle.get_in_direction(dir, recttbl, cur) return target end +--- Return true if the area are exactly identical. +-- +-- The areas are table with a `x`, `y`, `width` and `height` keys. +-- +-- @tparam table a The area. +-- @tparam table b The other area. +-- @treturn boolean If the areas are identical. +function gears.geometry.rectangle.are_equal(a, b) + for _, v in ipairs {"x", "y", "width", "height"} do + if a[v] ~= b[v] then return false end + end + return true +end + --- Check if an area intersect another area. -- @param a The area. -- @param b The other area.