diff options
| author | Gerd Moellmann | 2000-01-25 15:57:26 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-01-25 15:57:26 +0000 |
| commit | 8a9f5d3c42b02fa5522aa284ad121bf559fea49a (patch) | |
| tree | 8c2c07784c60ecf2a05e55da9ab606cf011d24ae /src | |
| parent | 30904ab7d1284e4936506eb72ebf92e954b841c9 (diff) | |
| download | emacs-8a9f5d3c42b02fa5522aa284ad121bf559fea49a.tar.gz emacs-8a9f5d3c42b02fa5522aa284ad121bf559fea49a.zip | |
(toplevel): Include systime.h and atimer.h.
(polling_for_input): Removed because unused.
(input_poll_signal) [POLL_FOR_INPUT]: Removed.
(poll_timer): New variable.
(poll_for_input, poll_for_input_1): New functions.
(start_polling, stop_polling): Rewritten.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index c5a760b623c..3691f1b997e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -38,6 +38,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 38 | #include "intervals.h" | 38 | #include "intervals.h" |
| 39 | #include "blockinput.h" | 39 | #include "blockinput.h" |
| 40 | #include "puresize.h" | 40 | #include "puresize.h" |
| 41 | #include "systime.h" | ||
| 42 | #include "atimer.h" | ||
| 41 | #include <setjmp.h> | 43 | #include <setjmp.h> |
| 42 | #include <errno.h> | 44 | #include <errno.h> |
| 43 | 45 | ||
| @@ -1689,37 +1691,48 @@ safe_run_hooks (hook) | |||
| 1689 | 1691 | ||
| 1690 | unbind_to (count, Qnil); | 1692 | unbind_to (count, Qnil); |
| 1691 | } | 1693 | } |
| 1694 | |||
| 1692 | 1695 | ||
| 1693 | /* Number of seconds between polling for input. */ | 1696 | /* Number of seconds between polling for input. This is a Lisp |
| 1697 | variable that can be bound. */ | ||
| 1698 | |||
| 1694 | int polling_period; | 1699 | int polling_period; |
| 1695 | 1700 | ||
| 1696 | /* Nonzero means polling for input is temporarily suppressed. */ | 1701 | /* Nonzero means polling for input is temporarily suppressed. */ |
| 1702 | |||
| 1697 | int poll_suppress_count; | 1703 | int poll_suppress_count; |
| 1698 | 1704 | ||
| 1699 | /* Nonzero if polling_for_input is actually being used. */ | 1705 | /* Asynchronous timer for polling. */ |
| 1700 | int polling_for_input; | 1706 | |
| 1707 | struct atimer *poll_timer; | ||
| 1708 | |||
| 1701 | 1709 | ||
| 1702 | #ifdef POLL_FOR_INPUT | 1710 | #ifdef POLL_FOR_INPUT |
| 1703 | 1711 | ||
| 1704 | /* Handle an alarm once each second and read pending input | 1712 | /* Poll for input, so what we catch a C-g if it comes in. This |
| 1705 | so as to handle a C-g if it comces in. */ | 1713 | function is called from x_make_frame_visible, see comment |
| 1714 | there. */ | ||
| 1706 | 1715 | ||
| 1707 | SIGTYPE | 1716 | void |
| 1708 | input_poll_signal (signalnum) /* If we don't have an argument, */ | 1717 | poll_for_input_1 () |
| 1709 | int signalnum; /* some compilers complain in signal calls. */ | ||
| 1710 | { | 1718 | { |
| 1711 | /* This causes the call to start_polling at the end | ||
| 1712 | to do its job. It also arranges for a quit or error | ||
| 1713 | from within read_avail_input to resume polling. */ | ||
| 1714 | poll_suppress_count++; | ||
| 1715 | if (interrupt_input_blocked == 0 | 1719 | if (interrupt_input_blocked == 0 |
| 1716 | && !waiting_for_input) | 1720 | && !waiting_for_input) |
| 1717 | read_avail_input (0); | 1721 | read_avail_input (0); |
| 1718 | /* Turn on the SIGALRM handler and request another alarm. */ | ||
| 1719 | start_polling (); | ||
| 1720 | } | 1722 | } |
| 1721 | 1723 | ||
| 1722 | #endif | 1724 | /* Timer callback function for poll_timer. TIMER is equal to |
| 1725 | poll_timer. */ | ||
| 1726 | |||
| 1727 | void | ||
| 1728 | poll_for_input (timer) | ||
| 1729 | struct atimer *timer; | ||
| 1730 | { | ||
| 1731 | if (poll_suppress_count == 0) | ||
| 1732 | poll_for_input_1 (); | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | #endif /* POLL_FOR_INPUT */ | ||
| 1723 | 1736 | ||
| 1724 | /* Begin signals to poll for input, if they are appropriate. | 1737 | /* Begin signals to poll for input, if they are appropriate. |
| 1725 | This function is called unconditionally from various places. */ | 1738 | This function is called unconditionally from various places. */ |
| @@ -1730,13 +1743,28 @@ start_polling () | |||
| 1730 | #ifdef POLL_FOR_INPUT | 1743 | #ifdef POLL_FOR_INPUT |
| 1731 | if (read_socket_hook && !interrupt_input) | 1744 | if (read_socket_hook && !interrupt_input) |
| 1732 | { | 1745 | { |
| 1733 | poll_suppress_count--; | 1746 | /* Turn alarm handling on unconditionally. It might have |
| 1734 | if (poll_suppress_count == 0) | 1747 | been turned off in process.c. */ |
| 1748 | turn_on_atimers (1); | ||
| 1749 | |||
| 1750 | /* If poll timer doesn't exist, are we need one with | ||
| 1751 | a different interval, start a new one. */ | ||
| 1752 | if (poll_timer == NULL | ||
| 1753 | || EMACS_SECS (poll_timer->interval) != polling_period) | ||
| 1735 | { | 1754 | { |
| 1736 | signal (SIGALRM, input_poll_signal); | 1755 | EMACS_TIME interval; |
| 1737 | polling_for_input = 1; | 1756 | |
| 1738 | alarm (polling_period); | 1757 | if (poll_timer) |
| 1758 | cancel_atimer (poll_timer); | ||
| 1759 | |||
| 1760 | EMACS_SET_SECS_USECS (interval, polling_period, 0); | ||
| 1761 | poll_timer = start_atimer (ATIMER_CONTINUOUS, interval, | ||
| 1762 | poll_for_input, NULL); | ||
| 1739 | } | 1763 | } |
| 1764 | |||
| 1765 | /* Let the timer's callback function poll for input | ||
| 1766 | if this becomes zero. */ | ||
| 1767 | --poll_suppress_count; | ||
| 1740 | } | 1768 | } |
| 1741 | #endif | 1769 | #endif |
| 1742 | } | 1770 | } |
| @@ -1760,14 +1788,7 @@ stop_polling () | |||
| 1760 | { | 1788 | { |
| 1761 | #ifdef POLL_FOR_INPUT | 1789 | #ifdef POLL_FOR_INPUT |
| 1762 | if (read_socket_hook && !interrupt_input) | 1790 | if (read_socket_hook && !interrupt_input) |
| 1763 | { | 1791 | ++poll_suppress_count; |
| 1764 | if (poll_suppress_count == 0) | ||
| 1765 | { | ||
| 1766 | polling_for_input = 0; | ||
| 1767 | alarm (0); | ||
| 1768 | } | ||
| 1769 | poll_suppress_count++; | ||
| 1770 | } | ||
| 1771 | #endif | 1792 | #endif |
| 1772 | } | 1793 | } |
| 1773 | 1794 | ||