* Indentation issues.
* Pulled some common code into a nicely packaged function. * Found some pointer/int issues. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@290 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
fa26d7b700
commit
5342fe966f
@ -1042,10 +1042,25 @@ void FGAPIENTRY glutLeaveMainLoop( void )
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP ;
|
||||
}
|
||||
|
||||
|
||||
#if TARGET_HOST_WIN32
|
||||
/*
|
||||
* Determine a GLUT modifer mask based on MS-WINDOWS system info.
|
||||
*/
|
||||
int fgGetWin32Modifiers (void)
|
||||
{
|
||||
return
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* The window procedure for handling Win32 events
|
||||
*/
|
||||
#if TARGET_HOST_WIN32
|
||||
LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
@ -1145,11 +1160,17 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
(fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
|
||||
SetCursor( NULL );
|
||||
#else
|
||||
|
||||
/* Set the cursor AND change it for this window class. */
|
||||
# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
|
||||
#define MAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( LoadCursor( NULL, b ) ); \
|
||||
break;
|
||||
|
||||
/* Nuke the cursor AND change it for this window class. */
|
||||
# define ZAP_CURSOR(a,b) case a: SetCursor( NULL ); \
|
||||
#define ZAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( NULL ); \
|
||||
break;
|
||||
|
||||
if( LOWORD( lParam ) == HTCLIENT )
|
||||
@ -1245,13 +1266,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
}
|
||||
|
||||
window->State.Modifiers =
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
if( ( wParam & MK_LBUTTON ) ||
|
||||
( wParam & MK_MBUTTON ) ||
|
||||
@ -1388,14 +1403,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
|
||||
fgSetWindow( window );
|
||||
|
||||
fgStructure.Window->State.Modifiers =
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
window->Callbacks.Mouse(
|
||||
button,
|
||||
@ -1436,13 +1444,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
|
||||
fgSetWindow( window );
|
||||
fgStructure.Window->State.Modifiers =
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
while( ticks-- )
|
||||
if( window->Callbacks.MouseWheel )
|
||||
@ -1485,13 +1487,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
* Remember the current modifiers state. This is done here in order
|
||||
* to make sure the VK_DELETE keyboard callback is executed properly.
|
||||
*/
|
||||
window->State.Modifiers =
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
GetCursorPos( &mouse_pos );
|
||||
ScreenToClient( window->Window.Handle, &mouse_pos );
|
||||
@ -1561,13 +1557,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
* Remember the current modifiers state. This is done here in order
|
||||
* to make sure the VK_DELETE keyboard callback is executed properly.
|
||||
*/
|
||||
window->State.Modifiers =
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
|
||||
GetCursorPos( &mouse_pos );
|
||||
ScreenToClient( window->Window.Handle, &mouse_pos );
|
||||
@ -1657,14 +1647,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
if( window->Callbacks.Keyboard )
|
||||
{
|
||||
fgSetWindow( window );
|
||||
window->State.Modifiers =
|
||||
( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
|
||||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
|
||||
( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
|
||||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
|
||||
( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
|
||||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
|
||||
|
||||
window->State.Modifiers = fgGetWin32Modifiers( );
|
||||
window->Callbacks.Keyboard( (char)wParam, window->State.MouseX,
|
||||
window->State.MouseY );
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
|
@ -561,7 +561,7 @@ static void fghcbWindowByID( SFG_Window *window, SFG_Enumerator *enumerator )
|
||||
/*
|
||||
* Check the window's handle. Hope this works. Looks ugly. That's for sure.
|
||||
*/
|
||||
if( window->ID == (int) (enumerator->data) )
|
||||
if( window->ID == (int) (enumerator->data) ) /* XXX int/ptr conversion! */
|
||||
{
|
||||
enumerator->found = TRUE;
|
||||
enumerator->data = window;
|
||||
@ -588,7 +588,7 @@ SFG_Window* fgWindowByID( int windowID )
|
||||
* Uses a method very similiar for fgWindowByHandle...
|
||||
*/
|
||||
enumerator.found = FALSE;
|
||||
enumerator.data = (void *) windowID;
|
||||
enumerator.data = (void *) windowID; /* XXX int/pointer conversion! */
|
||||
fgEnumWindows( fghcbWindowByID, &enumerator );
|
||||
if( enumerator.found == TRUE )
|
||||
return( SFG_Window *) enumerator.data;
|
||||
|
Reference in New Issue
Block a user