wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 72c7d317e210eb8777bbe401052311347f288280
parent 942665ff642c982d91e9197053a58f1651cafc80
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Sat, 17 Jun 2006 12:47:01 +0200

some more changes in liblitz (I need now a working wmii that I can change the Client/Bar rendering)


Diffstat:
liblitz/input.c | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
liblitz/tile.c | 1+
2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/liblitz/input.c b/liblitz/input.c @@ -4,6 +4,7 @@ */ #include <stdlib.h> +#include <string.h> #include <cext.h> #include "blitz.h" @@ -13,14 +14,72 @@ blitz_create_input(Drawable drawable, GC gc) BlitzWidget *i = cext_emallocz(sizeof(BlitzWidget)); i->drawable = drawable; i->gc = gc; + i->draw = blitz_draw_input; return i; } void blitz_draw_input(BlitzWidget *i) { + unsigned int x, y, w, h, shortened, len; + static char text[2048]; + XGCValues gcv; + blitz_draw_tile(i); + if (!i->text) + return; + + x = y = shortened = 0; + w = h = 1; + cext_strlcpy(text, i->text, sizeof(text)); + len = strlen(text); + gcv.foreground = i->color.fg; + gcv.background = i->color.bg; + if(i->font.set) + XChangeGC(__blitz.display, i->gc, GCForeground | GCBackground, &gcv); + else { + gcv.font = i->font.xfont->fid; + XChangeGC(__blitz.display, i->gc, GCForeground | GCBackground | GCFont, &gcv); + } + + h = i->font.ascent + i->font.descent; + y = i->rect.y + i->rect.height / 2 - h / 2 + i->font.ascent; + + /* shorten text if necessary */ + while (len && (w = blitz_textwidth(&i->font, text)) > i->rect.width) { + text[len - 1] = 0; + len--; + shortened = 1; + } + + if (w > i->rect.width) + return; + + /* mark shortened info in the string */ + if (shortened) { + if (len > 3) + text[len - 3] = '.'; + if (len > 2) + text[len - 2] = '.'; + if (len > 1) + text[len - 1] = '.'; + } + switch (i->align) { + case EAST: + x = i->rect.x + i->rect.width - (h / 2 + w); + break; + case CENTER: + x = i->rect.x + (i->rect.width - w) / 2; + break; + default: + x = i->rect.x + h / 2; + break; + } + if(i->font.set) + XmbDrawString(__blitz.display, i->drawable, i->font.set, i->gc, x, y, text, len); + else + XDrawString(__blitz.display, i->drawable, i->gc, x, y, text, len); } void diff --git a/liblitz/tile.c b/liblitz/tile.c @@ -13,6 +13,7 @@ blitz_create_tile(Drawable drawable, GC gc) BlitzWidget *t = cext_emallocz(sizeof(BlitzWidget)); t->drawable = drawable; t->gc = gc; + t->draw = blitz_draw_tile; return t; }