Preserve old mousegrabber behavior (additionally)

18f6ab1 changed the behavior when resizing floating clients using the
mouse (via modkey + RMB).

Previously, you could initiate the mousegrabber using e.g. "modkey +
RMB", release the key and button, and resize the window using the left
mouse button.

This restores this behavior by canceling the mousegrabbers only if the
cursor was moved, without _any_ mouse button being pressed.

Fixes https://github.com/awesomeWM/awesome/issues/309.
Closes https://github.com/awesomeWM/awesome/pull/310.
This commit is contained in:
Daniel Hahler 2015-07-13 20:52:16 +02:00
parent 5e6f104e0e
commit 355e4696ba
3 changed files with 9 additions and 3 deletions

View File

@ -28,10 +28,12 @@ function floating.mouse_resize_handler(c, corner, x, y)
-- Warp mouse pointer -- Warp mouse pointer
capi.mouse.coords({ x = x, y = y }) capi.mouse.coords({ x = x, y = y })
local prev_coords = {}
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
for k, v in ipairs(_mouse.buttons) do for k, v in ipairs(_mouse.buttons) do
if v then if v then
local ng local ng
prev_coords = { x =_mouse.x, y = _mouse.y }
if corner == "bottom_right" then if corner == "bottom_right" then
ng = { width = _mouse.x - g.x, ng = { width = _mouse.x - g.x,
height = _mouse.y - g.y } height = _mouse.y - g.y }
@ -74,7 +76,7 @@ function floating.mouse_resize_handler(c, corner, x, y)
return true return true
end end
end end
return false return prev_coords.x == _mouse.x and prev_coords.y == _mouse.y
end, corner .. "_corner") end, corner .. "_corner")
end end

View File

@ -30,9 +30,11 @@ function magnifier.mouse_resize_handler(c, corner, x, y)
local center_y = wa.y + wa.height / 2 local center_y = wa.y + wa.height / 2
local maxdist_pow = (wa.width^2 + wa.height^2) / 4 local maxdist_pow = (wa.width^2 + wa.height^2) / 4
local prev_coords = {}
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
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 }
local dx = center_x - _mouse.x local dx = center_x - _mouse.x
local dy = center_y - _mouse.y local dy = center_y - _mouse.y
local dist = dx^2 + dy^2 local dist = dx^2 + dy^2
@ -43,7 +45,7 @@ function magnifier.mouse_resize_handler(c, corner, x, y)
return true return true
end end
end end
return false return prev_coords.x == _mouse.x and prev_coords.y == _mouse.y
end, corner .. "_corner") end, corner .. "_corner")
end end

View File

@ -69,9 +69,11 @@ local function mouse_resize_handler(c, corner, x, y, orientation)
capi.mouse.coords({ y = wa.y + wa.height * (1 - mwfact), x= g.x + offset }) capi.mouse.coords({ y = wa.y + wa.height * (1 - mwfact), x= g.x + offset })
end end
local prev_coords = {}
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
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 }
local fact_x = (_mouse.x - wa.x) / wa.width local fact_x = (_mouse.x - wa.x) / wa.width
local fact_y = (_mouse.y - wa.y) / wa.height local fact_y = (_mouse.y - wa.y) / wa.height
local mwfact local mwfact
@ -114,7 +116,7 @@ local function mouse_resize_handler(c, corner, x, y, orientation)
return true return true
end end
end end
return false return prev_coords.x == _mouse.x and prev_coords.y == _mouse.y
end, cursor) end, cursor)
end end