From a62e749216a979c73ad4b46a5d3211b429e15e1c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 27 Apr 2016 21:16:20 -0400 Subject: [PATCH] mouse.snap: Add some configuration options --- lib/awful/mouse/init.lua | 11 ++++++++++- lib/awful/mouse/snap.lua | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/awful/mouse/init.lua b/lib/awful/mouse/init.lua index b9026a8c..ee86d2fe 100644 --- a/lib/awful/mouse/init.lua +++ b/lib/awful/mouse/init.lua @@ -38,6 +38,15 @@ mouse.wibox = {} -- @tparam[opt=8] integer default_distance -- @see awful.mouse.snap +--- Enable screen edges snapping. +-- @tfield[opt=true] boolean awful.mouse.snap.edge_enabled + +--- Enable client to client snapping. +-- @tfield[opt=true] boolean awful.mouse.snap.client_enabled + +--- Enable changing tag when a client is dragged to the edge of the screen. +-- @tfield[opt=false] integer awful.mouse.snap.drag_to_tag_enabled + --- The snap outline background color. -- @beautiful beautiful.snap_bg -- @tparam color|string|gradient|pattern color @@ -46,7 +55,7 @@ mouse.wibox = {} -- @beautiful beautiful.snap_border_width -- @param integer ---- The snap outline width. +--- The snap outline shape. -- @beautiful beautiful.snap_shape -- @tparam function shape A `gears.shape` compatible function diff --git a/lib/awful/mouse/snap.lua b/lib/awful/mouse/snap.lua index 76974a55..684217cd 100644 --- a/lib/awful/mouse/snap.lua +++ b/lib/awful/mouse/snap.lua @@ -248,21 +248,21 @@ end -- Enable edge snapping resize.add_move_callback(function(c, geo, args) -- Screen edge snapping (areosnap) - if args and (args.snap == nil or args.snap) then--TODO add a config option + if (module.edge_enabled ~= false) + and args and (args.snap == nil or args.snap) then detect_areasnap(c, 16) end -- Snapping between clients - 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 + if (module.client_enabled ~= false) + and args and (args.snap == nil or args.snap) then + return module.snap(c, args.snap, geo.x, geo.y) end end, "mouse.move") -- Apply the aerosnap resize.add_leave_callback(function(c, _, args) + if module.edge_enabled == false then return end return apply_areasnap(c, args) end, "mouse.move")