From b028a0ba1d56a23de8ebd848570836226830a507 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 2 Aug 2015 21:51:06 +0200 Subject: [PATCH] xresources.apply_dpi: use "round" instead of "ceil" Given an outcome of e.g. 1.01 its more sane to use 1 than 2, especially for `border_width`. This uses the method from `wibox.layout.flex`. Closes https://github.com/awesomeWM/awesome/pull/389. --- lib/beautiful/xresources.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/beautiful/xresources.lua b/lib/beautiful/xresources.lua index 7f1766fe8..ba945f2b6 100644 --- a/lib/beautiful/xresources.lua +++ b/lib/beautiful/xresources.lua @@ -10,6 +10,7 @@ -- Grab environment local print = print local awesome = awesome +local floor = math.floor local xresources = {} @@ -91,9 +92,9 @@ end --- Compute resulting size applying current DPI value (optionally per screen). -- @tparam number size Size -- @tparam[opt] integer s The screen. --- @treturn integer Resulting size (using `math.ceil`). +-- @treturn integer Resulting size (rounded to integer). function xresources.apply_dpi(size, s) - return math.ceil(size/96*xresources.get_dpi(s)) + return floor(size/96*xresources.get_dpi(s) + 0.5) end return xresources