diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2010-05-22 22:10:32 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2010-05-22 22:10:32 +0000 |
commit | 4f9f6cd563eaa13aa47e047162e1c5992ec6fc36 (patch) | |
tree | d77387b016fb11f551831babf5c6c09adb7721e9 /app | |
parent | 563a5814563244f5270cb0754b99c2e8999fb002 (diff) |
replace XFetchName() with something more intelligent which attempts to
use the appropriate netwm Atom first, as well as deal with utf8.
slightly different incarnation tested by sthen@ and ajacoutot@ - thanks!
ok oga@
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/calmwm.h | 4 | ||||
-rw-r--r-- | app/cwm/client.c | 9 | ||||
-rw-r--r-- | app/cwm/xutil.c | 34 |
3 files changed, 40 insertions, 7 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index f990208a6..45bf772e2 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.117 2010/04/11 16:51:26 okan Exp $ + * $Id: calmwm.h,v 1.118 2010/05/22 22:10:31 okan Exp $ */ #ifndef _CALMWM_H_ @@ -401,7 +401,7 @@ void xu_key_grab(Window, int, int); void xu_key_ungrab(Window, int, int); void xu_sendmsg(Window, Atom, long); int xu_getprop(Window, Atom, Atom, long, u_char **); -char *xu_getstrprop(struct client_ctx *, Atom atm); +int xu_getstrprop(Window, Atom, char **); void xu_setstate(struct client_ctx *, int); int xu_getstate(struct client_ctx *, int *); unsigned long xu_getcolor(struct screen_ctx *, char *); diff --git a/app/cwm/client.c b/app/cwm/client.c index a7beb2eb2..dd2860830 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.75 2010/04/11 16:51:26 okan Exp $ + * $Id: client.c,v 1.76 2010/05/22 22:10:31 okan Exp $ */ #include <sys/param.h> @@ -183,7 +183,7 @@ client_delete(struct client_ctx *cc) while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) { TAILQ_REMOVE(&cc->nameq, wn, entry); if (wn->name != emptystring) - XFree(wn->name); + xfree(wn->name); xfree(wn); } @@ -523,7 +523,8 @@ client_setname(struct client_ctx *cc) struct winname *wn; char *newname; - XFetchName(X_Dpy, cc->win, &newname); + if (!xu_getstrprop(cc->win, _NET_WM_NAME, &newname)) + xu_getstrprop(cc->win, XA_WM_NAME, &newname); if (newname == NULL) newname = emptystring; @@ -549,7 +550,7 @@ match: assert(wn != NULL); TAILQ_REMOVE(&cc->nameq, wn, entry); if (wn->name != emptystring) - XFree(wn->name); + xfree(wn->name); xfree(wn); cc->nameqlen--; } diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c index 8164370f7..2b482f5e6 100644 --- a/app/cwm/xutil.c +++ b/app/cwm/xutil.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xutil.c,v 1.30 2010/04/11 16:51:26 okan Exp $ + * $Id: xutil.c,v 1.31 2010/05/22 22:10:31 okan Exp $ */ #include <sys/param.h> @@ -152,6 +152,38 @@ xu_getprop(Window win, Atom atm, Atom type, long len, u_char **p) } int +xu_getstrprop(Window win, Atom atm, char **text) { + XTextProperty prop; + char **list; + int nitems; + + *text = NULL; + + XGetTextProperty(X_Dpy, win, &prop, atm); + if (!prop.nitems) + return (0); + + if (Xutf8TextPropertyToTextList(X_Dpy, &prop, &list, + &nitems) == Success && nitems > 0 && *list) { + if (nitems > 1) { + XTextProperty prop2; + if (Xutf8TextListToTextProperty(X_Dpy, list, nitems, + XUTF8StringStyle, &prop2) == Success) { + *text = xstrdup(prop2.value); + XFree(prop2.value); + } + } else { + *text = xstrdup(*list); + } + XFreeStringList(list); + } + + XFree(prop.value); + + return (nitems); +} + +int xu_getstate(struct client_ctx *cc, int *state) { long *p = NULL; |