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