Refactor helpers.float_and_edge_snap

Also now it respects beautiful.useless_gap
This commit is contained in:
elenapan 2020-03-11 01:16:34 +02:00
parent 96daf9e29a
commit a535cede1e

View file

@ -249,38 +249,36 @@ function helpers.move_client_dwim(c, direction)
end
-- Make client floating and snap to the desired edge
-- Respects gaps
-- TODO needs work
function helpers.float_and_edge_snap(c, direction)
-- if not c.floating then
-- c.floating = true
-- end
naughty.notify({ text = "double tap"})
c.maximized = false
c.floating = true
local workarea = awful.screen.focused().workarea
local f
if direction == "up" then
local axis = 'horizontally'
local f = awful.placement.scale
f = awful.placement.scale
+ awful.placement.top
+ (axis and awful.placement['maximize_'..axis] or nil)
local geo = f(client.focus, {honor_padding = true, honor_workarea=true, to_percent = 0.5})
elseif direction == "down" then
local axis = 'horizontally'
local f = awful.placement.scale
f = awful.placement.scale
+ awful.placement.bottom
+ (axis and awful.placement['maximize_'..axis] or nil)
local geo = f(client.focus, {honor_padding = true, honor_workarea=true, to_percent = 0.5})
elseif direction == "left" then
local axis = 'vertically'
local f = awful.placement.scale
f = awful.placement.scale
+ awful.placement.left
+ (axis and awful.placement['maximize_'..axis] or nil)
local geo = f(client.focus, {honor_padding = true, honor_workarea=true, to_percent = 0.5})
elseif direction == "right" then
local axis = 'vertically'
local f = awful.placement.scale
f = awful.placement.scale
+ awful.placement.right
+ (axis and awful.placement['maximize_'..axis] or nil)
local geo = f(client.focus, {honor_padding = true, honor_workarea=true, to_percent = 0.5})
end
-- TODO gap should be different depending on position
f(client.focus, {honor_padding = true, honor_workarea=true, to_percent = 0.5, margins = beautiful.useless_gap * 2 })
end
-- Rounds a number to any number of decimals