mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
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
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue