My window manager lacks support for _NET_WM_NAME and _NET_WM_ICON_NAME, as do several others. As such, rxvt-unicode titles which include non- atin-1 characters are incorrectly rendered.
This patch allows rxvt-unicode to set the WM_NAME and WM_ICON_NAME properties as COMPOUND_TEXT whenever the strings cannot be encoded in ISO-8859-1 (the encoding which Xlib presumes all STRINGs are). It uses XwcTextListToTextProperty(3) with XStdICCTextStyle, which tells Xlib to use COMPOUND_TEXT unless STRING would work. This is the same logic used by most apps, some via Xlib and some self coded. I gave rxvt_term::set_compound_text_property() the same prototype as rxvt_term::set_string_property() and rxvt_term::set_utf8_property(); doing so requires casting the address of the (const char *)str to a (char **), which changing the prototype to make str non-const would obviously avoid. I can change that if that is preferred. I've tested with a number of LANG settings, both for urxvt and for the interior shell. Only one combination causes problems, but it is no worse than the status quo. If the shell is set to have urxvt use the $CWD in WM_NAME, and you visit a directory which was created using a different encoding than the shell's the shell can send bogus data to urxvt. As long as urxvt gets valid data, though, it it is properly passed on to the window manager, even if the wm's LANG differs from urxvt's.
commit 35ebc0726cfa69e788fb5c6f4d67eb0f1f5d0792 Author: James Cloos <[email protected]> Date: Sat Jul 17 16:43:23 2010 -0400 Permit WM_NAME and WM_ICON_NAME to be COMPOUND_TEXT Add a method to set a property as COMPOUND_TEXT, falling back to STRING if the text fits in ISO-8859-1. Use that method to set the WM_NAME and WM_ICON_NAME properties. Signed-off-by: James Cloos <[email protected]> diff --git a/src/main.C b/src/main.C index 88bd0e5..6f6f8ba 100644 --- a/src/main.C +++ b/src/main.C @@ -749,6 +749,20 @@ rxvt_term::set_string_property (Atom prop, const char *str, int len) (const unsigned char *)str, len >= 0 ? len : strlen (str)); } +/* If the value can be expressed as STRING, it is set as such. */ +/* Otherwise it is set as COMPOUND_TEXT */ +void +rxvt_term::set_compound_text_property (Atom prop, const char *str, int len) +{ + XTextProperty ct; + + XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct); + + XSetTextProperty (dpy, parent[0], &ct, prop); + + XFree (ct.value); +} + void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) { @@ -769,7 +783,7 @@ rxvt_term::set_utf8_property (Atom prop, const char *str, int len) void rxvt_term::set_title (const char *str) { - set_string_property (XA_WM_NAME, str); + set_compound_text_property (XA_WM_NAME, str); #if ENABLE_EWMH set_utf8_property (xa[XA_NET_WM_NAME], str); #endif @@ -778,7 +792,7 @@ rxvt_term::set_title (const char *str) void rxvt_term::set_icon_name (const char *str) { - set_string_property (XA_WM_ICON_NAME, str); + set_compound_text_property (XA_WM_ICON_NAME, str); #if ENABLE_EWMH set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); #endif diff --git a/src/rxvt.h b/src/rxvt.h index 95a4f00..7c8bfe5 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1287,6 +1287,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen void window_calc (unsigned int newwidth, unsigned int newheight); bool set_fonts (); void set_string_property (Atom prop, const char *str, int len = -1); + void set_compound_text_property (Atom prop, const char *str, int len = -1); void set_utf8_property (Atom prop, const char *str, int len = -1); void set_title (const char *str); void set_icon_name (const char *str);
-JimC -- James Cloos <[email protected]> OpenPGP: 1024D/ED7DAEA6
_______________________________________________ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
