|
@@ -31,61 +31,26 @@
|
|
|
#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)
|
|
|
+static void UpdateContentScale(SDL_VideoDevice *_this)
|
|
|
{
|
|
|
- SDL_VideoDevice *_this = data;
|
|
|
- float scale_factor = 1.0;
|
|
|
- int i;
|
|
|
-
|
|
|
- if (SDL_strcmp(name, SDL_XSETTINGS_GDK_WINDOW_SCALING_FACTOR) != 0 ||
|
|
|
- SDL_strcmp(name, SDL_XSETTINGS_XFT_DPI) != 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (setting->type != XSETTINGS_TYPE_INT) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- switch (action) {
|
|
|
- case XSETTINGS_ACTION_NEW:
|
|
|
- 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;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
if (_this) {
|
|
|
- for (i = 0; i < _this->num_displays; ++i) {
|
|
|
+ float scale_factor = X11_GetGlobalContentScale(_this);
|
|
|
+ for (int i = 0; i < _this->num_displays; ++i) {
|
|
|
SDL_SetDisplayContentScale(_this->displays[i], scale_factor);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void X11_XsettingsNotify(const char *name, XSettingsAction action, XSettingsSetting *setting, void *data)
|
|
|
+{
|
|
|
+ SDL_VideoDevice *_this = data;
|
|
|
+ UpdateContentScale(_this);
|
|
|
+}
|
|
|
+
|
|
|
static void OnGtkXftDpi(GtkSettings *settings, GParamSpec *pspec, gpointer ptr)
|
|
|
{
|
|
|
SDL_VideoDevice *_this = (SDL_VideoDevice *)ptr;
|
|
|
-
|
|
|
- SDL_GtkContext *gtk = SDL_Gtk_EnterContext();
|
|
|
- if (gtk) {
|
|
|
- int dpi = 0;
|
|
|
- gtk->g.object_get(settings, "gtk-xft-dpi", &dpi, NULL);
|
|
|
-
|
|
|
- if (dpi != 0) {
|
|
|
- float scale_factor = dpi / 1024.f / 96.f;
|
|
|
-
|
|
|
- for (int i = 0; i < _this->num_displays; ++i) {
|
|
|
- SDL_VideoDisplay *display = _this->displays[i];
|
|
|
- SDL_SetDisplayContentScale(display, scale_factor);
|
|
|
- }
|
|
|
- }
|
|
|
- SDL_Gtk_ExitContext(gtk);
|
|
|
- }
|
|
|
+ UpdateContentScale(_this);
|
|
|
}
|
|
|
|
|
|
void X11_InitXsettings(SDL_VideoDevice *_this)
|
|
@@ -110,11 +75,10 @@ void X11_InitXsettings(SDL_VideoDevice *_this)
|
|
|
if (gtksettings && xft_dpi_signal_handler_id) {
|
|
|
xsettings_data->gtksettings = gtksettings;
|
|
|
xsettings_data->xft_dpi_signal_handler_id = xft_dpi_signal_handler_id;
|
|
|
- } else {
|
|
|
- xsettings_data->xsettings = xsettings_client_new(data->display,
|
|
|
- DefaultScreen(data->display), X11_XsettingsNotify, NULL, _this);
|
|
|
}
|
|
|
|
|
|
+ xsettings_data->xsettings = xsettings_client_new(data->display,
|
|
|
+ DefaultScreen(data->display), X11_XsettingsNotify, NULL, _this);
|
|
|
}
|
|
|
|
|
|
void X11_QuitXsettings(SDL_VideoDevice *_this)
|