placement: Stop detecting screen objects using `type(o.geometry)`.

All object type will now use tables instead of function, so this
check will break.
This commit is contained in:
Emmanuel Lepage Vallee 2019-10-20 01:11:23 -04:00
parent d2b7d292b0
commit 36999de123
1 changed files with 22 additions and 24 deletions

View File

@ -392,31 +392,29 @@ local function geometry_common(obj, args, new_geo, ignore_border_width)
and obj.coords(new_geo) or obj.coords() and obj.coords(new_geo) or obj.coords()
return {x=coords.x, y=coords.y, width=0, height=0} return {x=coords.x, y=coords.y, width=0, height=0}
elseif obj.geometry then elseif obj.geometry then
local geo = obj.geometry if obj.get_bounding_geometry then
-- It is a screen, it doesn't support setting new sizes.
-- It is either a drawable or something that implement its API return obj:get_bounding_geometry(args)
if type(geo) == "function" then
local dgeo = area_common(
obj, fix_new_geometry(new_geo, args), ignore_border_width, args
)
-- Apply the margins
if args.margins then
local delta = get_decoration(args)
return {
x = dgeo.x - (delta.left or 0),
y = dgeo.y - (delta.top or 0),
width = dgeo.width + (delta.left or 0) + (delta.right or 0),
height = dgeo.height + (delta.top or 0) + (delta.bottom or 0),
}
end
return dgeo
end end
-- It is a screen, it doesn't support setting new sizes. -- It is either a drawable or something that implement its API
return obj:get_bounding_geometry(args) local dgeo = area_common(
obj, fix_new_geometry(new_geo, args), ignore_border_width, args
)
-- Apply the margins
if args.margins then
local delta = get_decoration(args)
return {
x = dgeo.x - (delta.left or 0),
y = dgeo.y - (delta.top or 0),
width = dgeo.width + (delta.left or 0) + (delta.right or 0),
height = dgeo.height + (delta.top or 0) + (delta.bottom or 0),
}
end
return dgeo
else else
assert(false, "Invalid object") assert(false, "Invalid object")
end end
@ -1462,7 +1460,7 @@ function placement.next_to(d, args)
args = add_context(args, "next_to") args = add_context(args, "next_to")
d = d or capi.client.focus d = d or capi.client.focus
local osize = type(d.geometry) == "function" and d:geometry() or nil local osize = type(d.geometry) == "function" and d:geometry() or d.geometry
local original_pos, original_anchors = args.preferred_positions, args.preferred_anchors local original_pos, original_anchors = args.preferred_positions, args.preferred_anchors
if type(original_pos) == "string" then if type(original_pos) == "string" then