[hackers] [wmii] Use Xutf8* rather than Xmb*. Convert from locale to UTF-8. Some other fixes.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri, 01 Jun 2007 01:09:29 -0000

changeset: 2093:dffebf3309c8
user: Kris Maglione <jg_AT_suckless.org>
date: Wed Apr 18 15:08:15 2007 -0400
summary: Use Xutf8* rather than Xmb*. Convert from locale to UTF-8. Some other fixes.

diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/Makefile
--- a/cmd/wmii/Makefile Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/Makefile Wed Apr 18 15:08:15 2007 -0400
@@ -8,7 +8,7 @@ HFILES= dat.h fns.h
 HFILES= dat.h fns.h
 
 LIB = ${LIBIXP}
-EXLDFLAGS = -lm ${LIBX11} -lXext
+EXLDFLAGS = -lm ${LIBX11} -lXext -L/usr/local/lib -liconv
 EXCFLAGS = ${INCX11}
 OBJ = area \
         bar \
@@ -23,6 +23,7 @@ OBJ = area \
         mouse \
         rule \
         printevent\
+ utf \
         view \
         x11 \
         ../util
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/client.c
--- a/cmd/wmii/client.c Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/client.c Wed Apr 18 15:08:15 2007 -0400
@@ -23,7 +23,8 @@ enum {
                 | EnterWindowMask
                 | FocusChangeMask,
         ButtonMask =
- ButtonPressMask | ButtonReleaseMask
+ ButtonPressMask
+ | ButtonReleaseMask
 };
 
 Client *
@@ -79,12 +80,13 @@ create_client(XWindow w, XWindowAttribut
 }
 
 static int
