Subject: Patch for FvwmWinList

From: Olivier Chapuis <[email-masked]>
Date: Fri, 22 Oct 1999 08:17:30 +0200

Hello,
This mail has two part and an attached patch. 
Part A: Description of 4 bugs of FvwmWinList
Part B: Description of a patch which fixes the first 3.

-----------------
Part A: Description of 4 bugs of FvwmWinList

1. This one depends on the fact that you use the option 
*FvwmWinListCurrentDesk
*FvwmWinListGeometry +0-0 #(not really needed)
(do not use *FvwmWinListAnchor)
and that WinList has a non zero border width.
Then do so that there are x applications in WinList in Desk0,
no applications in WinList in Desk1 and y applications in WinList
in Desk3 with x not equal to y. Switch between these 3 desks
(Desk0-->Desk1-->Desk2-->Desk1-->Desk0). In may machine the position
of WinList is bad, the bad position come from the BorderWidth
of WinList.

2. Now with the above configuration enable animation for WinList 
and do so that the *FvwmWinListFollowWindowList is *not* activated 
(this the default). Then, Iconify/DeIconify the windows, the geometry
of the WinList buttons in the animation are sometimes false (you may 
need to play a little bit to see that, open other windows and 
Iconify/DeIconify).

3. I have some problems with WinList at startup. If animation
is enable for winlist and an application is started iconified
(i.e., + I Module FvwmConsole in StartFunc and Style FvwmConsole
starticonic), then I've got:

FvwmWinList: Cause of next X Error.
   Error: 3
   Major opcode of failed request:  40 (TranslateCoords)
   Minor opcode of failed request:  0
   Resource id of failed request:  0x0
 Leaving a core dump now

4. At start up if there are some applications (started in .xinitrc
or in a Fvwm Start Functions, but not started iconified), then WinList 
some time crash with a core file:

