From 75af0a24c76b19dcdcac2e427b7392ba639330f9 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 21 Apr 2016 04:07:35 -0400 Subject: [PATCH] awful.placement: Add a 'pretend' option --- lib/awful/placement.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/awful/placement.lua b/lib/awful/placement.lua index 435d34d0..e9133198 100644 --- a/lib/awful/placement.lua +++ b/lib/awful/placement.lua @@ -18,6 +18,11 @@ -- -- ### Common arguments -- +-- **pretend** (*boolean*): +-- +-- Do not apply the new geometry. This is useful if only the return values is +-- necessary. +-- -- **honor_workarea** (*boolean*): -- -- Take workarea into account when placing the drawable (default: false) @@ -209,14 +214,17 @@ local function geometry_common(obj, args, new_geo, ignore_border_width) -- It's a mouse if obj.coords then - local coords = new_geo and obj.coords(new_geo) or obj.coords() + local coords = (not args.pretend and new_geo) + 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, new_geo, ignore_border_width) + local dgeo = area_common( + obj, (not args.pretend) and new_geo or nil, ignore_border_width + ) -- Apply the margins if args.margins then @@ -680,6 +688,7 @@ function placement.resize_to_mouse(d, args) -- Otherwise, the result will always be 1x1 local _, closest_corner = placement.closest_corner(capi.mouse, { parent = d, + pretend = true, include_sides = args.include_sides or false, })