wmii

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

commit 970e0d1fe535e4dc11cb1aa6a64f80676b5fa39c
parent da01e0d0d11d871bada841cd4d76d0bf78c3d94b
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Mon, 24 Apr 2006 01:01:49 +0200

added Xutf8 stuff again, needs polishing


Diffstat:
cmd/wm/client.c | 36+++++++++++++++++++++++++++---------
liblitz/blitz.h | 1+
liblitz/draw.c | 5++++-
liblitz/font.c | 19++++++++++++++-----
4 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -22,11 +22,29 @@ static void update_client_name(Client *c) { XTextProperty name; - XGetTextProperty(dpy, c->win, &name, XA_WM_NAME); - if(name.value) { - cext_strlcpy(c->name, (char *)name.value, sizeof(c->name)); - free(name.value); + XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]); + if(!name.value || !name.nitems) + XGetTextProperty(dpy, c->win, &name, XA_WM_NAME); + if(name.value && name.nitems) { + if(name.encoding == XA_STRING) + cext_strlcpy(c->name, (char *)name.value, sizeof(c->name)); + else { + int n; + char **list = nil; + name.nitems = strlen((char *)name.value); + if(Xutf8TextPropertyToTextList(dpy, &name, &list, &n) == Success + && n > 0 && *list) + { + cext_strlcpy(c->name, *list, sizeof(c->name)); + XFreeStringList(list); + } + else + c->name[0] = 0; + } + XFree(name.value); } + else + c->name[0] = 0; } Client * @@ -194,11 +212,6 @@ prop_client(Client *c, XPropertyEvent *e) return; } switch (e->atom) { - case XA_WM_NAME: - update_client_name(c); - if(c->frame.size) - draw_client(c); - break; case XA_WM_TRANSIENT_FOR: XGetTransientForHint(dpy, c->win, &c->trans); break; @@ -208,6 +221,11 @@ prop_client(Client *c, XPropertyEvent *e) } break; } + if(e->atom == XA_WM_NAME || e->atom == net_atom[NetWMName]) { + update_client_name(c); + if(c->frame.size) + draw_client(c); + } } /* speed reasoned function for client property change */ diff --git a/liblitz/blitz.h b/liblitz/blitz.h @@ -22,6 +22,7 @@ typedef struct { typedef struct { XFontStruct *xfont; + XFontSet set; } BlitzFont; typedef struct { diff --git a/liblitz/draw.c b/liblitz/draw.c @@ -102,7 +102,10 @@ xdrawtext(Display *dpy, BlitzDraw *d) } XSetBackground(dpy, d->gc, d->color.bg); XSetForeground(dpy, d->gc, d->color.fg); - XDrawString(dpy, d->drawable, d->gc, x, y, text, len); + if(d->font.set) + Xutf8DrawString(dpy, d->drawable, d->font.set, d->gc, x, y, text, len); + else + XDrawString(dpy, d->drawable, d->gc, x, y, text, len); } void diff --git a/liblitz/font.c b/liblitz/font.c @@ -12,15 +12,24 @@ void blitz_loadfont(Display *dpy, BlitzFont *font, char *fontstr) { + char *fontname = fontstr; + char **missing = nil, *def = "?"; + int nmissing; + if(font->set) + XFreeFontSet(dpy, font->set); if(font->xfont) XFreeFont(dpy, font->xfont); - - font->xfont = XLoadQueryFont(dpy, fontstr); - if (!font->xfont) - font->xfont = XLoadQueryFont(dpy, "fixed"); - + font->xfont = XLoadQueryFont(dpy, fontname); + if (!font->xfont) { + fontname = "fixed"; + font->xfont = XLoadQueryFont(dpy, fontname); + } if (!font->xfont) { fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n"); exit(1); } + font->set = XCreateFontSet(dpy, fontname, &missing, &nmissing, &def); + + if(missing) + XFreeStringList(missing); }