Resolve [ 853044 ] FreeGLUT menus on Win32 in task bar and ALT-TAB list
[freeglut] / src / freeglut_window.c
index f99b673..eb1842d 100644 (file)
@@ -29,7 +29,7 @@
 #include "config.h"
 #endif
 
-#include "../include/GL/freeglut.h"
+#include <GL/freeglut.h>
 #include "freeglut_internal.h"
 
 /*
@@ -268,11 +268,12 @@ void fgOpenWindow( SFG_Window* window, const char* title,
      * XXX simplify this.
      */
     if( !window->IsMenu )
-       window->Window.VisualInfo = fgChooseVisual( );
+        window->Window.VisualInfo = fgChooseVisual( );
     else if( fgStructure.MenuContext )
         window->Window.VisualInfo = fgChooseVisual( );
     else
     {
+        /* XXX Why are menus double- and depth-buffered? */
         unsigned int current_DisplayMode = fgState.DisplayMode ;
         fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
         window->Window.VisualInfo = fgChooseVisual( );
@@ -310,7 +311,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
     window->State.IsOffscreen = GL_FALSE;
     if( fgState.DisplayMode & GLUT_OFFSCREEN )
     {
-       window->State.IsOffscreen = GL_TRUE;
+        window->State.IsOffscreen = GL_TRUE;
         window->Window.Pixmap = XCreatePixmap(
             fgDisplay.Display, fgDisplay.RootWindow,
             w, h,
@@ -336,11 +337,8 @@ void fgOpenWindow( SFG_Window* window, const char* title,
          * XXX A: Not appreciably, but it WILL make it easier to debug.
          * XXX    Try tracing old GLUT and try tracing freeglut.  Old GLUT
          * XXX    turns off events that it doesn't need and is a whole lot
-         * XXX    more pleasant to trace.  (Hint: Think mouse-motion!)
-         * XXX
-         * XXX    It may make a difference in networked environments or on
-         * XXX    some very slow systems, but I think that that is secondary
-         * XXX    to making debugging easier.
+         * XXX    more pleasant to trace.  (Think mouse-motion!  Tons of
+         * XXX    ``bonus'' GUI events stream in.)
          */
         winAttr.event_mask        =
             StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
@@ -395,7 +393,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
             );
         }
 
-/*      window->Window.Context = fgStructure.MenuContext->Context ; */
+        /* window->Window.Context = fgStructure.MenuContext->Context; */
         window->Window.Context = glXCreateContext(
             fgDisplay.Display, window->Window.VisualInfo,
             NULL, fgState.ForceDirectContext | fgState.TryDirectContext
@@ -483,7 +481,8 @@ void fgOpenWindow( SFG_Window* window, const char* title,
 #elif TARGET_HOST_WIN32
 
     WNDCLASS wc;
-    int flags;
+    DWORD flags;
+    DWORD exFlags = 0;
     ATOM atom;
 
     freeglut_assert_ready;
@@ -536,14 +535,18 @@ void fgOpenWindow( SFG_Window* window, const char* title,
         flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
 
         if ( window->IsMenu )
-            flags |= WS_POPUP ;
+        {
+            flags |= WS_POPUP;
+            exFlags |= WS_EX_TOOLWINDOW;
+        }
         else if( window->Parent == NULL )
             flags |= WS_OVERLAPPEDWINDOW;
         else
             flags |= WS_CHILD;
     }
 
-    window->Window.Handle = CreateWindow( 
+    window->Window.Handle = CreateWindowEx(
+        exFlags,
         "FREEGLUT",
         title,
         flags,
@@ -645,14 +648,20 @@ int FGAPIENTRY glutCreateWindow( const char* title )
  */
 int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
 {
-    SFG_Window* window = NULL;
-    SFG_Window* parent = NULL;
-
-    freeglut_assert_ready;
-    parent = fgWindowByID( parentID );
-    freeglut_return_val_if_fail( parent != NULL, 0 );
-    window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE );
-    return window->ID;
+    int ret = 0;
+    
+    if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
+    {
+        SFG_Window* window = NULL;
+        SFG_Window* parent = NULL;
+
+        freeglut_assert_ready;
+        parent = fgWindowByID( parentID );
+        freeglut_return_val_if_fail( parent != NULL, 0 );
+        window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE );
+        ret = window->ID;
+    }
+    return ret;
 }
 
 /*
@@ -1029,7 +1038,7 @@ void FGAPIENTRY glutFullScreen( void )
                       rect.bottom - rect.top,
                       SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING |
                       SWP_NOZORDER
-                    );
+        );
 #endif
     }
 }