From 36999de123ac921b4e30bb88c090a685bec0ca6b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 20 Oct 2019 01:11:23 -0400 Subject: [PATCH] placement: Stop detecting screen objects using `type(o.geometry)`. All object type will now use tables instead of function, so this check will break. --- lib/awful/placement.lua | 46 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index 173ce7bea..1522cb306 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -392,31 +392,29 @@ local function geometry_common(obj, args, new_geo, ignore_border_width) and obj.coords(new_geo) or obj.coords() return {x=coords.x, y=coords.y, width=0, height=0} elseif obj.geometry then - local geo = obj.geometry - - -- It is either a drawable or something that implement its API - 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 + if obj.get_bounding_geometry then + -- It is a screen, it doesn't support setting new sizes. + return obj:get_bounding_geometry(args) end - -- It is a screen, it doesn't support setting new sizes. - return obj:get_bounding_geometry(args) + -- It is either a drawable or something that implement its API + 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 assert(false, "Invalid object") end @@ -1462,7 +1460,7 @@ function placement.next_to(d, args) args = add_context(args, "next_to") 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 if type(original_pos) == "string" then