Index: quartz/gdkeventloop-quartz.c
===================================================================
--- quartz/gdkeventloop-quartz.c	(revision 18828)
+++ quartz/gdkeventloop-quartz.c	(working copy)
@@ -60,6 +60,8 @@
   return FALSE;
 }
 
+extern void gdk_window_quartz_update_timed ();
+
 static gboolean
 gdk_event_dispatch (GSource     *source,
 		    GSourceFunc  callback,
@@ -75,9 +77,10 @@
 
   if (event)
     {
-      if (_gdk_event_func)
+      if (_gdk_event_func) {
 	(*_gdk_event_func) (event, _gdk_event_data);
-
+        gdk_window_quartz_process_immediate_updates ();
+      }
       gdk_event_free (event);
     }
 
Index: quartz/GdkQuartzView.c
===================================================================
--- quartz/GdkQuartzView.c	(revision 18828)
+++ quartz/GdkQuartzView.c	(working copy)
@@ -18,7 +18,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-
 #import "GdkQuartzView.h"
 #include "gdkwindow-quartz.h"
 #include "gdkprivate-quartz.h"
Index: quartz/gdkwindow-quartz.c
===================================================================
--- quartz/gdkwindow-quartz.c	(revision 18828)
+++ quartz/gdkwindow-quartz.c	(working copy)
@@ -19,6 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <sys/time.h>
 #include <config.h>
 
 #include "gdk.h"
@@ -26,6 +27,7 @@
 
 static gpointer parent_class;
 
+static GSList *immediate_update_toplevels;
 static GSList *update_windows;
 static guint   update_idle;
 
@@ -260,17 +262,19 @@
     }
 }
 
+static gboolean gdk_window_quartz_update_timed (gpointer data);
+
 static void
-gdk_window_quartz_process_updates_internal (GdkWindow *window)
+gdk_window_quartz_process_updates_internal (GdkWindow *window, GSList** redisplay_list, gboolean immediate_flush)
 {
   GdkWindowObject *private = (GdkWindowObject *) window;
   GdkWindowImplQuartz *impl = (GdkWindowImplQuartz *) private->impl;
-      
+
   if (private->update_area)
     {
       int i, n_rects;
       GdkRectangle *rects;
-
+      
       gdk_region_get_rectangles (private->update_area, &rects, &n_rects);
 
       gdk_region_destroy (private->update_area);
@@ -282,19 +286,35 @@
 							rects[i].width, rects[i].height)];
 	}
 
-      [impl->view displayIfNeeded];
+      NSWindow* win;
+      GdkWindow* top = gdk_window_get_toplevel (window);
+      
+      if (top != window) {
+	      GdkWindowObject* toppriv = (GdkWindowObject *) top;
+	      GdkWindowImplQuartz* topimpl = (GdkWindowImplQuartz *) toppriv->impl;
+	      win = topimpl->toplevel;
+      } else {
+	      win = impl->toplevel;
+      }
+      
+      if (win && g_slist_find ((*redisplay_list), win) == NULL) {
+	      (*redisplay_list) = g_slist_prepend ((*redisplay_list), win);
+      }
 
       g_free (rects);
     }
 }
 
 static void
-gdk_window_quartz_process_all_updates (void)
+gdk_window_quartz_process_all_updates ()
 {
-  GSList *old_update_windows = update_windows;
-  GSList *tmp_list = update_windows;
+  GSList *old_update_windows;
+  GSList *tmp_list;
+  GSList *toplevels = NULL;
 
   update_idle = 0;
+  old_update_windows = update_windows;
+  tmp_list = update_windows;
   update_windows = NULL;
 
   g_slist_foreach (old_update_windows, (GFunc) g_object_ref, NULL);
@@ -303,14 +323,23 @@
 
   while (tmp_list)
     {
-      gdk_window_quartz_process_updates_internal (tmp_list->data);
-
+	    gdk_window_quartz_process_updates_internal (tmp_list->data, &toplevels, FALSE);
       g_object_unref (tmp_list->data);
       tmp_list = tmp_list->next;
     }
 
+    /* Now flush all top level windows */
+
+  while (toplevels) 
+    {
+	 NSWindow* win = (NSWindow*) toplevels->data;
+	 [win displayIfNeeded];
+	 toplevels = toplevels->next;
+    }
+		    
   GDK_QUARTZ_RELEASE_POOL;
 
+  g_slist_free (toplevels);
   g_slist_free (old_update_windows);
 }
 
@@ -318,12 +347,43 @@
 gdk_window_quartz_update_idle (gpointer data)
 {
   GDK_THREADS_ENTER ();
-  gdk_window_quartz_process_all_updates ();
+  gdk_window_quartz_process_all_updates (TRUE);
   GDK_THREADS_LEAVE ();
 
   return FALSE;
 }
 
+void
+gdk_window_quartz_process_immediate_updates ()
+{
+  GSList *tmplist;
+  struct timeval in, out;
+  double diff;
+  
+  gettimeofday (&in, NULL);
+	
+  if (immediate_update_toplevels == NULL) 
+    return;
+
+  tmplist = immediate_update_toplevels;
+  immediate_update_toplevels = NULL;
+  
+  GDK_QUARTZ_ALLOC_POOL;
+
+  while (tmplist) 
+    {
+	 NSWindow* window = (NSWindow *) tmplist->data;
+	 [window displayIfNeeded];
+	 tmplist = tmplist->next;
+    }
+		    
+  GDK_QUARTZ_RELEASE_POOL;
+  gettimeofday (&out, NULL);
+  diff = ((out.tv_sec * 1000000) + out.tv_usec) - ((in.tv_sec * 1000000) + in.tv_usec);
+  g_printf ("FLUSH took %f usecs\n", diff);
+  g_slist_free (tmplist);
+}
+
 static void
 gdk_window_impl_quartz_invalidate_maybe_recurse (GdkPaintable *paintable,
 						 GdkRegion    *region,
@@ -365,7 +425,7 @@
 
   if (private->update_area)
     {
-      gdk_window_quartz_process_updates_internal ((GdkWindow *) private);
+	    gdk_window_quartz_process_updates_internal ((GdkWindow *) private, &immediate_update_toplevels, TRUE);
       update_windows = g_slist_remove (update_windows, private);
     }
 }
