x11: Don't use GetXftDPI() when XRandR can tell us the DPI per-output. Fixes #5764.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c
index c322b4d..abfd387 100644
--- a/src/video/x11/SDL_x11modes.c
+++ b/src/video/x11/SDL_x11modes.c
@@ -148,30 +148,6 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
return SDL_PIXELFORMAT_UNKNOWN;
}
-static int
-GetXftDPI(Display* dpy)
-{
- char* xdefault_resource;
- int xft_dpi, err;
-
- xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi");
-
- if(!xdefault_resource) {
- return 0;
- }
-
- /*
- * It's possible for SDL_atoi to call SDL_strtol, if it fails due to a
- * overflow or an underflow, it will return LONG_MAX or LONG_MIN and set
- * errno to ERANGE. So we need to check for this so we dont get crazy dpi
- * values
- */
- xft_dpi = SDL_atoi(xdefault_resource);
- err = errno;
-
- return err == ERANGE ? 0 : xft_dpi;
-}
-
#if SDL_VIDEO_DRIVER_X11_XRANDR
static SDL_bool
CheckXRandR(Display * display, int *major, int *minor)
@@ -333,7 +309,6 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre
Uint32 pixelformat;
XPixmapFormatValues *pixmapformats;
int scanline_pad;
- int xft_dpi = 0;
int i, n;
if (get_visualinfo(dpy, screen, &vinfo) < 0) {
@@ -405,14 +380,6 @@ X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput outputid, XRRScre
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);
-
- /* if xft dpi is available we will use this over xrandr (!!! FIXME: ...yeah?) */
- xft_dpi = GetXftDPI(dpy);
- if (xft_dpi > 0) {
- displaydata->hdpi = (float) xft_dpi;
- displaydata->vdpi = (float) xft_dpi;
- }
-
displaydata->scanline_pad = scanline_pad;
displaydata->x = display_x;
displaydata->y = display_y;
@@ -565,6 +532,30 @@ X11_InitModes_XRandR(_THIS)
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
+static int
+GetXftDPI(Display* dpy)
+{
+ char* xdefault_resource;
+ int xft_dpi, err;
+
+ xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi");
+
+ if(!xdefault_resource) {
+ return 0;
+ }
+
+ /*
+ * It's possible for SDL_atoi to call SDL_strtol, if it fails due to a
+ * overflow or an underflow, it will return LONG_MAX or LONG_MIN and set
+ * errno to ERANGE. So we need to check for this so we dont get crazy dpi
+ * values
+ */
+ xft_dpi = SDL_atoi(xdefault_resource);
+ err = errno;
+
+ return err == ERANGE ? 0 : xft_dpi;
+}
+
/* This is used if there's no better functionality--like XRandR--to use.
It won't attempt to supply different display modes at all, but it can
enumerate the current displays and their current sizes. */