awful.placement: Fix a closest_corner corner case

When the mouse was exactly on the right or bottom edge, there was a
rounding error.
This commit is contained in:
Emmanuel Lepage Vallee 2016-04-21 04:01:41 -04:00
parent 7242b30c01
commit e93e2913b6
1 changed files with 4 additions and 2 deletions

View File

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