X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2FCommon%2Ffreeglut_main.c;h=66281ea71812108a55b42aa5fa0f0a7f2648e8c6;hb=814beaa77f437cf4cf6cac9f748235488f6478a1;hp=e7b4cb8e651ab1c50b80c3a77e865ddf72c73889;hpb=6ff4a7eb4780b498d9630d343d6302b76af8e8c5;p=freeglut diff --git a/src/Common/freeglut_main.c b/src/Common/freeglut_main.c index e7b4cb8..66281ea 100644 --- a/src/Common/freeglut_main.c +++ b/src/Common/freeglut_main.c @@ -70,18 +70,12 @@ struct GXKeyList gxKeyList; # define MIN(a,b) (((a)<(b)) ? (a) : (b)) #endif -#ifdef WM_TOUCH - typedef BOOL (WINAPI *pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int); - typedef BOOL (WINAPI *pCloseTouchInputHandle)(HTOUCHINPUT); - static pGetTouchInputInfo fghGetTouchInputInfo = (pGetTouchInputInfo)0xDEADBEEF; - static pCloseTouchInputHandle fghCloseTouchInputHandle = (pCloseTouchInputHandle)0xDEADBEEF; -#endif - -extern void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height ); -extern void fghcbPlatformDisplayWindow ( SFG_Window *window ); -extern void fghPlatformSleepForEvents( long msec ); -extern void fghProcessSingleEvent ( void ); -extern void fghMainLoopPreliminaryWork ( void ); +extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ); +extern void fgPlatformDisplayWindow ( SFG_Window *window ); +extern unsigned long fgPlatformSystemTime ( void ); +extern void fgPlatformSleepForEvents( long msec ); +extern void fgPlatformProcessSingleEvent ( void ); +extern void fgPlatformMainLoopPreliminaryWork ( void ); /* @@ -103,11 +97,11 @@ extern void fghMainLoopPreliminaryWork ( void ); * match the new window size. */ #if TARGET_HOST_POSIX_X11 -static void fghPlatformReshapeWindow ( SFG_Window *window, int width, int height ) +void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) { - XResizeWindow( fgDisplay.Display, window->Window.Handle, + XResizeWindow( fgDisplay.pDisplay.Display, window->Window.Handle, width, height ); - XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */ + XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ } #endif @@ -117,7 +111,7 @@ static void fghReshapeWindow ( SFG_Window *window, int width, int height ) freeglut_return_if_fail( window != NULL ); - fghPlatformReshapeWindow ( window, width, height ); + fgPlatformReshapeWindow ( window, width, height ); if( FETCH_WCB( *window, Reshape ) ) INVOKE_WCB( *window, Reshape, ( width, height ) ); @@ -177,10 +171,20 @@ void fghRedrawWindow ( SFG_Window *window ) * A static helper function to execute display callback for a window */ #if TARGET_HOST_POSIX_X11 -static void fghcbPlatformDisplayWindow ( SFG_Window *window ) +void fgPlatformDisplayWindow ( SFG_Window *window ) { fghRedrawWindow ( window ) ; } + + +unsigned long fgPlatformSystemTime ( void ) +{ +#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY + struct timeval now; + gettimeofday( &now, NULL ); + return now.tv_usec/1000 + now.tv_sec*1000; +#endif +} #endif static void fghcbDisplayWindow( SFG_Window *window, @@ -190,7 +194,7 @@ static void fghcbDisplayWindow( SFG_Window *window, window->State.Visible ) { window->State.Redisplay = GL_FALSE; - fghcbPlatformDisplayWindow ( window ); + fgPlatformDisplayWindow ( window ); } fgEnumSubWindows( window, fghcbDisplayWindow, enumerator ); @@ -269,18 +273,9 @@ static void fghCheckTimers( void ) * when subtracting an initial start time, unless the total time exceeds * 32-bit, where the GLUT API return value is also overflowed. */ -unsigned long fgSystemTime(void) { -#if TARGET_HOST_SOLARIS || HAVE_GETTIMEOFDAY - struct timeval now; - gettimeofday( &now, NULL ); - return now.tv_usec/1000 + now.tv_sec*1000; -#elif TARGET_HOST_MS_WINDOWS -# if defined(_WIN32_WCE) - return GetTickCount(); -# else - return timeGetTime(); -# endif -#endif +unsigned long fgSystemTime(void) +{ + return fgPlatformSystemTime (); } /* @@ -423,7 +418,7 @@ static long fghNextTimer( void ) */ #if TARGET_HOST_POSIX_X11 -static void fghPlatformSleepForEvents( long msec ) +void fgPlatformSleepForEvents( long msec ) { /* * Possibly due to aggressive use of XFlush() and friends, @@ -434,14 +429,14 @@ static void fghPlatformSleepForEvents( long msec ) * need to allow that we may have an empty socket but non- * empty event queue. */ - if( ! XPending( fgDisplay.Display ) ) + if( ! XPending( fgDisplay.pDisplay.Display ) ) { fd_set fdset; int err; int socket; struct timeval wait; - socket = ConnectionNumber( fgDisplay.Display ); + socket = ConnectionNumber( fgDisplay.pDisplay.Display ); FD_ZERO( &fdset ); FD_SET( socket, &fdset ); wait.tv_sec = msec / 1000; @@ -469,14 +464,14 @@ static void fghSleepForEvents( void ) if( fghHaveJoystick( ) && ( msec > 10 ) ) msec = 10; - fghPlatformSleepForEvents ( msec ); + fgPlatformSleepForEvents ( msec ); } #if TARGET_HOST_POSIX_X11 /* * Returns GLUT modifier mask for the state field of an X11 event. */ -int fghGetModifiers( int state ) +int fgPlatformGetModifiers( int state ) { int ret = 0; @@ -933,7 +928,7 @@ static void fghPrintEvent( XEvent *event ) } -void fghProcessSingleEvent ( void ) +void fgPlatformProcessSingleEvent ( void ) { SFG_Window* window; XEvent event; @@ -950,9 +945,9 @@ void fghProcessSingleEvent ( void ) FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" ); - while( XPending( fgDisplay.Display ) ) + while( XPending( fgDisplay.pDisplay.Display ) ) { - XNextEvent( fgDisplay.Display, &event ); + XNextEvent( fgDisplay.pDisplay.Display, &event ); #if _DEBUG fghPrintEvent( &event ); #endif @@ -965,7 +960,7 @@ void fghProcessSingleEvent ( void ) break; } /* Destroy the window when the WM_DELETE_WINDOW message arrives */ - if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow ) + if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.pDisplay.DeleteWindow ) { GETWINDOW( xclient ); @@ -1006,13 +1001,13 @@ void fghProcessSingleEvent ( void ) height = event.xconfigure.height; } - if( ( width != window->State.OldWidth ) || - ( height != window->State.OldHeight ) ) + if( ( width != window->State.pWState.OldWidth ) || + ( height != window->State.pWState.OldHeight ) ) { SFG_Window *current_window = fgStructure.CurrentWindow; - window->State.OldWidth = width; - window->State.OldHeight = height; + window->State.pWState.OldWidth = width; + window->State.pWState.OldHeight = height; if( FETCH_WCB( *window, Reshape ) ) INVOKE_WCB( *window, Reshape, ( width, height ) ); else @@ -1147,7 +1142,7 @@ void fghProcessSingleEvent ( void ) * XXX track ButtonPress/ButtonRelease events in our own * XXX bit-mask? */ - fgState.Modifiers = fghGetModifiers( event.xmotion.state ); + fgState.Modifiers = fgPlatformGetModifiers( event.xmotion.state ); if ( event.xmotion.state & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) ) { INVOKE_WCB( *window, Motion, ( event.xmotion.x, event.xmotion.y ) ); @@ -1201,7 +1196,7 @@ void fghProcessSingleEvent ( void ) ! FETCH_WCB( *window, MouseWheel ) ) break; - fgState.Modifiers = fghGetModifiers( event.xbutton.state ); + fgState.Modifiers = fgPlatformGetModifiers( event.xbutton.state ); /* Finally execute the mouse or mouse wheel callback */ if( ( button < glutDeviceGet ( GLUT_NUM_MOUSE_BUTTONS ) ) || ( ! FETCH_WCB( *window, MouseWheel ) ) ) @@ -1263,7 +1258,7 @@ void fghProcessSingleEvent ( void ) */ char keys[32]; - XQueryKeymap( fgDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */ + XQueryKeymap( fgDisplay.pDisplay.Display, keys ); /* Look at X11 keystate to detect repeat mode */ if ( event.xkey.keycode<256 ) /* XQueryKeymap is limited to 256 keycodes */ { @@ -1316,7 +1311,7 @@ void fghProcessSingleEvent ( void ) if( keyboard_cb ) { fgSetWindow( window ); - fgState.Modifiers = fghGetModifiers( event.xkey.state ); + fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state ); keyboard_cb( asciiCode[ 0 ], event.xkey.x, event.xkey.y ); @@ -1385,7 +1380,7 @@ void fghProcessSingleEvent ( void ) if( special_cb && (special != -1) ) { fgSetWindow( window ); - fgState.Modifiers = fghGetModifiers( event.xkey.state ); + fgState.Modifiers = fgPlatformGetModifiers( event.xkey.state ); special_cb( special, event.xkey.x, event.xkey.y ); fgState.Modifiers = INVALID_MODIFIERS; } @@ -1412,7 +1407,7 @@ void fghProcessSingleEvent ( void ) } -static void fghMainLoopPreliminaryWork ( void ) +void fgPlatformMainLoopPreliminaryWork ( void ) { } #endif @@ -1424,7 +1419,7 @@ static void fghMainLoopPreliminaryWork ( void ) */ void FGAPIENTRY glutMainLoopEvent( void ) { - fghProcessSingleEvent (); + fgPlatformProcessSingleEvent (); if( fgState.Timers.First ) fghCheckTimers( ); @@ -1444,7 +1439,7 @@ void FGAPIENTRY glutMainLoop( void ) FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" ); - fghMainLoopPreliminaryWork (); + fgPlatformMainLoopPreliminaryWork (); fgState.ExecState = GLUT_EXEC_STATE_RUNNING ; while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )