Subject: FVWM: Monster patch for fvwm 2.0.43

From: Grant McDorman <[email-masked]>
Date: Wed, 11 Sep 1996 10:50:28 -0400 (EDT)

-----BEGIN PGP SIGNED MESSAGE-----

The attached patch contains all of the changes/patches I've made to fvwm
2.0.43. (I'm sending this since I'm not sure I sent in all of the changes
before).

The changes in this patch:
   * FvwmButtons
      parse.c       Change to parse old-style SwallowModule command (tested)
      FvwmButtons.c Change to remove XLib calls from signal handler (part
                    tested)
   * FvwmConsole
      FCtest.c      Fixes to prevent memory corruption (tested)
   
   * fvwm
      placement.c   Change to allow RandomPlacement for transient windows
                    (dialogs) (tested)
      fvwm.c        Change to remove X calls from the X fatal I/O error
                    handler (needs to be tested on Digital Unix)

Grant McDorman <[email-masked]>
                                ISG Technologies, Inc.
*** fvwm-2.0.43/modules/FvwmButtons/parse.c.orig	Thu Jun 27 10:46:22 1996
--- fvwm-2.0.43/modules/FvwmButtons/parse.c	Tue Jul  9 13:07:27 1996
***************
*** 670,675 ****
--- 670,679 ----
  	  exit(1);
  	}
        s+=7;
+       if (mystrncasecmp(s,"module",6)==0)
+ 	{
+ 	  s+=6;
+ 	}
        b->hangon=seekright(&s);
        b->flags|=(b_Swallow|b_Hangon);
        b->swallow|=1;
*** fvwm-2.0.43/modules/FvwmButtons/FvwmButtons.c.orig	Thu Jun 27 10:45:30 1996
--- fvwm-2.0.43/modules/FvwmButtons/FvwmButtons.c	Wed Sep 11 10:31:58 1996
***************
*** 27,32 ****
--- 27,33 ----
  #include <string.h>
  #include <sys/wait.h>
  #include <sys/time.h>
+ #include <sys/stat.h>
  #if defined ___AIX || defined _AIX || defined __QNX__ || defined ___AIXV3 || d
efined AIXV3 || defined _SEQUENT_
  #include <sys/select.h>
  #endif
***************
*** 75,80 ****
--- 76,82 ----
  /* ------------------------------ prototypes ------------------------------- *
/
  
  void DeadPipe(int nonsense);
+ void CleanUp(void);
  void SetButtonSize(button_info*,int,int);
  /* main */
  void Loop(void);
***************
*** 123,128 ****
--- 125,132 ----
  GC  NormalGC;
  int Width,Height;
  
+ int running = 1;
+ 
  int x= -30000,y= -30000,w= -1,h= -1,gravity = NorthWestGravity;
  int new_desk = 0;
  int ready = 0;
