Discard the event if it would fill the last slot. */
if (kbd_fetch_ptr - 1 != kbd_store_ptr)
{
+ *kbd_store_ptr = *event;
+ ++kbd_store_ptr;
+ }
+}
-#if 0 /* The SELECTION_REQUEST_EVENT case looks bogus, and it's error
- prone to assign individual members for other events, in case
- the input_event structure is changed. --2000-07-13, gerd. */
- struct input_event *sp = kbd_store_ptr;
- sp->kind = event->kind;
- if (event->kind == SELECTION_REQUEST_EVENT)
- {
- /* We must not use the ordinary copying code for this case,
- since `part' is an enum and copying it might not copy enough
- in this case. */
- bcopy (event, (char *) sp, sizeof (*event));
- }
- else
- {
- sp->code = event->code;
- sp->part = event->part;
- sp->frame_or_window = event->frame_or_window;
- sp->arg = event->arg;
- sp->modifiers = event->modifiers;
- sp->x = event->x;
- sp->y = event->y;
- sp->timestamp = event->timestamp;
- }
-#else
- *kbd_store_ptr = *event;
-#endif
+/* Put an input event back in the head of the event queue. */
- ++kbd_store_ptr;
+void
+kbd_buffer_unget_event (event)
+ register struct 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)
+ {
+ --kbd_fetch_ptr;
+ *kbd_fetch_ptr = *event;
}
}
/* These two kinds of events get special handling
and don't actually appear to the command loop.
We return nil for them. */
- if (event->kind == SELECTION_REQUEST_EVENT)
+ if (event->kind == SELECTION_REQUEST_EVENT
+ || event->kind == SELECTION_CLEAR_EVENT)
{
#ifdef HAVE_X11
struct input_event copy;
copy = *event;
kbd_fetch_ptr = event + 1;
input_pending = readable_events (0);
- x_handle_selection_request (©);
+ x_handle_selection_event (©);
#else
/* We're getting selection request events, but we don't have
a window system. */
#endif
}
- else if (event->kind == SELECTION_CLEAR_EVENT)
- {
-#ifdef HAVE_X11
- struct input_event copy;
-
- /* Remove it from the buffer before processing it. */
- copy = *event;
- kbd_fetch_ptr = event + 1;
- input_pending = readable_events (0);
- x_handle_selection_clear (©);
-#else
- /* We're getting selection request events, but we don't have
- a window system. */
- abort ();
-#endif
- }
#if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
else if (event->kind == DELETE_WINDOW_EVENT)
{
/* These two kinds of events get special handling
and don't actually appear to the command loop. */
- if (event->kind == SELECTION_REQUEST_EVENT)
+ if (event->kind == SELECTION_REQUEST_EVENT
+ || event->kind == SELECTION_CLEAR_EVENT)
{
#ifdef HAVE_X11
struct input_event copy;
copy = *event;
kbd_fetch_ptr = event + 1;
input_pending = readable_events (0);
- x_handle_selection_request (©);
-#else
- /* We're getting selection request events, but we don't have
- a window system. */
- abort ();
-#endif
- }
-
- else if (event->kind == SELECTION_CLEAR_EVENT)
- {
-#ifdef HAVE_X11
- struct input_event copy;
-
- /* Remove it from the buffer before processing it, */
- copy = *event;
-
- kbd_fetch_ptr = event + 1;
- input_pending = readable_events (0);
- x_handle_selection_clear (©);
+ x_handle_selection_event (©);
#else
/* We're getting selection request events, but we don't have
a window system. */
{
if (event == kbd_buffer + KBD_BUFFER_SIZE)
event = kbd_buffer;
- if (event->kind != SELECTION_REQUEST_EVENT)
+ if (event->kind != SELECTION_REQUEST_EVENT
+ && event->kind != SELECTION_CLEAR_EVENT)
{
mark_object (event->x);
mark_object (event->y);