void redraw_bars();
/*
- * Calculate the rendered width of a string with the configured font.
+ * Predicts the length of text based on cached data.
* The string has to be encoded in ucs2 and glyph_len has to be the length
- * of the string (in width)
+ * of the string (in glyphs).
*
*/
-int get_string_width(xcb_char2b_t *string, int glyph_len);
+uint32_t predict_text_extents(xcb_char2b_t *text, uint32_t length);
#endif
xcb_char2b_t *ucs2_name = (xcb_char2b_t*) convert_utf8_to_ucs2(params->workspaces_walk->name, &ucs2_len);
params->workspaces_walk->ucs2_name = ucs2_name;
params->workspaces_walk->name_glyphs = ucs2_len;
- params->workspaces_walk->name_width = get_string_width(params->workspaces_walk->ucs2_name,
- params->workspaces_walk->name_glyphs);
+ params->workspaces_walk->name_width =
+ predict_text_extents(params->workspaces_walk->ucs2_name,
+ params->workspaces_walk->name_glyphs);
printf("Got Workspace %s, name_width: %d, glyphs: %d\n",
params->workspaces_walk->name,
ev_io *xkb_io;
/*
- * Predicts the length of text based on cached data
+ * Predicts the length of text based on cached data.
+ * The string has to be encoded in ucs2 and glyph_len has to be the length
+ * of the string (in glyphs).
*
*/
uint32_t predict_text_extents(xcb_char2b_t *text, uint32_t length) {
}
}
-/*
- * Calculate the rendered width of a string with the configured font.
- * The string has to be encoded in ucs2 and glyph_len has to be the length
- * of the string (in width)
- *
- */
-int get_string_width(xcb_char2b_t *string, int glyph_len) {
- xcb_query_text_extents_cookie_t cookie;
- xcb_query_text_extents_reply_t *reply;
- xcb_generic_error_t *error = NULL;
- int width;
-
- cookie = xcb_query_text_extents(xcb_connection, xcb_font, glyph_len, string);
- reply = xcb_query_text_extents_reply(xcb_connection, cookie, &error);
- if (error != NULL) {
- printf("ERROR: Could not get text extents! XCB-errorcode: %d\n", error->error_code);
- exit(EXIT_FAILURE);
- }
-
- width = reply->overall_width;
- free(reply);
- return width;
-}
-
/*
* Initialize xcb and use the specified fontname for text-rendering
*