mirror of
https://github.com/0intro/wmii
synced 2025-02-12 12:24:49 +03:00
improved UTF8-usage due to X_HAVE_UTF8_STRING checks
This commit is contained in:
parent
f754b18164
commit
c8a5beaf86
@ -26,14 +26,21 @@ update_client_name(Client *c)
|
||||
|
||||
name.nitems = 0;
|
||||
c->name[0] = 0;
|
||||
XGetWMName(dpy, c->win, &name);
|
||||
XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
|
||||
if(!name.nitems)
|
||||
XGetWMName(dpy, c->win, &name);
|
||||
if(!name.nitems)
|
||||
return;
|
||||
if(name.encoding == XA_STRING)
|
||||
cext_strlcpy(c->name, (char *)name.value, sizeof(c->name));
|
||||
else {
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
if(Xutf8TextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
#else
|
||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
#endif
|
||||
{
|
||||
cext_strlcpy(c->name, *list, sizeof(c->name));
|
||||
XFreeStringList(list);
|
||||
@ -243,7 +250,7 @@ prop_client(Client *c, XPropertyEvent *e)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(e->atom == XA_WM_NAME) {
|
||||
if(e->atom == XA_WM_NAME || e->atom == net_atom[NetWMName]) {
|
||||
update_client_name(c);
|
||||
if(c->frame.size)
|
||||
draw_client(c);
|
||||
|
@ -121,6 +121,11 @@ init_atoms()
|
||||
wm_atom[WMState] = XInternAtom(dpy, "WM_STATE", False);
|
||||
wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||
wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
|
||||
net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
|
||||
XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *) net_atom, NetLast);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -18,6 +18,13 @@ enum {
|
||||
WMLast
|
||||
};
|
||||
|
||||
/* NET atoms */
|
||||
enum {
|
||||
NetSupported,
|
||||
NetWMName,
|
||||
NetLast
|
||||
};
|
||||
|
||||
/* Column modes */
|
||||
enum {
|
||||
Coldefault,
|
||||
@ -184,6 +191,7 @@ XRectangle brect;
|
||||
Qid root_qid;
|
||||
Default def;
|
||||
Atom wm_atom[WMLast];
|
||||
Atom net_atom[NetLast];
|
||||
Cursor cursor[CurLast];
|
||||
unsigned int valid_mask;
|
||||
unsigned int num_lock_mask;
|
||||
|
@ -110,7 +110,11 @@ xdrawtext(Display *dpy, BlitzDraw *d)
|
||||
break;
|
||||
}
|
||||
if(d->font.set)
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
Xutf8DrawString(dpy, d->drawable, d->font.set, d->gc, x, y, text, len);
|
||||
#else
|
||||
XmbDrawString(dpy, d->drawable, d->font.set, d->gc, x, y, text, len);
|
||||
#endif
|
||||
else
|
||||
XDrawString(dpy, d->drawable, d->gc, x, y, text, len);
|
||||
}
|
||||
|
@ -16,7 +16,11 @@ blitz_textwidth(Display *dpy, BlitzFont *font, char *text)
|
||||
{
|
||||
if(font->set) {
|
||||
XRectangle r;
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
Xutf8TextExtents(font->set, text, strlen(text), nil, &r);
|
||||
#else
|
||||
XmbTextExtents(font->set, text, strlen(text), nil, &r);
|
||||
#endif
|
||||
return r.width;
|
||||
}
|
||||
return XTextWidth(font->xfont, text, strlen(text));
|
||||
|
Loading…
x
Reference in New Issue
Block a user