From bed7abf5d1fa1ad7859dee3c8f9b2bc3d28b9d25 Mon Sep 17 00:00:00 2001 From: ma9e <36235154+ma9e@users.noreply.github.com> Date: Sun, 22 Apr 2018 01:02:52 -0500 Subject: [PATCH] Add support for gaps between snapped contents (#2208) --- lib/awful/mouse/init.lua | 4 ++++ lib/awful/mouse/snap.lua | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/awful/mouse/init.lua b/lib/awful/mouse/init.lua index 23240429..662daa06 100644 --- a/lib/awful/mouse/init.lua +++ b/lib/awful/mouse/init.lua @@ -57,6 +57,10 @@ mouse.wibox = {} -- @beautiful beautiful.snap_shape -- @tparam function shape A `gears.shape` compatible function +--- The gap between snapped contents. +-- @beautiful beautiful.snapper_gap +-- @tparam number (default: 0) + --- Get the client object under the pointer. -- @deprecated awful.mouse.client_under_pointer -- @return The client object under the pointer, if one can be found. diff --git a/lib/awful/mouse/snap.lua b/lib/awful/mouse/snap.lua index e212d123..b1a115e0 100644 --- a/lib/awful/mouse/snap.lua +++ b/lib/awful/mouse/snap.lua @@ -197,11 +197,12 @@ function module.snap(c, snap, x, y, fixed_x, fixed_y) c = c or capi.client.focus local cur_geom = c:geometry() local geom = c:geometry() - geom.width = geom.width + (2 * c.border_width) - geom.height = geom.height + (2 * c.border_width) + local snapper_gap = beautiful.snapper_gap or 0 local edge - geom.x = x or geom.x - geom.y = y or geom.y + geom.x = (x or geom.x) - snapper_gap + geom.y = (y or geom.y) - snapper_gap + geom.width = geom.width + (2 * c.border_width) + (2 * snapper_gap) + geom.height = geom.height + (2 * c.border_width) + (2 * snapper_gap) geom, edge = snap_inside(geom, c.screen.geometry, snap) geom = snap_inside(geom, c.screen.workarea, snap) @@ -227,14 +228,18 @@ function module.snap(c, snap, x, y, fixed_x, fixed_y) for _, snapper in ipairs(aclient.visible(c.screen)) do if snapper ~= c then local snapper_geom = snapper:geometry() - snapper_geom.width = snapper_geom.width + (2 * snapper.border_width) - snapper_geom.height = snapper_geom.height + (2 * snapper.border_width) + snapper_geom.x = snapper_geom.x - snapper_gap + snapper_geom.y = snapper_geom.y - snapper_gap + snapper_geom.width = snapper_geom.width + (2 * snapper.border_width) + (2 * snapper_gap) + snapper_geom.height = snapper_geom.height + (2 * snapper.border_width) + (2 * snapper_gap) geom = snap_outside(geom, snapper_geom, snap) end end - geom.width = geom.width - (2 * c.border_width) - geom.height = geom.height - (2 * c.border_width) + geom.x = geom.x + snapper_gap + geom.y = geom.y + snapper_gap + geom.width = geom.width - (2 * c.border_width) - (2 * snapper_gap) + geom.height = geom.height - (2 * c.border_width) - (2 * snapper_gap) -- It's easiest to undo changes afterwards if they're not allowed if fixed_x then geom.x = cur_geom.x end