From: Axel Wagner Date: Fri, 17 Sep 2010 01:27:06 +0000 (+0200) Subject: Use only xcb_query_font() X-Git-Tag: 4.0.1~7^2~59 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c82556f0f2ac97bf2731f3f6aed008dca946cca9;p=i3%2Fi3 Use only xcb_query_font() --- diff --git a/i3bar/include/xcb.h b/i3bar/include/xcb.h index 82216f7f..75402285 100644 --- a/i3bar/include/xcb.h +++ b/i3bar/include/xcb.h @@ -9,8 +9,6 @@ #ifndef XCB_H_ #define XCB_H_ -int font_height; - /* * Initialize xcb and use the specified fontname for text-rendering * diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index e200c5e4..f4f064a1 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -44,6 +44,7 @@ xcb_font_t xcb_font; /* We need to cache some data to speed up text-width-prediction */ xcb_query_font_reply_t *font_info; +int font_height; xcb_charinfo_t *font_table; /* These are only relevant for XKB, which we only need for grabbing modifiers */ @@ -434,13 +435,8 @@ void init_xcb(char *fontname) { exit(EXIT_FAILURE); } - /* We also need the fontheight to configure our bars accordingly */ - xcb_list_fonts_with_info_cookie_t font_info_cookie; - font_info_cookie = xcb_list_fonts_with_info(xcb_connection, - 1, - strlen(fontname), - fontname); - + /* We need to save info about the font, because we need the fonts height and + * information about the width of characters */ xcb_query_font_cookie_t query_font_cookie; query_font_cookie = xcb_query_font(xcb_connection, xcb_font); @@ -517,16 +513,10 @@ void init_xcb(char *fontname) { get_atoms(); /* Now we calculate the font-height */ - xcb_list_fonts_with_info_reply_t *reply; - reply = xcb_list_fonts_with_info_reply(xcb_connection, - font_info_cookie, - NULL); - font_height = reply->font_ascent + reply->font_descent; - FREE(reply); - font_info = xcb_query_font_reply(xcb_connection, query_font_cookie, &err); + font_height = font_info->font_ascent + font_info->font_descent; if (err != NULL) { printf("ERROR: Could not query font! XCB-error: %d\n", err->error_code);