Implement set_font_colors.

This paves the way for other font rendering backends. Fonts and
colors shouldn't be specified manually from now on.
This commit is contained in:
Fernando Tarlá Cardoso Lemos
2011-11-14 20:20:18 -02:00
committed by Michael Stapelberg
parent eafc7af606
commit 344c04af12
8 changed files with 63 additions and 68 deletions

View File

@ -81,14 +81,25 @@ void set_font(i3Font *font) {
savedFont = font;
}
/*
* Defines the colors to be used for the forthcoming draw_text calls.
*
*/
void set_font_colors(xcb_gcontext_t gc, uint32_t foreground, uint32_t background) {
assert(savedFont != NULL);
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
uint32_t values[] = { foreground, background, savedFont->id };
xcb_change_gc(conn, gc, mask, values);
}
/*
* Draws text onto the specified X drawable (normally a pixmap) at the
* specified coordinates (from the top left corner of the leftmost, uppermost
* glyph) and using the provided gc. Text can be specified as UCS-2 or UTF-8.
*
*/
void draw_text(char *text, size_t text_len, bool is_ucs2,
xcb_drawable_t drawable, xcb_gcontext_t gc, int x, int y) {
void draw_text(char *text, size_t text_len, bool is_ucs2, xcb_drawable_t drawable,
xcb_gcontext_t gc, int x, int y, int max_width) {
assert(savedFont != NULL);
assert(text_len != 0);