* Grab the next event to be processed...
*/
XNextEvent( fgDisplay.Display, &event );
- window = fgWindowByHandle ( event.xany.window ) ;
/*
* Check the event's type
/*
* Call the window closure callback, remove from the structure, etc.
*/
- fgStructure.Window = window ;
/* fgAddToWindowDestroyList ( window, FALSE ); */
break;
*/
if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
{
- fgStructure.Window = window ;
+ GETWINDOW( xclient );
/*
* Call the XWindows functions to close the window
* We are too dumb to process partial exposes...
*/
if( event.xexpose.count == 0 )
- fghRedrawWindowByHandle( window->Window.Handle );
+ fghRedrawWindowByHandle( event.xexpose.window );
break;
case ConfigureNotify:
/*
* The window's visiblity might have changed
*/
+ GETWINDOW( xvisibility );
+
/*
* Break now if no window status callback has been hooked to that window
*/
/*
* Mouse is over one of our windows
*/
- GETMOUSE( xcrossing );
+ GETWINDOW( xcrossing ); GETMOUSE( xcrossing );
/*
* Is there an entry callback hooked to the window?
/*
* Mouse is no longer over one of our windows
*/
- GETMOUSE( xcrossing );
+ GETWINDOW( xcrossing ); GETMOUSE( xcrossing );
/*
* Is there an entry callback hooked to the window?
/*
* The mouse cursor was moved...
*/
- GETMOUSE( xmotion );
+ GETWINDOW( xmotion ); GETMOUSE( xmotion );
/*
* Set the current window
* A mouse button has been pressed or released. Traditionally,
* break if the window was found within the freeglut structures.
*/
- GETMOUSE( xbutton );
+ GETWINDOW( xbutton ); GETMOUSE( xbutton );
/*
* GLUT API assumes that you can't have more than three mouse buttons, so:
/*
* A key has been pressed, find the window that had the focus:
*/
- GETMOUSE( xkey );
+ GETWINDOW( xkey ); GETMOUSE( xkey );
if( event.type == KeyPress )
{
fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
/*
- * Create the OpenGL rendering context now
+ * Create or get the OpenGL rendering context now
*/
- window->Window.Context = wglCreateContext( window->Window.Device );
+ if ( fgState.UseCurrentContext == TRUE )
+ window->Window.Context = wglGetCurrentContext();
+ else
+ window->Window.Context = wglCreateContext( window->Window.Device );
/*
* Still, we'll be needing to explicitly resize the window
*/
if( fgStructure.Window == window )
{
+ int used = FALSE ;
+ SFG_Window *iter ;
+
wglMakeCurrent( NULL, NULL );
- wglDeleteContext( window->Window.Context );
+ /* Step through the list of windows. If the rendering context is notbeing used
+ * by another window, then we delete it.
+ */
+ for ( iter = fgStructure.Windows.First; iter; iter = iter->Node.Next )
+ {
+ if ( ( iter->Window.Context == window->Window.Context ) && ( iter != window ) )
+ used = TRUE ;
+ }
+
+ if ( used == FALSE ) wglDeleteContext( window->Window.Context );
}
/*