fixes for menus being attached to multiple buttons/windows (John Fay)
[freeglut] / src / freeglut_window.c
index b466602..043b8f3 100644 (file)
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include <GL/freeglut.h>
 #include "freeglut_internal.h"
 
@@ -131,6 +127,16 @@ XVisualInfo* fgChooseVisual( void )
             ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
     }
 
+    if( fgState.DisplayMode & GLUT_AUX1 )
+        ATTRIB_VAL( GLX_AUX_BUFFERS, 1 );
+    if( fgState.DisplayMode & GLUT_AUX2 )
+        ATTRIB_VAL( GLX_AUX_BUFFERS, 2 );
+    if( fgState.DisplayMode & GLUT_AUX3 )
+        ATTRIB_VAL( GLX_AUX_BUFFERS, 3 );
+    if( fgState.DisplayMode & GLUT_AUX4 )
+        ATTRIB_VAL( GLX_AUX_BUFFERS, 4 );
+
+
     /* Push a null at the end of the list */
     ATTRIB( None );
 
@@ -208,7 +214,17 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
     pfd.cDepthBits      = 24;
     pfd.cStencilBits    = 8;
 #endif
-    pfd.cAuxBuffers     = 0;
+    if( fgState.DisplayMode & GLUT_AUX4 )
+        pfd.cAuxBuffers = 4;
+    else if( fgState.DisplayMode & GLUT_AUX3 )
+        pfd.cAuxBuffers = 3;
+    else if( fgState.DisplayMode & GLUT_AUX2 )
+        pfd.cAuxBuffers = 2;
+    else if( fgState.DisplayMode & GLUT_AUX1 )
+        pfd.cAuxBuffers = 1;
+    else
+        pfd.cAuxBuffers = 0;
+
     pfd.iLayerType      = layer_type;
     pfd.bReserved       = 0;
     pfd.dwLayerMask     = 0;
@@ -306,7 +322,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
     }
 
     FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.VisualInfo != NULL,
-                                  "Unable to get window visual info", "fgOpenWindow" );
+                                  "Visual with necessary capabilities not found", "fgOpenWindow" );
 
     /*
      * XXX HINT: the masks should be updated when adding/removing callbacks.
@@ -320,7 +336,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
      */
     winAttr.event_mask        =
         StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
-        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
+        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
         VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
         PointerMotionMask | ButtonMotionMask;
     winAttr.background_pixmap = None;
@@ -405,12 +421,6 @@ void fgOpenWindow( SFG_Window* window, const char* title,
     }
 #endif
 
-    glXMakeCurrent(
-        fgDisplay.Display,
-        window->Window.Handle,
-        window->Window.Context
-    );
-
     /*
      * XXX Assume the new window is visible by default
      * XXX Is this a  safe assumption?
@@ -456,6 +466,12 @@ void fgOpenWindow( SFG_Window* window, const char* title,
     XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
                      &fgDisplay.DeleteWindow, 1 );
 
+    glXMakeCurrent(
+        fgDisplay.Display,
+        window->Window.Handle,
+        window->Window.Context
+    );
+
     XMapWindow( fgDisplay.Display, window->Window.Handle );
 
 #elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
@@ -577,7 +593,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
 #endif /* TARGET_HOST_WINCE */
 
     UpdateWindow( window->Window.Handle );
-    ShowCursor( TRUE );  /* XXX Old comments say "hide cusror"! */
+    ShowCursor( TRUE );  /* XXX Old comments say "hide cursor"! */
 
 #endif