Subject: Patch for FvwmIconMan - to use or not to use

From: Chris Rankin <[email-masked]>
Date: Mon, 25 Jan 1999 20:15:13 -0500 (EST)

Hi,
There seems to be some debate about whether FvwmIconMan needs
patching; anyway, here is the patch (in clear-text so that more people
have a chance to spot any silly typos). Your call, Dominik ;-) .

CHANGES:
* Move XPending() in the main event loop so that it always gets
called. This keeps X-events flowing through the pipes.
* Don't use GetFdWidth() because it potentially adds a lot of overhead
to the select() call. This change requires a max(a,b) macro.
* Add siginterrupt() calls to signal code (if we're not using
sigaction())

I have tested this module by creating > 10 windows, and fvwm2 didn't
coredump or hang or anything. (However, it DID fail to completely
erase an odd button when I had so many windows that the icon-manager
switched to 2-column mode.)

Cheers,
Chris.

==========================================================================

--- FvwmIconMan.c.orig	Fri Jan 22 23:01:13 1999
+++ FvwmIconMan.c	Sun Jan 24 10:46:15 1999
@@ -15,7 +15,6 @@
 #include "../../fvwm/module.h"

-static int fd_width;
 static volatile sig_atomic_t isTerminated = False;
 
 static char *IM_VERSION = "1.3";
@@ -127,12 +126,22 @@
 static void main_loop (void)
 {
   fd_set readset, saveset;
+  int    fd_width;
+
+  fd_width = max(x_fd,Fvwm_fd[1]) + 1;
 
   FD_ZERO (&saveset);
   FD_SET (Fvwm_fd[1], &saveset);
   FD_SET (x_fd, &saveset);
 
   while( !isTerminated ) {
+
+    /*
+     * If there are events in the event-queue then do nothing,
+     * otherwise read events from the XServer into the queue.
+     */
+    XPending(theDisplay);
+
     /* Check the pipes for anything to read, and block if
      * there is nothing there yet ...
      */
@@ -142,7 +151,7 @@
     }
     else {
 
-      if (FD_ISSET (x_fd, &readset) || XPending (theDisplay)) {
+      if (FD_ISSET(x_fd, &readset)) {
         xevent_loop();
       }
       if (FD_ISSET(Fvwm_fd[1],&readset)) {
@@ -235,6 +244,13 @@
   signal(SIGHUP,  TerminateHandler);
   signal(SIGTERM, TerminateHandler);
   signal(SIGQUIT, TerminateHandler);
+#ifdef HAVE_SIGINTERRUPT
+  siginterrupt(SIGPIPE, True);
+  siginterrupt(SIGINT,  True);
+  siginterrupt(SIGHUP,  True);
+  siginterrupt(SIGTERM, True);
+  siginterrupt(SIGQUIT, True);
+#endif
 #endif
 
   read_in_resources (argv[3]);
@@ -244,7 +260,6 @@
   }
 
   assert (globals.managers);
-  fd_width = GetFdWidth();
 
   SetMessageMask(Fvwm_fd,M_CONFIGURE_WINDOW | M_RES_CLASS | M_RES_NAME |
                  M_ADD_WINDOW | M_DESTROY_WINDOW | M_ICON_NAME |
--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
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].