/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/*
- * Executes a single iteration in the FreeGLUT processing loop.
+ * Executes a single iteration in the freeglut processing loop.
*/
void FGAPIENTRY glutMainLoopEvent( void )
{
* 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.
*/
- fgAddToWindowDestroyList ( window, FALSE );
+ fgStructure.Window = window ;
+/* fgAddToWindowDestroyList ( window, FALSE ); */
break;
*/
if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
{
+ fgStructure.Window = window ;
+
+ /*
+ * Call the XWindows functions to close the window
+ */
+ fgCloseWindow ( window ) ;
+
+ /*
+ * Call the window closure callback, remove from the structure, etc.
+ */
+ fgAddToWindowDestroyList ( window, FALSE );
}
break;
* We are too dumb to process partial exposes...
*/
if( event.xexpose.count == 0 )
- fghRedrawWindowByHandle( event.xexpose.window );
+ fghRedrawWindowByHandle( window->Window.Handle );
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
*/
- GETWINDOW( xcrossing ); GETMOUSE( xcrossing );
+ GETMOUSE( xcrossing );
/*
* Is there an entry callback hooked to the window?
/*
* Mouse is no longer over one of our windows
*/
- GETWINDOW( xcrossing ); GETMOUSE( xcrossing );
+ GETMOUSE( xcrossing );
/*
* Is there an entry callback hooked to the window?
/*
* The mouse cursor was moved...
*/
- GETWINDOW( xmotion ); GETMOUSE( xmotion );
+ GETMOUSE( xmotion );
+
+ /*
+ * Set the current window
+ */
+ fgStructure.Window = window ;
/*
* What kind of a movement was it?
* A mouse button has been pressed or released. Traditionally,
* break if the window was found within the freeglut structures.
*/
- GETWINDOW( xbutton ); GETMOUSE( 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:
*/
- GETWINDOW( xkey ); GETMOUSE( xkey );
+ GETMOUSE( xkey );
if( event.type == KeyPress )
{
}
/*
- * Enters the FreeGLUT processing loop. Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
+ * Enters the freeglut processing loop. Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
*/
void FGAPIENTRY glutMainLoop( void )
{
}
/*
- * Leaves the FreeGLUT processing loop.
+ * Leaves the freeglut processing loop.
*/
void FGAPIENTRY glutLeaveMainLoop( void )
{
case WM_ACTIVATE:
if (LOWORD(wParam) != WA_INACTIVE)
{
- //glutSetCursor( fgStructure.Window->State.Cursor );
+ /* glutSetCursor( fgStructure.Window->State.Cursor ); */
printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, window->State.Cursor );
glutSetCursor( window->State.Cursor );
(fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
SetCursor( NULL );
#else
- // Set the cursor AND change it for this window class.
+ /* Set the cursor AND change it for this window class. */
# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
break;
- // Nuke the cursor AND change it for this window class.
+ /* Nuke the cursor AND change it for this window class. */
# define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
break;
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
- //MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO );
+ /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
default:
case WM_KEYDOWN:
{
int keypress = -1;
+ POINT mouse_pos ;
/*
* Ignore the automatic key repetition if needed:
( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
/*
+ * Set the mouse position
+ */
+ GetCursorPos ( &mouse_pos ) ;
+ ScreenToClient ( window->Window.Handle, &mouse_pos ) ;
+
+ window->State.MouseX = mouse_pos.x ;
+ window->State.MouseY = mouse_pos.y ;
+
+ /*
* Convert the Win32 keystroke codes to GLUTtish way
*/
# define KEY(a,b) case a: keypress = b; break;
case WM_KEYUP:
{
int keypress = -1;
+ POINT mouse_pos ;
/*
* Set the current window
( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
/*
+ * Set the mouse position
+ */
+ GetCursorPos ( &mouse_pos ) ;
+ ScreenToClient ( window->Window.Handle, &mouse_pos ) ;
+
+ window->State.MouseX = mouse_pos.x ;
+ window->State.MouseY = mouse_pos.y ;
+
+ /*
* Convert the Win32 keystroke codes to GLUTtish way. "KEY(a,b)" was defined under "WM_KEYDOWN"
*/
*/
if( window->Callbacks.KeyboardUp != NULL )
window->Callbacks.KeyboardUp( 127, window->State.MouseX, window->State.MouseY );
+
+ break ;
default:
- /*
- * Call the KeyboardUp callback for a regular character if there is one.
- */
- if( window->Callbacks.KeyboardUp != NULL )
- window->Callbacks.KeyboardUp( wParam, window->State.MouseX, window->State.MouseY );
+ {
+ /*
+ * Call the KeyboardUp callback for a regular character if there is one.
+ */
+ BYTE state[ 256 ];
+ WORD code[ 2 ];
+
+ GetKeyboardState(state);
+
+ if ( ToAscii( wParam, 0, state, code, 0 ) == 1 )
+ wParam=code[ 0 ];
+
+ if( window->Callbacks.KeyboardUp != NULL )
+ window->Callbacks.KeyboardUp( (char)wParam, window->State.MouseX, window->State.MouseY );
+ }
}
/*
/*
* Have the special callback executed:
*/
- window->Callbacks.Keyboard( wParam, window->State.MouseX, window->State.MouseY );
+ window->Callbacks.Keyboard( (char)wParam, window->State.MouseX, window->State.MouseY );
/*
* Thrash the modifiers register now
if ( window->Callbacks.Display )
window->Callbacks.Display () ;
-// lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ;
+/* lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ) ; */
break ;
/*