diff src/keyboard.c @ 83622:0a3247aa24a4

Merged from emacs--devo--0 Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-744 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-745 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-746 Merge from emacs--rel--22 * emacs@sv.gnu.org/emacs--devo--0--patch-747 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-748 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-749 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-750 Merge from emacs--rel--22 * emacs@sv.gnu.org/emacs--devo--0--patch-751 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-752 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-753 Merge from emacs--rel--22 * emacs@sv.gnu.org/emacs--devo--0--patch-754 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-755 Merge from emacs--rel--22 * emacs@sv.gnu.org/emacs--devo--0--patch-756 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-757 Update from CVS: lisp/textmodes/sgml-mode.el: Revert last change. * emacs@sv.gnu.org/emacs--devo--0--patch-758 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-759 Merge from emacs--rel--22 * emacs@sv.gnu.org/emacs--devo--0--patch-760 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-761 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-14 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-15 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-16 Update from CVS: src/xterm.c (XTread_socket): Revert last change. * emacs@sv.gnu.org/emacs--rel--22--patch-17 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-18 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-19 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-20 Update from CVS * emacs@sv.gnu.org/emacs--rel--22--patch-21 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-221 Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-12 Creator: Karoly Lorentey <karoly@lorentey.hu>
author Miles Bader <miles@gnu.org>
date Sun, 20 May 2007 23:29:14 +0000
parents 95193d50d928 62b6aa7f8c37
children 422451dd396a
line wrap: on
line diff
--- a/src/keyboard.c	Sun May 20 23:27:36 2007 +0000
+++ b/src/keyboard.c	Sun May 20 23:29:14 2007 +0000
@@ -508,7 +508,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
 
@@ -661,7 +661,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,
@@ -1466,7 +1466,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.  */
@@ -1542,7 +1542,7 @@
   return 0;
 }
 
-#endif	/* HAVE_MOUSE */
+#endif	/* HAVE_MOUSE || HAVE_GPM */
 
 /* This is the actual command reading loop,
    sans error-handling encapsulation.  */
@@ -2476,7 +2476,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
@@ -3753,7 +3753,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;
@@ -4103,7 +4103,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
@@ -4125,7 +4125,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
@@ -4361,7 +4361,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 ())
     {
@@ -4406,7 +4406,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!  */
@@ -6123,6 +6123,66 @@
       }
 #endif
 
+#ifdef HAVE_GPM
+    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));
+       }
+#endif /* HAVE_GPM */
+
       /* The 'kind' field of the event is something we don't recognize.  */
     default:
       abort ();
@@ -7057,7 +7117,27 @@
   if (! tty->input)
     return 0;                   /* The terminal is suspended. */
 
-  /* Determine how many characters we should *try* to read.  */
+#ifdef HAVE_GPM
+  if (term_gpm && gpm_tty == tty->terminal->id)
+  {
+      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 (tty, &event, &hold_quit);
+      }
+      if (hold_quit.kind != NO_EVENT)
+	  kbd_buffer_store_event (&hold_quit);
+      if (nread)
+	  return nread;
+  }
+#endif /* HAVE_GPM */
+
+/* Determine how many characters we should *try* to read.  */
 #ifdef FIONREAD
   /* Find out how much input is available.  */
   if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
@@ -11440,7 +11520,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;
@@ -11636,7 +11716,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
@@ -11768,7 +11848,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);