changeset 57950:c8eda2a302f0

(kbd_buffer_store_event_hold): Remove obsolete code. (kbd_buffer_unget_event): New function. (kbd_buffer_get_event, swallow_events): Combine SELECTION events and use x_handle_selection_event. (mark_kboards): Don't mark x and y of SELECTION_CLEAR_EVENT.
author Kim F. Storm <storm@cua.dk>
date Fri, 05 Nov 2004 11:30:01 +0000
parents 7a4dd36b2893
children fbbae2d9a2f4
files src/keyboard.c
diffstat 1 files changed, 26 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Fri Nov 05 11:05:08 2004 +0000
+++ b/src/keyboard.c	Fri Nov 05 11:30:01 2004 +0000
@@ -3698,40 +3698,30 @@
      Discard the event if it would fill the last slot.  */
   if (kbd_fetch_ptr - 1 != 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
-
       ++kbd_store_ptr;
     }
 }
 
 
+/* Put an input event back in the head of the event queue.  */
+
+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;
+    }
+}
+
+
 /* Generate HELP_EVENT input_events in BUFP which has room for
    SIZE events.  If there's not enough room in BUFP, ignore this
    event.
@@ -3942,7 +3932,8 @@
       /* 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;
@@ -3953,7 +3944,7 @@
 	  copy = *event;
 	  kbd_fetch_ptr = event + 1;
 	  input_pending = readable_events (0);
-	  x_handle_selection_request (&copy);
+	  x_handle_selection_event (&copy);
 #else
 	  /* We're getting selection request events, but we don't have
              a window system.  */
@@ -3961,22 +3952,6 @@
 #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 (&copy);
-#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)
 	{
@@ -4201,7 +4176,8 @@
 
       /* 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;
@@ -4212,25 +4188,7 @@
 	  copy = *event;
 	  kbd_fetch_ptr = event + 1;
 	  input_pending = readable_events (0);
-	  x_handle_selection_request (&copy);
-#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 (&copy);
+	  x_handle_selection_event (&copy);
 #else
 	  /* We're getting selection request events, but we don't have
              a window system.  */
@@ -11456,7 +11414,8 @@
       {
 	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);