x11: deal with xrandr display size in millimeters being zero. Xquartz on macOS reports a zero size, which leads to a division by zero here.
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 3db587a..dca9ff0 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3797,7 +3797,8 @@ SDL_SetWindowHitTest(SDL_Window * window, SDL_HitTest callback, void *userdata)
return 0;
}
-float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
+float
+SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
{
float den2 = hinches * hinches + vinches * vinches;
if (den2 <= 0.0f) {
diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index 87eb1e0..1215235 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -464,8 +464,8 @@ X11_InitModes_XRandR(_THIS)
displaydata->screen = screen;
displaydata->visual = vinfo.visual;
displaydata->depth = vinfo.depth;
- displaydata->hdpi = ((float) mode.w) * 25.4f / display_mm_width;
- displaydata->vdpi = ((float) mode.h) * 25.4f / display_mm_height;
+ displaydata->hdpi = display_mm_width ? (((float) mode.w) * 25.4f / display_mm_width) : 0.0f;
+ displaydata->vdpi = display_mm_height ? (((float) mode.h) * 25.4f / display_mm_height) : 0.0f;
displaydata->ddpi = SDL_ComputeDiagonalDPI(mode.w, mode.h, ((float) display_mm_width) / 25.4f,((float) display_mm_height) / 25.4f);
displaydata->scanline_pad = scanline_pad;
displaydata->x = display_x;