Subject: I18N_MB patch follow-ups: a bug in FvwmPager...

From: Makoto MATSUSHITA (まつしたまこと) <[email-masked]>
Date: Thu, 03 Jun 1999 03:10:16 +0900

This is just a follow-up of my previous patch of I18N_MB for
fvwm-2.2. I've received a report of that the patch does not draw a
string in FvwmPager.

If you have already used the patch, please backout the changes of
fvwm-2.2/modules/FvwmPager/x_pager.c (or copy from original fvwm-2.2), 
then apply a patch attached below.

Sorry for inconvenience.

***

Yes I know, there are many problems in this implementation of multibyte
support. But in any way, I do NOT want to use fvwm without this patch;
a window manager with no support of multibyte is, just a scrap for me:)

We should know other major window managers are already have its own
code for multibyte support. I'm afraid the our greatest window manager,
named 'fvwm', becomes an old-fashioned window manager (already?).

-- -
Makoto `MAR' MATSUSHITA

--- x_pager.c.orig	Fri Jan 29 01:24:48 1999
+++ x_pager.c	Wed Jun  2 16:10:44 1999
@@ -38,6 +38,14 @@
 
 extern int icon_w, icon_h, icon_x, icon_y;
 XFontStruct *font, *windowFont;
+#ifdef I18N_MB
+XFontSet fontset, windowFontset;
+#ifdef __STDC__
+#define XTextWidth(x,y,z) XmbTextEscapement(x ## set,y,z)
+#else
+#define XTextWidth(x,y,z) XmbTextEscapement(x/**/set,y,z)
+#endif
+#endif
 
 GC NormalGC,DashedGC,HiliteGC,rvGC;
 GC StdGC;
@@ -106,6 +114,12 @@
 {
   XWMHints wmhints;
   XClassHint class1;
+#ifdef I18N_MB
+  char **ml;
+  int mc;
+  char *ds;
+  XFontStruct **fs_list;
+#endif
 
   XTextProperty name;
   unsigned long valuemask;
@@ -128,6 +142,22 @@
   wm_del_win = XInternAtom(dpy,"WM_DELETE_WINDOW",False);
 
   /* load the font */
+#ifdef I18N_MB
+  if (!uselabel || ((fontset = XCreateFontSet(dpy, font_string, &ml, &mc, &ds)) == NULL))
+    {
+#ifdef STRICTLY_FIXED
+      if ((fontset = XCreateFontSet(dpy, "fixed", &ml, &mc, &ds)) == NULL)
+#else
+      if ((fontset = XCreateFontSet(dpy, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*", &ml, &mc, &ds)) == NULL)
+#endif
+      {
+	fprintf(stderr,"%s: No fonts available\n",MyName);
+	exit(1);
+      }
+    }
+  XFontsOfFontSet(fontset, &fs_list, &ml);
+  font = fs_list[0];
+#else
   if (!uselabel || ((font = XLoadQueryFont(dpy, font_string)) == NULL))
     {
       if ((font = XLoadQueryFont(dpy, "fixed")) == NULL)
@@ -136,18 +166,38 @@
 	  exit(1);
 	}
     };
+#endif
   if(uselabel)
     label_h = font->ascent + font->descent+2;
   else
     label_h = 0;
 
-
+#ifdef I18N_MB
+  if(smallFont != NULL)
+    {
+      windowFontset = XCreateFontSet(dpy, smallFont, &ml, &mc, &ds);
+      if (windowFontset != NULL)
+      {
+        XFontsOfFontSet(windowFontset, &fs_list, &ml);
+        windowFont = fs_list[0];
+      } else {
+        windowFontset = NULL;
+        windowFont = NULL;
+      }
+    }
+  else
+    {
+      windowFontset = NULL;
+      windowFont = NULL;
+    }
+#else
   if(smallFont!= NULL)
     {
       windowFont= XLoadQueryFont(dpy, smallFont);
     }
   else
     windowFont= NULL;
+#endif
 
   /* Load the colors */
   fore_pix = GetColor(PagerFore);
@@ -273,10 +323,17 @@
   XSetWMProtocols(dpy,Scr.Pager_w,&wm_del_win,1);
   XSetWMNormalHints(dpy,Scr.Pager_w,&sizehints);
 
+#ifdef I18N_MB
+  if((desk1==desk2)&&(Desks[0].label != NULL))
+    XmbTextListToTextProperty(dpy,&Desks[0].label,1,XStdICCTextStyle,&name);
+  else
+    XmbTextListToTextProperty(dpy,&pager_name,1,XStdICCTextStyle,&name);
+#else
   if((desk1==desk2)&&(Desks[0].label != NULL))
     XStringListToTextProperty(&Desks[0].label,1,&name);
   else
     XStringListToTextProperty(&pager_name,1,&name);
+#endif
 
   attributes.event_mask = (StructureNotifyMask| ExposureMask);
   if(icon_w < 1)
@@ -437,6 +494,23 @@
       (BalloonBack == NULL) ? 0 : GetColor(BalloonBack);
 
     /* get font for balloon */
+#ifdef I18N_MB
+    if ( (balloon.fontset = XCreateFontSet(dpy, BalloonFont, &ml, &mc, &ds)) == NULL ) {
+#ifdef STRICTLY_FIXED
+      if ( (balloon.fontset = XCreateFontSet(dpy, "fixed", &ml, &mc, &ds)) == NULL )
+#else
+      if ( (balloon.fontset = XCreateFontSet(dpy, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*", &ml, &mc, &ds)) == NULL )
+#endif
+      {
+        fprintf(stderr,"%s: No fonts available.\n", MyName);
+        exit(1);
+      }
+      fprintf(stderr, "%s: Can't find font '%s', using fixed.\n",
+              MyName, BalloonFont);
+    }
+    XFontsOfFontSet(balloon.fontset, &fs_list, &ml);
+    balloon.font = fs_list[0];
+#else
     if ( (balloon.font = XLoadQueryFont(dpy, BalloonFont)) == NULL ) {
       if ( (balloon.font = XLoadQueryFont(dpy, "fixed")) == NULL ) {
         fprintf(stderr,"%s: No fonts available.\n", MyName);
@@ -445,6 +519,7 @@
       fprintf(stderr, "%s: Can't find font '%s', using fixed.\n",
               MyName, BalloonFont);
     }
+#endif
 
     balloon.height = balloon.font->ascent + balloon.font->descent + 1;
 
@@ -764,6 +839,9 @@
 {
   int n1,m1,x,y,n,m,i;
   XTextProperty name;
+#ifdef I18N_MB
+  int ret;
+#endif
   char str[100],*sptr;
   static int icon_desk_shown = -1000;
 
@@ -800,11 +878,22 @@
 	  sprintf(str,"Desk %d",Scr.CurrentDesk);
 	  sptr = &str[0];
 	}
+#ifdef I18N_MB
+      if ((ret = XmbTextListToTextProperty(dpy,&sptr,1,XStdICCTextStyle,&name))
+        == XNoMemory)
+      {
+        fprintf(stderr,"%s: cannot allocate window name",MyName);
+        return;
+      }
+      else if (ret != Success)
+        return;
+#else
       if (XStringListToTextProperty(&sptr,1,&name) == 0)
 	{
 	  fprintf(stderr,"%s: cannot allocate window name",MyName);
 	  return;
 	}
+#endif
       XSetWMIconName(dpy,Scr.Pager_w,&name);
     }
 }
@@ -918,10 +1007,18 @@
     {
       hor_off = (desk_w -w)/2;
       if(i == (Scr.CurrentDesk - desk1))
+#ifdef I18N_MB
+	XmbDrawString (dpy, Desks[i].title_w, fontset, rvGC,hor_off,font->ascent +1 ,
+#else
 	XDrawString (dpy, Desks[i].title_w,rvGC,hor_off,font->ascent +1 ,
+#endif
 		     ptr, strlen(ptr));
       else
+#ifdef I18N_MB
+	XmbDrawString (dpy, Desks[i].title_w,fontset, NormalGC,hor_off,font->ascent+1  ,
+#else
 	XDrawString (dpy, Desks[i].title_w,NormalGC,hor_off,font->ascent+1  ,
+#endif
 		     ptr, strlen(ptr));
     }
 }
@@ -1650,7 +1747,11 @@
   if(t->PagerView != None)
     {
       XClearWindow(dpy, t->PagerView);
+#ifdef I18N_MB
+      XmbDrawString (dpy, t->PagerView, windowFontset, StdGC,2,windowFont->ascent+2 ,
+#else
       XDrawString (dpy, t->PagerView,StdGC,2,windowFont->ascent+2 ,
+#endif
 			t->icon_name, strlen(t->icon_name));
     }
 }
@@ -1690,7 +1791,11 @@
 
     }
   XClearWindow(dpy, t->IconView);
+#ifdef I18N_MB
+  XmbDrawString (dpy, t->IconView, windowFontset, StdGC,2,windowFont->ascent+2 ,
+#else
   XDrawString (dpy, t->IconView,StdGC,2,windowFont->ascent+2 ,
+#endif
 	       t->icon_name, strlen(t->icon_name));
 
 }
@@ -2038,7 +2143,11 @@
   if ( BalloonFore == NULL )
     XSetForeground(dpy, BalloonGC, balloon.pw->text);
 
+#ifdef I18N_MB
+  XmbDrawString(dpy, balloon.w, balloon.fontset, BalloonGC,
+#else
   XDrawString(dpy, balloon.w, BalloonGC,
+#endif
               2, balloon.font->ascent,
               balloon.pw->icon_name, strlen(balloon.pw->icon_name));
 }

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]