- SFG_Window* window;
- XEvent event;
- int modifiers;
-
- /*
- * This code was repeated constantly, so here it goes into a definition:
- */
-# define GETWINDOW(a) \
- window = fgWindowByHandle( event.a.window ); \
- if( window == NULL ) \
- break;
-# define GETMOUSE(a) \
- window->State.MouseX = event.a.x; \
- window->State.MouseY = event.a.y;
-
- freeglut_assert_ready;
- while( XPending( fgDisplay.Display ) )
- {
- XNextEvent( fgDisplay.Display, &event );
- switch( event.type )
- {
- case DestroyNotify:
- /*
- * This is sent to confirm the XDestroyWindow call.
- */
- /*
- * Call the window closure callback, remove from the structure, etc.
- */
-/* fgAddToWindowDestroyList ( window, FALSE ); */
-
- break;
-
- case ClientMessage:
- /*
- * Destroy the window when the WM_DELETE_WINDOW message arrives
- */
- if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
- {
- GETWINDOW( xclient );
-
- /*
- * Call the XWindows functions to close the window
- */
- fgCloseWindow ( window ) ;
-
- /*
- * Call the window closure callback, remove from the structure, etc.
- */
- fgAddToWindowDestroyList ( window, FALSE );
- }
- break;
-
- case UnmapNotify:
- /*
- * A window of ours has been unmapped...
- */
- break;
-
- case Expose:
- /*
- * We are too dumb to process partial exposes...
- */
- if( event.xexpose.count == 0 )
- fghRedrawWindowByHandle( event.xexpose.window );
- break;
-
- /*
- * CreateNotify causes a configure-event so that sub-windows are
- * handled compatibly with GLUT.
- *
- * NOTE that it is possible that you will more than one Reshape
- * event for your top-level window, but something like this appears
- * to be required for compatbility.
- *
- * GLUT presumably does this because it generally tries to treat
- * sub-windows the same as windows.
- *
- */
- case CreateNotify:
- case ConfigureNotify:
- /*
- * The window gets resized
- */
- fghReshapeWindowByHandle(
- event.xconfigure.window,
- event.xconfigure.width,
- event.xconfigure.height
- );
- break;
-
- case MappingNotify:
- /*
- * Have the client's keyboard knowledge updated (xlib.ps,
- * page 206, says that's a good thing to do)
- */
- XRefreshKeyboardMapping( (XMappingEvent *) &event );
- break;
-
- case VisibilityNotify:
- {
- /*
- * The window's visiblity might have changed
- */
- GETWINDOW( xvisibility );
-
- /*
- * Break now if no window status callback has been hooked to that window
- */
- if( window->Callbacks.WindowStatus == NULL )
- break;
-
- /*
- * We're going to send a callback to a window. Make it current.
- */
- fgSetWindow( window );