feat(lib: awful: layout: suit: tile): add 'resize_jump_to_corner'
This commit is contained in:
parent
d5818d0e1a
commit
b47eabf4f0
|
@ -23,6 +23,9 @@ local capi =
|
||||||
|
|
||||||
local tile = {}
|
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 function mouse_resize_handler(c, corner, x, y, orientation)
|
||||||
local orientation = orientation or "tile"
|
local orientation = orientation or "tile"
|
||||||
local wa = capi.screen[c.screen].workarea
|
local wa = capi.screen[c.screen].workarea
|
||||||
|
@ -30,7 +33,9 @@ local function mouse_resize_handler(c, corner, x, y, orientation)
|
||||||
local cursor
|
local cursor
|
||||||
local g = c:geometry()
|
local g = c:geometry()
|
||||||
local offset = 0
|
local offset = 0
|
||||||
local x,y
|
local corner_coords
|
||||||
|
local coordinates_delta = {x=0,y=0}
|
||||||
|
|
||||||
if orientation == "tile" then
|
if orientation == "tile" then
|
||||||
cursor = "cross"
|
cursor = "cross"
|
||||||
if g.height+15 > wa.height then
|
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
|
elseif not (g.y+g.height+15 > wa.y+wa.height) then
|
||||||
offset = g.height
|
offset = g.height
|
||||||
end
|
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
|
elseif orientation == "left" then
|
||||||
cursor = "cross"
|
cursor = "cross"
|
||||||
if g.height+15 >= wa.height then
|
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
|
elseif not (g.y+g.height+15 > wa.y+wa.height) then
|
||||||
offset = g.height
|
offset = g.height
|
||||||
end
|
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
|
elseif orientation == "bottom" then
|
||||||
cursor = "cross"
|
cursor = "cross"
|
||||||
if g.width+15 >= wa.width then
|
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
|
elseif not (g.x+g.width+15 > wa.x+wa.width) then
|
||||||
offset = g.width
|
offset = g.width
|
||||||
end
|
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
|
else
|
||||||
cursor = "cross"
|
cursor = "cross"
|
||||||
if g.width+15 >= wa.width then
|
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
|
elseif not (g.x+g.width+15 > wa.x+wa.width) then
|
||||||
offset = g.width
|
offset = g.width
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
local prev_coords = {}
|
local prev_coords = {}
|
||||||
capi.mousegrabber.run(function (_mouse)
|
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
|
for k, v in ipairs(_mouse.buttons) do
|
||||||
if v then
|
if v then
|
||||||
prev_coords = { x =_mouse.x, y = _mouse.y }
|
prev_coords = { x =_mouse.x, y = _mouse.y }
|
||||||
|
|
Loading…
Reference in New Issue