diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-11-28 19:16:57 +0200 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-11-28 19:16:57 +0200 |
commit | 81135bc5487346ed8eaefa5307a0e217c4b2576e (patch) | |
tree | 23d4015aaf1025025fda89d8f8b9630295c39aea | |
parent | 03c8dbe789b587dd6a9c6fa6279c4204748be09b (diff) | |
download | metacity-81135bc5487346ed8eaefa5307a0e217c4b2576e.tar.gz |
libmetacity: add meta_theme_impl_get_scale
-rw-r--r-- | libmetacity/meta-theme-gtk.c | 6 | ||||
-rw-r--r-- | libmetacity/meta-theme-impl-private.h | 6 | ||||
-rw-r--r-- | libmetacity/meta-theme-impl.c | 39 | ||||
-rw-r--r-- | libmetacity/meta-theme-metacity.c | 6 | ||||
-rw-r--r-- | libmetacity/meta-theme.c | 10 |
5 files changed, 37 insertions, 30 deletions
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c index 22a8f67f..f80c5535 100644 --- a/libmetacity/meta-theme-gtk.c +++ b/libmetacity/meta-theme-gtk.c @@ -235,7 +235,7 @@ meta_theme_gtk_get_frame_borders (MetaThemeImpl *impl, text_height = 0; /* Scale geometry for HiDPI, see comment in meta_theme_gtk_draw_frame () */ - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (impl); title_height = layout->gtk.title_margin.top + text_height / scale + @@ -327,7 +327,7 @@ meta_theme_gtk_calc_geometry (MetaThemeImpl *impl, fgeom->height = height; /* Scale geometry for HiDPI, see comment in meta_theme_gtk_draw_frame () */ - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (impl); content_width = width - borders.invisible.left - layout->gtk.frame_border.left * scale - @@ -655,7 +655,7 @@ meta_theme_gtk_draw_frame (MetaThemeImpl *impl, * radii, ...) at the correct scale - as a result, we have to "unscale" * the geometry again to not apply the scaling twice */ - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (impl); cairo_scale (cr, scale, scale); borders = &fgeom->borders; diff --git a/libmetacity/meta-theme-impl-private.h b/libmetacity/meta-theme-impl-private.h index 1112fc3b..92276184 100644 --- a/libmetacity/meta-theme-impl-private.h +++ b/libmetacity/meta-theme-impl-private.h @@ -80,6 +80,9 @@ G_GNUC_INTERNAL gboolean meta_theme_impl_get_composited (MetaThemeImpl *impl); G_GNUC_INTERNAL +gint meta_theme_impl_get_scale (MetaThemeImpl *impl); + +G_GNUC_INTERNAL void meta_theme_impl_add_style_set (MetaThemeImpl *impl, MetaFrameType type, MetaFrameStyleSet *style_set); @@ -93,9 +96,6 @@ void scale_border (GtkBorder *bord double factor); G_GNUC_INTERNAL -int get_window_scaling_factor (void); - -G_GNUC_INTERNAL gboolean is_button_visible (MetaButton *button, MetaFrameFlags flags); diff --git a/libmetacity/meta-theme-impl.c b/libmetacity/meta-theme-impl.c index 1a1da9e9..e523ffb0 100644 --- a/libmetacity/meta-theme-impl.c +++ b/libmetacity/meta-theme-impl.c @@ -25,6 +25,7 @@ typedef struct { gboolean composited; + gint scale; MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST]; } MetaThemeImplPrivate; @@ -105,6 +106,28 @@ meta_theme_impl_get_composited (MetaThemeImpl *impl) return priv->composited; } +gint +meta_theme_impl_get_scale (MetaThemeImpl *impl) +{ + GValue value = G_VALUE_INIT; + MetaThemeImplPrivate *priv; + GdkScreen *screen; + + priv = meta_theme_impl_get_instance_private (impl); + + if (priv->scale != 0) + return priv->scale; + + screen = gdk_screen_get_default (); + + g_value_init (&value, G_TYPE_INT); + + if (gdk_screen_get_setting (screen, "gdk-window-scaling-factor", &value)) + return g_value_get_int (&value); + else + return 1; +} + void meta_theme_impl_add_style_set (MetaThemeImpl *impl, MetaFrameType type, @@ -141,22 +164,6 @@ scale_border (GtkBorder *border, border->bottom *= factor; } -int -get_window_scaling_factor (void) -{ - GdkScreen *screen; - GValue value = G_VALUE_INIT; - - screen = gdk_screen_get_default (); - - g_value_init (&value, G_TYPE_INT); - - if (gdk_screen_get_setting (screen, "gdk-window-scaling-factor", &value)) - return g_value_get_int (&value); - else - return 1; -} - gboolean is_button_visible (MetaButton *button, MetaFrameFlags flags) diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c index 702d0921..35989e1a 100644 --- a/libmetacity/meta-theme-metacity.c +++ b/libmetacity/meta-theme-metacity.c @@ -4645,7 +4645,7 @@ meta_theme_metacity_get_frame_borders (MetaThemeImpl *impl, text_height = 0; /* Scale geometry for HiDPI, see comment in meta_theme_metacity_draw_frame () */ - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (impl); buttons_height = layout->metacity.button_height + layout->button_border.top + @@ -4799,7 +4799,7 @@ meta_theme_metacity_calc_geometry (MetaThemeImpl *impl, button_height = -1; /* Scale geometry for HiDPI, see comment in meta_theme_metacity_draw_frame () */ - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (impl); switch (layout->metacity.button_sizing) { @@ -5303,7 +5303,7 @@ meta_theme_metacity_draw_frame (MetaThemeImpl *impl, * radii, ...) at the correct scale - as a result, we have to "unscale" * the geometry again to not apply the scaling twice */ - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (impl); cairo_scale (cr, scale, scale); borders = &fgeom->borders; diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c index ccbd1100..5a6fded7 100644 --- a/libmetacity/meta-theme.c +++ b/libmetacity/meta-theme.c @@ -79,11 +79,11 @@ get_style_info (MetaTheme *theme, if (style_info == NULL) { - gint window_scale; + gint scale; - window_scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (theme->impl); style_info = meta_style_info_new (theme->gtk_theme_name, variant, - theme->composited, window_scale); + theme->composited, scale); g_hash_table_insert (theme->variants, g_strdup (key), style_info); } @@ -195,7 +195,7 @@ font_desc_apply_scale (PangoFontDescription *font_desc, old_size = pango_font_description_get_size (font_desc); style = get_frame_style (theme, type, flags); - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (theme->impl); new_size = MAX (old_size * (style->layout->title_scale / scale), 1); @@ -308,7 +308,7 @@ get_title_height (MetaTheme *theme, pango_font_metrics_unref (metrics); title_height = PANGO_PIXELS (ascent + descent); - scale = get_window_scaling_factor (); + scale = meta_theme_impl_get_scale (theme->impl); title_height *= scale; |