[metacity] libmetacity: add meta_theme_set_dpi
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] libmetacity: add meta_theme_set_dpi
- Date: Sun, 2 Apr 2017 16:23:54 +0000 (UTC)
commit 8823b220ae3e8718d598d738d99829b08f826b40
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Apr 2 19:05:58 2017 +0300
libmetacity: add meta_theme_set_dpi
libmetacity/meta-theme.c | 18 +++++++++++++++++-
libmetacity/meta-theme.h | 3 +++
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 02b29fa..3227d6a 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 c544bd3..622c8c3 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 f2b9b05..06c14f8 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]