awful.screen.object.get_dpi: Ignore outputs with size 0 (#2063)

For example, Xephyr reports its output with a size of 0x0. Since a
division by zero is in no one's interest, just ignore such outputs when
trying to compute the DPI value.

Thanks to @timroes for pointing this out:
c8fac753c4 (commitcomment-25072296)

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-10-21 19:23:04 +02:00 committed by Daniel Hahler
parent 03580db5bb
commit c7d75ed119

View file

@ -529,9 +529,12 @@ function screen.object.get_dpi(s)
local dpi = nil
local geo = s.geometry
for _, o in pairs(s.outputs) do
local dpix = geo.width * mm_per_inch / o.mm_width
local dpiy = geo.height * mm_per_inch / o.mm_height
dpi = math.min(dpix, dpiy, dpi or dpix)
-- Ignore outputs with width/height 0
if o.mm_width ~= 0 and o.mm_height ~= 0 then
local dpix = geo.width * mm_per_inch / o.mm_width
local dpiy = geo.height * mm_per_inch / o.mm_height
dpi = math.min(dpix, dpiy, dpi or dpix)
end
end
if dpi then
return dpi