--- povray-3.50c/src/unix.cpp	2003-01-07 02:08:30.000000000 +0100
+++ povray-3.50c-ww/src/unix.cpp	2003-11-29 12:09:14.000000000 +0100
@@ -382,7 +386,7 @@
 static XColor  *GetBestColor PARAMS((long r, long g, long b));
 static void     SelectVisual PARAMS((Visual **theVisual, unsigned int *theDepth));
 static void     BuildColormap PARAMS((Visual *theVisual));
-static Bool     HandleXEvents PARAMS((XEvent *theEvent, Bool finished));
+static Bool     HandleXEvents PARAMS((Bool finished));
 static int      HandleXError PARAMS((Display *ErrorDisplay,
                                      XErrorEvent *ErrorEvent));
 static int      HandleXIOError PARAMS((Display *ErrorDisplay));
@@ -3187,10 +3200,7 @@
     /* Sit and handle events until we quit, but don't busy wait */
     while (!finished)
     {
-      XEvent theEvent;
-
-      XNextEvent(theDisplay, &theEvent);
-      finished = HandleXEvents(&theEvent, True);
+      finished = HandleXEvents(True);
     }
   }
 }
@@ -3220,12 +3230,9 @@
 
 int XWIN_Test_Abort()
 {
-  XEvent theEvent;
-
-  if (theDisplay && 
-      XCheckWindowEvent(theDisplay, theWindow, theEVENTMASK, &theEvent))
+  if(theDisplay)
   {
-    return (HandleXEvents(&theEvent, False) ? true : false);
+    return(HandleXEvents(False) ? true : false);
   }
 
   return false;
@@ -3327,7 +3334,7 @@
 *
 ******************************************************************************/
 
-int HandleXEvents(XEvent *theEvent, Bool finished)
+int HandleXEvents(Bool finished)
 {
   Bool   refresh = False;
   Bool   abortRender = False;
@@ -3335,9 +3342,20 @@
   int    refresh_x_max = 0;
   int    refresh_y_min = theImage->height - 1;
   int    refresh_y_max = 0;
+  int    npending=0;
+  XEvent _theEvent,*theEvent=&_theEvent;  // <-- (**)
 
   do
   {
+    if(!finished)
+    {
+      /* Process available events; return if no events available. */
+      if(!npending)  npending=XPending(theDisplay);
+      if(!npending)  break;
+      --npending;
+    }
+    XNextEvent(theDisplay,theEvent);
+    
     KeySym theKeySym;
 
 #if (X11_DEBUG > 0)
@@ -3465,7 +3510,7 @@
 #endif
     }
   }
-  while (XCheckWindowEvent(theDisplay, theWindow, theEVENTMASK, theEvent));
+  while(!finished);
 
   if (refresh && !abortRender)
   {

