Common subdirectories: ../libcons.cvs/CVS and ./CVS
diff -upN ../libcons.cvs/Makefile ./Makefile
--- ../libcons.cvs/Makefile	2002-09-13 23:40:10.000000000 +0000
+++ ./Makefile	2004-04-02 07:44:48.000000000 +0000
@@ -23,7 +23,7 @@ SRCS= demuxer.c init-init.c init-loop.c 
       dir-changed.c file-changed.c opts-std-startup.c cons-lookup.c \
       cons-switch.c vcons-remove.c vcons-add.c vcons-open.c \
       vcons-close.c vcons-destroy.c vcons-refresh.c vcons-scrollback.c \
-      vcons-input.c
+      vcons-input.c vcons-move-mouse.c vcons-event.c
 LCLHDRS = priv.h mutations.h
 installhdrs = cons.h
 
diff -upN ../libcons.cvs/cons.h ./cons.h
--- ../libcons.cvs/cons.h	2003-08-16 18:06:23.000000000 +0000
+++ ./cons.h	2004-04-02 07:42:20.000000000 +0000
@@ -123,6 +123,31 @@ struct cons
   int slack;
 };
 
+
+enum mouse_movement
+  {
+    MOUSE_MOVE_REL,
+    MOUSE_MOVE_ABS,
+    MOUSE_MOVE_PROC
+  };
+
+enum mouse_button
+  {
+    MOUSE_BUTTON_NO_OP,
+    MOUSE_BUTTON_PRESSED,
+    MOUSE_BUTTON_RELEASED
+  };
+
+typedef struct mouse_event
+{ 
+  enum mouse_movement mouse_movement;
+  float x;
+  float y;
+  
+  enum mouse_button mouse_button;
+  int button;
+} *mouse_event_t;
+
 
 /* The user must define this variable.  Set this to the name of the
    console client.  */
@@ -256,6 +281,14 @@ typedef enum
    down.  */
 int cons_vcons_scrollback (vcons_t vcons, cons_scroll_t type, float value);
 
+/* Set the mouse cursor position to X, Y.  VCONS is locked.  */
+error_t cons_vcons_set_mousecursor_pos (vcons_t vcons, float x, float y);
+
+/* If STATUS is set to 0, hide the mouse cursor, otherwise show
+   it.  VCONS is locked.  */
+error_t cons_vcons_set_mousecursor_status (vcons_t vcons, int status);
+
+
 
 extern const struct argp cons_startup_argp;
 
@@ -286,4 +319,6 @@ void cons_vcons_destroy (void *port);
 /* Redraw the virtual console VCONS, which is locked.  */
 void cons_vcons_refresh (vcons_t vcons);
 
+error_t cons_vcons_move_mouse (vcons_t vcons, mouse_event_t ev);
+
 #endif	/* hurd/cons.h */
diff -upN ../libcons.cvs/file-changed.c ./file-changed.c
--- ../libcons.cvs/file-changed.c	2003-08-02 21:43:46.000000000 +0000
+++ ./file-changed.c	2004-04-02 07:02:31.000000000 +0000
@@ -1,5 +1,5 @@
 /* file-changed.c - Handling file changed notifications.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
    Written by Marcus Brinkmann.
 
    This file is part of the GNU Hurd.
@@ -93,6 +93,7 @@ cons_S_file_changed (cons_notify_t notif
 		    /* The cursor was visible before.  */
 		    cons_vcons_set_cursor_status (vcons, CONS_CURSOR_INVISIBLE);
 
+		  _cons_vcons_console_event (vcons, CONSEVT_OUTPUT);
 		  cons_vcons_update (vcons);
 		}
 	      if (change.what.cursor_status)
@@ -185,6 +186,7 @@ cons_S_file_changed (cons_notify_t notif
 					      end - size + 1,
 					      0, (size - vis_start)
 					      / vcons->state.screen.width);
+			  _cons_vcons_console_event (vcons, CONSEVT_OUTPUT);
 			  cons_vcons_update (vcons);
 			}
 		      vcons->state.screen.cur_line = new_cur_line;
@@ -342,6 +344,7 @@ cons_S_file_changed (cons_notify_t notif
 					  (size - rotate)
 					  / vcons->state.screen.width);
 		    }
