*/
static void fgSleepForEvents( void )
{
-#if TARGET_HOST_UNIX_X11
- fd_set fdset;
- int err;
- int socket;
- struct timeval wait;
- long msec;
-
+ long msec;
+
if( fgState.IdleCallback || fgHavePendingRedisplays( ) )
return;
- socket = ConnectionNumber( fgDisplay.Display );
- FD_ZERO( &fdset );
- FD_SET( socket, &fdset );
msec = fgNextTimer( );
- if( fgHaveJoystick( ) )
- msec = MIN( msec, 10 );
-
- wait.tv_sec = msec / 1000;
- wait.tv_usec = (msec % 1000) * 1000;
- err = select( socket+1, &fdset, NULL, NULL, &wait );
+ if( fgHaveJoystick( ) ) /* XXX Use GLUT timers for joysticks... */
+ msec = MIN( msec, 10 ); /* XXX Dumb; forces granularity to .01sec */
- if( -1 == err )
- fgWarning ( "freeglut select() error: %d\n", errno );
-
+#if TARGET_HOST_UNIX_X11
+ {
+ fd_set fdset;
+ int err;
+ int socket;
+ struct timeval wait;
+
+ socket = ConnectionNumber( fgDisplay.Display );
+ FD_ZERO( &fdset );
+ FD_SET( socket, &fdset );
+ wait.tv_sec = msec / 1000;
+ wait.tv_usec = (msec % 1000) * 1000;
+ err = select( socket+1, &fdset, NULL, NULL, &wait );
+
+ if( -1 == err )
+ fgWarning ( "freeglut select() error: %d\n", errno );
+ }
#elif TARGET_HOST_WIN32
+ MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLEVENTS );
#endif
}