Subject: Experimental patch to FvwmWinList (part 2)

From: Chris Rankin <[email-masked]>
Date: Mon, 25 Jan 1999 00:35:11 -0500 (EST)

Hi,
This patch is basically a rehash of the one I posted earlier, except
that it has one extra feature: it doesn't use GetFdWidth().

The reason for not using GetFdWidth() is that this function is written
to return the MAXIMUM number of open descriptors for a process. For
Linux 2.2.0, this is 1024. However, all we really need is "1 + highest
descriptor number", and for FvwmWinList we only have two descriptors
to choose from.

>From an aesthetic point of view, this also removes a global variable.

I see this patch as a "potentially minor efficiency improvement" - it
can probably wait for 2.2 but I would recommend it. (Similarly for
FvwmIconMan.) It successfully compiles and runs on my system (for what
it's worth)

Cheers,
Chris.

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

--- FvwmWinList.c.orig	Fri Jan 22 22:51:10 1999
+++ FvwmWinList.c	Sat Jan 23 11:31:37 1999
@@ -81,7 +81,6 @@
 
 /* File type information */
 FILE *console;
-int fd_width;
 int Fvwm_fd[2];
 int x_fd;
 
@@ -207,8 +206,6 @@
   InitArray(&buttons,0,0,win_width, fontheight+6);
   InitList(&windows);
 
-  fd_width = GetFdWidth();
-
   /* Request a list of all windows,
    * wait for ConfigureWindow packets */
 
@@ -235,9 +232,20 @@
 ******************************************************************************/
 void MainEventLoop(void)
 {
-fd_set readset;
+  fd_set readset;
+  int    fd_width;
+
+  fd_width = max(x_fd, Fvwm_fd[1]) + 1;
 
   while( !isTerminated ) {
+
+    /*
+     * If there are events in the queue then do nothing,
+     * otherwise read events from the XServer and put them
+     * into the input queue.
+     */
+    XPending(dpy);
+
     FD_ZERO(&readset);
     FD_SET(Fvwm_fd[1],&readset);
     FD_SET(x_fd,&readset);
@@ -248,7 +256,7 @@
      */
     if (select(fd_width,SELECT_TYPE_ARG234 &readset,NULL,NULL,NULL) > 0) {
 
-      if (FD_ISSET(x_fd,&readset) || XPending(dpy)) LoopOnEvents();
+      if (FD_ISSET(x_fd,&readset)) LoopOnEvents();
       if (FD_ISSET(Fvwm_fd[1],&readset)) ReadFvwmPipe();
 
     }
--
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].