Find this kind of bug is definitely out of my juridiction - please, PLEASE maintain...
[freeglut] / src / fg_main.c
index fb3d9db..d17801c 100644 (file)
@@ -54,7 +54,7 @@
 #    define MIN(a,b) (((a)<(b)) ? (a) : (b))
 #endif
 
-extern void fgPlatformProcessWork   ( SFG_Window *window );
+extern void fgProcessWork   ( SFG_Window *window );
 extern fg_time_t fgPlatformSystemTime ( void );
 extern void fgPlatformSleepForEvents( fg_time_t msec );
 extern void fgPlatformProcessSingleEvent ( void );
@@ -163,7 +163,7 @@ static void fghcbProcessWork( SFG_Window *window,
                               SFG_Enumerator *enumerator )
 {
     if( window->State.WorkMask )
-               fgPlatformProcessWork ( window );
+               fgProcessWork ( window );
 
     fgEnumSubWindows( window, fghcbProcessWork, enumerator );
 }
@@ -393,7 +393,7 @@ static void fghSleepForEvents( void )
 
 
 /* Step through the work list */
-void fgPlatformProcessWork(SFG_Window *window)
+void fgProcessWork(SFG_Window *window)
 {
     unsigned int workMask = window->State.WorkMask;
     /* Now clear it so that any callback generated by the actions below can set work again */
@@ -432,10 +432,17 @@ void fgPlatformProcessWork(SFG_Window *window)
         }
     }
 
-    if (workMask & GLUT_DISPLAY_WORK)
+    /* check window state's workmask as well as some of the above callbacks might have generated redisplay requests. We can deal with those right now instead of wait for the next mainloop iteration. */
+    if (workMask & GLUT_DISPLAY_WORK || window->State.WorkMask & GLUT_DISPLAY_WORK)
     {
         if( window->State.Visible )
+        {
+            /* Strip out display work from the work list */
+            /* NB: do this before the display callback is called as user might call postredisplay in his display callback */
+            window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
+
             fghRedrawWindow ( window );
+        }
     }
 }