From ee931f54802bc0da8953f0d2eb86c1a147edef6e Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 14 Mar 2017 17:12:22 +0100 Subject: [PATCH] [Textbox] Remove unneeded calls to pango_layout_get_baseline. Now bulk time is spend in drawing, not calculating. --- source/widgets/textbox.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 347cb7ca..0f2d95ee 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -343,7 +343,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) // Skip the side MARGIN on the X axis. int x = widget_padding_get_left ( WIDGET ( tb ) ) + offset; - int y = 0; if ( tb->flags & TB_RIGHT ) { int line_width = 0; @@ -357,13 +356,13 @@ static void textbox_draw ( widget *wid, cairo_t *draw ) } int top = widget_padding_get_top ( WIDGET ( tb ) ); - y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; rofi_theme_get_color ( WIDGET ( tb ), "foreground", draw ); // Text rofi_theme_get_color ( WIDGET ( tb ), "text", draw ); // draw the cursor if ( tb->flags & TB_EDITABLE && tb->blink ) { + int y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE; // We want to place the cursor based on the text shown. const char *text = pango_layout_get_text ( tb->layout ); // Clamp the position, should not be needed, but we are paranoid.