mirror of https://github.com/libsdl-org/SDL.git
Check the Xft/DPI XSETTINGS
Similar to Xrm's "Xft.dpi" key, but stores in 1024th increments.
This commit is contained in:
parent
e049098733
commit
a98774e62c
|
|
@ -231,9 +231,18 @@ static float GetGlobalContentScale(SDL_VideoDevice *_this)
|
|||
}
|
||||
}
|
||||
|
||||
/* If that failed, try the XSETTINGS key... */
|
||||
/* If that failed, try the XSETTINGS keys... */
|
||||
if (scale_factor <= 0.0) {
|
||||
scale_factor = X11_GetXsettingsIntKey(_this, "Gdk/WindowScalingFactor", -1);
|
||||
|
||||
/* The Xft/DPI key is stored in increments of 1024th */
|
||||
if (scale_factor <= 0.0) {
|
||||
int dpi = X11_GetXsettingsIntKey(_this, "Xft/DPI", -1);
|
||||
if (dpi > 0) {
|
||||
scale_factor = (double) dpi / 1024.0;
|
||||
scale_factor /= 96.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If that failed, try the GDK_SCALE envvar... */
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "SDL_x11settings.h"
|
||||
|
||||
#define SDL_XSETTINGS_GDK_WINDOW_SCALING_FACTOR "Gdk/WindowScalingFactor"
|
||||
#define SDL_XSETTINGS_XFT_DPI "Xft/DPI"
|
||||
|
||||
static void X11_XsettingsNotify(const char *name, XSettingsAction action, XSettingsSetting *setting, void *data)
|
||||
{
|
||||
|
|
@ -34,7 +35,8 @@ static void X11_XsettingsNotify(const char *name, XSettingsAction action, XSetti
|
|||
float scale_factor = 1.0;
|
||||
int i;
|
||||
|
||||
if (SDL_strcmp(name, SDL_XSETTINGS_GDK_WINDOW_SCALING_FACTOR) != 0) {
|
||||
if (SDL_strcmp(name, SDL_XSETTINGS_GDK_WINDOW_SCALING_FACTOR) != 0 ||
|
||||
SDL_strcmp(name, SDL_XSETTINGS_XFT_DPI) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +49,9 @@ static void X11_XsettingsNotify(const char *name, XSettingsAction action, XSetti
|
|||
SDL_FALLTHROUGH;
|
||||
case XSETTINGS_ACTION_CHANGED:
|
||||
scale_factor = setting->data.v_int;
|
||||
if (SDL_strcmp(name, SDL_XSETTINGS_XFT_DPI) == 0) {
|
||||
scale_factor = scale_factor / 1024.0f / 96.0f;
|
||||
}
|
||||
break;
|
||||
case XSETTINGS_ACTION_DELETED:
|
||||
scale_factor = 1.0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue