mirror of https://github.com/encounter/SDL.git
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.
This commit is contained in:
parent
082132a70c
commit
9d04205263
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue