improved comments and mouse coord adjustments (John Fay)

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@521 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
brianp 2004-10-05 22:06:22 +00:00
parent 6f4c8c6ed3
commit 2a1a8f1a36
3 changed files with 37 additions and 42 deletions

View File

@ -594,11 +594,8 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
} }
} }
/* /* Compact {argv}. */
* Compact {argv}. for( i = j = 1; i < *pargc; i++, j++ )
*/
j = 1;
for( i = 1; i < *pargc; i++, j++ )
{ {
/* Guaranteed to end because there are "*pargc" arguments left */ /* Guaranteed to end because there are "*pargc" arguments left */
while ( argv[ j ] == NULL ) while ( argv[ j ] == NULL )

View File

@ -944,9 +944,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
special_cb = FETCH_WCB( *window, SpecialUp ); special_cb = FETCH_WCB( *window, SpecialUp );
} }
/* /* Is there a keyboard/special callback hooked for this window? */
* Is there a keyboard/special callback hooked for this window?
*/
if( keyboard_cb || special_cb ) if( keyboard_cb || special_cb )
{ {
XComposeStatus composeStatus; XComposeStatus composeStatus;
@ -954,21 +952,15 @@ void FGAPIENTRY glutMainLoopEvent( void )
KeySym keySym; KeySym keySym;
int len; int len;
/* /* Check for the ASCII/KeySym codes associated with the event: */
* Check for the ASCII/KeySym codes associated with the event:
*/
len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode), len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
&keySym, &composeStatus &keySym, &composeStatus
); );
/* /* GLUT API tells us to have two separate callbacks... */
* GLUT API tells us to have two separate callbacks...
*/
if( len > 0 ) if( len > 0 )
{ {
/* /* ...one for the ASCII translateable keypresses... */
* ...one for the ASCII translateable keypresses...
*/
if( keyboard_cb ) if( keyboard_cb )
{ {
fgSetWindow( window ); fgSetWindow( window );
@ -1311,7 +1303,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
* XXX function (or perhaps invoke glutSetCursor())? * XXX function (or perhaps invoke glutSetCursor())?
* XXX That is, why are we duplicating code, here, from * XXX That is, why are we duplicating code, here, from
* XXX glutSetCursor()? The WIN32 code should be able to just * XXX glutSetCursor()? The WIN32 code should be able to just
* XXX call glutSetCurdsor() instead of defining two macros * XXX call glutSetCursor() instead of defining two macros
* XXX and implementing a nested case in-line. * XXX and implementing a nested case in-line.
*/ */
case WM_SETCURSOR: case WM_SETCURSOR:
@ -1384,6 +1376,10 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
window->State.MouseX = LOWORD( lParam ); window->State.MouseX = LOWORD( lParam );
window->State.MouseY = HIWORD( lParam ); window->State.MouseY = HIWORD( lParam );
#endif /* TARGET_HOST_WINCE */ #endif /* TARGET_HOST_WINCE */
/* Restrict to [-32768, 32767] to match X11 behaviour */
/* See comment in "freeglut_developer" mailing list 10/4/04 */
if ( window->State.MouseX > 32767 ) window->State.MouseX -= 65536;
if ( window->State.MouseY > 32767 ) window->State.MouseY -= 65536;
if ( window->ActiveMenu ) if ( window->ActiveMenu )
{ {
@ -1425,6 +1421,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
window->State.MouseY = HIWORD( lParam ); window->State.MouseY = HIWORD( lParam );
#endif /* TARGET_HOST_WINCE */ #endif /* TARGET_HOST_WINCE */
/* Restrict to [-32768, 32767] to match X11 behaviour */
/* See comment in "freeglut_developer" mailing list 10/4/04 */
if ( window->State.MouseX > 32767 ) window->State.MouseX -= 65536;
if ( window->State.MouseY > 32767 ) window->State.MouseY -= 65536;
switch( uMsg ) switch( uMsg )
{ {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
@ -1540,6 +1541,19 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break; break;
} }
/* Set capture so that the window captures all the mouse messages */
/*
* XXX - Multiple button support: Under X11, the mouse is not released
* XXX - from the window until all buttons have been released, even if the
* XXX - user presses a button in another window. This will take more
* XXX - code changes than I am up to at the moment (10/5/04). The present
* XXX - is a 90 percent solution.
*/
if ( pressed == GL_TRUE )
SetCapture ( window->Window.Handle ) ;
else
ReleaseCapture () ;
if( ! FETCH_WCB( *window, Mouse ) ) if( ! FETCH_WCB( *window, Mouse ) )
break; break;
@ -1644,9 +1658,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
window->State.MouseX = mouse_pos.x; window->State.MouseX = mouse_pos.x;
window->State.MouseY = mouse_pos.y; window->State.MouseY = mouse_pos.y;
/* /* Convert the Win32 keystroke codes to GLUTtish way */
* Convert the Win32 keystroke codes to GLUTtish way
*/
# define KEY(a,b) case a: keypress = b; break; # define KEY(a,b) case a: keypress = b; break;
switch( wParam ) switch( wParam )
@ -1674,9 +1686,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
KEY( VK_INSERT, GLUT_KEY_INSERT ); KEY( VK_INSERT, GLUT_KEY_INSERT );
case VK_DELETE: case VK_DELETE:
/* /* The delete key should be treated as an ASCII keypress: */
* The delete key should be treated as an ASCII keypress:
*/
INVOKE_WCB( *window, Keyboard, INVOKE_WCB( *window, Keyboard,
( 127, window->State.MouseX, window->State.MouseY ) ( 127, window->State.MouseX, window->State.MouseY )
); );
@ -1762,9 +1772,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
KEY( VK_INSERT, GLUT_KEY_INSERT ); KEY( VK_INSERT, GLUT_KEY_INSERT );
case VK_DELETE: case VK_DELETE:
/* /* The delete key should be treated as an ASCII keypress: */
* The delete key should be treated as an ASCII keypress:
*/
INVOKE_WCB( *window, KeyboardUp, INVOKE_WCB( *window, KeyboardUp,
( 127, window->State.MouseX, window->State.MouseY ) ( 127, window->State.MouseX, window->State.MouseY )
); );
@ -1821,9 +1829,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
/*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */ /*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */
break; break;
/* /* Other messages that I have seen and which are not handled already */
* Other messages that I have seen and which are not handled already
*/
case WM_SETTEXT: /* 0x000c */ case WM_SETTEXT: /* 0x000c */
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
/* Pass it on to "DefWindowProc" to set the window text */ /* Pass it on to "DefWindowProc" to set the window text */
@ -1942,9 +1948,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break; break;
default: default:
/* /* Handle unhandled messages */
* Handle unhandled messages
*/
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
break; break;
} }

View File

@ -87,9 +87,7 @@ XVisualInfo* fgChooseVisual( void )
int attributes[ 32 ]; int attributes[ 32 ];
int where = 0; int where = 0;
/* /* First we have to process the display mode settings... */
* First we have to process the display mode settings...
*/
/* /*
* XXX Why is there a semi-colon in this #define? The code * XXX Why is there a semi-colon in this #define? The code
* XXX that uses the macro seems to always add more semicolons... * XXX that uses the macro seems to always add more semicolons...
@ -133,9 +131,7 @@ XVisualInfo* fgChooseVisual( void )
ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 ); ATTRIB_VAL( GLX_ACCUM_ALPHA_SIZE, 1 );
} }
/* /* Push a null at the end of the list */
* Push a null at the end of the list
*/
ATTRIB( None ); ATTRIB( None );
if( ! wantIndexedMode ) if( ! wantIndexedMode )
@ -186,9 +182,7 @@ GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
#pragma message( "fgSetupPixelFormat(): there is still some work to do here!" ) #pragma message( "fgSetupPixelFormat(): there is still some work to do here!" )
#endif #endif
/* /* Specify which pixel format do we opt for... */
* Specify which pixel format do we opt for...
*/
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1; pfd.nVersion = 1;
pfd.dwFlags = flags; pfd.dwFlags = flags;