aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 378350710b..3360b11850 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -676,6 +676,9 @@ static Lisp_Object apply_modifiers P_ ((int, Lisp_Object));
static void clear_event P_ ((struct input_event *));
static void any_kboard_state P_ ((void));
static SIGTYPE interrupt_signal P_ ((int signalnum));
+static void timer_start_idle P_ ((void));
+static void timer_stop_idle P_ ((void));
+static void timer_resume_idle P_ ((void));
/* Nonzero means don't try to suspend even if the operating system seems
to support it. */
@@ -2387,7 +2390,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
volatile Lisp_Object also_record;
volatile int reread;
struct gcpro gcpro1, gcpro2;
- EMACS_TIME last_idle_start;
int polling_stopped_here = 0;
also_record = Qnil;
@@ -2894,9 +2896,6 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
non_reread:
- /* Record the last idle start time so that we can reset it
- should the next event read be a help-echo. */
- last_idle_start = timer_idleness_start_time;
timer_stop_idle ();
RESUME_POLLING;
@@ -2936,7 +2935,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
prevents automatic window selection (under
mouse_autoselect_window from acting as a real input event, for
example banishing the mouse under mouse-avoidance-mode. */
- timer_idleness_start_time = last_idle_start;
+ timer_resume_idle ();
/* Resume allowing input from any kboard, if that was true before. */
if (!was_locked)
@@ -3134,7 +3133,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
show_help_echo (help, window, object, position, 0);
/* We stopped being idle for this event; undo that. */
- timer_idleness_start_time = last_idle_start;
+ timer_resume_idle ();
goto retry;
}
@@ -4251,7 +4250,7 @@ swallow_events (do_display)
/* Record the start of when Emacs is idle,
for the sake of running idle-time timers. */
-void
+static void
timer_start_idle ()
{
Lisp_Object timers;
@@ -4279,12 +4278,23 @@ timer_start_idle ()
/* Record that Emacs is no longer idle, so stop running idle-time timers. */
-void
+static void
timer_stop_idle ()
{
EMACS_SET_SECS_USECS (timer_idleness_start_time, -1, -1);
}
+/* Resume idle timer from last idle start time. */
+
+static void
+timer_resume_idle ()
+{
+ if (! EMACS_TIME_NEG_P (timer_idleness_start_time))
+ return;
+
+ timer_idleness_start_time = timer_last_idleness_start_time;
+}
+
/* This is only for debugging. */
struct input_event last_timer_event;
@@ -8846,14 +8856,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
keymap may have changed, so replay the sequence. */
if (BUFFERP (key))
{
- EMACS_TIME initial_idleness_start_time;
- EMACS_SET_SECS_USECS (initial_idleness_start_time,
- EMACS_SECS (timer_last_idleness_start_time),
- EMACS_USECS (timer_last_idleness_start_time));
-
- /* Resume idle state, using the same start-time as before. */
- timer_start_idle ();
- timer_idleness_start_time = initial_idleness_start_time;
+ timer_resume_idle ();
mock_input = t;
/* Reset the current buffer from the selected window