+		  _cons_vcons_console_event (vcons, CONSEVT_OUTPUT);
 		  cons_vcons_update (vcons);
 		}
 	    }
diff -upN ../libcons.cvs/opts-std-startup.c ./opts-std-startup.c
--- ../libcons.cvs/opts-std-startup.c	2003-08-02 21:43:46.000000000 +0000
+++ ./opts-std-startup.c	2004-04-02 00:35:20.000000000 +0000
@@ -1,5 +1,5 @@
 /* opts-std-startup.c - Standard startup-time command line parser.
-   Copyright (C) 1995,96,97,98,99,2001,02,2003 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,2001,02,2003,2004 Free Software Foundation, Inc.
    Written by Miles Bader <miles@gnu.org> and Marcus Brinkmann.
 
    This file is part of the GNU Hurd.
@@ -25,7 +25,7 @@
 #include "priv.h"
 
 
-/* Option keys for long-only options in diskfs_common_options.  */
+/* Option keys for long-only options in argp_option.  */
 #define OPT_SLACK			600	/* --slack */
 #define OPT_JUMP_DOWN_ON_INPUT		601	/* --jump-down-on-input */
 #define OPT_NO_JUMP_DOWN_ON_INPUT	602	/* --no-jump-down-on-input */
@@ -33,13 +33,20 @@
 #define OPT_NO_JUMP_DOWN_ON_OUTPUT	604	/* --no-jump-down-on-output */
 #define OPT_VISUAL_BELL			605	/* --visual-bell */
 #define OPT_AUDIBLE_BELL		606	/* --audible-bell */
+#define OPT_MOUSE_SHOW			607	/* --mouse-show */
+#define OPT_MOUSE_HIDE			608	/* --mouse-hide */
+#define OPT_MOUSE_SENS			609	/* --mouse-sensitivity */
 
-/* Common value for diskfs_common_options and diskfs_default_sync_interval. */
+/* The number of records the client is allowed to lag behind the server.  */
 #define DEFAULT_SLACK 100
 #define DEFAULT_SLACK_STRING STRINGIFY(DEFAULT_SLACK)
 #define STRINGIFY(x) STRINGIFY_1(x)
 #define STRINGIFY_1(x) #x
 
+/* The mouse sensitivity.  */
+#define DEFAULT_MOUSE_SENS 3.0
+#define DEFAULT_MOUSE_SENS_STRING STRINGIFY(DEFAULT_SLACK)
+
 /* Number of records the client is allowed to lag behind the
    server.  */
 int _cons_slack = DEFAULT_SLACK;
@@ -59,6 +66,15 @@ bell_type_t _cons_visual_bell = BELL_VIS
 /* The type of bell used for the audible bell.  */
 bell_type_t _cons_audible_bell = BELL_AUDIBLE;
 
+/* The type of events that will make the mouse cursor visible.  */
+int _cons_show_mouse = CONSEVT_MOUSEMOVE;
+
+/* The type of events that will hide the mouse cursor.  */
+int _cons_hide_mouse = CONSEVT_KEYPRESS;
+
+/* The mouse sensitivity.  */
+float _cons_mouse_sens = DEFAULT_MOUSE_SENS;
+
 static const struct argp_option
 startup_options[] =
 {
@@ -76,6 +92,15 @@ startup_options[] =
     "off, visual, audible" },
   { "audible-bell", OPT_AUDIBLE_BELL, "BELL", 0, "Audible bell: on (default), "
     "off, visual, audible" },
+  { "mouse-show", OPT_MOUSE_SHOW, "EVENTS", 0, "One or more of the events" 
+    " MOUSEMOVE, MOUSEBUTTON, KEYPRESS, OUTPUT (default is MOUSEMOVE), if one"
+    " of these events occur the mouse cursor will be made visible" },
+  { "mouse-hide", OPT_MOUSE_HIDE, "EVENTS", 0, "One or more of the events" 
+    " MOUSEMOVE, MOUSEBUTTON, KEYPRESS, OUTPUT (default is KEYPRESS), if one"
+    " of these events occur the mouse cursor will be hidden " },
+  { "mouse-sensitivity", OPT_MOUSE_SENS, "SENSITIVITY", 0, "The mouse"
+    " sensitivity (default " DEFAULT_MOUSE_SENS_STRING ").  A lower value"
+    " means more sensitive" },
   { 0, 0 }
 };
 
