summaryrefslogtreecommitdiff
path: root/plugins/xsettings/msd-xsettings-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/xsettings/msd-xsettings-manager.c')
-rw-r--r--plugins/xsettings/msd-xsettings-manager.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/plugins/xsettings/msd-xsettings-manager.c b/plugins/xsettings/msd-xsettings-manager.c
index 33dd16d..c8199da 100644
--- a/plugins/xsettings/msd-xsettings-manager.c
+++ b/plugins/xsettings/msd-xsettings-manager.c
@@ -2,6 +2,7 @@
*
* Copyright (C) 2007 Rodrigo Moya
* Copyright (C) 2007 William Jon McCann <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -75,12 +76,17 @@
#define DPI_HIGH_REASONABLE_VALUE 500
/* The minimum resolution at which we turn on a window-scale of 2 */
-#define HIDPI_LIMIT (DPI_FALLBACK * 2)
+/* Set this to 90% of 2x DPI_FALLBACK, to catch QHD laptop screens */
+/* that are just below the 2x DPI_FALLBACK mark */
+#define HIDPI_LIMIT (DPI_FALLBACK * 2 * 90 / 100)
/* The minimum screen height at which we turn on a window-scale of 2;
* below this there just isn't enough vertical real estate for GNOME
* apps to work, and it's better to just be tiny */
-#define HIDPI_MIN_HEIGHT 1500
+#define HIDPI_MIN_HEIGHT 1440
+
+#define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT(i) == 2) ? TRUE : FALSE))
+#define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1))
typedef struct _TranslationEntry TranslationEntry;
typedef void (* TranslationFunc) (MateXSettingsManager *manager,
@@ -505,19 +511,19 @@ update_user_env_variable (const gchar *variable,
}
static gboolean
-delayed_toggle_bg_draw (gboolean value)
+delayed_toggle_bg_draw (gpointer value)
{
GSettings *settings;
settings = g_settings_new ("org.mate.background");
- g_settings_set_boolean (settings, "show-desktop-icons", value);
+ g_settings_set_boolean (settings, "show-desktop-icons", GPOINTER_TO_BOOLEAN (value));
g_object_unref (settings);
- return FALSE;
+ return G_SOURCE_REMOVE;
}
static void
-scale_change_workarounds (MateXSettingsManager *manager, int new_scale)
+scale_change_workarounds (MateXSettingsManager *manager, int new_scale, int unscaled_dpi)
{
if (manager->priv->window_scale == new_scale)
return;
@@ -531,8 +537,11 @@ scale_change_workarounds (MateXSettingsManager *manager, int new_scale)
gsettings = g_hash_table_lookup (manager->priv->gsettings, INTERFACE_SCHEMA);
/* If enabled, set env variables to properly scale QT applications */
if (g_settings_get_boolean (gsettings, SCALING_FACTOR_QT_KEY)) {
- if (!update_user_env_variable ("QT_AUTO_SCREEN_SCALE_FACTOR", "0", &error)) {
- g_warning ("There was a problem when setting QT_AUTO_SCREEN_SCALE_FACTOR=0: %s", error->message);
+ char dpibuf[G_ASCII_DTOSTR_BUF_SIZE];
+ g_snprintf (dpibuf, sizeof (dpibuf), "%d", (int) (unscaled_dpi / 1024.0 + 0.5));
+
+ if (!update_user_env_variable ("QT_FONT_DPI", dpibuf, &error)) {
+ g_warning ("There was a problem when setting QT_FONT_DPI=%s: %s", dpibuf, error->message);
g_clear_error (&error);
}
if (!update_user_env_variable ("QT_SCALE_FACTOR", new_scale == 2 ? "2" : "1", &error)) {
@@ -574,8 +583,8 @@ scale_change_workarounds (MateXSettingsManager *manager, int new_scale)
desktop_settings = g_settings_new ("org.mate.background");
if (g_settings_get_boolean (desktop_settings, "show-desktop-icons")) {
/* Delay the toggle to allow enough time for the desktop to redraw */
- g_timeout_add_seconds (1, (GSourceFunc) delayed_toggle_bg_draw, (gpointer) FALSE);
- g_timeout_add_seconds (2, (GSourceFunc) delayed_toggle_bg_draw, (gpointer) TRUE);
+ g_timeout_add_seconds (1, delayed_toggle_bg_draw, GBOOLEAN_TO_POINTER (FALSE));
+ g_timeout_add_seconds (2, delayed_toggle_bg_draw, GBOOLEAN_TO_POINTER (TRUE));
}
g_object_unref (desktop_settings);
}
@@ -607,7 +616,7 @@ xft_settings_set_xsettings (MateXSettingsManager *manager,
}
mate_settings_profile_end (NULL);
- scale_change_workarounds (manager, settings->window_scale);
+ scale_change_workarounds (manager, settings->window_scale, settings->dpi);
}
static void
@@ -657,8 +666,8 @@ xft_settings_set_xresources (MateXftSettings *settings)
g_debug("xft_settings_set_xresources: orig res '%s'", add_string->str);
- update_property (add_string, "Xft.dpi",
- g_ascii_dtostr (dpibuf, sizeof (dpibuf), (double) settings->dpi / 1024.0));
+ g_snprintf (dpibuf, sizeof (dpibuf), "%d", (int) (settings->scaled_dpi / 1024.0 + 0.5));
+ update_property (add_string, "Xft.dpi", dpibuf);
update_property (add_string, "Xft.antialias",
settings->antialias ? "1" : "0");
update_property (add_string, "Xft.hinting",