Subject: A patch for executeModuleSync

From: Olivier Chapuis <[email-masked]>
Date: Sun, 17 Oct 1999 09:48:37 +0200

Hello,
Attached to this message a patch that allows to escape to a
ModuleSynchronous [Timeout time] FvwmModule
command with Ctl-Alt-Escape.

With this patch the executeModuleSynch loop is as
follows:  
1. try to obtain a message from the module during 1 sec
2. Handle the module message if any (possibly return)
3. return if "loop time" >= "Timeout time" 
4. return if Ctl-Alt-Escape
5. Go to 1.

Don't now if this is really useful ... May be the better way to
handle this patch is to put it in the trash.

The ChangeLog is not in the patch, here it is:

*module_interface.c (executeModuleSync):  New logic in the 
executeModuleSynch loop. Ctl-Alt-Escape allows to exit from a 
ModuleSynchronous command.

Olivier

PS1: There are no doc, I will write it if you apply the patch
(I will handle Wait too).

PS2: Tim, I will try to do the "escape sequence" configurable,
but later.

Index: fvwm/module_interface.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/module_interface.c,v
retrieving revision 1.31
diff -u -b -B -u -r1.31 module_interface.c
--- fvwm/module_interface.c	1999/10/16 10:32:54	1.31
+++ fvwm/module_interface.c	1999/10/17 07:49:58
@@ -34,6 +34,7 @@
 #include <ctype.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <X11/keysym.h>
 
 #include <fcntl.h>
 #include <sys/time.h>
@@ -338,13 +339,15 @@
   char *next;
   char *token;
   char *expect = NULL;
-  struct timeval timeout = {42, 0};
-  struct timeval *timeoutP = &timeout;
+  struct timeval timeout = {0, 1};
+  struct timeval *timeoutP = &timeout; /* use 1sec timeout in select */
   int pipe_slot;
   fd_set in_fdset;
   fd_set out_fdset;
   Window targetWindow;
   extern fd_set_size_t fd_width;
+  time_t start_time;
+  XEvent tmpevent;
 
   if (!action)
     return;
@@ -389,22 +392,11 @@
     return;
   }
 
-  /* wait for the message from the module */
-
   /* wait for module input */
+  start_time = time(NULL);
+
   while (1)
   {
-    if (sec > 0)
-    {
-      timeout.tv_sec = sec;
-      timeout.tv_usec = 0;
-      timeoutP = &timeout;
-    }
-    else
-    {
-      timeoutP = NULL;
-    }
-
     FD_ZERO(&in_fdset);
     FD_ZERO(&out_fdset);
     if(readPipes[pipe_slot] >= 0)
@@ -437,10 +429,19 @@
         FlushQueue(pipe_slot);
       }
     }
-    else
+    usleep(1000);
+    if (difftime(time(NULL), start_time) >= sec && sec)
     {
       /* timeout */
       return;
+    }
+    /* Check for "Ctl-Alt-Escape" */
+    if (XCheckMaskEvent(dpy, KeyPressMask, &tmpevent))
+    {
+	if (tmpevent.type == KeyPress &&
+	       XLookupKeysym(&(tmpevent.xkey),0) == XK_Escape &&
+	       tmpevent.xbutton.state & ControlMask)
+	  return;
     }
   }
 }

---

From: Dominik Vogt <[email-masked]>
Date: Mon, 18 Oct 1999 11:51:19 +0200

On Sun, Oct 17, 1999 at 09:48:37AM +0200, Olivier Chapuis wrote:
>...

At least it won't hurt if somebody makes a typo with his timeout.
I've applied it.

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
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]