placement: Add some extra checks to limit the risk of regressions.
Given noone understand this code, this will prevent some semi likely regressions from going unnoticed. The main risk is the shims not producing the exact same results as the real implementation and cause different code paths to be taken. As of this commit, both the "real" and "shim" implementation were given the same set of tests with print() at every step of next_to. The resulting log was then checksummed to ensure both are identical.
This commit is contained in:
parent
89867386c5
commit
8bcdd0b794
|
@ -717,6 +717,10 @@ local function get_relative_regions(geo, mode, is_absolute)
|
||||||
dgeo = geo.drawable.get_wibox():geometry()
|
dgeo = geo.drawable.get_wibox():geometry()
|
||||||
elseif geo.drawable and geo.drawable.drawable then
|
elseif geo.drawable and geo.drawable.drawable then
|
||||||
bw, dgeo = 0, geo.drawable.drawable:geometry()
|
bw, dgeo = 0, geo.drawable.drawable:geometry()
|
||||||
|
else
|
||||||
|
-- The placement isn't done on an object at all, having no border is
|
||||||
|
-- normal.
|
||||||
|
assert(mode == "geometry")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add the infamous border size
|
-- Add the infamous border size
|
||||||
|
@ -1392,6 +1396,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 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
|
||||||
|
@ -1492,7 +1497,14 @@ function placement.next_to(d, args)
|
||||||
|
|
||||||
attach(d, placement.next_to, args)
|
attach(d, placement.next_to, args)
|
||||||
|
|
||||||
return fix_new_geometry(ngeo, args, true), pref_name, dir
|
local ret = fix_new_geometry(ngeo, args, true)
|
||||||
|
|
||||||
|
-- Make sure the geometry didn't change, it would indicate an
|
||||||
|
-- "off by border" issue.
|
||||||
|
assert((not osize.width) or ret.width == d.width)
|
||||||
|
assert((not osize.height) or ret.height == d.height)
|
||||||
|
|
||||||
|
return ret, pref_name, dir
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Restore the geometry.
|
--- Restore the geometry.
|
||||||
|
|
Loading…
Reference in New Issue