Skip to content
Permalink
Browse files

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.
  • Loading branch information
icculus committed Jan 4, 2017
1 parent 082132a commit 9d042052639f7c3927b280b0e3f1cac360ffca42
Showing with 4 additions and 3 deletions.
  1. +2 −1 src/video/SDL_video.c
  2. +2 −2 src/video/x11/SDL_x11modes.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) {
@@ -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;

0 comments on commit 9d04205

Please sign in to comment.