Merge pull request #2104 from Elv13/fix_2101
Fix the resize/move "after" mode
This commit is contained in:
commit
10057ec51c
|
@ -156,11 +156,12 @@ local function handler(_, client, context, args) --luacheck: no unused_args
|
||||||
capi.mousegrabber.run(function (_mouse)
|
capi.mousegrabber.run(function (_mouse)
|
||||||
if not client.valid then return end
|
if not client.valid then return end
|
||||||
|
|
||||||
-- Resize everytime the mouse moves (default behavior).
|
-- Resize everytime the mouse moves (default behavior) in live mode,
|
||||||
if args.mode == "live" then
|
-- otherwise keep the current geometry
|
||||||
-- Get the new geometry
|
geo = setmetatable(
|
||||||
geo = setmetatable(args.placement(client, args), {__index=args})
|
args.mode == "live" and args.placement(client, args) or client:geometry(),
|
||||||
end
|
{__index=args}
|
||||||
|
)
|
||||||
|
|
||||||
-- Execute the move callbacks. This can be used to add features such as
|
-- Execute the move callbacks. This can be used to add features such as
|
||||||
-- snap or adding fancy graphical effects.
|
-- snap or adding fancy graphical effects.
|
||||||
|
@ -182,7 +183,9 @@ local function handler(_, client, context, args) --luacheck: no unused_args
|
||||||
end
|
end
|
||||||
|
|
||||||
-- In case it was modified
|
-- In case it was modified
|
||||||
setmetatable(geo,{__index=args})
|
if geo then
|
||||||
|
setmetatable(geo, {__index=args})
|
||||||
|
end
|
||||||
|
|
||||||
if args.mode == "live" then
|
if args.mode == "live" then
|
||||||
-- Ask the resizing handler to resize the client
|
-- Ask the resizing handler to resize the client
|
||||||
|
|
|
@ -103,7 +103,7 @@ table.insert(steps, function()
|
||||||
return true
|
return true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Shirnk the client by 100px from the top right
|
-- Shrink the client by 100px from the top right
|
||||||
table.insert(steps, function()
|
table.insert(steps, function()
|
||||||
|
|
||||||
local c = client.get()[1]
|
local c = client.get()[1]
|
||||||
|
@ -113,6 +113,51 @@ table.insert(steps, function()
|
||||||
-- assert(c:geometry().width == 200-2*c.border_width) --FIXME off by border width...
|
-- assert(c:geometry().width == 200-2*c.border_width) --FIXME off by border width...
|
||||||
-- assert(c:geometry().height == 200-2*c.border_width) --FIXME off by border width...
|
-- assert(c:geometry().height == 200-2*c.border_width) --FIXME off by border width...
|
||||||
|
|
||||||
|
|
||||||
|
-- Now do a couple check with the "after" mode to make sure it doesn't
|
||||||
|
-- regress.
|
||||||
|
root.fake_input("button_release",1)
|
||||||
|
|
||||||
|
mousegrabber.stop()
|
||||||
|
|
||||||
|
amouse.resize.set_mode("after")
|
||||||
|
c.border_width = 0
|
||||||
|
c:geometry {
|
||||||
|
x = 100,
|
||||||
|
y = 200,
|
||||||
|
width = 300,
|
||||||
|
height = 200,
|
||||||
|
}
|
||||||
|
assert(c:geometry().x == 100)
|
||||||
|
assert(c:geometry().y == 200)
|
||||||
|
assert(c:geometry().width == 300)
|
||||||
|
assert(c:geometry().height == 200)
|
||||||
|
|
||||||
|
root.fake_input("button_press",1)
|
||||||
|
amouse.client.resize(c)
|
||||||
|
|
||||||
|
mouse.coords {x = 500, y= 500}
|
||||||
|
|
||||||
|
return true
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Grow the client by 100px from the top left ("after" mode)
|
||||||
|
table.insert(steps, function()
|
||||||
|
|
||||||
|
-- local c = client.get()[1]
|
||||||
|
|
||||||
|
-- if not mousegrabber.isrunning then --FIXME it should work, but doesn't
|
||||||
|
-- return true
|
||||||
|
-- end
|
||||||
|
|
||||||
|
--FIXME, the mousegrabber callback says the mouse buttons are not pressed,
|
||||||
|
-- theirfor the test is broken
|
||||||
|
-- Nothing should have changed until button_release is done
|
||||||
|
--assert(c:geometry().x == 100)
|
||||||
|
--assert(c:geometry().y == 200)
|
||||||
|
--assert(c:geometry().width == 300)
|
||||||
|
--assert(c:geometry().height == 200)
|
||||||
|
|
||||||
mouse.coords {x = 300, y= 200}
|
mouse.coords {x = 300, y= 200}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -120,11 +165,17 @@ end)
|
||||||
|
|
||||||
-- Stop the resize
|
-- Stop the resize
|
||||||
table.insert(steps, function()
|
table.insert(steps, function()
|
||||||
|
|
||||||
|
local c = client.get()[1]
|
||||||
|
|
||||||
root.fake_input("button_release",1)
|
root.fake_input("button_release",1)
|
||||||
|
|
||||||
-- if not mousegrabber.isrunning then --FIXME it should work, but doesn't
|
assert(c:geometry().x == 100)
|
||||||
-- return true
|
assert(c:geometry().y == 200)
|
||||||
-- end
|
assert(c:geometry().width == 400)
|
||||||
|
assert(c:geometry().height == 300)
|
||||||
|
|
||||||
|
amouse.resize.set_mode("live")
|
||||||
|
|
||||||
mousegrabber.stop()
|
mousegrabber.stop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue