awful.mouse: Add a request::geometry handler.
This commit is contained in:
parent
f8f57fb6b7
commit
be455cb140
|
@ -329,8 +329,9 @@ end
|
||||||
|
|
||||||
--- Resize a client.
|
--- Resize a client.
|
||||||
-- @param c The client to resize, or the focused one by default.
|
-- @param c The client to resize, or the focused one by default.
|
||||||
-- @param corner The corner to grab on resize. Auto detected by default.
|
-- @tparam string corner The corner to grab on resize. Auto detected by default.
|
||||||
function mouse.client.resize(c, corner)
|
-- @tparam[opt={}] table args A set of `awful.placement` arguments
|
||||||
|
function mouse.client.resize(c, corner, args)
|
||||||
c = c or capi.client.focus
|
c = c or capi.client.focus
|
||||||
|
|
||||||
if not c then return end
|
if not c then return end
|
||||||
|
@ -342,16 +343,39 @@ function mouse.client.resize(c, corner)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local lay = layout.get(c.screen)
|
-- Move the mouse to the corner
|
||||||
local corner2, x, y = mouse.client.corner(c, corner)
|
if corner and aplace[corner] then
|
||||||
|
aplace[corner](capi.mouse, {parent=c})
|
||||||
|
end
|
||||||
|
|
||||||
|
mouse.resize(c, "mouse.resize", args or {include_sides=true})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Default handler for `request::geometry` signals with `mouse.resize` context.
|
||||||
|
-- @tparam client c The client
|
||||||
|
-- @tparam string context The context
|
||||||
|
-- @tparam[opt={}] table hints The hints to pass to the handler
|
||||||
|
function mouse.resize_handler(c, context, hints)
|
||||||
|
if hints and context and context:find("mouse.*") then
|
||||||
|
-- This handler only handle the floating clients. If the client is tiled,
|
||||||
|
-- then it let the layouts handle it.
|
||||||
|
local lay = c.screen.selected_tag.layout
|
||||||
|
|
||||||
if lay == layout.suit.floating or c.floating then
|
if lay == layout.suit.floating or c.floating then
|
||||||
return layout.suit.floating.mouse_resize_handler(c, corner2, x, y)
|
c:geometry {
|
||||||
elseif lay.mouse_resize_handler then
|
x = hints.x,
|
||||||
return lay.mouse_resize_handler(c, corner2, x, y)
|
y = hints.y,
|
||||||
|
width = hints.width,
|
||||||
|
height = hints.height,
|
||||||
|
}
|
||||||
|
elseif lay.resize_handler then
|
||||||
|
lay.resize_handler(c, context, hints)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
capi.client.connect_signal("request::geometry", mouse.resize_handler)
|
||||||
|
|
||||||
-- Set the cursor at startup
|
-- Set the cursor at startup
|
||||||
capi.root.cursor("left_ptr")
|
capi.root.cursor("left_ptr")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue