[Xfce4-commits] [xfce/xfwm4] 02/05: Use GTK3 scaling attributes for window titles
noreply at xfce.org
noreply at xfce.org
Thu Jun 6 21:20:32 CEST 2019
This is an automated email from the git hooks/post-receive script.
o l i v i e r p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfwm4.
commit d5113fbc1424cf95e55f4ddbc06e66d94a7bb328
Author: Viktor Odintsev <ninetls at xfce.org>
Date: Wed Dec 26 16:50:23 2018 +0300
Use GTK3 scaling attributes for window titles
---
src/frame.c | 4 ++++
src/screen.c | 31 +++++++++++++++++++++++++++++--
src/screen.h | 1 +
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/frame.c b/src/frame.c
index 923203b..34d1466 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -199,6 +199,10 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap *
layout = gtk_widget_create_pango_layout (myScreenGetGtkWidget (screen_info), c->name);
pango_layout_set_font_description (layout, myScreenGetFontDescription (screen_info));
pango_layout_set_auto_dir (layout, FALSE);
+ if (screen_info->pango_attr_list != NULL)
+ {
+ pango_layout_set_attributes (layout, screen_info->pango_attr_list);
+ }
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
title_height = screen_info->font_height;
diff --git a/src/screen.c b/src/screen.c
index f18c0d7..f4daa47 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -306,6 +306,7 @@ myScreenInit (DisplayInfo *display_info, GdkScreen *gscr, unsigned long event_ma
screen_info->font_height = 0;
screen_info->font_desc = NULL;
+ screen_info->pango_attr_list = NULL;
screen_info->box_gc = None;
for (i = 0; i < SIDE_COUNT; i++)
@@ -391,6 +392,11 @@ myScreenClose (ScreenInfo *screen_info)
screen_info->monitors_index = NULL;
}
+ if (screen_info->pango_attr_list)
+ {
+ pango_attr_list_unref (screen_info->pango_attr_list);
+ }
+
return (screen_info);
}
@@ -866,7 +872,10 @@ myScreenUpdateFontHeight (ScreenInfo *screen_info)
PangoFontDescription *desc;
PangoContext *context;
PangoFontMetrics *metrics;
+ PangoAttribute *attr;
GtkWidget *widget;
+ gint font_height;
+ gint scale;
g_return_val_if_fail (screen_info != NULL, FALSE);
@@ -877,11 +886,29 @@ myScreenUpdateFontHeight (ScreenInfo *screen_info)
if (desc != NULL && context != NULL)
{
metrics = pango_context_get_metrics (context, desc, NULL);
- screen_info->font_height =
+ scale = gtk_widget_get_scale_factor (widget);
+ font_height =
PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
+ pango_font_metrics_get_descent (metrics)) * scale;
pango_font_metrics_unref (metrics);
+ if (font_height != screen_info->font_height)
+ {
+ screen_info->font_height = font_height;
+
+ if (screen_info->pango_attr_list != NULL)
+ {
+ pango_attr_list_unref (screen_info->pango_attr_list);
+ screen_info->pango_attr_list = NULL;
+ }
+ if (scale != 1)
+ {
+ screen_info->pango_attr_list = pango_attr_list_new ();
+ attr = pango_attr_scale_new (scale);
+ pango_attr_list_insert (screen_info->pango_attr_list, attr);
+ }
+ }
+
return TRUE;
}
diff --git a/src/screen.h b/src/screen.h
index 96d52ee..74b9279 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -117,6 +117,7 @@ struct _ScreenInfo
/* Title font */
gint font_height;
PangoFontDescription *font_desc;
+ PangoAttrList *pango_attr_list;
/* Screen data */
Colormap cmap;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list