redisplay is now also on the work list instead of handled separately
[freeglut] / src / x11 / fg_main_x11.c
index 7af570f..897b7ee 100644 (file)
@@ -698,7 +698,7 @@ void fgPlatformProcessSingleEvent ( void )
             if( event.xexpose.count == 0 )
             {
                 GETWINDOW( xexpose );
-                window->State.Redisplay = GL_TRUE;
+                window->State.WorkMask |= GLUT_DISPLAY_WORK;
             }
             break;
 
@@ -1085,6 +1085,8 @@ void fgPlatformProcessWork(SFG_Window *window)
     /* Now clear it so that any callback generated by the actions below can set work again */
     window->State.WorkMask = 0;
 
+    if (workMask&~GLUT_DISPLAY_WORK)    /* Display work is the common case, skip all the below at once */
+    {    
     /* This is before the first display callback: call a few callbacks to inform user of window size, position, etc
      * we know this is before the first display callback of a window as for all windows GLUT_INIT_WORK is set when
      * they are opened, and work is done before displaying in the mainloop.
@@ -1144,5 +1146,15 @@ void fgPlatformProcessWork(SFG_Window *window)
             break;
         }
     }
+    }
+
+    if (workMask & GLUT_DISPLAY_WORK)
+    {
+        if( window->State.Visible )
+            fghRedrawWindow ( window );
+
+        /* Strip out display work that might have ended up on work list now as some of the above genereates callbacks */
+        window->State.WorkMask &= ~GLUT_DISPLAY_WORK;
+    }
 }