Commit 93c8941c authored by Olivier Fourdan's avatar Olivier Fourdan 🛠️
Browse files

screen: Remove pre-computed font height



Bug: 16067

The font height is not used anymore, remove it.

Signed-off-by: default avatarOlivier Fourdan <fourdan@xfce.org>

(cherry picked from commit 065a1204)
parent d2c453d5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2767,7 +2767,7 @@ refresh_font_cb (GObject * obj, GdkEvent * ev, gpointer data)
    for (list = display_info->screens; list; list = g_slist_next (list))
    {
        ScreenInfo *screen_info = (ScreenInfo *) list->data;
        myScreenUpdateFontHeight (screen_info);
        myScreenUpdateFontAttr (screen_info);
        clientUpdateAllFrames (screen_info, UPDATE_FRAME);
    }

+7 −41
Original line number Diff line number Diff line
@@ -304,7 +304,6 @@ myScreenInit (DisplayInfo *display_info, GdkScreen *gscr, unsigned long event_ma
    screen_info->systray = getSystrayWindow (display_info, screen_info->net_system_tray_selection);
#endif

    screen_info->font_height = 0;
    screen_info->font_desc = NULL;
    screen_info->pango_attr_list = NULL;
    screen_info->box_gc = None;
@@ -866,52 +865,19 @@ myScreenGetFontDescription (ScreenInfo *screen_info)
    return getUIPangoFontDesc (widget);
}

gboolean
myScreenUpdateFontHeight (ScreenInfo *screen_info)
void
myScreenUpdateFontAttr (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);
    g_clear_pointer (&screen_info->pango_attr_list, pango_attr_list_unref);

    widget = myScreenGetGtkWidget (screen_info);
    desc = myScreenGetFontDescription (screen_info);
    context = getUIPangoContext (widget);

    if (desc != NULL && context != NULL)
    {
        metrics = pango_context_get_metrics (context, desc, NULL);
    scale = gtk_widget_get_scale_factor (widget);
        font_height =
                 PANGO_PIXELS (pango_font_metrics_get_ascent (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;
    }

    return FALSE;
}
+1 −2
Original line number Diff line number Diff line
@@ -115,7 +115,6 @@ struct _ScreenInfo
    GC box_gc;

    /* Title font */
    gint font_height;
    PangoFontDescription *font_desc;
    PangoAttrList *pango_attr_list;

@@ -297,7 +296,7 @@ void myScreenFindMonitorAtPoint (ScreenInfo *,
                                                                 gint,
                                                                 GdkRectangle *);
PangoFontDescription *   myScreenGetFontDescription             (ScreenInfo *);
gboolean                 myScreenUpdateFontHeight               (ScreenInfo *);
void                     myScreenUpdateFontAttr                 (ScreenInfo *);
void                     myScreenGetXineramaMonitorGeometry     (ScreenInfo *,
                                                                 gint,
                                                                 GdkRectangle *);
+1 −2
Original line number Diff line number Diff line
@@ -465,13 +465,12 @@ loadTheme (ScreenInfo *screen_info, Settings *rc)
        g_value_unset (&tmp_val2);
    }

    screen_info->font_height = 0;
    font = getStringValue ("title_font", rc);
    if (font && strlen (font))
    {
        screen_info->font_desc = pango_font_description_from_string (font);
    }
    myScreenUpdateFontHeight (screen_info);
    myScreenUpdateFontAttr (screen_info);

    gdk_rgba_parse (&screen_info->title_colors[ACTIVE], getStringValue ("active_text_color", rc));
    gdk_rgba_parse (&screen_info->title_colors[INACTIVE], getStringValue ("inactive_text_color", rc));