Core was generated by `/usr/local/libexec/fvwm/2.3.10/FvwmWinList 24 4 none 0 8'.
Program terminated with signal 11, Erreur de segmentation. (segmentation fault)
#0  0x40061b20 in ?? ()
(gdb) where
#0  0x40061b20 in ?? ()
#1  0x4005ed20 in ?? ()
#2  0x804a2aa in ?? ()
#3  0x804a5e3 in ?? ()
#4  0x804b212 in ?? ()
#5  0x804b0e5 in ?? ()
#6  0x804ab1c in ?? ()
#7  0x804aad9 in ?? ()
#8  0x804aa00 in ?? ()
(gdb) quit

Arg !!!

I have tried to solve this by reverting the patch which lock
on send only after SendFinishedStartupNotification, but the
same thing happen.

-----------------
Part B: Description of a patch which fixes the first 3.

Now the patch. It solves Bug 1, 2 and 3 but *not* 4.

1. Reason of the bug (IMHO): When winlist map it self we've got
a ConfigureNotify event and the positions given "forget" the border 
width and title width. I've take these width at first winlist map 
and do the appropriate correction in winlist position.   

2. The bug is visible in the code, the "button position" is
badly computed. I have modified FindItemDesk (never used in the code)
and use it in ProcessMessage to compute the good item in the current
Desk.

3. I forbid any animation before WinList has mapped itself for the
first time.

I have tried to test this patch with a lot of different configuration
option and situations. It seems to work good and I hope that I have not
introduced other bugs ...

modules/ChangeLog

FvwmWinList/FvwmWinList.c (ProcessMessage, LoopOnEvents, AdjustWindow): 
FvwmWinList/List.c (FindItemDesk):
Fix a positions bug. Fix some animation bugs.

Olivier

Index: modules/FvwmWinList/FvwmWinList.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmWinList/FvwmWinList.c,v
retrieving revision 1.49
diff -u -b -B -u -r1.49 FvwmWinList.c
--- FvwmWinList.c	1999/10/20 15:50:46	1.49
+++ FvwmWinList.c	1999/10/22 06:17:20
@@ -106,7 +106,7 @@
 
 /* Module related information */
 char *Module;
-int WindowIsUp=0,win_width=5,win_height=5,win_grav,win_x,win_y,win_title,win_border;
+int WindowIsUp=0,win_width=5,win_height=5,win_grav,win_x,win_y,win_title,win_border_x=0,win_border_y=0;
 int Clength,Transient=0,Pressed=0,ButPressed,Checked=0;
 int MinWidth=DEFMINWIDTH,MaxWidth=DEFMAXWIDTH;
 ButtonArray buttons;
@@ -328,7 +328,7 @@
 ******************************************************************************/
 void ProcessMessage(unsigned long type,unsigned long *body)
 {
-  int redraw=0,i;
+  int redraw=0,i,j;
   Item *flagitem;
   char *name,*string;
   static int current_focus=-1;
@@ -401,6 +401,15 @@
     case M_ICON_NAME:
       if ((type==M_ICON_NAME && !UseIconNames) ||
           (type==M_WINDOW_NAME && UseIconNames)) break;
+      /* We get the win_borders only when WinList  map it self, this is ok 
+       *  since we need it only after an unmap */
+      if (!strcmp((char *)&body[3],&Module[1]))
+      {
+	win_border_x = body[10];
+	win_border_y = body[10];
+	if (win_grav == NorthWestGravity || win_grav == NorthEastGravity)
+	  win_border_y +=  body[9];
+      }
       if ((i=UpdateItemName(&windows,body[0],(char *)&body[3]))==-1) break;
       string=(char *)&body[3];
       flagitem = ItemFlags(&windows,body[0]);
@@ -425,14 +434,18 @@
 	flagitem = ItemFlags(&windows, body[0]);
 	if ((type == M_DEICONIFY && IS_ICONIFIED(flagitem))
 	    || (type == M_ICONIFY && !IS_ICONIFIED(flagitem))) {
-	  if (IS_ICON_SUPPRESSED(flagitem) && AnimCommand
+	  if (IS_ICON_SUPPRESSED(flagitem) && AnimCommand && WindowIsUp
 	      && (AnimCommand[0] != 0)) {
 	    char buff[MAX_MODULE_INPUT_TEXT_LEN];
 	    Window child;
 	    int x, y;
 
 	    /* find out where our button is */
-	    XTranslateCoordinates(dpy, win, Root, 0, i * buttonheight,
+	    if (ShowCurrentDesk) 
+	      j = FindItemDesk(&windows, body[0],CurrentDesk);
+	    else 
+	      j = i;
+	    XTranslateCoordinates(dpy, win, Root, 0, j * buttonheight,
 				  &x, &y, &child);
 	    /* tell FvwmAnimate to animate to our button */
 	    if (IS_ICONIFIED(flagitem)) {
@@ -813,7 +826,8 @@
           RedrawWindow(True);
         break;
       case ConfigureNotify:
-        /* if send_event is true it means the user has moved the window
+        /* if send_event is true it means the user has moved the window or
+	 * that winlist has mapped itself,
          * take note of the new position. If it is false it comes from the
          * Xserver and the coordinates are always (0,0) - ignore it */
         if (Event.xconfigure.send_event) {
@@ -945,10 +959,22 @@
   {
     if (Anchor)
     {
-      if (win_grav == SouthEastGravity || win_grav == NorthEastGravity)
-        win_x += win_width - new_width;
-      if (win_grav == SouthEastGravity || win_grav == SouthWestGravity)
-        win_y += win_height - new_height;
+        if (win_grav == NorthWestGravity) {
+        win_x -= (WindowIsUp-1) * win_border_x;
+	win_y -= (WindowIsUp-1) * win_border_y;
+      }
+      if (win_grav == NorthEastGravity) {
+        win_x += win_width - new_width + (WindowIsUp-1) * win_border_x;
+	win_y -= (WindowIsUp-1) * win_border_y;
+      }
+      if (win_grav == SouthEastGravity) {
+	win_y += win_height - new_height + (WindowIsUp -1) * win_border_y;
+	win_x += win_width - new_width + (WindowIsUp -1) * win_border_x;
+      } 
+      if (win_grav == SouthWestGravity) {
+        win_y += win_height - new_height + (WindowIsUp -1) * win_border_y;
+	win_x -= (WindowIsUp -1) * win_border_x;
+      }
       XMoveResizeWindow(dpy, win, win_x, win_y, new_width, new_height);
     }
     else
Index: modules/FvwmWinList/List.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmWinList/List.c,v
retrieving revision 1.11
diff -u -b -B -u -r1.11 List.c
--- List.c	1999/06/27 14:47:25	1.11
+++ List.c	1999/10/22 06:17:23
@@ -134,7 +134,8 @@
   Item *temp;
   int i;
 
-  for(i=0,temp=list->head;temp!=NULL && (temp->id!=id || temp->desk != desk) ;i++,temp=temp->next);
+  for(i=0,temp=list->head;temp!=NULL && temp->id!=id;temp=temp->next) 
+    if (temp->desk == desk) i++;
   if (temp==NULL) return -1;
   return i;
 }

---

From: Tim Phipps <[email-masked]>
Date: Fri, 22 Oct 1999 10:53:36 +0100

> Part B: Description of a patch which fixes the first 3.
Nice work, I've applied the patch. I took the liberty of renaming the
variable WindowIsUp to WindowState as it confuse me into thinking it was
a booloean. And I changed the `if' statements to adjust the window
geomtery into a couple of switches.

> Program terminated with signal 11, Erreur de segmentation. (segmentation fault)

Indeed.  core files without debug are useless. Is it possible for you to
compile with debug on? I think a "make clean; make CFLAGS=-g" will do
it.

Cheers,
Tim.
--
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]