Hello, I always use fspanel, it's very nice. GNOME is too heavy for my cheap machine, but sawfish with fspanel provides very comfortable environment for me. Thanks. But It can't handle Japanese fonts, so that when I read Japanese page on Mozilla, iconified page title is disappeared on fspanel. So, I wrote I18N patch for fspanel-0.7. If you are interested in I18N, I'm very happy :). Regards, -- Masanori Kobayasi --- fspanel.c.orig Sun Jun 17 22:27:04 2001 +++ fspanel.c Sun Jun 17 22:27:34 2001 @@ -5,6 +5,7 @@ ** See file COPYING for license details. ** ********************************************************/ +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #ifdef HAVE_XPM #include @@ -29,7 +31,7 @@ #define ICONHEIGHT 16 #define WINHEIGHT 24 #define WINWIDTH (scr_width) -#define FONT_NAME "-*-lucida*-m*-r-*-*-12-*-*" +#define FONT_NAME "-*-fixed-m*-r-normal-*-12-*-*" /* don't edit these */ #define TEXTPAD 6 @@ -42,6 +44,7 @@ Pixmap generic_mask; GC fore_gc; XFontStruct *xfs; +Bool use_fontset; int scr_screen; int scr_depth; int scr_width; @@ -49,6 +52,13 @@ int text_y; /*int time_width;*/ +typedef struct { + XFontSet fset; + int ascent, descent; +} QuasiXFontStruct; + +QuasiXFontStruct *qxfs; + unsigned short cols[] = { 0xd75c, 0xd75c, 0xd75c, /* 0. light gray */ 0xbefb, 0xbaea, 0xbefb, /* 1. mid gray */ @@ -111,6 +121,32 @@ return prop_data; } +char * +get_icon_name (Window win) +{ + XTextProperty text_prop; + int status; + char *iconname; + + status = XGetWMIconName (dd, win, &text_prop); + if (!status || !text_prop.value || !text_prop.nitems) return NULL; + if (text_prop.encoding == XA_STRING) { + if (!text_prop.value) return NULL; + iconname = (char *)strdup (text_prop.value); + XFree (text_prop.value); + return iconname; + } else { + char **list; + int num; + XmbTextPropertyToTextList (dd, &text_prop, &list, &num); + if (!num || !*list) return NULL; + XFree (text_prop.value); + iconname = (char *)strdup (*list); + XFreeStringList (list); + return iconname; + } +} + void set_foreground (int index) { @@ -281,7 +317,7 @@ tk = calloc (1, sizeof (task)); tk->win = win; tk->focused = focus; - tk->name = get_prop_data (win, XA_WM_NAME, XA_STRING, 0); + tk->name = get_icon_name (win); tk->iconified = is_iconified (win); get_task_kdeicon (tk); @@ -415,20 +451,50 @@ while (j < PALETTE_COUNT); fontname = FONT_NAME; - do - { - xfs = XLoadQueryFont (dd, fontname); - fontname = "fixed"; + if (use_fontset) { + char **missing_charset_list_return; + int missing_charset_count_return; + char *def_string_return; + + char *basename2; + basename2 = (char *)malloc(strlen(fontname) + 3); + if (basename2) sprintf(basename2, "%s,*", fontname); + else basename2 = fontname; + + qxfs = (QuasiXFontStruct *)malloc(sizeof(QuasiXFontStruct)); + do + { + qxfs->fset = XCreateFontSet (dd, basename2, &missing_charset_list_return, + &missing_charset_count_return, + &def_string_return); + fontname = "fixed"; + } + while (!qxfs->fset); + qxfs->ascent =-XExtentsOfFontSet(qxfs->fset)->max_logical_extent.y; + qxfs->descent = XExtentsOfFontSet(qxfs->fset)->max_logical_extent.height + +XExtentsOfFontSet(qxfs->fset)->max_logical_extent.y; + } else { + do + { + xfs = XLoadQueryFont (dd, fontname); + fontname = "fixed"; + } + while (!xfs); } - while (!xfs); - /*time_width = XTextWidth (xfs, "88:88", 5); */ #define time_width (35) - text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2); + if (use_fontset) + text_y = qxfs->ascent + ((WINHEIGHT - qxfs->ascent) / 2); + else + text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2); - gcv.font = xfs->fid; gcv.graphics_exposures = False; - fore_gc = XCreateGC (dd, root_win, GCFont | GCGraphicsExposures, &gcv); + if (use_fontset) + fore_gc = XCreateGC (dd, root_win, GCGraphicsExposures, &gcv); + else { + gcv.font = xfs->fid; + fore_gc = XCreateGC (dd, root_win, GCFont | GCGraphicsExposures, &gcv); + } #ifdef HAVE_XPM XpmCreatePixmapFromData (dd, root_win, icon_xpm, &generic_icon, @@ -489,16 +555,24 @@ /* check how many chars can fit */ len = strlen (tk->name); - while (XTextWidth (xfs, tk->name, len) >= taskw - (text_x - x) - 2 - && len > 0) - len--; + if (use_fontset) { + while (XmbTextEscapement (qxfs->fset, tk->name, len) >= taskw - (text_x - x) - 2 + && len > 0) + len--; + } else { + while (XTextWidth (xfs, tk->name, len) >= taskw - (text_x - x) - 2 + && len > 0) + len--; + } if (tk->iconified) { /* draw task's name dark (iconified) */ set_foreground (3); - XDrawString (dd, tb->win, fore_gc, text_x, text_y + 1, tk->name, - len); + if (use_fontset) + XmbDrawString (dd, tb->win, qxfs->fset, fore_gc, text_x, text_y + 1, tk->name, len); + else + XDrawString (dd, tb->win, fore_gc, text_x, text_y + 1, tk->name, len); set_foreground (4); } else { @@ -506,7 +580,10 @@ } /* draw task's name here */ - XDrawString (dd, tb->win, fore_gc, text_x, text_y, tk->name, len); + if (use_fontset) + XmbDrawString (dd, tb->win, qxfs->fset, fore_gc, text_x, text_y, tk->name, len); + else + XDrawString (dd, tb->win, fore_gc, text_x, text_y, tk->name, len); } #ifndef HAVE_XPM @@ -553,8 +630,12 @@ draw_line (tb, x, 2, x, WINHEIGHT - 2); set_foreground (5); - XDrawString (dd, tb->win, fore_gc, x + TEXTPAD - 1, text_y, - time_str, 5); + if (use_fontset) + XmbDrawString (dd, tb->win, qxfs->fset, fore_gc, x + TEXTPAD - 1, text_y, + time_str, 5); + else + XDrawString (dd, tb->win, fore_gc, x + TEXTPAD - 1, text_y, + time_str, 5); } void @@ -919,7 +1000,7 @@ /* window's title changed */ if (tk->name) XFree (tk->name); - tk->name = get_prop_data (tk->win, XA_WM_NAME, XA_STRING, 0); + tk->name = get_icon_name (tk->win); gui_draw_task (tb, tk); } else if (at == atom_WM_STATE) { @@ -959,6 +1040,15 @@ int xfd; time_t now; struct tm *lt; + char *loc; + + loc = setlocale(LC_ALL, ""); + if (!loc || !strcmp(loc, "C") || !strcmp(loc, "POSIX") || + !XSupportsLocale()) { + use_fontset = False; + } else { + use_fontset = True; + } dd = XOpenDisplay (NULL); if (!dd)