/* The buffer that was current when the last command was started. */
Lisp_Object last_point_position_buffer;
-#ifdef MULTI_FRAME
-/* The frame in which the last input event occurred, or Qmacro if the
- last event came from a macro. We use this to determine when to
- generate switch-frame events. This may be cleared by functions
- like Fselect_frame, to make sure that a switch-frame event is
- generated by the next character. */
-Lisp_Object internal_last_event_frame;
-#endif
-
-/* A user-visible version of the above, intended to allow users to
- figure out where the last event came from, if the event doesn't
- carry that information itself (i.e. if it was a character). */
-Lisp_Object Vlast_event_frame;
-
/* The timestamp of the last input event we received from the X server.
X Windows wants this for selection ownership. */
unsigned long last_event_timestamp;
call mouse_position_hook to get the promised position, so don't set
it unless you're prepared to substantiate the claim! */
int mouse_moved;
-
-#define MOUSE_ACTIVITY_AVAILABLE (FRAMEP (do_mouse_tracking) && mouse_moved)
-#else /* Not HAVE_MOUSE. */
-#define MOUSE_ACTIVITY_AVAILABLE 0
#endif /* HAVE_MOUSE. */
/* Symbols to head events. */
internal_last_event_frame after each command is read, but
events read from a macro should never cause a new frame to be
selected. */
- Vlast_event_frame = internal_last_event_frame = Qmacro;
+ if (!current_perdisplay)
+ abort ();
+ current_perdisplay->internal_last_event_frame = Qmacro;
+ current_perdisplay->Vlast_event_frame = Qmacro;
#endif
/* Exit the macro if we are at the end.
{
XSETINT (c, quit_char);
#ifdef MULTI_FRAME
- XSETFRAME (internal_last_event_frame, selected_frame);
- Vlast_event_frame = internal_last_event_frame;
+ XSETFRAME (current_perdisplay->internal_last_event_frame,
+ selected_frame);
+ current_perdisplay->Vlast_event_frame
+ = current_perdisplay->internal_last_event_frame;
#endif
/* If we report the quit char as an event,
don't do so more than once. */
*mouse_position_hook provides the mouse position. */
static PERDISPLAY *
-find_active_event_queue ()
+find_active_event_queue (check_mouse)
+ int check_mouse;
{
PERDISPLAY *perd;
{
if (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
return perd;
+#ifdef HAVE_MOUSE
+ if (check_mouse && FRAMEP (do_mouse_tracking) && mouse_moved)
+ return perd;
+#endif
}
return 0;
}
static int
readable_events ()
{
- return find_active_event_queue () != NULL || MOUSE_ACTIVITY_AVAILABLE;
+ return find_active_event_queue (1) != NULL;
}
/* Set this for debugging, to have a way to get out */
focus = FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window));
if (NILP (focus))
- internal_last_event_frame = event->frame_or_window;
+ perd->internal_last_event_frame = event->frame_or_window;
else
- internal_last_event_frame = focus;
- Vlast_event_frame = internal_last_event_frame;
+ perd->internal_last_event_frame = focus;
+ perd->Vlast_event_frame = perd->internal_last_event_frame;
}
#endif
/* Wait until there is input available. */
for (;;)
{
- perd = find_active_event_queue ();
- if (perd || MOUSE_ACTIVITY_AVAILABLE)
+ perd = find_active_event_queue (1);
+ if (perd)
break;
/* If the quit flag is set, then read_char will return
#ifdef SIGIO
gobble_input (0);
#endif /* SIGIO */
- perd = find_active_event_queue ();
- if (!(perd || MOUSE_ACTIVITY_AVAILABLE))
+ perd = find_active_event_queue (1);
+ if (!perd)
{
Lisp_Object minus_one;
XSETINT (minus_one, -1);
wait_reading_process_input (0, 0, minus_one, 1);
- if (!interrupt_input && find_active_event_queue () == NULL)
+ if (!interrupt_input && find_active_event_queue (0) == NULL)
/* Pass 1 for EXPECT since we just waited to have input. */
read_avail_input (1);
}
/* At this point, we know that there is a readable event available
somewhere. If the event queue is empty, then there must be a
mouse movement enabled and available. */
- if (perd)
+ if (perd->kbd_fetch_ptr != perd->kbd_store_ptr)
{
struct input_event *event;
if (! NILP (focus))
frame = focus;
- if (! EQ (frame, internal_last_event_frame)
+ if (! EQ (frame, perd->internal_last_event_frame)
&& XFRAME (frame) != selected_frame)
obj = make_lispy_switch_frame (frame);
- internal_last_event_frame = frame;
+ perd->internal_last_event_frame = frame;
#endif /* MULTI_FRAME */
/* If we didn't decide to make a switch-frame event, go ahead
if (NILP (frame))
XSETFRAME (frame, f);
- if (! EQ (frame, internal_last_event_frame)
+ if (! EQ (frame, perd->internal_last_event_frame)
&& XFRAME (frame) != selected_frame)
obj = make_lispy_switch_frame (frame);
- internal_last_event_frame = frame;
+ perd->internal_last_event_frame = frame;
}
#endif
input_pending = readable_events ();
#ifdef MULTI_FRAME
- Vlast_event_frame = internal_last_event_frame;
+ perd->Vlast_event_frame = perd->internal_last_event_frame;
#endif
return (obj);
swallow_events ()
{
PERDISPLAY *perd;
- while ((perd = find_active_event_queue ()) != NULL)
+ while ((perd = find_active_event_queue (0)) != NULL)
{
struct input_event *event;
abort ();
#endif
#ifdef MULTI_FRAME
- if (FRAMEP (internal_last_event_frame)
- && XFRAME (internal_last_event_frame) != selected_frame)
- Fhandle_switch_frame (make_lispy_switch_frame (internal_last_event_frame));
+ {
+ Lisp_Object frame;
+
+ if (!current_perdisplay)
+ abort ();
+ frame = current_perdisplay->internal_last_event_frame;
+ if (FRAMEP (frame) && XFRAME (frame) != selected_frame)
+ Fhandle_switch_frame (make_lispy_switch_frame (frame));
+ }
#endif
_longjmp (getcjmp, 1);
perd->kbd_store_ptr = perd->kbd_buffer;
perd->kbd_buffer_frame_or_window
= Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
+#ifdef MULTI_FRAME
+ /* This means that command_loop_1 won't try to select anything the first
+ time through. */
+ perd->internal_last_event_frame = Qnil;
+#endif
+ perd->Vlast_event_frame = Qnil;
}
/*
#endif
input_pending = 0;
-#ifdef MULTI_FRAME
- /* This means that command_loop_1 won't try to select anything the first
- time through. */
- internal_last_event_frame = Qnil;
- Vlast_event_frame = internal_last_event_frame;
-#endif
-
#ifndef MULTI_PERDISPLAY
if (initialized)
wipe_perdisplay (&the_only_perdisplay);
"Number of complete keys read from the keyboard so far.");
num_input_keys = 0;
- DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
- "The frame in which the most recently read event occurred.\n\
-If the last event came from a keyboard macro, this is set to `macro'.");
- Vlast_event_frame = Qnil;
-
DEFVAR_LISP ("help-char", &Vhelp_char,
"Character to recognize as meaning Help.\n\
When it is read, do `(eval help-form)', and display result if it's a string.\n\
or a list whose car is a number for just one or more C-U's\n\
or nil if no argument has been specified.\n\
This is what `(interactive \"P\")' returns.");
+
+ DEFVAR_DISPLAY ("last-event-frame", Vlast_event_frame,
+ "The frame in which the most recently read event occurred.\n\
+If the last event came from a keyboard macro, this is set to `macro'.");
}
keys_of_keyboard ()