@@ -86,6 +111,30 @@ static const char doc[] = "A console cli
 static error_t
 parse_startup_opt (int opt, char *arg, struct argp_state *state)
 {
+  int parse_events (char *events)
+    {
+      char *evtstr = strdupa (events);
+      char *tok = strtok (evtstr, ",");
+      int evmask = 0;
+
+      while (tok)
+	{
+	  if (!strcasecmp ("mousemove", tok))
+	    evmask |= CONSEVT_MOUSEMOVE;
+	  else if (!strcasecmp ("mousebutton", tok))
+	    evmask |= CONSEVT_MOUSEBUTTON;
+	  else if (!strcasecmp ("keypress", tok))
+	    evmask |= CONSEVT_KEYPRESS;
+	  else if (!strcasecmp ("output", tok))
+	    evmask |= CONSEVT_OUTPUT;
+	  else
+	    argp_error (state, "The event can be one of: MOUSEMOVE,"
+			" MOUSEBUTTON, KEYPRESS or OUTPUT");
+	  tok = strtok (NULL, ",");
+	}
+      return evmask;
+    }
+
   switch (opt)
     {
     case OPT_SLACK:
@@ -131,7 +180,28 @@ parse_startup_opt (int opt, char *arg, s
 	argp_error (state, "The visual bell can be one of: on, off, visual, "
 		    "audible");
       break;
-      
+
+    case OPT_MOUSE_SHOW:
+      _cons_show_mouse = parse_events (arg);
+      break;
+
+    case OPT_MOUSE_HIDE:
+      _cons_hide_mouse = parse_events (arg);
+      break;
+
+    case OPT_MOUSE_SENS:
+      {
+	char *tail;
+	
+	errno = 0;
+	_cons_mouse_sens = strtod (arg, &tail);
+	if (tail == NULL || tail == arg || *tail != '\0')
+	  argp_error (state, "SENSITIVITY is not a number: %s", arg);
+	if (errno)
+	  argp_error (state, "Overflow in argument SENSITIVITY %s", arg);
+	break;
+      }
+
     case ARGP_KEY_ARG:
       if (state->arg_num > 0)
 	/* Too many arguments.  */
diff -upN ../libcons.cvs/priv.h ./priv.h
--- ../libcons.cvs/priv.h	2003-08-02 21:43:46.000000000 +0000
+++ ./priv.h	2004-04-02 00:52:07.000000000 +0000
@@ -29,6 +29,11 @@ typedef enum
     BELL_AUDIBLE
   } bell_type_t;
 
+#define CONSEVT_MOUSEMOVE	(1 << 1)
+#define CONSEVT_MOUSEBUTTON	(1 << 2)
+#define CONSEVT_KEYPRESS	(1 << 4)
+#define CONSEVT_OUTPUT		(1 << 8)
+
 
 /* Number of records the client is allowed to lag behind the
    server.  */
@@ -49,11 +54,26 @@ extern bell_type_t _cons_visual_bell;
 /* The type of bell used for the audible bell.  */
 extern bell_type_t _cons_audible_bell;
 
+/* The type of events that will make the mouse cursor visible.  */
+extern int _cons_show_mouse;
+
+/* The type of events that will hide the mouse cursor.  */
+extern int _cons_hide_mouse;
+
+/* The mouse sensitivity.  */
+extern float _cons_mouse_sens;
+
 
 /* Non-locking version of cons_vcons_scrollback.  Does also not update
    the display.  */
 int _cons_vcons_scrollback (vcons_t vcons, cons_scroll_t type, float value);
 
+/* Non-locking version of cons_vcons_input.  */
+error_t _cons_vcons_input (vcons_t vcons, char *buf, size_t size);
+
+/* Generate the console event EVENT for console VCONS.  */
+void _cons_vcons_console_event (vcons_t vcons, int event);
+
 
 /* Called by MiG to translate ports into cons_notify_t.  mutations.h
    arranges for this to happen for the fs_notify interfaces. */
diff -upN ../libcons.cvs/vcons-event.c ./vcons-event.c
--- ../libcons.cvs/vcons-event.c	1970-01-01 00:00:00.000000000 +0000
+++ ./vcons-event.c	2004-04-02 07:39:07.000000000 +0000
@@ -0,0 +1,31 @@
+/* vcons-event.c - Handle console events.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Written by Marco Gerards.
+
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   The GNU Hurd is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
+
+#include "cons.h"
+#include "priv.h"
+
+void
+_cons_vcons_console_event (vcons_t vcons, int event)
+{
+  if (_cons_show_mouse & event)
+    cons_vcons_set_mousecursor_status (vcons, 1);
+  else if (_cons_hide_mouse & event)
+    cons_vcons_set_mousecursor_status (vcons, 0);
+}
diff -upN ../libcons.cvs/vcons-input.c ./vcons-input.c
--- ../libcons.cvs/vcons-input.c	2002-09-13 23:53:55.000000000 +0000
+++ ./vcons-input.c	2004-04-02 07:02:54.000000000 +0000
@@ -1,5 +1,5 @@
 /* vcons-input.c - Add input to a virtual console.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
    Written by Marcus Brinkmann.
 
    This file is part of the GNU Hurd.
@@ -24,18 +24,12 @@
 #include "cons.h"
 #include "priv.h"
 
-/* Enter SIZE bytes from the buffer BUF into the virtual console
-   VCONS.  */
+/* Non-locking version of cons_vcons_input.  */
 error_t
-cons_vcons_input (vcons_t vcons, char *buf, size_t size)
+_cons_vcons_input (vcons_t vcons, char *buf, size_t size)
 {
   int ret;
 
-  mutex_lock (&vcons->lock);
-
-  if (vcons->scrolling && _cons_jump_down_on_input)
-    _cons_vcons_scrollback (vcons, CONS_SCROLL_ABSOLUTE_LINE, 0);
-
   do
     {
       ret = write (vcons->input, buf, size);
@@ -47,8 +41,24 @@ cons_vcons_input (vcons_t vcons, char *b
     }
   while (size && (ret != -1 || errno == EINTR));
 
-  mutex_unlock (&vcons->lock);
   return 0;
 }
 
 
+/* Enter SIZE bytes from the buffer BUF into the virtual console
+   VCONS.  */
+error_t
+cons_vcons_input (vcons_t vcons, char *buf, size_t size)
+{
+  mutex_lock (&vcons->lock);
+
+  _cons_vcons_console_event (vcons, CONSEVT_KEYPRESS);
+  
+  if (vcons->scrolling && _cons_jump_down_on_input)
+    _cons_vcons_scrollback (vcons, CONS_SCROLL_ABSOLUTE_LINE, 0);
+
+  _cons_vcons_input (vcons, buf, size);
+
+  mutex_unlock (&vcons->lock);
+  return 0;
+}
diff -upN ../libcons.cvs/vcons-move-mouse.c ./vcons-move-mouse.c
--- ../libcons.cvs/vcons-move-mouse.c	1970-01-01 00:00:00.000000000 +0000
+++ ./vcons-move-mouse.c	2004-07-27 07:07:34.000000000 +0000
@@ -0,0 +1,98 @@
+/* vcons-move-mouse.c - Catch mouse events.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Written by Marco Gerards.
+   
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   The GNU Hurd is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "cons.h"
+#include "priv.h"
+
+static float mousepos_x;
+static float mousepos_y;
+
+error_t
+cons_vcons_move_mouse (vcons_t vcons, mouse_event_t ev)
+{
+  int ret;
+  char event[CONS_MOUSE_EVENT_LENGTH];
+  uint32_t report_events = vcons->display->flags & CONS_FLAGS_TRACK_MOUSE;
+  
+  mutex_lock (&vcons->lock);
+  
+  switch (ev->mouse_movement)
+    {
+    case MOUSE_MOVE_REL:
+      mousepos_x += ((float) ev->x / _cons_mouse_sens);
+      mousepos_y += ((float) ev->y / _cons_mouse_sens);
+      break;
+
+    case MOUSE_MOVE_PROC:
+    case MOUSE_MOVE_ABS:
+      break;
+    }
+
+  /* Keep the mouse cursor in range of the VC.  */
+  if (mousepos_x < 0)
+    mousepos_x = 0;
+  if (mousepos_y < 0)
+    mousepos_y = 0;
+  if (mousepos_x >= (float) vcons->state.screen.width)
+    mousepos_x = vcons->state.screen.width - 1;
+  if (mousepos_y >= (float) vcons->state.screen.height)
+    mousepos_y = vcons->state.screen.height - 1;
+  
+  cons_vcons_set_mousecursor_pos (vcons, (float) mousepos_x, (float) mousepos_y);
+  
+  /* Report a mouse movement event.  */
+  if (ev->x || ev->y)
+    _cons_vcons_console_event (vcons, CONSEVT_MOUSEMOVE);
+  
+  /* Report a mouse button event.  */
+  if (ev->mouse_button != MOUSE_BUTTON_NO_OP)
+    _cons_vcons_console_event (vcons, CONSEVT_MOUSEBUTTON);
+  
+  if (report_events)
+    {
+      switch (ev->mouse_button)
+	{
+	case MOUSE_BUTTON_NO_OP:
+	  break;
+
+	case MOUSE_BUTTON_PRESSED:
+	  /* Make a xterm like event string.  */
+	  CONS_MOUSE_EVENT (event, ev->button, (int) mousepos_x + 1, (int) mousepos_y + 1);
+
+	  _cons_vcons_input (vcons, event, CONS_MOUSE_EVENT_LENGTH);
+	  /* And send it to the server.  */
+	  break;
+
+	case MOUSE_BUTTON_RELEASED:
+	  /* Make a xterm like event string.  */
+	  CONS_MOUSE_EVENT (event, CONS_MOUSE_RELEASE, (int) mousepos_x + 1, (int) mousepos_y + 1);
+
+	  /* And send it to the server.  */
+	  _cons_vcons_input (vcons,  event, CONS_MOUSE_EVENT_LENGTH);
+	  break;
+	}
+    }
+  
+  mutex_unlock (&vcons->lock);
+  return 0;
+}
diff -upN ../libcons.cvs/vcons-refresh.c ./vcons-refresh.c
--- ../libcons.cvs/vcons-refresh.c	2003-08-15 21:04:10.000000000 +0000
+++ ./vcons-refresh.c	2004-04-02 07:03:08.000000000 +0000
@@ -1,5 +1,5 @@
 /* vcons-refresh.c - Redraw a virtual console.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
    Written by Marcus Brinkmann.
 
    This file is part of the GNU Hurd.
@@ -22,6 +22,7 @@
 #include <assert.h>
 
 #include "cons.h"
+#include "priv.h"
 
 /* Redraw the virtual console VCONS, which is locked.  */
 void
@@ -70,5 +71,6 @@ cons_vcons_refresh (vcons_t vcons)
   cons_vcons_set_cursor_status (vcons, vcons->state.cursor.status);
   cons_vcons_set_scroll_lock (vcons, vcons->state.flags
 			      & CONS_FLAGS_SCROLL_LOCK);
+  _cons_vcons_console_event (vcons, CONSEVT_OUTPUT);
   cons_vcons_update (vcons);
 }
diff -upN ../libcons.cvs/vcons-scrollback.c ./vcons-scrollback.c
--- ../libcons.cvs/vcons-scrollback.c	2002-09-17 11:47:15.000000000 +0000
+++ ./vcons-scrollback.c	2004-04-02 07:03:15.000000000 +0000
@@ -1,5 +1,5 @@
 /* vcons-scrollback.c - Move forward and backward in the scrollback buffer.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
    Written by Marcus Brinkmann.
 
    This file is part of the GNU Hurd.
@@ -23,6 +23,7 @@
 #include <cthreads.h>
 
 #include "cons.h"
+#include "priv.h"
 
 /* Non-locking version of cons_vcons_scrollback.  Does also not update
    the display.  */
@@ -155,6 +156,7 @@ cons_vcons_scrollback (vcons_t vcons, co
 
   mutex_lock (&vcons->lock);
   ret = _cons_vcons_scrollback (vcons, type, value);
+  _cons_vcons_console_event (vcons, CONSEVT_OUTPUT);
   cons_vcons_update (vcons);
   mutex_unlock (&vcons->lock);
   return ret;
