From e93e2913b670ba8aee80842e6090417e76fe1bfa Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 21 Apr 2016 04:01:41 -0400 Subject: [PATCH] awful.placement: Fix a closest_corner corner case When the mouse was exactly on the right or bottom edge, there was a rounding error. --- lib/awful/placement.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index e9133198..59fea71f 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -500,8 +500,10 @@ function placement.closest_corner(d, args) -- Use the product of 3 to get the closest point in a NxN matrix local function f(_n, mat) n = _n - corner_i = -math.ceil( ( (sgeo.x - pos.x) * n) / sgeo.width ) - corner_j = -math.ceil( ( (sgeo.y - pos.y) * n) / sgeo.height ) + -- The +1 is required to avoid a rounding error when + -- pos.x == sgeo.x+sgeo.width + corner_i = -math.ceil( ( (sgeo.x - pos.x) * n) / (sgeo.width + 1)) + corner_j = -math.ceil( ( (sgeo.y - pos.y) * n) / (sgeo.height + 1)) return mat[corner_j + 1][corner_i + 1] end