diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2017-04-02 19:05:58 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2017-04-02 19:05:58 +0300 |
commit | 8823b220ae3e8718d598d738d99829b08f826b40 (patch) | |
tree | ae49549de1a4b9970f8dcb9727be4aebc3379adb | |
parent | 8547f41b2cf90b2829904248ccf786dc3e106b37 (diff) | |
download | metacity-8823b220ae3e8718d598d738d99829b08f826b40.tar.gz |
libmetacity: add meta_theme_set_dpi
-rw-r--r-- | libmetacity/meta-theme.c | 18 | ||||
-rw-r--r-- | libmetacity/meta-theme.h | 3 | ||||
-rw-r--r-- | src/ui/ui.c | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c index 02b29fa9..3227d6a9 100644 --- a/libmetacity/meta-theme.c +++ b/libmetacity/meta-theme.c @@ -45,6 +45,7 @@ struct _MetaTheme gboolean composited; gint scale; + gdouble dpi; PangoFontDescription *titlebar_font; @@ -292,7 +293,7 @@ ensure_pango_context (MetaTheme *theme) options = gdk_screen_get_font_options (screen); pango_cairo_context_set_font_options (context, options); - dpi = gdk_screen_get_resolution (screen); + dpi = theme->dpi * theme->scale; pango_cairo_context_set_resolution (context, dpi); theme->context = context; @@ -601,6 +602,7 @@ meta_theme_init (MetaTheme *theme) { theme->composited = TRUE; theme->scale = 1; + theme->dpi = 96.0; theme->variants = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); @@ -808,6 +810,20 @@ meta_theme_set_composited (MetaTheme *theme, } void +meta_theme_set_dpi (MetaTheme *theme, + gdouble dpi) +{ + if (theme->dpi == dpi) + return; + + theme->dpi = dpi; + + g_clear_object (&theme->context); + g_hash_table_remove_all (theme->font_descs); + g_hash_table_remove_all (theme->title_heights); +} + +void meta_theme_set_scale (MetaTheme *theme, gint scale) { diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h index c544bd3e..622c8c3f 100644 --- a/libmetacity/meta-theme.h +++ b/libmetacity/meta-theme.h @@ -125,6 +125,9 @@ void meta_theme_set_composited (MetaTheme *theme, void meta_theme_set_scale (MetaTheme *theme, gint scale); +void meta_theme_set_dpi (MetaTheme *theme, + gdouble dpi); + void meta_theme_set_titlebar_font (MetaTheme *theme, const PangoFontDescription *titlebar_font); diff --git a/src/ui/ui.c b/src/ui/ui.c index f2b9b059..06c14f86 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -114,6 +114,7 @@ notify_gtk_xft_dpi_cb (GtkSettings *settings, ui->dpi = get_xft_dpi (ui); meta_theme_set_scale (ui->theme, ui->scale); + meta_theme_set_dpi (ui->theme, ui->dpi); } void @@ -823,6 +824,7 @@ load_theme (MetaUI *ui, meta_theme_set_composited (theme, ui->composited); meta_theme_set_scale (theme, ui->scale); + meta_theme_set_dpi (theme, ui->dpi); titlebar_font = meta_prefs_get_titlebar_font (); meta_theme_set_titlebar_font (theme, titlebar_font); |