awful.mouse: Deprecate awful.mouse.client.corner

This commit is contained in:
Emmanuel Lepage Vallee 2016-04-21 01:51:34 -04:00
parent 75af0a24c7
commit 7242b30c01
1 changed files with 19 additions and 36 deletions

View File

@ -11,6 +11,7 @@
local layout = require("awful.layout") local layout = require("awful.layout")
local tag = require("awful.tag") local tag = require("awful.tag")
local aclient = require("awful.client") local aclient = require("awful.client")
local aplace = require("awful.placement")
local awibox = require("awful.wibox") local awibox = require("awful.wibox")
local util = require("awful.util") local util = require("awful.util")
local type = type local type = type
@ -297,49 +298,31 @@ function mouse.wibox.move(w)
end end
--- Get a client corner coordinates. --- Get a client corner coordinates.
-- @param c The client to get corner from, focused one by default. -- @tparam[opt=client.focus] client c The client to get corner from, focused one by default.
-- @param corner The corner to use: auto, top_left, top_right, bottom_left, -- @tparam string corner The corner to use: auto, top_left, top_right, bottom_left,
-- bottom_right. Default is auto, and auto find the nearest corner. -- bottom_right, left, right, top bottom. Default is auto, and auto find the
-- @return Actual used corner and x and y coordinates. -- nearest corner.
-- @treturn string The corner name
-- @treturn number x The horizontal position
-- @treturn number y The vertical position
function mouse.client.corner(c, corner) function mouse.client.corner(c, corner)
util.deprecated(
"Use awful.placement.closest_corner(mouse) or awful.placement[corner](mouse)"..
" instead of awful.mouse.client.corner"
)
c = c or capi.client.focus c = c or capi.client.focus
if not c then return end if not c then return end
local g = c:geometry() local ngeo = nil
if not corner or corner == "auto" then if (not corner) or corner == "auto" then
local m_c = capi.mouse.coords() ngeo, corner = aplace.closest_corner(mouse, {parent = c})
if math.abs(g.y - m_c.y) < math.abs(g.y + g.height - m_c.y) then elseif corner and aplace[corner] then
if math.abs(g.x - m_c.x) < math.abs(g.x + g.width - m_c.x) then ngeo = aplace[corner](mouse, {parent = c})
corner = "top_left"
else
corner = "top_right"
end
else
if math.abs(g.x - m_c.x) < math.abs(g.x + g.width - m_c.x) then
corner = "bottom_left"
else
corner = "bottom_right"
end
end
end end
local x, y return corner, ngeo and ngeo.x or nil, ngeo and ngeo.y or nil
if corner == "top_right" then
x = g.x + g.width
y = g.y
elseif corner == "top_left" then
x = g.x
y = g.y
elseif corner == "bottom_left" then
x = g.x
y = g.y + g.height
else
x = g.x + g.width
y = g.y + g.height
end
return corner, x, y
end end
--- Resize a client. --- Resize a client.