changeset 80980:51a9e0fd18ae

(Qmouse_fixup_help_message) (make_lispy_movement, tracking_off, Ftrack_mouse, some_mouse_moved) (show_help_echo, readable_events, kbd_buffer_get_event, init_keyboard): Extend HAVE_MOUSE ifdefs to HAVE_GPM_H. (make_lispy_event): Add case GPM_CLICK_EVENT. (read_avail_input): Handle mouse input.
author Nick Roberts <nickrob@snap.net.nz>
date Sun, 20 May 2007 02:29:50 +0000
parents 3d81d0b44577
children f454fb9563fd
files src/keyboard.c
diffstat 1 files changed, 92 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Sun May 20 02:27:53 2007 +0000
+++ b/src/keyboard.c	Sun May 20 02:29:50 2007 +0000
@@ -521,7 +521,7 @@
 Lisp_Object Qselect_window;
 Lisp_Object Qhelp_echo;
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 Lisp_Object Qmouse_fixup_help_message;
 #endif
 
@@ -677,7 +677,7 @@
 static Lisp_Object read_char_minibuf_menu_prompt P_ ((int, int,
 						      Lisp_Object *));
 static Lisp_Object make_lispy_event P_ ((struct input_event *));
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 static Lisp_Object make_lispy_movement P_ ((struct frame *, Lisp_Object,
 					    enum scroll_bar_part,
 					    Lisp_Object, Lisp_Object,
@@ -1390,7 +1390,7 @@
   return Qnil;
 }
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
 
 /* Restore mouse tracking enablement.  See Ftrack_mouse for the only use
    of this function.  */
@@ -1466,7 +1466,7 @@
   return 0;
 }
 
-#endif	/* HAVE_MOUSE */
+#endif	/* HAVE_MOUSE || HAVE_GPM */
 
 /* This is the actual command reading loop,
    sans error-handling encapsulation.  */
@@ -2388,7 +2388,7 @@
 	return;
     }
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   if (!noninteractive && STRINGP (help))
     {
       /* The mouse-fixup-help-message Lisp function can call
@@ -3640,7 +3640,7 @@
 	return 1;
     }
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   if (!(flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
       && !NILP (do_mouse_tracking) && some_mouse_moved ())
     return 1;
@@ -3992,7 +3992,7 @@
     {
       if (kbd_fetch_ptr != kbd_store_ptr)
 	break;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
       if (!NILP (do_mouse_tracking) && some_mouse_moved ())
 	break;
 #endif
@@ -4014,7 +4014,7 @@
 #endif /* SIGIO */
       if (kbd_fetch_ptr != kbd_store_ptr)
 	break;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
       if (!NILP (do_mouse_tracking) && some_mouse_moved ())
 	break;
 #endif
@@ -4250,7 +4250,7 @@
 	    }
 	}
     }
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   /* Try generating a mouse motion event.  */
   else if (!NILP (do_mouse_tracking) && some_mouse_moved ())
     {
@@ -4291,7 +4291,7 @@
       if (!NILP (x) && NILP (obj))
 	obj = make_lispy_movement (f, bar_window, part, x, y, time);
     }
-#endif	/* HAVE_MOUSE */
+#endif	/* HAVE_MOUSE || HAVE GPM */
   else
     /* We were promised by the above while loop that there was
        something for us to read!  */
@@ -6008,6 +6008,64 @@
       }
 #endif
 
+    case GPM_CLICK_EVENT:
+      {
+	FRAME_PTR f = XFRAME (event->frame_or_window);
+	Lisp_Object head, position;
+	Lisp_Object *start_pos_ptr;
+	Lisp_Object start_pos;
+	int button = event->code;
+
+	if (button >= ASIZE (button_down_location))
+	  {
+	    button_down_location = larger_vector (button_down_location,
+						  button + 1, Qnil);
+	    mouse_syms = larger_vector (mouse_syms, button + 1, Qnil);
+	  }
+
+	start_pos_ptr = &AREF (button_down_location, button);
+	start_pos = *start_pos_ptr;
+
+	position = make_lispy_position (f, &event->x, &event->y,
+					    event->timestamp);
+
+ 	if (event->modifiers & down_modifier)
+	  *start_pos_ptr = Fcopy_alist (position);
+	else if (event->modifiers & (up_modifier | drag_modifier))
+	  {
+	    if (!CONSP (start_pos))
+	      return Qnil;
+	    event->modifiers &= ~up_modifier;
+	  }
+
+	head = modify_event_symbol (button,
+				    event->modifiers,
+				    Qmouse_click, Vlispy_mouse_stem,
+				    NULL,
+				    &mouse_syms,
+				    XVECTOR (mouse_syms)->size);
+
+	if (event->modifiers & drag_modifier)
+	  return Fcons (head,
+			Fcons (start_pos,
+			       Fcons (position,
+				      Qnil)));
+	else if (event->modifiers & double_modifier)
+	  return Fcons (head,
+			Fcons (position,
+			       Fcons (make_number (2),
+				      Qnil)));
+	else if (event->modifiers & triple_modifier)
+	  return Fcons (head,
+			Fcons (position,
+			       Fcons (make_number (3),
+				      Qnil)));
+ 	else
+	  return Fcons (head,
+			Fcons (position,
+			       Qnil));
+       }
+
       /* The 'kind' field of the event is something we don't recognize.  */
     default:
       abort ();
@@ -6865,8 +6923,28 @@
       if (n_to_read == 0)
 	return 0;
 #else /* not MSDOS */
+#ifdef HAVE_GPM_H
+      if (term_gpm)
+	{
+	  Gpm_Event event;
+	  struct input_event hold_quit;
+	  int gpm;
+
+	  EVENT_INIT (hold_quit);
+	  hold_quit.kind = NO_EVENT;
+
+	  while (gpm = Gpm_GetEvent (&event), gpm == 1) {
+	    nread += handle_one_term_event (&event, &hold_quit);
+	  }
+	  if (hold_quit.kind != NO_EVENT)
+	    kbd_buffer_store_event (&hold_quit);
+	  if (nread)
+	    return nread;
+	}
+#endif /* HAVE_GPM_H */
 #ifdef FIONREAD
-      /* Find out how much input is available.  */
+
+     /* Find out how much input is available.  */
       if (ioctl (input_fd, FIONREAD, &n_to_read) < 0)
 	/* Formerly simply reported no input, but that sometimes led to
 	   a failure of Emacs to terminate.
@@ -11045,7 +11123,7 @@
   recent_keys_index = 0;
   kbd_fetch_ptr = kbd_buffer;
   kbd_store_ptr = kbd_buffer;
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   do_mouse_tracking = Qnil;
 #endif
   input_pending = 0;
@@ -11235,7 +11313,7 @@
   Qmenu_bar = intern ("menu-bar");
   staticpro (&Qmenu_bar);
 
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   Qmouse_fixup_help_message = intern ("mouse-fixup-help-message");
   staticpro (&Qmouse_fixup_help_message);
 #endif
@@ -11367,7 +11445,7 @@
   defsubr (&Sread_key_sequence);
   defsubr (&Sread_key_sequence_vector);
   defsubr (&Srecursive_edit);
-#ifdef HAVE_MOUSE
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
   defsubr (&Strack_mouse);
 #endif
   defsubr (&Sinput_pending_p);