aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index d2ab3a80249..441c23e10c7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1897,6 +1897,9 @@ int poll_suppress_count;
1897 1897
1898static struct atimer *poll_timer; 1898static struct atimer *poll_timer;
1899 1899
1900/* The poll period that constructed this timer. */
1901static Lisp_Object poll_timer_time;
1902
1900#if defined CYGWIN || defined DOS_NT 1903#if defined CYGWIN || defined DOS_NT
1901/* Poll for input, so that we catch a C-g if it comes in. */ 1904/* Poll for input, so that we catch a C-g if it comes in. */
1902void 1905void
@@ -1938,17 +1941,18 @@ start_polling (void)
1938 1941
1939 /* If poll timer doesn't exist, or we need one with 1942 /* If poll timer doesn't exist, or we need one with
1940 a different interval, start a new one. */ 1943 a different interval, start a new one. */
1941 if (poll_timer == NULL 1944 if (NUMBERP (Vpolling_period)
1942 || poll_timer->interval.tv_sec != polling_period) 1945 && (poll_timer == NULL
1946 || NILP (Fequal (Vpolling_period, poll_timer_time))))
1943 { 1947 {
1944 time_t period = max (1, min (polling_period, TYPE_MAXIMUM (time_t))); 1948 struct timespec interval = dtotimespec (XFLOATINT (Vpolling_period));
1945 struct timespec interval = make_timespec (period, 0);
1946 1949
1947 if (poll_timer) 1950 if (poll_timer)
1948 cancel_atimer (poll_timer); 1951 cancel_atimer (poll_timer);
1949 1952
1950 poll_timer = start_atimer (ATIMER_CONTINUOUS, interval, 1953 poll_timer = start_atimer (ATIMER_CONTINUOUS, interval,
1951 poll_for_input, NULL); 1954 poll_for_input, NULL);
1955 poll_timer_time = Vpolling_period;
1952 } 1956 }
1953 1957
1954 /* Let the timer's callback function poll for input 1958 /* Let the timer's callback function poll for input
@@ -2016,14 +2020,28 @@ void
2016bind_polling_period (int n) 2020bind_polling_period (int n)
2017{ 2021{
2018#ifdef POLL_FOR_INPUT 2022#ifdef POLL_FOR_INPUT
2019 intmax_t new = polling_period; 2023 if (FIXNUMP (Vpolling_period))
2024 {
2025 intmax_t new = XFIXNUM (Vpolling_period);
2026
2027 if (n > new)
2028 new = n;
2029
2030 stop_other_atimers (poll_timer);
2031 stop_polling ();
2032 specbind (Qpolling_period, make_int (new));
2033 }
2034 else if (FLOATP (Vpolling_period))
2035 {
2036 double new = XFLOAT_DATA (Vpolling_period);
2020 2037
2021 if (n > new) 2038 stop_other_atimers (poll_timer);
2022 new = n; 2039 stop_polling ();
2040 specbind (Qpolling_period, (n > new
2041 ? make_int (n)
2042 : Vpolling_period));
2043 }
2023 2044
2024 stop_other_atimers (poll_timer);
2025 stop_polling ();
2026 specbind (Qpolling_period, make_int (new));
2027 /* Start a new alarm with the new period. */ 2045 /* Start a new alarm with the new period. */
2028 start_polling (); 2046 start_polling ();
2029#endif 2047#endif
@@ -12066,6 +12084,11 @@ syms_of_keyboard (void)
12066 help_form_saved_window_configs = Qnil; 12084 help_form_saved_window_configs = Qnil;
12067 staticpro (&help_form_saved_window_configs); 12085 staticpro (&help_form_saved_window_configs);
12068 12086
12087#ifdef POLL_FOR_INPUT
12088 poll_timer_time = Qnil;
12089 staticpro (&poll_timer_time);
12090#endif
12091
12069 defsubr (&Scurrent_idle_time); 12092 defsubr (&Scurrent_idle_time);
12070 defsubr (&Sevent_symbol_parse_modifiers); 12093 defsubr (&Sevent_symbol_parse_modifiers);
12071 defsubr (&Sevent_convert_list); 12094 defsubr (&Sevent_convert_list);
@@ -12223,12 +12246,12 @@ The value may be integer or floating point.
12223If the value is zero, don't echo at all. */); 12246If the value is zero, don't echo at all. */);
12224 Vecho_keystrokes = make_fixnum (1); 12247 Vecho_keystrokes = make_fixnum (1);
12225 12248
12226 DEFVAR_INT ("polling-period", polling_period, 12249 DEFVAR_LISP ("polling-period", Vpolling_period,
12227 doc: /* Interval between polling for input during Lisp execution. 12250 doc: /* Interval between polling for input during Lisp execution.
12228The reason for polling is to make C-g work to stop a running program. 12251The reason for polling is to make C-g work to stop a running program.
12229Polling is needed only when using X windows and SIGIO does not work. 12252Polling is needed only when using X windows and SIGIO does not work.
12230Polling is automatically disabled in all other cases. */); 12253Polling is automatically disabled in all other cases. */);
12231 polling_period = 2; 12254 Vpolling_period = make_float (2.0);
12232 12255
12233 DEFVAR_LISP ("double-click-time", Vdouble_click_time, 12256 DEFVAR_LISP ("double-click-time", Vdouble_click_time,
12234 doc: /* Maximum time between mouse clicks to make a double-click. 12257 doc: /* Maximum time between mouse clicks to make a double-click.