From e8e85d268bc0334fabbcc152b96aff8bfab4204f Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 11 Jan 2004 18:09:01 +0000 Subject: [PATCH] * configure.ac src/time.c: + Look for Sleep in -lkernel32. * examples/cacaview.c: + Use caca_wait_event() instead of usleep()/caca_get_event(). --- configure.ac | 8 +++++++- examples/cacaview.c | 19 ++++++++----------- src/time.c | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 1501fca..6267e2e 100644 --- a/configure.ac +++ b/configure.ac @@ -29,7 +29,13 @@ AC_ARG_ENABLE(x11, [ --enable-x11 X11 support (autodetected)]) AC_CHECK_HEADERS(inttypes.h endian.h) -AC_CHECK_FUNCS(vsnprintf getenv putenv strcasecmp usleep Sleep gettimeofday) +AC_CHECK_FUNCS(vsnprintf getenv putenv strcasecmp usleep gettimeofday) +case "${target_os}" in + *mingw32*|*cygwin*) + AC_CHECK_LIB(kernel32, Sleep, + [AC_DEFINE(HAVE_KERNEL32_SLEEP, 1, [Define if you have Windows' Sleep])]) + ;; +esac AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm") CACA_DRIVERS="" diff --git a/examples/cacaview.c b/examples/cacaview.c index 44ac0f7..a8b70d3 100644 --- a/examples/cacaview.c +++ b/examples/cacaview.c @@ -114,7 +114,12 @@ int main(int argc, char **argv) unsigned int event, new_status = 0, new_help = 0; - while((event = caca_get_event(CACA_EVENT_KEY_PRESS))) + if(update) + event = caca_get_event(CACA_EVENT_KEY_PRESS); + else + event = caca_wait_event(CACA_EVENT_KEY_PRESS); + + while(event) { unsigned int key = event & 0x00ffffff; @@ -229,6 +234,8 @@ int main(int argc, char **argv) if(help || new_help) help = new_help; + + event = caca_get_event(CACA_EVENT_KEY_PRESS); } if(items && reload) @@ -258,16 +265,6 @@ int main(int argc, char **argv) free(buffer); } - if(!update) - { -#if defined(HAVE_USLEEP) - usleep(10000); -#elif defined(HAVE_SLEEP) - Sleep(10); -#endif - continue; - } - caca_clear(); if(!items) diff --git a/src/time.c b/src/time.c index 071234d..9208d69 100644 --- a/src/time.c +++ b/src/time.c @@ -46,7 +46,7 @@ void _caca_sleep(unsigned int usec) { #if defined(HAVE_USLEEP) usleep(usec); -#elif defined(HAVE_SLEEP) +#elif defined(HAVE_KERNEL32_SLEEP) Sleep(usec / 1000); #else SLEEP