Add support for gaps between snapped contents (#2208)

This commit is contained in:
ma9e 2018-04-22 01:02:52 -05:00 committed by Emmanuel Lepage Vallée
parent c0b8388f9b
commit bed7abf5d1
2 changed files with 17 additions and 8 deletions

View File

@ -57,6 +57,10 @@ mouse.wibox = {}
-- @beautiful beautiful.snap_shape -- @beautiful beautiful.snap_shape
-- @tparam function shape A `gears.shape` compatible function -- @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. --- Get the client object under the pointer.
-- @deprecated awful.mouse.client_under_pointer -- @deprecated awful.mouse.client_under_pointer
-- @return The client object under the pointer, if one can be found. -- @return The client object under the pointer, if one can be found.

View File

@ -197,11 +197,12 @@ function module.snap(c, snap, x, y, fixed_x, fixed_y)
c = c or capi.client.focus c = c or capi.client.focus
local cur_geom = c:geometry() local cur_geom = c:geometry()
local geom = c:geometry() local geom = c:geometry()
geom.width = geom.width + (2 * c.border_width) local snapper_gap = beautiful.snapper_gap or 0
geom.height = geom.height + (2 * c.border_width)
local edge local edge
geom.x = x or geom.x geom.x = (x or geom.x) - snapper_gap
geom.y = y or geom.y 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, edge = snap_inside(geom, c.screen.geometry, snap)
geom = snap_inside(geom, c.screen.workarea, 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 for _, snapper in ipairs(aclient.visible(c.screen)) do
if snapper ~= c then if snapper ~= c then
local snapper_geom = snapper:geometry() local snapper_geom = snapper:geometry()
snapper_geom.width = snapper_geom.width + (2 * snapper.border_width) snapper_geom.x = snapper_geom.x - snapper_gap
snapper_geom.height = snapper_geom.height + (2 * snapper.border_width) 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) geom = snap_outside(geom, snapper_geom, snap)
end end
end end
geom.width = geom.width - (2 * c.border_width) geom.x = geom.x + snapper_gap
geom.height = geom.height - (2 * c.border_width) 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 -- It's easiest to undo changes afterwards if they're not allowed
if fixed_x then geom.x = cur_geom.x end if fixed_x then geom.x = cur_geom.x end