From d5818d0e1a4ae5fcb5a8e3fa02d3e750addfd90a Mon Sep 17 00:00:00 2001 From: actionless Date: Fri, 7 Aug 2015 18:50:08 +0200 Subject: [PATCH 1/2] feat(lib: awful: layout: suit: floating): add 'resize_jump_to_corner' --- lib/awful/layout/suit/floating.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/awful/layout/suit/floating.lua b/lib/awful/layout/suit/floating.lua index 306898657..3a320df17 100644 --- a/lib/awful/layout/suit/floating.lua +++ b/lib/awful/layout/suit/floating.lua @@ -18,6 +18,9 @@ local capi = local floating = {} +--- Jump mouse cursor to the client's corner when resizing it. +floating.resize_jump_to_corner = true + function floating.mouse_resize_handler(c, corner, x, y) local g = c:geometry() @@ -25,11 +28,22 @@ function floating.mouse_resize_handler(c, corner, x, y) local fixed_x = c.maximized_horizontal local fixed_y = c.maximized_vertical - -- Warp mouse pointer - capi.mouse.coords({ x = x, y = y }) - local prev_coords = {} + local coordinates_delta = {x=0,y=0} + if floating.resize_jump_to_corner then + -- Warp mouse pointer + capi.mouse.coords({ x = x, y = y }) + else + local corner_x, corner_y = x, y + local mouse_coords = capi.mouse.coords() + x = mouse_coords.x + y = mouse_coords.y + coordinates_delta = {x=corner_x-x,y=corner_y-y} + end + capi.mousegrabber.run(function (_mouse) + _mouse.x = _mouse.x + coordinates_delta.x + _mouse.y = _mouse.y + coordinates_delta.y for k, v in ipairs(_mouse.buttons) do if v then local ng From b47eabf4f042c16c72350b02bd22d51659bf29d3 Mon Sep 17 00:00:00 2001 From: actionless Date: Tue, 11 Aug 2015 22:43:17 +0200 Subject: [PATCH 2/2] feat(lib: awful: layout: suit: tile): add 'resize_jump_to_corner' --- lib/awful/layout/suit/tile.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/awful/layout/suit/tile.lua b/lib/awful/layout/suit/tile.lua index 20abadeca..42808e736 100644 --- a/lib/awful/layout/suit/tile.lua +++ b/lib/awful/layout/suit/tile.lua @@ -23,6 +23,9 @@ local capi = local tile = {} +--- Jump mouse cursor to the client's corner when resizing it. +tile.resize_jump_to_corner = true + local function mouse_resize_handler(c, corner, x, y, orientation) local orientation = orientation or "tile" local wa = capi.screen[c.screen].workarea @@ -30,7 +33,9 @@ local function mouse_resize_handler(c, corner, x, y, orientation) local cursor local g = c:geometry() local offset = 0 - local x,y + local corner_coords + local coordinates_delta = {x=0,y=0} + if orientation == "tile" then cursor = "cross" if g.height+15 > wa.height then @@ -39,7 +44,7 @@ local function mouse_resize_handler(c, corner, x, y, orientation) elseif not (g.y+g.height+15 > wa.y+wa.height) then offset = g.height end - capi.mouse.coords({ x = wa.x + wa.width * mwfact, y = g.y + offset }) + corner_coords = { x = wa.x + wa.width * mwfact, y = g.y + offset } elseif orientation == "left" then cursor = "cross" if g.height+15 >= wa.height then @@ -48,7 +53,7 @@ local function mouse_resize_handler(c, corner, x, y, orientation) elseif not (g.y+g.height+15 > wa.y+wa.height) then offset = g.height end - capi.mouse.coords({ x = wa.x + wa.width * (1 - mwfact), y = g.y + offset }) + corner_coords = { x = wa.x + wa.width * (1 - mwfact), y = g.y + offset } elseif orientation == "bottom" then cursor = "cross" if g.width+15 >= wa.width then @@ -57,7 +62,7 @@ local function mouse_resize_handler(c, corner, x, y, orientation) elseif not (g.x+g.width+15 > wa.x+wa.width) then offset = g.width end - capi.mouse.coords({ y = wa.y + wa.height * mwfact, x = g.x + offset}) + corner_coords = { y = wa.y + wa.height * mwfact, x = g.x + offset} else cursor = "cross" if g.width+15 >= wa.width then @@ -66,11 +71,22 @@ local function mouse_resize_handler(c, corner, x, y, orientation) elseif not (g.x+g.width+15 > wa.x+wa.width) then offset = g.width end - capi.mouse.coords({ y = wa.y + wa.height * (1 - mwfact), x= g.x + offset }) + corner_coords = { y = wa.y + wa.height * (1 - mwfact), x= g.x + offset } + end + if tile.resize_jump_to_corner then + capi.mouse.coords(corner_coords) + else + local mouse_coords = capi.mouse.coords() + coordinates_delta = { + x = corner_coords.x - mouse_coords.x, + y = corner_coords.y - mouse_coords.y, + } end local prev_coords = {} capi.mousegrabber.run(function (_mouse) + _mouse.x = _mouse.x + coordinates_delta.x + _mouse.y = _mouse.y + coordinates_delta.y for k, v in ipairs(_mouse.buttons) do if v then prev_coords = { x =_mouse.x, y = _mouse.y }