diff options
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 378350710b9..3360b11850e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -676,6 +676,9 @@ static Lisp_Object apply_modifiers P_ ((int, Lisp_Object)); | |||
| 676 | static void clear_event P_ ((struct input_event *)); | 676 | static void clear_event P_ ((struct input_event *)); |
| 677 | static void any_kboard_state P_ ((void)); | 677 | static void any_kboard_state P_ ((void)); |
| 678 | static SIGTYPE interrupt_signal P_ ((int signalnum)); | 678 | static SIGTYPE interrupt_signal P_ ((int signalnum)); |
| 679 | static void timer_start_idle P_ ((void)); | ||
| 680 | static void timer_stop_idle P_ ((void)); | ||
| 681 | static void timer_resume_idle P_ ((void)); | ||
| 679 | 682 | ||
| 680 | /* Nonzero means don't try to suspend even if the operating system seems | 683 | /* Nonzero means don't try to suspend even if the operating system seems |
| 681 | to support it. */ | 684 | to support it. */ |
| @@ -2387,7 +2390,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2387 | volatile Lisp_Object also_record; | 2390 | volatile Lisp_Object also_record; |
| 2388 | volatile int reread; | 2391 | volatile int reread; |
| 2389 | struct gcpro gcpro1, gcpro2; | 2392 | struct gcpro gcpro1, gcpro2; |
| 2390 | EMACS_TIME last_idle_start; | ||
| 2391 | int polling_stopped_here = 0; | 2393 | int polling_stopped_here = 0; |
| 2392 | 2394 | ||
| 2393 | also_record = Qnil; | 2395 | also_record = Qnil; |
| @@ -2894,9 +2896,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2894 | 2896 | ||
| 2895 | non_reread: | 2897 | non_reread: |
| 2896 | 2898 | ||
| 2897 | /* Record the last idle start time so that we can reset it | ||
| 2898 | should the next event read be a help-echo. */ | ||
| 2899 | last_idle_start = timer_idleness_start_time; | ||
| 2900 | timer_stop_idle (); | 2899 | timer_stop_idle (); |
| 2901 | RESUME_POLLING; | 2900 | RESUME_POLLING; |
| 2902 | 2901 | ||
| @@ -2936,7 +2935,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2936 | prevents automatic window selection (under | 2935 | prevents automatic window selection (under |
| 2937 | mouse_autoselect_window from acting as a real input event, for | 2936 | mouse_autoselect_window from acting as a real input event, for |
| 2938 | example banishing the mouse under mouse-avoidance-mode. */ | 2937 | example banishing the mouse under mouse-avoidance-mode. */ |
| 2939 | timer_idleness_start_time = last_idle_start; | 2938 | timer_resume_idle (); |
| 2940 | 2939 | ||
| 2941 | /* Resume allowing input from any kboard, if that was true before. */ | 2940 | /* Resume allowing input from any kboard, if that was true before. */ |
| 2942 | if (!was_locked) | 2941 | if (!was_locked) |
| @@ -3134,7 +3133,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 3134 | show_help_echo (help, window, object, position, 0); | 3133 | show_help_echo (help, window, object, position, 0); |
| 3135 | 3134 | ||
| 3136 | /* We stopped being idle for this event; undo that. */ | 3135 | /* We stopped being idle for this event; undo that. */ |
| 3137 | timer_idleness_start_time = last_idle_start; | 3136 | timer_resume_idle (); |
| 3138 | goto retry; | 3137 | goto retry; |
| 3139 | } | 3138 | } |
| 3140 | 3139 | ||
| @@ -4251,7 +4250,7 @@ swallow_events (do_display) | |||
| 4251 | /* Record the start of when Emacs is idle, | 4250 | /* Record the start of when Emacs is idle, |
| 4252 | for the sake of running idle-time timers. */ | 4251 | for the sake of running idle-time timers. */ |
| 4253 | 4252 | ||
| 4254 | void | 4253 | static void |
| 4255 | timer_start_idle () | 4254 | timer_start_idle () |
| 4256 | { | 4255 | { |
| 4257 | Lisp_Object timers; | 4256 | Lisp_Object timers; |
| @@ -4279,12 +4278,23 @@ timer_start_idle () | |||
| 4279 | 4278 | ||
| 4280 | /* Record that Emacs is no longer idle, so stop running idle-time timers. */ | 4279 | /* Record that Emacs is no longer idle, so stop running idle-time timers. */ |
| 4281 | 4280 | ||
| 4282 | void | 4281 | static void |
| 4283 | timer_stop_idle () | 4282 | timer_stop_idle () |
| 4284 | { | 4283 | { |
| 4285 | EMACS_SET_SECS_USECS (timer_idleness_start_time, -1, -1); | 4284 | EMACS_SET_SECS_USECS (timer_idleness_start_time, -1, -1); |
| 4286 | } | 4285 | } |
| 4287 | 4286 | ||
| 4287 | /* Resume idle timer from last idle start time. */ | ||
| 4288 | |||
| 4289 | static void | ||
| 4290 | timer_resume_idle () | ||
| 4291 | { | ||
| 4292 | if (! EMACS_TIME_NEG_P (timer_idleness_start_time)) | ||
| 4293 | return; | ||
| 4294 | |||
| 4295 | timer_idleness_start_time = timer_last_idleness_start_time; | ||
| 4296 | } | ||
| 4297 | |||
| 4288 | /* This is only for debugging. */ | 4298 | /* This is only for debugging. */ |
| 4289 | struct input_event last_timer_event; | 4299 | struct input_event last_timer_event; |
| 4290 | 4300 | ||
| @@ -8846,14 +8856,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8846 | keymap may have changed, so replay the sequence. */ | 8856 | keymap may have changed, so replay the sequence. */ |
| 8847 | if (BUFFERP (key)) | 8857 | if (BUFFERP (key)) |
| 8848 | { | 8858 | { |
| 8849 | EMACS_TIME initial_idleness_start_time; | 8859 | timer_resume_idle (); |
| 8850 | EMACS_SET_SECS_USECS (initial_idleness_start_time, | ||
| 8851 | EMACS_SECS (timer_last_idleness_start_time), | ||
| 8852 | EMACS_USECS (timer_last_idleness_start_time)); | ||
| 8853 | |||
| 8854 | /* Resume idle state, using the same start-time as before. */ | ||
| 8855 | timer_start_idle (); | ||
| 8856 | timer_idleness_start_time = initial_idleness_start_time; | ||
| 8857 | 8860 | ||
| 8858 | mock_input = t; | 8861 | mock_input = t; |
| 8859 | /* Reset the current buffer from the selected window | 8862 | /* Reset the current buffer from the selected window |