remove extraneous DPI code

since 5 months ago (ttps://github.com/libsdl-org/SDL/commit/c289bad9007cb672c994f726d967f6e5682f200d)
SDL2 now reads Xft.dpi. There is no need to link to X11 anymore.
This commit is contained in:
takase1121 2021-08-15 08:09:06 +08:00 committed by Francesco
parent 02d59c8ec2
commit 35fd29fc39
1 changed files with 1 additions and 31 deletions

View File

@ -9,10 +9,6 @@
#include <windows.h>
#elif __linux__
#include <unistd.h>
#include <SDL_syswm.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <signal.h>
#elif __APPLE__
#include <mach-o/dyld.h>
@ -22,35 +18,9 @@
SDL_Window *window;
static double get_scale(void) {
#ifdef _WIN32
float dpi;
float dpi = 96.0;
SDL_GetDisplayDPI(0, NULL, &dpi, NULL);
return dpi / 96.0;
#elif __linux__
SDL_SysWMinfo info;
XrmDatabase db;
XrmValue value;
char *type = NULL;
SDL_VERSION(&info.version);
if (!SDL_GetWindowWMInfo(window, &info)
|| info.subsystem != SDL_SYSWM_X11)
return 1.0;
char *resource = XResourceManagerString(info.info.x11.display);
if (resource == NULL)
return 1.0;
XrmInitialize();
db = XrmGetStringDatabase(resource);
if (XrmGetResource(db, "Xft.dpi", "String", &type, &value) == False
|| value.addr == NULL)
return 1.0;
return atof(value.addr) / 96.0;
#else
return 1.0;
#endif
}