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

Revert "frame: Fix title align"

Bug: 16711

We need to keep the pango font attributes for the scale with HiDPI.

This reverts commit 34a31e27.

(cherry picked from commit fbd07808)
parent 4925f82a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2767,6 +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);
        clientUpdateAllFrames (screen_info, UPDATE_FRAME);
    }

+8 −1
Original line number Diff line number Diff line
@@ -205,7 +205,14 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap *
    }
    pango_layout_get_pixel_extents (layout, NULL, &logical_rect);

    title_height = screen_info->font_height;
    if (!title_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 + (frameDecorationTop(screen_info) - title_height) / 2;
    if (title_y + title_height > frameDecorationTop(screen_info))
    {
+51 −0
Original line number Diff line number Diff line
@@ -304,6 +304,7 @@ 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;
@@ -864,3 +865,53 @@ myScreenGetFontDescription (ScreenInfo *screen_info)
    widget = myScreenGetGtkWidget (screen_info);
    return getUIPangoFontDesc (widget);
}

gboolean
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);

    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;
}
+2 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ struct _ScreenInfo
    GC box_gc;

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

@@ -296,6 +297,7 @@ void myScreenFindMonitorAtPoint (ScreenInfo *,
                                                                 gint,
                                                                 GdkRectangle *);
PangoFontDescription *   myScreenGetFontDescription             (ScreenInfo *);
gboolean                 myScreenUpdateFontHeight               (ScreenInfo *);
void                     myScreenGetXineramaMonitorGeometry     (ScreenInfo *,
                                                                 gint,
                                                                 GdkRectangle *);
+2 −0
Original line number Diff line number Diff line
@@ -465,11 +465,13 @@ 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);

    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));