To: vim-dev@vim.org Subject: Patch 6.2.343 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.343 Problem: Title doesn't work with some window managers. X11: Setting the text property for the window title is hard coded. Solution: Use STRING format when possible. Use the UTF-8 function when it's available and 'encoding' is utf-8. Use XStringListToTextProperty(). Do the same for the icon name. (David Harrison) Files: src/os_unix.c *** ../vim-6.2.342/src/os_unix.c Fri Mar 5 15:21:09 2004 --- src/os_unix.c Thu Mar 11 20:54:54 2004 *************** *** 1607,1612 **** --- 1607,1619 ---- return retval; } + /* Are Xutf8 functions available? Avoid error from old compilers. */ + #if defined(X_HAVE_UTF8_STRING) && defined(FEAT_MBYTE) + # if X_HAVE_UTF8_STRING + # define USE_UTF8_STRING + # endif + #endif + /* * Set x11 Window Title * *************** *** 1616,1646 **** set_x11_title(title) char_u *title; { #if XtSpecificationRelease >= 4 - XTextProperty text_prop; # ifdef FEAT_XFONTSET ! Status status; ! status = XmbTextListToTextProperty(x11_display, (char **)&title, 1, ! XCompoundTextStyle, &text_prop); ! /* Status is a positive number when some chars could not be converted. ! * Accept that, we don't know what to do otherwise. */ ! if (status < Success) ! # endif ! { ! text_prop.value = title; ! text_prop.nitems = STRLEN(title); ! text_prop.encoding = XA_STRING; ! text_prop.format = 8; ! } ! XSetWMName(x11_display, x11_window, &text_prop); ! # ifdef FEAT_XFONTSET ! if (status >= Success) ! XFree((void *)text_prop.value); # endif #else ! XStoreName(x11_display, x11_window, (char *)title); #endif XFlush(x11_display); } --- 1623,1655 ---- set_x11_title(title) char_u *title; { + /* XmbSetWMProperties() and Xutf8SetWMProperties() should use a STRING + * when possible, COMPOUND_TEXT otherwise. COMPOUND_TEXT isn't + * supported everywhere and STRING doesn't work for multi-byte titles. + */ + #ifdef USE_UTF8_STRING + if (enc_utf8) + Xutf8SetWMProperties(x11_display, x11_window, (const char *)title, + NULL, NULL, 0, NULL, NULL, NULL); + else + #endif + { #if XtSpecificationRelease >= 4 # ifdef FEAT_XFONTSET ! XmbSetWMProperties(x11_display, x11_window, (const char *)title, ! NULL, NULL, 0, NULL, NULL, NULL); ! # else ! XTextProperty text_prop; ! /* directly from example 3-18 "basicwin" of Xlib Programming Manual */ ! (void)XStringListToTextProperty((char **)&title, 1, &text_prop); ! XSetWMProperties(x11_display, x11_window, &text_prop, ! NULL, NULL, 0, NULL, NULL, NULL); # endif #else ! XStoreName(x11_display, x11_window, (char *)title); #endif + } XFlush(x11_display); } *************** *** 1653,1683 **** set_x11_icon(icon) char_u *icon; { #if XtSpecificationRelease >= 4 - XTextProperty text_prop; # ifdef FEAT_XFONTSET ! Status status; ! status = XmbTextListToTextProperty(x11_display, (char **)&icon, 1, ! XCompoundTextStyle, &text_prop); ! /* Status is a positive number when some chars could not be converted. ! * Accept that, we don't know what to do otherwise. */ ! if (status < Success) ! # endif ! { ! text_prop.value = icon; ! text_prop.nitems = STRLEN(icon); ! text_prop.encoding = XA_STRING; ! text_prop.format = 8; ! } ! XSetWMIconName(x11_display, x11_window, &text_prop); ! # ifdef FEAT_XFONTSET ! if (status >= Success) ! XFree((void *)text_prop.value); # endif #else ! XSetIconName(x11_display, x11_window, (char *)icon); #endif XFlush(x11_display); } --- 1662,1690 ---- set_x11_icon(icon) char_u *icon; { + /* See above for comments about using X*SetWMProperties(). */ + #ifdef USE_UTF8_STRING + if (enc_utf8) + Xutf8SetWMProperties(x11_display, x11_window, NULL, (const char *)icon, + NULL, 0, NULL, NULL, NULL); + else + #endif + { #if XtSpecificationRelease >= 4 # ifdef FEAT_XFONTSET ! XmbSetWMProperties(x11_display, x11_window, NULL, (const char *)icon, ! NULL, 0, NULL, NULL, NULL); ! # else ! XTextProperty text_prop; ! (void)XStringListToTextProperty((char **)&icon, 1, &text_prop); ! XSetWMProperties(x11_display, x11_window, NULL, &text_prop, ! NULL, 0, NULL, NULL, NULL); # endif #else ! XSetIconName(x11_display, x11_window, (char *)icon); #endif + } XFlush(x11_display); } *** ../vim-6.2.342/src/version.c Thu Mar 11 20:49:02 2004 --- src/version.c Thu Mar 11 20:50:31 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 343, /**/ -- hundred-and-one symptoms of being an internet addict: 6. You refuse to go to a vacation spot with no electricity and no phone lines. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///