From eaad50f7624c8946e57ca075f8b7e383b1715bcc Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Thu, 25 Jan 2018 20:05:18 -0500 Subject: Add support for HiDPI displays (#208) * Support font size and mouse cursor auto-scaling for HiDPI displays * Fix where DPI is getting scaled * Remove ceil for scaled DPI --- plugins/xsettings/msd-xsettings-manager.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins/xsettings') diff --git a/plugins/xsettings/msd-xsettings-manager.c b/plugins/xsettings/msd-xsettings-manager.c index 8016abb..9105088 100644 --- a/plugins/xsettings/msd-xsettings-manager.c +++ b/plugins/xsettings/msd-xsettings-manager.c @@ -232,6 +232,7 @@ get_dpi_from_x_server (void) { GdkScreen *screen; double dpi; + gint scale; screen = gdk_screen_get_default (); if (screen != NULL) { @@ -254,6 +255,11 @@ get_dpi_from_x_server (void) dpi = DPI_FALLBACK; } + + scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen)); + if (scale) + dpi = dpi * scale; + return dpi; } @@ -301,24 +307,28 @@ xft_settings_get (MateXSettingsManager *manager, MateXftSettings *settings) { GSettings *mouse_gsettings; + GdkScreen *screen; char *antialiasing; char *hinting; char *rgba_order; double dpi; + gint scale; mouse_gsettings = g_hash_table_lookup (manager->priv->gsettings, MOUSE_SCHEMA); + screen = gdk_screen_get_default(); antialiasing = g_settings_get_string (manager->priv->gsettings_font, FONT_ANTIALIASING_KEY); hinting = g_settings_get_string (manager->priv->gsettings_font, FONT_HINTING_KEY); rgba_order = g_settings_get_string (manager->priv->gsettings_font, FONT_RGBA_ORDER_KEY); dpi = get_dpi_from_gsettings_or_x_server (manager->priv->gsettings_font); + scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen)); settings->antialias = TRUE; settings->hinting = TRUE; settings->hintstyle = "hintslight"; settings->dpi = dpi * 1024; /* Xft wants 1/1024ths of an inch */ settings->cursor_theme = g_settings_get_string (mouse_gsettings, CURSOR_THEME_KEY); - settings->cursor_size = g_settings_get_int (mouse_gsettings, CURSOR_SIZE_KEY); + settings->cursor_size = scale * g_settings_get_int (mouse_gsettings, CURSOR_SIZE_KEY); settings->rgba = "rgb"; if (rgba_order) { -- cgit v1.2.1