static int limit;
xcb_window_t root;
xcb_connection_t *conn;
+xcb_screen_t *root_screen;
+
+/*
+ * Having verboselog() and errorlog() is necessary when using libi3.
+ *
+ */
+void verboselog(char *fmt, ...) {
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stdout, fmt, args);
+ va_end(args);
+}
+
+void errorlog(char *fmt, ...) {
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+}
/*
* Concats the glyphs (either UCS-2 or UTF-8) to a single string, suitable for
/* draw the prompt … */
if (prompt != NULL) {
- draw_text((char *)i3string_as_ucs2(prompt), i3string_get_num_glyphs(prompt), true, pixmap, pixmap_gc, 4, 4, 492);
+ draw_text(prompt, pixmap, pixmap_gc, 4, 4, 492);
}
/* … and the text */
if (input_position > 0)
- draw_text((char *)glyphs_ucs, input_position, true, pixmap, pixmap_gc, 4, 4 + prompt_offset, 492 - prompt_offset);
+ {
+ i3String *input = i3string_from_ucs2(glyphs_ucs, input_position);
+ draw_text(input, pixmap, pixmap_gc, 4, 4, 492);
+ i3string_free(input);
+ }
/* Copy the contents of the pixmap to the real window */
xcb_copy_area(conn, pixmap, win, pixmap_gc, 0, 0, 0, 0, /* */ 500, font.height + 8);
sockfd = ipc_connect(socket_path);
if (prompt != NULL)
- prompt_offset = predict_text_width((char *)i3string_as_ucs2(prompt), i3string_get_num_glyphs(prompt), true);
+ prompt_offset = predict_text_width(prompt);
int screens;
conn = xcb_connect(NULL, &screens);
if (!conn || xcb_connection_has_error(conn))
die("Cannot open display\n");
- xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screens);
+ root_screen = xcb_aux_get_screen(conn, screens);
root = root_screen->root;
symbols = xcb_key_symbols_alloc(conn);