From 19d4a3f60218cd05fc78402d857fb5ab2202e83f Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 12 Aug 2016 17:00:16 -0400 Subject: [PATCH 1/2] placement.under_mouse: Fix a rounding error. When object size contains odd numbers, the result was +1px off. --- lib/awful/placement.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index 0eb7825a..778977e3 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -761,8 +761,8 @@ function placement.under_mouse(d, args) local m_coords = capi.mouse.coords() local ngeo = geometry_common(d, args) - ngeo.x = m_coords.x - ngeo.width / 2 - ngeo.y = m_coords.y - ngeo.height / 2 + ngeo.x = math.floor(m_coords.x - ngeo.width / 2) + ngeo.y = math.floor(m_coords.y - ngeo.height / 2) local bw = d.border_width or 0 ngeo.width = ngeo.width - 2*bw From 9d69448ac1c64bf2d24d05ef861f0c9dcbc43d07 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 12 Aug 2016 17:01:08 -0400 Subject: [PATCH 2/2] tests: Test mouse.move on odd sized clients. Close #1039 --- tests/test-resize.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test-resize.lua b/tests/test-resize.lua index d7c8085e..a1681890 100644 --- a/tests/test-resize.lua +++ b/tests/test-resize.lua @@ -403,6 +403,39 @@ table.insert(steps, function() assert(c.first_tag == cur_tag) + c:geometry { + x = 99, + y = 99, + width = 99, + height = 99, + } + + return true +end) + +-- Test that odd number sized clients don't move by accident +for _=1, 15 do + table.insert(steps, function() + local c = client.get()[1] + + root.fake_input("button_press",1) + amouse.client.move(c) + root.fake_input("button_release",1) + + + return true + end) +end + +table.insert(steps, function() + local c = client.get()[1] + root.fake_input("button_release",1) + + assert(c.x == 99) + assert(c.y == 99) + assert(c.width == 99) + assert(c.height == 99) + return true end)