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:
parent
03580db5bb
commit
c7d75ed119
|
@ -529,10 +529,13 @@ function screen.object.get_dpi(s)
|
|||
local dpi = nil
|
||||
local geo = s.geometry
|
||||
for _, o in pairs(s.outputs) do
|
||||
-- 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
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue