placement: Fix `border_width` for `next_to`

All previous users used client side borders so the issue went
unnoticed. This code will be unit tested by the `popup` module
in a few commits.
This commit is contained in:
Emmanuel Lepage Vallee 2018-01-09 00:39:53 -05:00
parent c3302c4bbe
commit 3fa42f3b1a
1 changed files with 25 additions and 14 deletions

View File

@ -644,7 +644,6 @@ local function get_cross_sections(abs_geo, mode)
} }
elseif mode == "geometry" then elseif mode == "geometry" then
-- The widget geometry extended to reach the end of the drawable -- The widget geometry extended to reach the end of the drawable
return { return {
h = { h = {
x = abs_geo.drawable_geo.x , x = abs_geo.drawable_geo.x ,
@ -702,23 +701,35 @@ local function get_relative_regions(geo, mode, is_absolute)
end end
end end
-- Get the drawable geometry -- Get the parent geometry using one way or another depending on the object
local dpos = geo.drawable and ( -- Type
geo.drawable.drawable and local bw, dgeo = 0, {x=0, y=0, width=1, height=1}
geo.drawable.drawable:geometry()
or geo.drawable:geometry() -- Detect various types of geometry table and (try) to get rid of the
) or {x=0, y=0} -- differences so the code below don't have to care anymore.
if geo.drawin then
bw, dgeo = geo.drawin.border_width, geo.drawin:geometry()
elseif geo.drawable and geo.drawable.get_wibox then
bw = geo.drawable.get_wibox().border_width
dgeo = geo.drawable.get_wibox():geometry()
elseif geo.drawable and geo.drawable.drawable then
bw, dgeo = 0, geo.drawable.drawable:geometry()
end
-- Add the infamous border size
dgeo.width = dgeo.width + 2*bw
dgeo.height = dgeo.height + 2*bw
-- Compute the absolute widget geometry -- Compute the absolute widget geometry
local abs_widget_geo = is_absolute and geo or { local abs_widget_geo = is_absolute and dgeo or {
x = dpos.x + geo.x , x = dgeo.x + geo.x + bw,
y = dpos.y + geo.y , y = dgeo.y + geo.y + bw,
width = geo.width , width = geo.width ,
height = geo.height , height = geo.height ,
drawable = geo.drawable , drawable = geo.drawable ,
} }
abs_widget_geo.drawable_geo = geo.drawable and dpos or geo abs_widget_geo.drawable_geo = geo.drawable and dgeo or geo
-- Get the point for comparison. -- Get the point for comparison.
local center_point = mode:match("cursor") and capi.mouse.coords() or { local center_point = mode:match("cursor") and capi.mouse.coords() or {