***************
*** 170,182 ****
  **/
  void DeadPipe(int whatever)
  {
    button_info *b,*ub=UberButton;
    int button=-1;
  
-   signal(SIGPIPE, SIG_IGN);/* Xsync may cause SIGPIPE */
- 
    XSync(Dpy,0); /* Wait for thing to settle down a bit */
    XGrabServer(Dpy); /* We don't want interference right now */
    while(NextButton(&ub,&b,&button,0))
      {
        /* delete swallowed windows */
--- 174,217 ----
  **/
  void DeadPipe(int whatever)
  {
+   struct stat buf;
+     
+   /*
+    * If a SIGPIPE arrives during this operation, just exit.
+    *  - the signal will probably because the server is shutting
+    *    down. Attempting to do any further processing is useless
+    *    and may in fact, on some platforms, put the process into
+    *    a tight loop (if SIGPIPE is ignored).
+    * 22 July 1996 GRM.
+    * 
+    * Further investigation: XSync may loop *without* causing a SIGPIPE.
+    * This may be because the connection is dead, or because of the
+    * fact that X operations in signal handlers are discouraged.
+    * 
+    * In order to cover all the bases, then, this function will now
+    * set a global flag which will cause the main loop to stop.
+    *
+    * SIGPIPE is reset to DeadPipe, as well.
+    */
+   signal(SIGPIPE, DeadPipe);
+ 
+   /*
+    * Try to check status of X connection.
+    */
+   if (fstat(XConnectionNumber(Dpy), &buf) == -1)
+       exit(0);
+   
+   running = 0;
+ }
+ 
+ void CleanUp(void)
+ {
    button_info *b,*ub=UberButton;
    int button=-1;
  
    XSync(Dpy,0); /* Wait for thing to settle down a bit */
    XGrabServer(Dpy); /* We don't want interference right now */
+ 
    while(NextButton(&ub,&b,&button,0))
      {
        /* delete swallowed windows */
***************
*** 506,512 ****
    int ex=10000,ey=10000,ex2=0,ey2=0;
  #endif
  
!   while(1)
      {
        if(My_XNextEvent(Dpy,&Event))
  	{
--- 541,547 ----
    int ex=10000,ey=10000,ex2=0,ey2=0;
  #endif
  
!   while(running)
      {
        if(My_XNextEvent(Dpy,&Event))
  	{
***************
*** 733,738 ****
--- 768,774 ----
  	  }
        }
      }
+     CleanUp();
  }
  
  /**
*** fvwm-2.0.43/modules/FvwmConsole/FCtest.c.orig	Mon Feb 26 14:33:04 1996
--- fvwm-2.0.43/modules/FvwmConsole/FCtest.c	Wed Jul 10 13:18:06 1996
***************
*** 27,33 ****
  
  void main(int argc, char **argv){
    char *tmp, *s;
!   char client[120];
    char **eargv;
    int i,j;
    char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL };
--- 27,33 ----
  
  void main(int argc, char **argv){
    char *tmp, *s;
!   static char client[120];
    char **eargv;
    int i,j;
    char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL };
*** fvwm-2.0.43/modules/FvwmConsole/FvwmConsole.c.orig	Tue Feb 27 19:10:41 1996
--- fvwm-2.0.43/modules/FvwmConsole/FvwmConsole.c	Wed Jul 10 14:59:04 1996
***************
*** 26,32 ****
  
  void main(int argc, char **argv){
    char *tmp, *s;
!   char client[120];
    char **eargv;
    int i,j;
    char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL };
--- 26,32 ----
  
  void main(int argc, char **argv){
    char *tmp, *s;
!   static char client[120];
    char **eargv;
    int i,j;
    char *xterm_a[] = {"-title", name,"-name",name, "-e",client,NULL };
***************
*** 57,63 ****
  	exit(1);
    }
  
!   if( ( eargv =(char **)safemalloc((argc-2)*sizeof(char *)) ) == NULL ) {
  	ErrMsg( "allocation" );
    }
  
--- 57,64 ----
  	exit(1);
    }
  
! #define ENARGS ((argc-FARGS+1)+sizeof(xterm_a)/sizeof(xterm_a[1]))
!   if( ( eargv =(char **)safemalloc(ENARGS*sizeof(char *)) ) == NULL ) {
  	ErrMsg( "allocation" );
    }
  
*** fvwm-2.0.43/fvwm/placement.c.orig	Mon Apr 24 14:14:08 1995
--- fvwm-2.0.43/fvwm/placement.c	Tue Jul  9 12:12:31 1996
***************
*** 162,168 ****
     *   If RandomPlacement was specified,
     *       then place the window in a psuedo-random location
     */
!   if (!(tmp_win->flags & TRANSIENT) && 
        !(tmp_win->hints.flags & USPosition) &&
        ((tflag & NO_PPOSITION_FLAG)||
         !(tmp_win->hints.flags & PPosition)) &&
--- 162,168 ----
     *   If RandomPlacement was specified,
     *       then place the window in a psuedo-random location
     */
!   if (!((tmp_win->flags & TRANSIENT) && (tmp_win->hints.flags & PPosition)) &&
        !(tmp_win->hints.flags & USPosition) &&
        ((tflag & NO_PPOSITION_FLAG)||
         !(tmp_win->hints.flags & PPosition)) &&
***************
*** 172,178 ****
  	(tmp_win->wmhints->initial_state == IconicState)) )
      {
        /* Get user's window placement, unless RandomPlacement is specified */  
 
!       if(tflag & RANDOM_PLACE_FLAG)
  	{
  	  if(tflag & SMART_PLACE_FLAG)
  	    SmartPlacement(tmp_win,tmp_win->frame_width+2*tmp_win->bw,
--- 172,178 ----
  	(tmp_win->wmhints->initial_state == IconicState)) )
      {
        /* Get user's window placement, unless RandomPlacement is specified */  
 
!       if(tflag & RANDOM_PLACE_FLAG || (tmp_win->flags & TRANSIENT))
  	{
  	  if(tflag & SMART_PLACE_FLAG)
  	    SmartPlacement(tmp_win,tmp_win->frame_width+2*tmp_win->bw,
*** fvwm-2.0.43/fvwm/fvwm.c.orig	Thu Jun 27 10:08:08 1996
--- fvwm-2.0.43/fvwm/fvwm.c	Wed Sep 11 09:25:16 1996
***************
*** 1146,1152 ****
    /* No action is taken because usually this action is caused by someone
       using "xlogout" to be able to switch between multiple window managers
       */
!   Done(0, NULL);
  }
  
  /***********************************************************************
--- 1146,1153 ----
    /* No action is taken because usually this action is caused by someone
       using "xlogout" to be able to switch between multiple window managers
       */
!   ClosePipes();
!   exit(1);
  }
  
  /***********************************************************************

---

From: Grant McDorman <[email-masked]>
Date: Wed, 11 Sep 1996 11:22:58 -0400 (EDT)

-----BEGIN PGP SIGNED MESSAGE-----

You must be much happier now <grin>...

On 11-Sep-96 21:23:03 Thomas Leitner wrote:
> On Wed, 11 Sep 1996, Grant McDorman wrote:
> 
> I've tested it under Digital Unix 4.0 and it works!
> 
> Tom
> 
> -

Grant McDorman <[email-masked]>
                                ISG Technologies, Inc.
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Thomas Leitner <[email-masked]>
Date: Wed, 11 Sep 1996 17:23:03 +0200 (MET DST)

-----BEGIN PGP SIGNED MESSAGE-----

Tom

- --------------------------------------------------------------------------
T o m   L e i t n e r                       Dept. of Communications
                                            Graz University of Technology, 
e-mail    : [email-masked]      Inffeldgasse 12
Phone     : +43-316-873-7455                A-8010 Graz / Austria / Europe
Fax       : +43-316-463-697
Home page : http://wiis.tu-graz.ac.at/people/tom.html
PGP public key on : ftp://wiis.tu-graz.ac.at/pgp-keys/tom.asc or send 
mail with subject "get Thomas Leitner" to [email-masked]
- --------------------------------------------------------------------------

---

From: "Charles Hines" <[email-masked]>
Date: Wed, 11 Sep 1996 13:30:01 -0400

>>>>> "Tom" == Thomas Leitner <[email-masked]> writes:
>>>>> "GM" == Grant McDorman <[email-masked]> writes:

GM> The attached patch contains all of the changes/patches I've made to fvwm
GM> 2.0.43. (I'm sending this since I'm not sure I sent in all of the changes
GM> before).

GM> The changes in this patch:
GM>    * FvwmButtons
GM>       parse.c       Change to parse old-style SwallowModule command (tested)
GM>       FvwmButtons.c Change to remove XLib calls from signal handler (part
GM>                     tested)
GM>    * FvwmConsole
GM>       FCtest.c      Fixes to prevent memory corruption (tested)

GM>    * fvwm
GM>       placement.c   Change to allow RandomPlacement for transient windows
GM>                     (dialogs) (tested)
GM>       fvwm.c        Change to remove X calls from the X fatal I/O error
GM>                     handler (needs to be tested on Digital Unix)

Tom> I've tested it under Digital Unix 4.0 and it works!

If nothing else out of that patch, this change to fvwm.c will almost
certainly be in 2.1.

As for the other parts of the patch, I haven't really looked them over
yet, but the FvwmButtons fixes will probably be in there too.  I got a
new version of FvwmConsole, so I'll have to compare your patch against
it and merge it in if necessary.

Chuck

---

From: kendall shaw <[email-masked]>
Date: Wed, 11 Sep 1996 11:49:59 -0700

>>>>> "G" == Grant McDorman <[email-masked]> writes:

    G>    * FvwmConsole
    G>       FCtest.c      Fixes to prevent memory corruption (tested)
   
[snip]

    G> --- fvwm-2.0.43/modules/FvwmConsole/FCtest.c	Wed Jul 10 13:18:06 1996

Hmm. My fvwm-2.0.43.tar.gz untarred to have fvwm-2.0.43/extras/FvwmConsole
instead. I must have a special version.

I couldn't figure out how to compile FvwmConsole, since it (INSTALL) asks me
to alter fvwm/makefiles.h, which I do not have.

Since you've made a patch, I imagine you must know. How do I compile
FvwmConsole?

kendall shaw

---

From: Grant McDorman <[email-masked]>
Date: Wed, 11 Sep 1996 15:29:07 -0400 (EDT)

> Since you've made a patch, I imagine you must know. How do I compile

Oops. I forgot I moved the directory from extras to modules, and changed
the top-level generated Makefile to include it. I forget whether that was
all that was necessary. (You could also change the Imakefile.)

---

From: kendall shaw <[email-masked]>
Date: Wed, 11 Sep 1996 14:50:12 -0700

>>>>> "G" == Grant McDorman <[email-masked]> writes:

    G> Oops. I forgot I moved the directory from extras to modules, and changed
    G> the top-level generated Makefile to include it. I forget whether that was
    G> all that was necessary. (You could also change the Imakefile.)

It seems to have worked for me. After installing readline, I moved
FvwmConsole into modules, mistakenly changed BINDIR in
FvwmConsole/Makefile to /usr/openwin/bin, ran all of the makes, and
then moved /usr/oepnwin/bin/FvwmConsole* to /usr/openwin/lib/X11/fvwm2.

Thanks.