Merge branch 'add-resize-option' of https://github.com/actionless/awesome
This commit is contained in:
commit
769d6acb64
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue