Subject: bug fixes to FvwmWinList: PATCH

From: Austin Donnelly <[email-masked]>
Date: Mon, 4 May 1998 22:26:31 +0100 (BST)

Do we have a current maintainer for FvwmWinList?

I've cleaned up the handler for M_FOCUS_CHANGE, re-instating support
for the

*FvwmWinListFocusFore <color>
*FvwmWinListFocusBack <color>

options.  Currently, they don't work at all in 2.0.46.

There were some useful old comments lying around.  From them, I
believe that this code was replaced by some from the TaskBar -
however, the TaskBar code doesn't quite handle focus changes correctly
(according to the old code).

The old (commented-out) code was also quite convoluted, but it was
enough for me to get the idea of things, and re-implement the focus
stuff properly.  That's lead to a (IMHO) cleaner handler for
M_FOCUS_CHANGE. I think it's now clearer to read, understand and
modify in future.

While looking at the code, I also got the title centering stuff
working again; I believe it broke when MiniIcon support went in.

This means the *FvwmWinListLeftJustify option is now of use again,
since FvwmWinList now defaults to centered titles (as it was always
claimed in the manpage).  Note there's no matching
*FvwmWinListCenterJustify option - so once you've picked LeftJustify,
there's no way of overriding it.

My fix to the centering stuff makes lines with a MiniIcon left
justified, so the CenterJustify/LeftJustify stuff only actually
affects lines that don't have an icon associated.  The reason I've not
changed the behaviour for icon lines is that its not clear what people
want in the case of icon lines with CenterJustify - should the icon
stay flush left, or should it float with the title?

Anyway, I've appended the patch below.  It includes an update to the
manpage fixing one obvious cut-n-paste-o, and documents the
LeftJustify option wrt MiniIcons.

Austin
------------------------------------------------------------
--- ButtonArray.c-old	Mon May  4 21:03:32 1998
+++ ButtonArray.c	Mon May  4 21:27:44 1998
@@ -318,6 +318,7 @@
 
   newx = 2;
 
+  /* buttons with MiniIcons are always LeftJustify'ed */
   if ((button->p.picture != 0)/* &&
       (w + button->p.width + w3p + 3 > MIN_BUTTON_SIZE)*/) {
 
@@ -334,19 +335,18 @@
     XChangeGC(dpy, hilite[set], gcm, &gcv);
 
     newx += button->p.width+4;
-    }
-	else
-	{
-		newx = 4;
-	}
+  }
+  else
+  {
+    /* no MiniIcon, so left justify or center the text as required */
+    if (LeftJustify)
+      newx = 4;
+    else
+      newx = max((w-button->tw)/2, 4);
+  }
 
   string=button->title;
-  if (LeftJustify) {
-/* newx set by pixmap    newx=4;
-*/
-  } else {
-/* set by pixmap    newx=max((w-button->tw)/2,4);
-*/
+  if (!LeftJustify) {
     if (TruncateLeft && (w-button->tw)/2 < 4) {
       if (button->truncatewidth == w)
 	string=button->truncate_title;
--- FvwmWinList.c-old	Mon May  4 21:19:46 1998
+++ FvwmWinList.c	Mon May  4 21:47:53 1998
@@ -363,34 +363,33 @@
         if (UpdateButtonSet(&buttons,i,(flags&ICONIFIED) ? 1 : 0)!=-1) redraw=1;
       free(name);
       break;
-    case M_FOCUS_CHANGE:
-
-/* old coded, before Task bar code spliced in
-
-      i=FindItem(&windows,body[0]);
-      if (i==current_focus) break;
-      if (current_focus!=-1)
-	if ((ItemFlags(&windows,ItemID(&windows,current_focus))&ICONIFIED)==0)
-	  if (UpdateButtonSet(&buttons,current_focus,0)!=-1) redraw=1;
-      current_focus=-1;
-      if (i!=-1&&(ItemFlags(&windows,body[0])&ICONIFIED)) break;
-      current_focus=i;
-      if (current_focus!=-1)
-	if (UpdateButtonSet(&buttons,current_focus,2)!=-1) redraw=1;
-* end of old code */
-
-/* Code copied Straight from TaskBar */
-
-    if ((i=FindItem(&windows,body[0]))!=-1)
-    {
-	    flags=ItemFlags(&windows,body[0]);
- 	    UpdateItemFlags(&windows,body[0],flags);
-    }
-    RadioButton(&buttons,i);
-    redraw = 1;
-    break;
 
+      /* note: we can get a M_FOCUS_CHANGE where
+       *   "i" == "current_focus"
+       * This seems to happen when (de)iconifing windows, eg xterm. */
+    case M_FOCUS_CHANGE:
+      i = FindItem(&windows,body[0]);
+      /* if we had a previous focus, de-colour it */
+      if (current_focus != -1)
+      {
+        if (ItemFlags(&windows,ItemID(&windows,current_focus))&ICONIFIED)
+	  UpdateButtonSet(&buttons,current_focus,1);
+	else
+	  UpdateButtonSet(&buttons,current_focus,0);
+      }
+      /* if we have a new focus, update the flags and colour in the button */
+      if (i!=-1)
+      {
+	flags=ItemFlags(&windows,body[0]);
+	UpdateItemFlags(&windows,body[0],flags);
+	UpdateButtonSet(&buttons,i,2);
+      }
+      /* note the new focus */
+      current_focus = i;
+      RadioButton(&buttons,i);
+      redraw = 1;
       break;
+
     case M_END_WINDOWLIST:
       if (!WindowIsUp) MakeMeWindow();
       redraw=1;
--- FvwmWinList.man-old	Mon May  4 22:06:45 1998
+++ FvwmWinList.man	Mon May  4 22:10:16 1998
@@ -73,7 +73,7 @@
 are iconified. If omitted, the color from \fBFvwmWinListFore\fP
 is used.
 
-.IP "*FvwmWinListFocusBack \fIcolor\fP"
+.IP "*FvwmWinListIconBack \fIcolor\fP"
 Specifies the color to use for the button for windows that
 are iconified. If omitted, the color from \fBFvwmWinListBack\fP
 is used.
@@ -91,8 +91,10 @@
 name.  This is useful to keep the width of the window small.
 
 .IP "*FvwmWinListLeftJustify
-By default, FvwmWinList will center the icon text in the icon.  This option
-causes it to be justified flush with the left edge of the icon.
+By default, FvwmWinList will center the icon text in the icon.  This
+option causes it to be justified flush with the left edge of the icon.
+However, buttons that have mini icons associated with them are always
+drawn left justified.
 
 .IP "*FvwmWinListMinWidth \fIwidth\fP"
 .IP "*FvwmWinListMaxWidth \fIwidth\fP"
------------------------------------------------------------
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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].