From 42780f5aa5ee676cee4a4ec745b703e7eb234199 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan <fourdan.olivier@wanadoo.fr> Date: Sat, 31 May 2008 23:41:10 +0000 Subject: [PATCH] Use actual font metrics to compute font height as it gives better results than layout extents, lighten icons of iconified windows in tabwin selector. (Old svn revision: 27001) --- src/frame.c | 16 ++++++++++++---- src/icons.c | 1 - src/screen.h | 3 +++ src/settings.c | 25 +++++++++++++++++++++++++ src/tabwin.c | 14 +++++++++++++- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/frame.c b/src/frame.c index 023f493a0..86f9fbfff 100644 --- a/src/frame.c +++ b/src/frame.c @@ -289,7 +289,7 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * PangoRectangle logical_rect; int width, x, hoffset, w1, w2, w3, w4, w5, temp; int voffset, title_x, title_y; - int top_height; + int title_height, top_height; TRACE ("entering frameCreateTitlePixmap"); @@ -344,10 +344,18 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * voffset = screen_info->params->title_vertical_offset_inactive; } - title_y = voffset + (frameTop (c) - logical_rect.height) / 2; - if (title_y + logical_rect.height > frameTop (c)) + title_height = screen_info->font_height; + if (!title_height) { - title_y = MAX (0, frameTop (c) - logical_rect.height); + /* If for some reason the font height is not known, + * use the actual pango layout height. + */ + title_height = logical_rect.height; + } + title_y = voffset + (frameTop (c) - title_height) / 2; + if (title_y + title_height > frameTop (c)) + { + title_y = MAX (0, frameTop (c) - title_height); } if (!xfwmPixmapNone(&screen_info->top[3][ACTIVE])) diff --git a/src/icons.c b/src/icons.c index 5743859b4..2fd91dbd2 100644 --- a/src/icons.c +++ b/src/icons.c @@ -524,4 +524,3 @@ getAppIcon (DisplayInfo *display_info, Window window, int width, int height) return xfce_inline_icon_at_size (default_icon_data, width, height); } - diff --git a/src/screen.h b/src/screen.h index b01b04423..8df75e693 100644 --- a/src/screen.h +++ b/src/screen.h @@ -83,6 +83,9 @@ struct _ScreenInfo GdkGC *black_gc; GdkGC *white_gc; + /* Title font height */ + int font_height; + /* Screen data */ Colormap cmap; GdkScreen *gscr; diff --git a/src/settings.c b/src/settings.c index 280400456..b0b5b0d91 100644 --- a/src/settings.c +++ b/src/settings.c @@ -994,6 +994,26 @@ getTitleShadow (Settings *rc, const gchar * name) return TITLE_SHADOW_NONE; } +static int +getFontHeight (const PangoFontDescription *desc, PangoContext *context) +{ + PangoFontMetrics *metrics; + PangoLanguage *language; + int height; + + g_return_val_if_fail (desc, 0); + g_return_val_if_fail (context, 0); + + language = pango_context_get_language (context); + metrics = pango_context_get_metrics (context, desc, language); + height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + + pango_font_metrics_get_descent (metrics)); + pango_font_metrics_unref (metrics); + + return height; +} + + static void loadTheme (ScreenInfo *screen_info, Settings *rc) { @@ -1038,12 +1058,14 @@ loadTheme (ScreenInfo *screen_info, Settings *rc) gchar *theme; gchar *font; PangoFontDescription *desc; + PangoContext *context; guint i, j; widget = myScreenGetGtkWidget (screen_info); display_info = screen_info->display_info; desc = NULL; + context = NULL; rc[0].value = getUIStyle (widget, "fg", "selected"); rc[1].value = getUIStyle (widget, "fg", "insensitive"); @@ -1096,13 +1118,16 @@ loadTheme (ScreenInfo *screen_info, Settings *rc) display_info->dbl_click_time = abs (g_value_get_int (&tmp_val)); } + screen_info->font_height = 0; font = getValue ("title_font", rc); if (font && strlen (font)) { desc = pango_font_description_from_string (font); + context = getUIPangoContext (widget); if (desc) { gtk_widget_modify_font (widget, desc); + screen_info->font_height = getFontHeight (desc, context); pango_font_description_free (desc); } } diff --git a/src/tabwin.c b/src/tabwin.c index b8ac6812e..82f5587f3 100644 --- a/src/tabwin.c +++ b/src/tabwin.c @@ -144,15 +144,27 @@ static GtkWidget * createWindowIcon (Client * c) { GdkPixbuf *icon_pixbuf; + GdkPixbuf *icon_pixbuf_stated; GtkWidget *icon; icon_pixbuf = getAppIcon (c->screen_info->display_info, c->window, WIN_ICON_SIZE, WIN_ICON_SIZE); + icon_pixbuf_stated = NULL; icon = gtk_image_new (); g_object_set_data (G_OBJECT (icon), "client-ptr-val", c); if (icon_pixbuf) { - gtk_image_set_from_pixbuf (GTK_IMAGE (icon), icon_pixbuf); + if (FLAG_TEST (c->flags, CLIENT_FLAG_ICONIFIED)) + { + icon_pixbuf_stated = gdk_pixbuf_copy (icon_pixbuf); + gdk_pixbuf_saturate_and_pixelate (icon_pixbuf, icon_pixbuf_stated, 0.5, TRUE); + gtk_image_set_from_pixbuf (GTK_IMAGE (icon), icon_pixbuf_stated); + g_object_unref(icon_pixbuf_stated); + } + else + { + gtk_image_set_from_pixbuf (GTK_IMAGE (icon), icon_pixbuf); + } g_object_unref(icon_pixbuf); } else -- GitLab