-dummy_error_handler(Display *dpy, XErrorEvent *error) {
+ignoreerrors(Display *d, XErrorEvent *e) {
         return 0;
 }
 
 void
 destroy_client(Client *c) {
+ int (*handler)(Display*, XErrorEvent*);
         char *dummy;
         Client **tc;
         XEvent ev;
@@ -96,8 +98,9 @@ destroy_client(Client *c) {
                 }
 
         XGrabServer(display);
+
         /* In case the client is already unmapped */
- XSetErrorHandler(dummy_error_handler);
+ handler = XSetErrorHandler(ignoreerrors);
 
         dummy = nil;
         update_client_views(c, &dummy);
@@ -110,7 +113,8 @@ destroy_client(Client *c) {
         sethandler(&c->win, nil);
 
         XSync(display, False);
- XSetErrorHandler(wmii_error_handler);
+ XSetErrorHandler(handler);
+
         XUngrabServer(display);
         flushevents(EnterWindowMask, False);
 
@@ -321,26 +325,31 @@ update_client_name(Client *c) {
 update_client_name(Client *c) {
         XTextProperty name;
         XClassHint ch = {0};
+ char **list, *str;
         int n;
- char **list = nil;
 
         c->name[0] = 0;
+ list = nil;
 
         name.nitems = 0;
         XGetTextProperty(display, c->win.w, &name, atom[NetWMName]);
- if(!name.nitems)
+ if(name.nitems > 0) {
+ if(Xutf8TextPropertyToTextList(display, &name, &list, &n) == Success) {
+ utfecpy(c->name, c->name+sizeof(c->name), list[0]);
+ XFreeStringList(list);
+ fprintf(stderr, "GotNetWMName: %x: %s\n", (uint)c->win.w, c->name);
+ }
+ }else {
                 XGetWMName(display, c->win.w, &name);
- if(!name.nitems)
- return;
-
- if(name.encoding == XA_STRING)
- strncpy(c->name, (char *)name.value, sizeof(c->name));
- else if(XmbTextPropertyToTextList(display, &name, &list, &n) >= Success)
- if(n > 0 && *list) {
- strncpy(c->name, *list, sizeof(c->name));
- XFreeStringList(list);
- }
- XFree(name.value);
+ if(name.nitems > 0) {
+ str = toutf8((char*)name.value);
+ utfecpy(c->name, c->name+sizeof(c->name), str);
+ fprintf(stderr, "GotWMName: %x: %s (was: %s)\n",
+ (uint)c->win.w, c->name, name.value);
+ free(str);
+ XFree(name.value);
+ }
+ }
 
         XGetClassHint(display, c->win.w, &ch);
         snprintf(c->props, sizeof(c->props), "%s:%s:%s",
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/dat.h Wed Apr 18 15:08:15 2007 -0400
@@ -4,6 +4,7 @@
 
 #include <regex.h>
 #include <ixp.h>
+#include <utf.h>
 #include "x11.h"
 
 #define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/fns.h Wed Apr 18 15:08:15 2007 -0400
@@ -143,7 +143,6 @@ uint newcolw(View*, int i);
 uint newcolw(View*, int i);
 
 /* wm.c */
-int wmii_error_handler(Display*, XErrorEvent *error);
 int win_proto(Window);
 
 /* x11.c */
@@ -191,3 +190,30 @@ Point translate(Window*, Window*, Point)
 Point translate(Window*, Window*, Point);
 int grabpointer(Window*, Window *confine, Cursor cur, int mask);
 void ungrabpointer();
+
+/* utf.c */
+int chartorune(Rune*, char*);
+int fullrune(char*, int n);
+int runelen(long);
+int runenlen(Rune*, int nrune);
+Rune* runestrcat(Rune*, Rune*);
+Rune* runestrchr(Rune*, Rune);
+int runestrcmp(Rune*, Rune*);
+Rune* runestrcpy(Rune*, Rune*);
+Rune* runestrdup(Rune*) ;
+Rune* runestrecpy(Rune*, Rune *end, Rune*);
+long runestrlen(Rune*);
+Rune* runestrncat(Rune*, Rune*, long);
+int runestrncmp(Rune*, Rune*, long);
+Rune* runestrncpy(Rune*, Rune*, long);
+Rune* runestrrchr(Rune*, Rune);
+Rune* runestrstr(Rune*, Rune*);
+int runetochar(char*, Rune *rune);
+Rune totitlerune(Rune);
+char* utfecpy(char*, char *end, char*);
+int utflen(char*);
+int utfnlen(char*, long);
+char* utfrrune(char*, long);
+char* utfrune(char*, long);
+char* utfutf(char*, char*);
+char* toutf8(const char*);
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/main.c
--- a/cmd/wmii/main.c Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/main.c Wed Apr 18 15:08:15 2007 -0400
@@ -21,7 +21,7 @@ static const char
 static const char
         version[] = "wmii-"VERSION", ©2007 Kris Maglione\n";
 
-static int (*x_error_handler) (Display *, XErrorEvent *);
+static int (*xlib_errorhandler) (Display*, XErrorEvent*);
 static char *address, *ns_path;
 static Bool check_other_wm;
 static struct sigaction sa;
@@ -257,8 +257,8 @@ struct {
  * Other types of errors call Xlib's default error handler, which
  * calls exit().
  */
-int
-wmii_error_handler(Display *dpy, XErrorEvent *error) {
+static int
+errorhandler(Display *dpy, XErrorEvent *error) {
         static Bool dead;
         int i;
 
@@ -274,7 +274,7 @@ wmii_error_handler(Display *dpy, XErrorE
                         argv0, error->request_code, error->error_code);
         if(!dead++)
                 cleanup();
- return x_error_handler(display, error); /* calls exit() */
+ return xlib_errorhandler(display, error); /* calls exit() */
 }
 
 static void
@@ -421,10 +421,14 @@ main(int argc, char *argv[]) {
 
         initdisplay();
 
+ xlib_errorhandler = XSetErrorHandler(errorhandler);
+
         check_other_wm = True;
- x_error_handler = XSetErrorHandler(wmii_error_handler);
- XSelectInput(display, scr.root.w, SubstructureRedirectMask | EnterWindowMask);
+ XSelectInput(display, scr.root.w,
+ SubstructureRedirectMask
+ | EnterWindowMask);
         XSync(display, False);
+
         check_other_wm = False;
 
         passwd = getpwuid(getuid());
@@ -432,7 +436,6 @@ main(int argc, char *argv[]) {
 
         init_environment();
 
- errstr = nil;
         sock = ixp_announce(address);
         if(sock < 0)
                 fatal("Can't create socket '%s': %s", address, errstr);
@@ -447,10 +450,6 @@ main(int argc, char *argv[]) {
 
         ixp_listen(&srv, sock, &p9srv, check_9pcon, nil);
         ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, nil);
-
- view = nil;
- client = nil;
- key = nil;
 
         def.font = loadfont(FONT);
         def.border = 1;
@@ -472,10 +471,10 @@ main(int argc, char *argv[]) {
                 s->ibuf = allocimage(Dx(s->rect), Dy(s->rect), scr.depth);
 
                 wa.event_mask =
- SubstructureRedirectMask
- | EnterWindowMask
- | LeaveWindowMask
- | FocusChangeMask;
+ SubstructureRedirectMask
+ | EnterWindowMask
+ | LeaveWindowMask
+ | FocusChangeMask;
                 wa.cursor = cursor[CurNormal];
                 setwinattr(&scr.root, &wa,
                                   CWEventMask
@@ -483,12 +482,12 @@ main(int argc, char *argv[]) {
                 initbar(s);
         }
 
- screen = &screens[0];
         screen->focus = nil;
         XSetInputFocus(display, screen->barwin->w, RevertToParent, CurrentTime);
 
         scan_wins();
         starting = False;
+
         select_view("nil");
         update_views();
         write_event("FocusTag %s\n", screen->sel->name);
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/mouse.c Wed Apr 18 15:08:15 2007 -0400
@@ -481,47 +481,39 @@ rect_morph_xy(Rectangle *r, Point d, Ali
         }
 }
 
-typedef struct {
- Rectangle *rects;
- int num;
- Rectangle r;
- int x, y;
- int dx, dy;
- Align mask;
-} SnapArgs;
-
-static void
-snap_line(SnapArgs *a) {
- Rectangle *r;
- int i, x, y;
-
- if(a->mask & (NORTH|SOUTH)) {
- for(i=0; i < a->num; i++) {
- r = &a->rects[i];
- if((r->min.x <= a->r.max.x) && (r->max.x >= a->r.min.x)) {
- y = r->min.y;
- if(abs(y - a->y) <= abs(a->dy))
- a->dy = y - a->y;
-
- y = r->max.y;
- if(abs(y - a->y) <= abs(a->dy))
- a->dy = y - a->y;
+static int
+snap_line(Rectangle *rects, int nrect, int d, int horiz, Rectangle *r, int x, int y) {
+ Rectangle *rp;
+ int i, tx, ty;
+
+ if(horiz) {
+ for(i=0; i < nrect; i++) {
+ rp = &rects[i];
+ if((rp->min.x <= r->max.x) && (rp->max.x >= r->min.x)) {
+ ty = rp->min.y;
+ if(abs(ty - y) <= abs(d))
+ d = ty - y;
+
+ ty = rp->max.y;
+ if(abs(ty - y) <= abs(d))
+ d = ty - y;
                         }
                 }
         }else {
- for(i=0; i < a->num; i++) {
- r = &a->rects[i];
- if((r->min.y <= a->r.max.y) && (r->max.y >= a->r.min.y)) {
- x = r->min.x;
- if(abs(x - a->x) <= abs(a->dx))
- a->dx = x - a->x;
-
- x = r->max.x;
- if(abs(x - a->x) <= abs(a->dx))
- a->dx = x - a->x;
- }
- }
- }
+ for(i=0; i < nrect; i++) {
+ rp = &rects[i];
+ if((rp->min.y <= r->max.y) && (rp->max.y >= r->min.y)) {
+ tx = rp->min.x;
+ if(abs(tx - x) <= abs(d))
+ d = tx - x;
+
+ tx = rp->max.x;
+ if(abs(tx - x) <= abs(d))
+ d = tx - x;
+ }
+ }
+ }
+ return d;
 }
 
 /* Returns a gravity for increment handling. It's normally the opposite of the mask
@@ -530,47 +522,34 @@ snap_line(SnapArgs *a) {
  */
 Align
 snap_rect(Rectangle *rects, int num, Rectangle *r, Align *mask, int snap) {
- SnapArgs a = { 0, };
         Align ret;
-
- a.rects = rects;
- a.num = num;
- a.dx = snap + 1;
- a.dy = snap + 1;
- a.r = *r;
-
- a.mask = NORTH|SOUTH;
- if(*mask & NORTH) {
- a.y = r->min.y;
- snap_line(&a);
- }
- if(*mask & SOUTH) {
- a.y = r->max.y;
- snap_line(&a);
- }
-
- a.mask = EAST|WEST;
- if(*mask & EAST) {
- a.x = r->max.x;
- snap_line(&a);
- }
- if(*mask & WEST) {
- a.x = r->min.x;
- snap_line(&a);
- }
+ Point d;
+
+ d.x = snap+1;
+ d.y = snap+1;
+
+ if(*mask&NORTH)
+ d.y = snap_line(rects, num, d.y, True, r, 0, r->min.y);
+ if(*mask&SOUTH)
+ d.y = snap_line(rects, num, d.y, True, r, 0, r->max.y);
+
+ if(*mask&EAST)
+ d.x = snap_line(rects, num, d.x, False, r, r->max.x, 0);
+ if(*mask&WEST)
+ d.x = snap_line(rects, num, d.x, False, r, r->min.x, 0);
 
         ret = CENTER;
- if(abs(a.dx) <= snap)
+ if(abs(d.x) <= snap)
                 ret ^= EAST|WEST;
         else
- a.dx = 0;
-
- if(abs(a.dy) <= snap)
+ d.x = 0;
+
+ if(abs(d.y) <= snap)
                 ret ^= NORTH|SOUTH;
         else
- a.dy = 0;
-
- rect_morph_xy(r, Pt(a.dx, a.dy), mask);
+ d.y = 0;
+
+ rect_morph_xy(r, d, mask);
         return ret ^ *mask;
 }
 
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/utf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/wmii/utf.c Wed Apr 18 15:08:15 2007 -0400
@@ -0,0 +1,348 @@
+/*
+ * The authors of this software are Rob Pike and Ken Thompson.
+ * Copyright (c) 2002 by Lucent Technologies.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
+ * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ */
+#include <iconv.h>
+#include <stdarg.h>
+#include <string.h>
+#include <util.h>
+#include "dat.h"
+#include "fns.h"
+
+enum
+{
+ Bit1 = 7,
+ Bitx = 6,
+ Bit2 = 5,
+ Bit3 = 4,
+ Bit4 = 3,
+
+ T1 = ((1<<(Bit1+1))-1) ^ 0xFF, /* 0000 0000 */
+ Tx = ((1<<(Bitx+1))-1) ^ 0xFF, /* 1000 0000 */
+ T2 = ((1<<(Bit2+1))-1) ^ 0xFF, /* 1100 0000 */
+ T3 = ((1<<(Bit3+1))-1) ^ 0xFF, /* 1110 0000 */
+ T4 = ((1<<(Bit4+1))-1) ^ 0xFF, /* 1111 0000 */
+
+ Rune1 = (1<<(Bit1+0*Bitx))-1, /* 0000 0000 0111 1111 */
+ Rune2 = (1<<(Bit2+1*Bitx))-1, /* 0000 0111 1111 1111 */
+ Rune3 = (1<<(Bit3+2*Bitx))-1, /* 1111 1111 1111 1111 */
+
+ Maskx = (1<<Bitx)-1, /* 0011 1111 */
+ Testx = Maskx ^ 0xFF, /* 1100 0000 */
+
+ Bad = Runeerror,
+};
+
+int
+chartorune(Rune *rune, char *str)
+{
+ int c, c1, c2;
+ long l;
+
+ /*
+ * one character sequence
+ * 00000-0007F => T1
+ */
+ c = *(uchar*)str;
+ if(c < Tx) {
+ *rune = c;
+ return 1;
+ }
+
+ /*
+ * two character sequence
+ * 0080-07FF => T2 Tx
+ */
+ c1 = *(uchar*)(str+1) ^ Tx;
+ if(c1 & Testx)
+ goto bad;
+ if(c < T3) {
+ if(c < T2)
+ goto bad;
+ l = ((c << Bitx) | c1) & Rune2;
+ if(l <= Rune1)
+ goto bad;
+ *rune = l;
+ return 2;
+ }
+
+ /*
+ * three character sequence
+ * 0800-FFFF => T3 Tx Tx
+ */
+ c2 = *(uchar*)(str+2) ^ Tx;
+ if(c2 & Testx)
+ goto bad;
+ if(c < T4) {
+ l = ((((c << Bitx) | c1) << Bitx) | c2) & Rune3;
+ if(l <= Rune2)
+ goto bad;
+ *rune = l;
+ return 3;
+ }
+
+ /*
+ * bad decoding
+ */
+bad:
+ *rune = Bad;
+ return 1;
+}
+
+int
+runetochar(char *str, Rune *rune)
+{
+ long c;
+
+ /*
+ * one character sequence
+ * 00000-0007F => 00-7F
+ */
+ c = *rune;
+ if(c <= Rune1) {
+ str[0] = c;
+ return 1;
+ }
+
+ /*
+ * two character sequence
+ * 0080-07FF => T2 Tx
+ */
+ if(c <= Rune2) {
+ str[0] = T2 | (c >> 1*Bitx);
+ str[1] = Tx | (c & Maskx);
+ return 2;
+ }
+
+ /*
+ * three character sequence
+ * 0800-FFFF => T3 Tx Tx
+ */
+ str[0] = T3 | (c >> 2*Bitx);
+ str[1] = Tx | ((c >> 1*Bitx) & Maskx);
+ str[2] = Tx | (c & Maskx);
+ return 3;
+}
+
+int
+runelen(long c)
+{
+ Rune rune;
+ char str[10];
+
+ rune = c;
+ return runetochar(str, &rune);
+}
+
+int
+runenlen(Rune *r, int nrune)
+{
+ int nb, c;
+
+ nb = 0;
+ while(nrune--) {
+ c = *r++;
+ if(c <= Rune1)
+ nb++;
+ else
+ if(c <= Rune2)
+ nb += 2;
+ else
+ nb += 3;
+ }
+ return nb;
+}
+
+int
+fullrune(char *str, int n)
+{
+ int c;
+
+ if(n > 0) {
+ c = *(uchar*)str;
+ if(c < Tx)
+ return 1;
+ if(n > 1)
+ if(c < T3 || n > 2)
+ return 1;
+ }
+ return 0;
+}
+
+char*
+utfecpy(char *to, char *e, char *from)
+{
+ char *end;
+
+ if(to >= e)
+ return to;
+ end = memccpy(to, from, '\0', e - to);
+ if(end == nil){
+ end = e-1;
+ while(end>to && (*--end&0xC0)==0x80)
+ ;
+ *end = '\0';
+ }else{
+ end--;
+ }
+ return end;
+}
+
+char*
+utfrune(char *s, long c)
+{
+ long c1;
+ Rune r;
+ int n;
+
+ if(c < Runesync) /* not part of utf sequence */
+ return strchr(s, c);
+
+ for(;;) {
+ c1 = *(uchar*)s;
+ if(c1 < Runeself) { /* one byte rune */
+ if(c1 == 0)
+ return 0;
+ if(c1 == c)
+ return s;
+ s++;
+ continue;
+ }
+ n = chartorune(&r, s);
+ if(r == c)
+ return s;
+ s += n;
+ }
+}
+
+int
+utflen(char *s)
+{
+ int c;
+ long n;
+ Rune rune;
+
+ n = 0;
+ for(;;) {
+ c = *(uchar*)s;
+ if(c < Runeself) {
+ if(c == 0)
+ return n;
+ s++;
+ } else
+ s += chartorune(&rune, s);
+ n++;
+ }
+}
+
+int
+utfnlen(char *s, long m)
+{
+ int c;
+ long n;
+ Rune rune;
+ char *es;
+
+ es = s + m;
+ for(n = 0; s < es; n++) {
+ c = *(uchar*)s;
+ if(c < Runeself){
+ if(c == '\0')
+ break;
+ s++;
+ continue;
+ }
+ if(!fullrune(s, es-s))
+ break;
+ s += chartorune(&rune, s);
+ }
+ return n;
+}
+
+char*
+utfrrune(char *s, long c)
+{
+ long c1;
+ Rune r;
+ char *s1;
+
+ if(c < Runesync) /* not part of utf sequence */
+ return strrchr(s, c);
+
+ s1 = 0;
+ for(;;) {
+ c1 = *(uchar*)s;
+ if(c1 < Runeself) { /* one byte rune */
+ if(c1 == 0)
+ return s1;
+ if(c1 == c)
+ s1 = s;
+ s++;
+ continue;
+ }
+ c1 = chartorune(&r, s);
+ if(r == c)
+ s1 = s;
+ s += c1;
+ }
+}
+
+/*
+ * Return pointer to first occurrence of s2 in s1,
+ * 0 if none
+ */
+char*
+utfutf(char *s1, char *s2)
+{
+ char *p;
+ long f, n1, n2;
+ Rune r;
+
+ n1 = chartorune(&r, s2);
+ f = r;
+ if(f <= Runesync) /* represents self */
+ return strstr(s1, s2);
+
+ n2 = strlen(s2);
+ for(p=s1; (p=utfrune(p, f)); p+=n1)
+ if(strncmp(p, s2, n2) == 0)
+ return p;
+ return 0;
+}
+
+char*
+toutf8(const char *str) {
+ static iconv_t cd;
+ char *buf, *pos;
+ int nbuf, nstr, bsize;
+
+ if(cd == nil)
+ cd = iconv_open("UTF-8", "");
+ iconv(cd, nil, nil, nil, nil);
+
+ nstr = strlen(str);
+ bsize = nstr * 1.25;
+ buf = emalloc(nbuf);
+ pos = buf;
+ nbuf = bsize-1;
+ while(iconv(cd, &str, &nstr, &pos, &nbuf) == -1)
+ if(errno == E2BIG) {
+ bsize *= 1.25;
+ nbuf = pos - buf;
+ buf = erealloc(buf, bsize);
+ pos = buf + nbuf;
+ nbuf = bsize - nbuf - 1;
+ }else
+ break;
+ *pos = '\0';
+ return buf;
+}
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/utf.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/wmii/utf.h Wed Apr 18 15:08:15 2007 -0400
@@ -0,0 +1,9 @@
+typedef ushort Rune; /* 16 bits */
+
+enum
+{
+ UTFmax = 3, /* maximum bytes per rune */
+ Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
+ Runeself = 0x80, /* rune and UTF sequences are the same (<) */
+ Runeerror = 0xFFFD, /* decoding error in UTF */
+};
diff -r b3e7bd11d96d -r dffebf3309c8 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Tue Apr 17 21:34:36 2007 -0400
+++ b/cmd/wmii/x11.c Wed Apr 18 15:08:15 2007 -0400
@@ -376,8 +376,9 @@ drawstring(Image *dst, Font *font,
                 w = textwidth_l(font, buf, len + min(shortened, 3));
                 if(w <= Dx(r) - (font->height & ~1))
                         break;
-
- buf[--len] = '.';
+ while(len > 0 && (buf[--len]&0xC0) == 0x80)
+ buf[len] = '.';
+ buf[len] = '.';
                 shortened++;
         }
 
@@ -399,7 +400,7 @@ drawstring(Image *dst, Font *font,
 
         XSetForeground(display, dst->gc, col);
         if(font->set)
- XmbDrawString(display, dst->image,
+ Xutf8DrawString(display, dst->image,
                                 font->set, dst->gc,
                                 x, y,
                                 buf, len);
@@ -506,7 +507,7 @@ textwidth_l(Font *font, char *text, uint
         XRectangle r;
 
         if(font->set) {
- XmbTextExtents(font->set, text, len, &r, nil);
+ Xutf8TextExtents(font->set, text, len, &r, nil);
                 return r.width;
         }
         return XTextWidth(font->xfont, text, len);
diff -r b3e7bd11d96d -r dffebf3309c8 config.mk
--- a/config.mk Tue Apr 17 21:34:36 2007 -0400
+++ b/config.mk Wed Apr 18 15:08:15 2007 -0400
@@ -9,7 +9,7 @@ INCLUDE = ${PREFIX}/include
 INCLUDE = ${PREFIX}/include
 
 # Includes and libs
-INCS = -I. -I${ROOT}/include -I${INCLUDE} -I/usr/include
+INCS = -I. -I${ROOT}/include -I${INCLUDE} -I/usr/include -I/usr/local/include
 LIBS = -L/usr/lib -lc
 
 # Flags
Received on Fri Jun 01 2007 - 03:09:28 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:57 UTC