summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2018-01-25 20:05:18 -0500
committerMartin Wimpress <[email protected]>2018-01-26 01:05:18 +0000
commiteaad50f7624c8946e57ca075f8b7e383b1715bcc (patch)
treedec5148045765ee369fbec58e19bee094d46b869
parent6ce8e3732215cc813597496001fa23b37f3d5bf3 (diff)
downloadmate-settings-daemon-eaad50f7624c8946e57ca075f8b7e383b1715bcc.tar.bz2
mate-settings-daemon-eaad50f7624c8946e57ca075f8b7e383b1715bcc.tar.xz
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
-rw-r--r--plugins/a11y-keyboard/msd-a11y-preferences-dialog.c5
-rw-r--r--plugins/xsettings/msd-xsettings-manager.c12
2 files changed, 16 insertions, 1 deletions
diff --git a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c
index 165d5b0..185b8c9 100644
--- a/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c
+++ b/plugins/a11y-keyboard/msd-a11y-preferences-dialog.c
@@ -173,6 +173,7 @@ get_dpi_from_x_server (void)
{
GdkScreen *screen;
double dpi;
+ int scale;
screen = gdk_screen_get_default ();
if (screen != NULL) {
@@ -181,6 +182,7 @@ get_dpi_from_x_server (void)
Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
@@ -192,6 +194,9 @@ get_dpi_from_x_server (void)
} else {
dpi = (width_dpi + height_dpi) / 2.0;
}
+
+ dpi *= scale;
+
} else {
/* Huh!? No screen? */
dpi = DPI_DEFAULT;
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) {