From baec2efe2d7fb6182f227171391969f4475a1258 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 22 Apr 2016 03:04:28 -0400 Subject: [PATCH] awful.mouse.move: Fix snapping support --- lib/awful/mouse/init.lua | 6 +++++- lib/awful/mouse/snap.lua | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/awful/mouse/init.lua b/lib/awful/mouse/init.lua index 867ca61f..5dbc774f 100644 --- a/lib/awful/mouse/init.lua +++ b/lib/awful/mouse/init.lua @@ -84,7 +84,11 @@ function mouse.client.move(c, snap, finished_cb) --luacheck: no unused args y = geo.y - coords.y, } - mouse.resize(c, "mouse.move", {placement=aplace.under_mouse, offset=offset}) + mouse.resize(c, "mouse.move", { + placement = aplace.under_mouse, + offset = offset, + snap = snap + }) end mouse.client.dragtotag = { } diff --git a/lib/awful/mouse/snap.lua b/lib/awful/mouse/snap.lua index 746151c8..33c101c2 100644 --- a/lib/awful/mouse/snap.lua +++ b/lib/awful/mouse/snap.lua @@ -8,6 +8,7 @@ --------------------------------------------------------------------------- local aclient = require("awful.client") +local resize = require("awful.mouse.resize") local capi = { root = root, @@ -121,5 +122,15 @@ function module.snap(c, snap, x, y, fixed_x, fixed_y) return geom end +-- Enable edge snapping +resize.add_move_callback(function(c, geo, args) + if args and (args.snap == nil or args.snap) then + local ngeo = module.snap(c, args.snap, geo.x, geo.y) + ngeo.x = ngeo.x + (2 * c.border_width) + ngeo.y = ngeo.y + (2 * c.border_width) + return ngeo + end +end, "mouse.move") + return setmetatable(module, {__call = function(_, ...) return module.snap(...) end})