Browse Source

Fix divide-by-zero issue in screen dpi calculation on raspberry pi

tags/2021-05-28
hogliux 10 years ago
parent
commit
3ed50c3f09
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      modules/juce_gui_basics/native/juce_linux_Windowing.cpp

+ 6
- 2
modules/juce_gui_basics/native/juce_linux_Windowing.cpp View File

@@ -1215,8 +1215,12 @@ private:
e.usableBounds = e.totalBounds.withZeroOrigin(); // Support for usable area is not implemented in JUCE yet
e.topLeftScaled = e.totalBounds.getTopLeft();
e.isMain = (mainDisplay == screens->outputs[j]) && (i == 0);
e.dpi = ((static_cast<double> (crtc->width) * 25.4 * 0.5) / static_cast<double> (output->mm_width))
+ ((static_cast<double> (crtc->height) * 25.4 * 0.5) / static_cast<double> (output->mm_height));
e.dpi = getDisplayDPI (0);
// The raspberry pi returns a zero sized display, so we need to guard for divide-by-zero
if (output->mm_width > 0 && output->mm_height > 0)
e.dpi = ((static_cast<double> (crtc->width) * 25.4 * 0.5) / static_cast<double> (output->mm_width))
+ ((static_cast<double> (crtc->height) * 25.4 * 0.5) / static_cast<double> (output->mm_height));
e.scale = masterScale * getScaleForDisplay (output->name, e);


Loading…
Cancel
Save