[metacity] libmetacity: scale text height
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] libmetacity: scale text height
- Date: Tue, 7 Jun 2016 18:28:34 +0000 (UTC)
commit 1abf31270f2d9c04c4946a7e5e0dc3f961395ba9
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Jun 5 21:05:46 2016 +0300
libmetacity: scale text height
libmetacity/meta-theme-gtk.c | 19 ++++++++++---------
libmetacity/meta-theme-metacity.c | 13 +++++++------
libmetacity/meta-theme.c | 11 +++++++----
3 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
index af951fe..1a0774b 100644
--- a/libmetacity/meta-theme-gtk.c
+++ b/libmetacity/meta-theme-gtk.c
@@ -214,9 +214,10 @@ meta_theme_gtk_get_frame_borders (MetaThemeImpl *impl,
MetaFrameBorders *borders)
{
gboolean composited;
+ gint scale;
+ gint title_height;
gint buttons_height;
gint content_height;
- gint scale;
composited = meta_theme_impl_get_composited (impl);
frame_layout_sync_with_style (layout, style_info, composited, flags);
@@ -231,16 +232,19 @@ meta_theme_gtk_get_frame_borders (MetaThemeImpl *impl,
if (!layout->has_title)
text_height = 0;
- else
- text_height = layout->gtk.title_margin.top +
- text_height +
- layout->gtk.title_margin.bottom;
+
+ /* Scale geometry for HiDPI, see comment in meta_theme_gtk_draw_frame () */
+ scale = get_window_scaling_factor ();
+
+ title_height = layout->gtk.title_margin.top +
+ text_height / scale +
+ layout->gtk.title_margin.bottom;
buttons_height = MAX ((gint) layout->gtk.icon_size, layout->gtk.button_min_size.height) +
layout->gtk.button_margin.top + layout->button_border.top +
layout->gtk.button_margin.bottom + layout->button_border.bottom;
- content_height = MAX (buttons_height, text_height);
+ content_height = MAX (title_height, buttons_height);
content_height = MAX (content_height, layout->gtk.titlebar_min_size.height) +
layout->gtk.titlebar_border.top +
layout->gtk.titlebar_border.bottom;
@@ -276,9 +280,6 @@ meta_theme_gtk_get_frame_borders (MetaThemeImpl *impl,
borders->total.bottom = borders->invisible.bottom + borders->visible.bottom;
borders->total.top = borders->invisible.top + borders->visible.top;
- /* Scale geometry for HiDPI, see comment in meta_theme_gtk_draw_frame () */
- scale = get_window_scaling_factor ();
-
scale_border (&borders->visible, scale);
scale_border (&borders->invisible, scale);
scale_border (&borders->total, scale);
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
index 6842948..f0e041b 100644
--- a/libmetacity/meta-theme-metacity.c
+++ b/libmetacity/meta-theme-metacity.c
@@ -4608,8 +4608,9 @@ meta_theme_metacity_get_frame_borders (MetaThemeImpl *impl,
MetaFrameType type,
MetaFrameBorders *borders)
{
- int buttons_height, title_height;
- int scale;
+ gint scale;
+ gint buttons_height;
+ gint title_height;
meta_frame_borders_clear (borders);
@@ -4622,11 +4623,14 @@ meta_theme_metacity_get_frame_borders (MetaThemeImpl *impl,
if (!layout->has_title)
text_height = 0;
+ /* Scale geometry for HiDPI, see comment in meta_theme_metacity_draw_frame () */
+ scale = get_window_scaling_factor ();
+
buttons_height = layout->metacity.button_height +
layout->button_border.top +
layout->button_border.bottom;
- title_height = text_height +
+ title_height = text_height / scale +
layout->metacity.title_vertical_pad +
layout->metacity.title_border.top +
layout->metacity.title_border.bottom;
@@ -4655,9 +4659,6 @@ meta_theme_metacity_get_frame_borders (MetaThemeImpl *impl,
borders->total.bottom = borders->invisible.bottom + borders->visible.bottom;
borders->total.top = borders->invisible.top + borders->visible.top;
- /* Scale geometry for HiDPI, see comment in meta_theme_metacity_draw_frame () */
- scale = get_window_scaling_factor ();
-
scale_border (&borders->visible, scale);
scale_border (&borders->invisible, scale);
scale_border (&borders->total, scale);
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c
index 2be6fb4..f19ac4c 100644
--- a/libmetacity/meta-theme.c
+++ b/libmetacity/meta-theme.c
@@ -395,17 +395,20 @@ meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc,
{
PangoFontMetrics *metrics;
PangoLanguage *lang;
- int retval;
+ gint text_height;
+ gint scale;
lang = pango_context_get_language (context);
metrics = pango_context_get_metrics (context, font_desc, lang);
- retval = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
+ text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
+ pango_font_metrics_get_descent (metrics));
pango_font_metrics_unref (metrics);
- return retval;
+ scale = get_window_scaling_factor ();
+
+ return text_height * scale;
}
MetaFrameType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]