From 5d5ba0e9e9279b128971c1b023ec260567518032 Mon Sep 17 00:00:00 2001 From: rkrolib Date: Tue, 30 Dec 2003 10:57:01 +0000 Subject: [PATCH] Hm... I thought that I committed this last night. What's up? This is Nigel's modified fgSleepForEvents(), essentially. Take 2. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@435 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/freeglut_main.c | 39 ++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/freeglut/freeglut/src/freeglut_main.c b/freeglut/freeglut/src/freeglut_main.c index 6375448..16248b5 100644 --- a/freeglut/freeglut/src/freeglut_main.c +++ b/freeglut/freeglut/src/freeglut_main.c @@ -450,31 +450,34 @@ static long fgNextTimer( void ) */ 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 ); + if( fgHaveJoystick( ) ) /* XXX Use GLUT timers for joysticks... */ + msec = MIN( msec, 10 ); /* XXX Dumb; forces granularity to .01sec */ - wait.tv_sec = msec / 1000; - wait.tv_usec = (msec % 1000) * 1000; - err = select( socket+1, &fdset, NULL, NULL, &wait ); +#if TARGET_HOST_UNIX_X11 + { + fd_set fdset; + int err; + int socket; + struct timeval wait; - if( -1 == err ) - fgWarning ( "freeglut select() error: %d\n", errno ); - + 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 }