* key.c (is_idle): Check for input on input_fd and gpm_fd.

This commit is contained in:
Pavel Roskin 2002-12-25 02:01:31 +00:00
parent 5365b83ae1
commit f8958b0a61
2 changed files with 20 additions and 10 deletions

View File

@ -1,5 +1,7 @@
2002-12-24 Pavel Roskin <proski@gnu.org>
* key.c (is_idle): Check for input on input_fd and gpm_fd.
* main.c (init_xterm_support): Revert last change, it doesn't
free all S-Lang memory anyways, but creates portability issues.

View File

@ -1000,22 +1000,30 @@ application_keypad_mode (void)
}
/* A function to check if we're idle.
Currently checks only for key presses.
We could also check the mouse. */
int is_idle (void)
/*
* Check if we are idle, i.e. there are no pending keyboard or mouse
* events. Return 1 is idle, 0 is there are pending events.
*/
int
is_idle (void)
{
/* Check for incoming key presses *
* If there are any we say we're busy */
int maxfdp;
fd_set select_set;
struct timeval timeout;
FD_ZERO (&select_set);
FD_SET (0, &select_set);
FD_SET (input_fd, &select_set);
maxfdp = input_fd;
#ifdef HAVE_LIBGPM
if (use_mouse_p == MOUSE_GPM && mouse_enabled && gpm_fd != -1) {
FD_SET (gpm_fd, &select_set);
maxfdp = max (maxfdp, gpm_fd);
}
#endif
timeout.tv_sec = 0;
timeout.tv_usec = 0;
select (1, &select_set, 0, 0, &timeout);
return ! FD_ISSET (0, &select_set);
select (maxfdp, &select_set, 0, 0, &timeout);
return !FD_ISSET (0, &select_set);
}