]> git.sur5r.net Git - i3/i3/commitdiff
Use only xcb_query_font()
authorAxel Wagner <mail@merovius.de>
Fri, 17 Sep 2010 01:27:06 +0000 (03:27 +0200)
committerAxel Wagner <mail@merovius.de>
Fri, 17 Sep 2010 01:51:41 +0000 (03:51 +0200)
i3bar/include/xcb.h
i3bar/src/xcb.c

index 82216f7f118c1a4b0a98c268fb9416e426869cce..75402285394c217e87ade8aa1093ed2069e91067 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef XCB_H_
 #define XCB_H_
 
-int font_height;
-
 /*
  * Initialize xcb and use the specified fontname for text-rendering
  *
index e200c5e46c1ce8cf248ea53d0ddaff385942cf05..f4f064a11489f9b1f1a0307705a8ede13222eafd 100644 (file)
@@ -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);