/* Circular buffer for pre-read keyboard input. */
-static struct input_event kbd_buffer[KBD_BUFFER_SIZE];
+static union buffered_input_event kbd_buffer[KBD_BUFFER_SIZE];
/* Pointer to next available character in kbd_buffer.
If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty.
This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the
next available char is in kbd_buffer[0]. */
-static struct input_event *kbd_fetch_ptr;
+static union buffered_input_event *kbd_fetch_ptr;
/* Pointer to next place to store character in kbd_buffer. This
may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the next
character should go in kbd_buffer[0]. */
-static struct input_event * volatile kbd_store_ptr;
+static union buffered_input_event *volatile kbd_store_ptr;
/* The above pair of variables forms a "queue empty" flag. When we
enqueue a non-hook event, we increment kbd_store_ptr. When we
static void save_getcjmp (sys_jmp_buf);
static void restore_getcjmp (sys_jmp_buf);
static Lisp_Object apply_modifiers (int, Lisp_Object);
-static void clear_event (struct input_event *);
static void restore_kboard_configuration (int);
-#ifdef USABLE_SIGIO
-static void deliver_input_available_signal (int signo);
-#endif
static void handle_interrupt (bool);
static _Noreturn void quit_throw_to_read_char (bool);
-static void process_special_events (void);
static void timer_start_idle (void);
static void timer_stop_idle (void);
static void timer_resume_idle (void);
#endif
))
{
- struct input_event *event;
+ union buffered_input_event *event;
event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
? kbd_fetch_ptr
&& !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
&& (event->kind == SCROLL_BAR_CLICK_EVENT
|| event->kind == HORIZONTAL_SCROLL_BAR_CLICK_EVENT)
- && event->part == scroll_bar_handle
- && event->modifiers == 0)
+ && event->ie.part == scroll_bar_handle
+ && event->ie.modifiers == 0)
#endif
&& !((flags & READABLE_EVENTS_FILTER_EVENTS)
&& event->kind == BUFFER_SWITCH_EVENT))
subsequent input events have been parsed (and discarded). */
void
-kbd_buffer_store_event_hold (register struct input_event *event,
- struct input_event *hold_quit)
+kbd_buffer_store_buffered_event (union buffered_input_event *event,
+ struct input_event *hold_quit)
{
if (event->kind == NO_EVENT)
emacs_abort ();
if (event->kind == ASCII_KEYSTROKE_EVENT)
{
- register int c = event->code & 0377;
+ int c = event->ie.code & 0377;
- if (event->modifiers & ctrl_modifier)
+ if (event->ie.modifiers & ctrl_modifier)
c = make_ctrl_char (c);
- c |= (event->modifiers
+ c |= (event->ie.modifiers
& (meta_modifier | alt_modifier
| hyper_modifier | super_modifier));
if (c == quit_char)
{
- KBOARD *kb = FRAME_KBOARD (XFRAME (event->frame_or_window));
- struct input_event *sp;
+ KBOARD *kb = FRAME_KBOARD (XFRAME (event->ie.frame_or_window));
if (single_kboard && kb != current_kboard)
{
kset_kbd_queue
- (kb, list2 (make_lispy_switch_frame (event->frame_or_window),
+ (kb, list2 (make_lispy_switch_frame (event->ie.frame_or_window),
make_number (c)));
kb->kbd_queue_has_data = 1;
+ union buffered_input_event *sp;
for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
{
if (sp == kbd_buffer + KBD_BUFFER_SIZE)
sp = kbd_buffer;
- if (event_to_kboard (sp) == kb)
+ if (event_to_kboard (&sp->ie) == kb)
{
- sp->kind = NO_EVENT;
- sp->frame_or_window = Qnil;
- sp->arg = Qnil;
+ sp->ie.kind = NO_EVENT;
+ sp->ie.frame_or_window = Qnil;
+ sp->ie.arg = Qnil;
}
}
return;
if (hold_quit)
{
- *hold_quit = *event;
+ *hold_quit = event->ie;
return;
}
{
Lisp_Object focus;
- focus = FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window));
+ focus = FRAME_FOCUS_FRAME (XFRAME (event->ie.frame_or_window));
if (NILP (focus))
- focus = event->frame_or_window;
+ focus = event->ie.frame_or_window;
internal_last_event_frame = focus;
Vlast_event_frame = focus;
}
}
-/* Put an input event back in the head of the event queue. */
+#ifdef HAVE_X11
+
+/* Put a selection input event back in the head of the event queue. */
void
-kbd_buffer_unget_event (register struct input_event *event)
+kbd_buffer_unget_event (struct selection_input_event *event)
{
if (kbd_fetch_ptr == kbd_buffer)
kbd_fetch_ptr = kbd_buffer + KBD_BUFFER_SIZE;
/* Don't let the very last slot in the buffer become full, */
- if (kbd_fetch_ptr - 1 != kbd_store_ptr)
+ union buffered_input_event *kp = kbd_fetch_ptr - 1;
+ if (kp != kbd_store_ptr)
{
- --kbd_fetch_ptr;
- *kbd_fetch_ptr = *event;
+ kp->sie = *event;
+ kbd_fetch_ptr = kp;
}
}
+#endif
+
/* Limit help event positions to this range, to avoid overflow problems. */
#define INPUT_EVENT_POS_MAX \
((ptrdiff_t) min (PTRDIFF_MAX, min (TYPE_MAXIMUM (Time) / 2, \
void
discard_mouse_events (void)
{
- struct input_event *sp;
+ union buffered_input_event *sp;
for (sp = kbd_fetch_ptr; sp != kbd_store_ptr; sp++)
{
if (sp == kbd_buffer + KBD_BUFFER_SIZE)
bool
kbd_buffer_events_waiting (void)
{
- struct input_event *sp;
+ union buffered_input_event *sp;
for (sp = kbd_fetch_ptr;
sp != kbd_store_ptr && sp->kind == NO_EVENT;
/* Clear input event EVENT. */
static void
-clear_event (struct input_event *event)
+clear_event (union buffered_input_event *event)
{
event->kind = NO_EVENT;
}
mouse movement enabled and available. */
if (kbd_fetch_ptr != kbd_store_ptr)
{
- struct input_event *event;
+ union buffered_input_event *event;
event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
? kbd_fetch_ptr
: kbd_buffer);
- *kbp = event_to_kboard (event);
+ *kbp = event_to_kboard (&event->ie);
if (*kbp == 0)
*kbp = current_kboard; /* Better than returning null ptr? */
|| event->kind == SELECTION_CLEAR_EVENT)
{
#ifdef HAVE_X11
- struct input_event copy;
-
/* Remove it from the buffer before processing it,
since otherwise swallow_events will see it
and process it again. */
- copy = *event;
+ struct selection_input_event copy = event->sie;
kbd_fetch_ptr = event + 1;
input_pending = readable_events (0);
x_handle_selection_event (©);
#if defined (HAVE_NS)
else if (event->kind == NS_TEXT_EVENT)
{
- if (event->code == KEY_NS_PUT_WORKING_TEXT)
+ if (event->ie.code == KEY_NS_PUT_WORKING_TEXT)
obj = list1 (intern ("ns-put-working-text"));
else
obj = list1 (intern ("ns-unput-working-text"));
else if (event->kind == DELETE_WINDOW_EVENT)
{
/* Make an event (delete-frame (FRAME)). */
- obj = list2 (Qdelete_frame, list1 (event->frame_or_window));
+ obj = list2 (Qdelete_frame, list1 (event->ie.frame_or_window));
kbd_fetch_ptr = event + 1;
}
#endif
else if (event->kind == ICONIFY_EVENT)
{
/* Make an event (iconify-frame (FRAME)). */
- obj = list2 (Qiconify_frame, list1 (event->frame_or_window));
+ obj = list2 (Qiconify_frame, list1 (event->ie.frame_or_window));
kbd_fetch_ptr = event + 1;
}
else if (event->kind == DEICONIFY_EVENT)
{
/* Make an event (make-frame-visible (FRAME)). */
- obj = list2 (Qmake_frame_visible, list1 (event->frame_or_window));
+ obj = list2 (Qmake_frame_visible, list1 (event->ie.frame_or_window));
kbd_fetch_ptr = event + 1;
}
#endif
{
kbd_fetch_ptr = event + 1;
input_pending = readable_events (0);
- if (FRAME_LIVE_P (XFRAME (event->frame_or_window)))
- x_activate_menubar (XFRAME (event->frame_or_window));
+ if (FRAME_LIVE_P (XFRAME (event->ie.frame_or_window)))
+ x_activate_menubar (XFRAME (event->ie.frame_or_window));
}
#endif
#ifdef HAVE_NTGUI
{
/* Make an event (language-change FRAME CODEPAGE LANGUAGE-ID). */
obj = list4 (Qlanguage_change,
- event->frame_or_window,
- make_number (event->code),
- make_number (event->modifiers));
+ event->ie.frame_or_window,
+ make_number (event->ie.code),
+ make_number (event->ie.modifiers));
kbd_fetch_ptr = event + 1;
}
#endif
{
#ifdef HAVE_W32NOTIFY
/* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK). */
- obj = list3 (Qfile_notify, event->arg, event->frame_or_window);
+ obj = list3 (Qfile_notify, event->ie.arg, event->ie.frame_or_window);
#else
- obj = make_lispy_event (event);
+ obj = make_lispy_event (&event->ie);
#endif
kbd_fetch_ptr = event + 1;
}
#endif /* USE_FILE_NOTIFY */
else if (event->kind == SAVE_SESSION_EVENT)
{
- obj = list2 (Qsave_session, event->arg);
+ obj = list2 (Qsave_session, event->ie.arg);
kbd_fetch_ptr = event + 1;
}
/* Just discard these, by returning nil.
{
Lisp_Object object, position, help, frame, window;
- frame = event->frame_or_window;
- object = event->arg;
- position = make_number (Time_to_position (event->timestamp));
- window = event->x;
- help = event->y;
+ frame = event->ie.frame_or_window;
+ object = event->ie.arg;
+ position = make_number (Time_to_position (event->ie.timestamp));
+ window = event->ie.x;
+ help = event->ie.y;
clear_event (event);
kbd_fetch_ptr = event + 1;
switch-frame event if necessary. */
Lisp_Object frame, focus;
- frame = event->frame_or_window;
+ frame = event->ie.frame_or_window;
focus = FRAME_FOCUS_FRAME (XFRAME (frame));
if (FRAMEP (focus))
frame = focus;
if (
#ifdef HAVE_X11
- ! NILP (event->arg)
+ ! NILP (event->ie.arg)
&&
#endif
!EQ (frame, internal_last_event_frame)
#ifdef HAVE_WINDOW_SYSTEM
Display_Info *di;
- Lisp_Object frame = event->frame_or_window;
+ Lisp_Object frame = event->ie.frame_or_window;
bool focused = false;
for (di = x_display_list; di && ! focused; di = di->next)
#ifdef HAVE_DBUS
else if (event->kind == DBUS_EVENT)
{
- obj = make_lispy_event (event);
+ obj = make_lispy_event (&event->ie);
kbd_fetch_ptr = event + 1;
}
#endif
else if (event->kind == CONFIG_CHANGED_EVENT)
{
- obj = make_lispy_event (event);
+ obj = make_lispy_event (&event->ie);
kbd_fetch_ptr = event + 1;
}
else
Lisp_Object frame;
Lisp_Object focus;
- frame = event->frame_or_window;
+ frame = event->ie.frame_or_window;
if (CONSP (frame))
frame = XCAR (frame);
else if (WINDOWP (frame))
if (NILP (obj))
{
- obj = make_lispy_event (event);
+ obj = make_lispy_event (&event->ie);
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
|| defined (HAVE_NS) || defined (USE_GTK)
beginning of the menu sequence, and we might as well leave
that as the `event with parameters' for this selection. */
if (used_mouse_menu
- && !EQ (event->frame_or_window, event->arg)
+ && !EQ (event->ie.frame_or_window, event->ie.arg)
&& (event->kind == MENU_BAR_EVENT
|| event->kind == TOOL_BAR_EVENT))
*used_mouse_menu = 1;
static void
process_special_events (void)
{
- struct input_event *event;
+ union buffered_input_event *event;
for (event = kbd_fetch_ptr; event != kbd_store_ptr; ++event)
{
between kbd_fetch_ptr and EVENT one slot to the right,
cyclically. */
- struct input_event copy = *event;
- struct input_event *beg
+ struct selection_input_event copy = event->sie;
+ union buffered_input_event *beg
= (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
? kbd_buffer : kbd_fetch_ptr;
if (event > beg)
- memmove (beg + 1, beg, (event - beg) * sizeof (struct input_event));
+ memmove (beg + 1, beg, (event - beg) * sizeof *beg);
else if (event < beg)
{
if (event > kbd_buffer)
memmove (kbd_buffer + 1, kbd_buffer,
- (event - kbd_buffer) * sizeof (struct input_event));
+ (event - kbd_buffer) * sizeof *kbd_buffer);
*kbd_buffer = *(kbd_buffer + KBD_BUFFER_SIZE - 1);
if (beg < kbd_buffer + KBD_BUFFER_SIZE - 1)
memmove (beg + 1, beg,
- (kbd_buffer + KBD_BUFFER_SIZE - 1 - beg)
- * sizeof (struct input_event));
+ (kbd_buffer + KBD_BUFFER_SIZE - 1 - beg) * sizeof *beg);
}
if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
kbd_fetch_ptr = kbd_buffer;
if (kbd_fetch_ptr->kind == ASCII_KEYSTROKE_EVENT)
- stuff_char (kbd_fetch_ptr->code);
+ stuff_char (kbd_fetch_ptr->ie.code);
clear_event (kbd_fetch_ptr);
}
mark_object (KVAR (kb, echo_string));
}
{
- struct input_event *event;
+ union buffered_input_event *event;
for (event = kbd_fetch_ptr; event != kbd_store_ptr; event++)
{
if (event == kbd_buffer + KBD_BUFFER_SIZE)
if (event->kind != SELECTION_REQUEST_EVENT
&& event->kind != SELECTION_CLEAR_EVENT)
{
- mark_object (event->x);
- mark_object (event->y);
- mark_object (event->frame_or_window);
- mark_object (event->arg);
+ mark_object (event->ie.x);
+ mark_object (event->ie.y);
+ mark_object (event->ie.frame_or_window);
+ mark_object (event->ie.arg);
}
}
}
struct prop_location;
struct selection_data;
-static void x_decline_selection_request (struct input_event *);
-static bool x_convert_selection (struct input_event *, Lisp_Object,
- Lisp_Object, Atom, bool,
+static void x_decline_selection_request (struct selection_input_event *);
+static bool x_convert_selection (Lisp_Object, Lisp_Object, Atom, bool,
struct x_display_info *);
static bool waiting_for_other_props_on_window (Display *, Window);
static struct prop_location *expect_property_change (Display *, Window,
struct selection_event_queue
{
- struct input_event event;
+ struct selection_input_event event;
struct selection_event_queue *next;
};
static int x_queue_selection_requests;
+/* True if the input events are duplicates. */
+
+static bool
+selection_input_event_equal (struct selection_input_event *a,
+ struct selection_input_event *b)
+{
+ return (a->kind == b->kind && a->dpyinfo == b->dpyinfo
+ && a->requestor == b->requestor && a->selection == b->selection
+ && a->target == b->target && a->property == b->property
+ && a->time == b->time);
+}
+
/* Queue up an SELECTION_REQUEST_EVENT *EVENT, to be processed later. */
static void
-x_queue_event (struct input_event *event)
+x_queue_event (struct selection_input_event *event)
{
struct selection_event_queue *queue_tmp;
This only happens for large requests which uses the incremental protocol. */
for (queue_tmp = selection_queue; queue_tmp; queue_tmp = queue_tmp->next)
{
- if (!memcmp (&queue_tmp->event, event, sizeof (*event)))
+ if (selection_input_event_equal (event, &queue_tmp->event))
{
TRACE1 ("DECLINE DUP SELECTION EVENT %p", queue_tmp);
x_decline_selection_request (event);
meaning we were unable to do what they wanted. */
static void
-x_decline_selection_request (struct input_event *event)
+x_decline_selection_request (struct selection_input_event *event)
{
XEvent reply_base;
XSelectionEvent *reply = &(reply_base.xselection);
/* This is the selection request currently being processed.
It is set to zero when the request is fully processed. */
-static struct input_event *x_selection_current_request;
+static struct selection_input_event *x_selection_current_request;
/* Display info in x_selection_request. */
#endif /* TRACE_SELECTION */
static void
-x_reply_selection_request (struct input_event *event,
+x_reply_selection_request (struct selection_input_event *event,
struct x_display_info *dpyinfo)
{
XEvent reply_base;
This is called from keyboard.c when such an event is found in the queue. */
static void
-x_handle_selection_request (struct input_event *event)
+x_handle_selection_request (struct selection_input_event *event)
{
struct gcpro gcpro1, gcpro2;
Time local_selection_time;
AREF (multprop, 2*j+1));
if (subproperty != None)
- x_convert_selection (event, selection_symbol, subtarget,
+ x_convert_selection (selection_symbol, subtarget,
subproperty, true, dpyinfo);
}
success = true;
{
if (property == None)
property = SELECTION_EVENT_TARGET (event);
- success = x_convert_selection (event, selection_symbol,
+ success = x_convert_selection (selection_symbol,
target_symbol, property,
false, dpyinfo);
}
Return true iff successful. */
static bool
-x_convert_selection (struct input_event *event, Lisp_Object selection_symbol,
+x_convert_selection (Lisp_Object selection_symbol,
Lisp_Object target_symbol, Atom property,
bool for_multiple, struct x_display_info *dpyinfo)
{
This is called from keyboard.c when such an event is found in the queue. */
static void
-x_handle_selection_clear (struct input_event *event)
+x_handle_selection_clear (struct selection_input_event *event)
{
Atom selection = SELECTION_EVENT_SELECTION (event);
Time changed_owner_time = SELECTION_EVENT_TIME (event);
}
void
-x_handle_selection_event (struct input_event *event)
+x_handle_selection_event (struct selection_input_event *event)
{
TRACE0 ("x_handle_selection_event");
if (event->kind != SELECTION_REQUEST_EVENT)
{
Time timestamp;
Atom selection_atom;
- union {
- struct selection_input_event sie;
- struct input_event ie;
- } event;
+ struct selection_input_event event;
struct frame *f = frame_for_x_selection (terminal);
struct x_display_info *dpyinfo;
the selection owner to None. The NCD server does, the MIT Sun4 server
doesn't. So we synthesize one; this means we might get two, but
that's ok, because the second one won't have any effect. */
- SELECTION_EVENT_DPYINFO (&event.sie) = dpyinfo;
- SELECTION_EVENT_SELECTION (&event.sie) = selection_atom;
- SELECTION_EVENT_TIME (&event.sie) = timestamp;
- x_handle_selection_clear (&event.ie);
+ SELECTION_EVENT_DPYINFO (&event) = dpyinfo;
+ SELECTION_EVENT_SELECTION (&event) = selection_atom;
+ SELECTION_EVENT_TIME (&event) = timestamp;
+ x_handle_selection_clear (&event);
return Qt;
}