[metacity] libmetacity: add meta_theme_impl_get_scale
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] libmetacity: add meta_theme_impl_get_scale
- Date: Mon, 28 Nov 2016 17:21:35 +0000 (UTC)
commit 81135bc5487346ed8eaefa5307a0e217c4b2576e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Nov 28 19:16:57 2016 +0200
libmetacity: add meta_theme_impl_get_scale
libmetacity/meta-theme-gtk.c | 6 ++--
libmetacity/meta-theme-impl-private.h | 6 ++--
libmetacity/meta-theme-impl.c | 39 +++++++++++++++++++-------------
libmetacity/meta-theme-metacity.c | 6 ++--
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 22a8f67..f80c553 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 1112fc3..9227618 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 1a1da9e..e523ffb 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 702d092..35989e1 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 ccbd110..5a6fded 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]