Fixed a bug for UNIX_X11 where window reshape events were causing freeglut
authorRichard Rauch <rkr@olib.org>
Tue, 2 Dec 2003 15:03:48 +0000 (15:03 +0000)
committerRichard Rauch <rkr@olib.org>
Tue, 2 Dec 2003 15:03:48 +0000 (15:03 +0000)
to mark the window as *needing* a reshape (which during general display
callback handling would result in effectively a glutReshapeWindow()).

The code is now system-dependant.  It should be abstracted to a function,
but is presently copied in two places.  Sorry.

Also, inverted the order of the associated if()/else check (in both
WIN32 and UNIX_X11 branches) since the former "else" part was a one-line
callback invocation.

This fixes two seemingly unrelated bugs that I was seeing in UNIX_X11.

git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@374 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_main.c

index 55e033a..bbcb1ab 100644 (file)
@@ -126,15 +126,15 @@ static void fghReshapeWindowByHandle ( SFG_WindowHandleType handle,
         );
     }
 
-#endif
-
-    if( !( FETCH_WCB( *window, Reshape ) ) )
+    if( FETCH_WCB( *window, Reshape ) )
+        INVOKE_WCB( *window, Reshape, ( width, height ) );
+    else
     {
         fgSetWindow( window );
         glViewport( 0, 0, width, height );
     }
-    else
-        INVOKE_WCB( *window, Reshape, ( width, height ) );
+
+#endif
 
     /*
      * Force a window redraw.  In Windows at least this is only a partial
@@ -552,9 +552,19 @@ void FGAPIENTRY glutMainLoopEvent( void )
         case CreateNotify:
         case ConfigureNotify:
             GETWINDOW( xconfigure );
-            window->State.NeedToResize = GL_TRUE ;
-            window->State.Width  = event.xconfigure.width ;
-            window->State.Height = event.xconfigure.height;
+            {
+                int width = event.xconfigure.width;
+                int height = event.xconfigure.height;
+
+                GETWINDOW( xconfigure );
+                if( FETCH_WCB( *window, Reshape ) )
+                    INVOKE_WCB( *window, Reshape, ( width, height ) );
+                else
+                {
+                    fgSetWindow( window );
+                    glViewport( 0, 0, width, height );
+                }
+            }
             break;
 
         case DestroyNotify: