summaryrefslogtreecommitdiff
path: root/libcons
diff options
context:
space:
mode:
authorMarco Gerards <marco@gnu.org>2005-01-06 21:53:26 +0000
committerMarco Gerards <marco@gnu.org>2005-01-06 21:53:26 +0000
commitf7cecd976b196288bd734eace2acff798a36513f (patch)
tree5e1015cbb3742b8167b4b53f395f273c4352503e /libcons
parent38fc4e4d1cef98a8b3d60b717647a9c65d91307f (diff)
2005-01-06 Marco Gerards <metgerards@student.han.nl>
* Makefile (SRCS): Add `vcons-move-mouse.c' and `vcons-event.c'. * cons.h (mouse_movement): New enum. (mouse_button): Likewise. (mouse_event): New struct. (mouse_event_t): New type. (cons_vcons_set_mousecursor_pos): New prototype. (cons_vcons_set_mousecursor_status): Likewise. (cons_vcons_move_mouse): Likewise. * file-changed.c (cons_S_file_changed): Generate the `CONS_EVT_OUTPUT' event, in case there was output. * opts-std-startup.c (OPT_MOUSE_SHOW, OPT_MOUSE_HIDE) (OPT_MOUSE_SENS, DEFAULT_MOUSE_SENS, DEFAULT_MOUSE_SENS_STRING): New macros. (_cons_show_mouse, _cons_hide_mouse, _cons_mouse_sens): New variables. (startup_options): Add the options `--mouse-show-on', `--mouse-hide-on' and `--mouse-sensitivity'. (parse_startup_opt): Parse the options that were added to `startup_options' using the new local function `parse_events'. * priv.h (CONS_EVT_MOUSE_MOVE, CONS_EVT_MOUSE_BUTTON) (CONS_EVT_KEYPRESS, CONS_EVT_OUTPUT): New macros. (_cons_show_mouse, _cons_hide_mouse, _cons_mouse_sens): New declarations. (_cons_vcons_input): New prototype. (_cons_vcons_console_event): Likewise. * vcons-event.c: New file. * vcons-move-mouse.c: Likewise. * vcons-input.c (_cons_vcons_input): New function. (cons_vcons_input): Rewritten to use _cons_vcons_input and report the `CONS_EVT_KEYPRESS' event. * vcons-refresh.c: Include "priv.h". (cons_vcons_refresh): Report the `CONS_EVT_OUTPUT' event. * vcons-scrollback.c: Include "priv.h". (cons_vcons_scrollback): Report the `CONS_EVT_OUTPUT' event.
Diffstat (limited to 'libcons')
-rw-r--r--libcons/ChangeLog37
-rw-r--r--libcons/Makefile4
-rw-r--r--libcons/cons.h41
-rw-r--r--libcons/file-changed.c5
-rw-r--r--libcons/opts-std-startup.c78
-rw-r--r--libcons/priv.h22
-rw-r--r--libcons/vcons-event.c31
-rw-r--r--libcons/vcons-input.c30
-rw-r--r--libcons/vcons-move-mouse.c103
-rw-r--r--libcons/vcons-refresh.c4
-rw-r--r--libcons/vcons-scrollback.c4
11 files changed, 338 insertions, 21 deletions
diff --git a/libcons/ChangeLog b/libcons/ChangeLog
index 3640c2b8..7e33f39a 100644
--- a/libcons/ChangeLog
+++ b/libcons/ChangeLog
@@ -1,3 +1,40 @@
+2005-01-06 Marco Gerards <metgerards@student.han.nl>
+
+ * Makefile (SRCS): Add `vcons-move-mouse.c' and `vcons-event.c'.
+ * cons.h (mouse_movement): New enum.
+ (mouse_button): Likewise.
+ (mouse_event): New struct.
+ (mouse_event_t): New type.
+ (cons_vcons_set_mousecursor_pos): New prototype.
+ (cons_vcons_set_mousecursor_status): Likewise.
+ (cons_vcons_move_mouse): Likewise.
+ * file-changed.c (cons_S_file_changed): Generate the
+ `CONS_EVT_OUTPUT' event, in case there was output.
+ * opts-std-startup.c (OPT_MOUSE_SHOW, OPT_MOUSE_HIDE)
+ (OPT_MOUSE_SENS, DEFAULT_MOUSE_SENS, DEFAULT_MOUSE_SENS_STRING):
+ New macros.
+ (_cons_show_mouse, _cons_hide_mouse, _cons_mouse_sens): New
+ variables.
+ (startup_options): Add the options `--mouse-show-on',
+ `--mouse-hide-on' and `--mouse-sensitivity'.
+ (parse_startup_opt): Parse the options that were added to
+ `startup_options' using the new local function `parse_events'.
+ * priv.h (CONS_EVT_MOUSE_MOVE, CONS_EVT_MOUSE_BUTTON)
+ (CONS_EVT_KEYPRESS, CONS_EVT_OUTPUT): New macros.
+ (_cons_show_mouse, _cons_hide_mouse, _cons_mouse_sens): New
+ declarations.
+ (_cons_vcons_input): New prototype.
+ (_cons_vcons_console_event): Likewise.
+ * vcons-event.c: New file.
+ * vcons-move-mouse.c: Likewise.
+ * vcons-input.c (_cons_vcons_input): New function.
+ (cons_vcons_input): Rewritten to use _cons_vcons_input and report
+ the `CONS_EVT_KEYPRESS' event.
+ * vcons-refresh.c: Include "priv.h".
+ (cons_vcons_refresh): Report the `CONS_EVT_OUTPUT' event.
+ * vcons-scrollback.c: Include "priv.h".
+ (cons_vcons_scrollback): Report the `CONS_EVT_OUTPUT' event.
+
2003-08-16 Marco Gerards <metgerards@student.han.nl>
* cons.h (cons_vcons_set_dimension): Fix typo.
diff --git a/libcons/Makefile b/libcons/Makefile
index 576f8b66..f3bab3f3 100644
--- a/libcons/Makefile
+++ b/libcons/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 1994,95,96,97,98,99,2000,01,02 Free Software Foundation, Inc.
+# Copyright (C) 1994,95,96,97,98,99,2000,01,02,2005 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -23,7 +23,7 @@ SRCS= demuxer.c init-init.c init-loop.c opts-version.c extra-version.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 --git a/libcons/cons.h b/libcons/cons.h
index 54868507..9915dc3b 100644
--- a/libcons/cons.h
+++ b/libcons/cons.h
@@ -1,5 +1,5 @@
/* cons.h - Definitions for cons helper and callback functions.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -123,6 +123,34 @@ struct cons
int slack;
};
+/* Determines if the mouse moves relatively, to an absolute location
+ or to an absolute location expressed by a percentage. */
+enum mouse_movement
+ {
+ CONS_VCONS_MOUSE_MOVE_REL,
+ CONS_VCONS_MOUSE_MOVE_ABS,
+ CONS_VCONS_MOUSE_MOVE_ABS_PERCENT
+ };
+
+/* The status of a mouse button. */
+enum mouse_button
+ {
+ CONS_VCONS_MOUSE_BUTTON_NO_OP,
+ CONS_VCONS_MOUSE_BUTTON_PRESSED,
+ CONS_VCONS_MOUSE_BUTTON_RELEASED
+ };
+
+/* An event produced by mouse movement an button presses. */
+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 +284,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 +322,7 @@ void cons_vcons_destroy (void *port);
/* Redraw the virtual console VCONS, which is locked. */
void cons_vcons_refresh (vcons_t vcons);
+/* Handle the event EV on the virtual console VCONS. */
+error_t cons_vcons_move_mouse (vcons_t vcons, mouse_event_t ev);
+
#endif /* hurd/cons.h */
diff --git a/libcons/file-changed.c b/libcons/file-changed.c
index 40c00af8..b12a6f10 100644
--- a/libcons/file-changed.c
+++ b/libcons/file-changed.c
@@ -1,5 +1,5 @@
/* file-changed.c - Handling file changed notifications.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 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 notify, natural_t tickno,
/* The cursor was visible before. */
cons_vcons_set_cursor_status (vcons, CONS_CURSOR_INVISIBLE);
+ _cons_vcons_console_event (vcons, CONS_EVT_OUTPUT);
cons_vcons_update (vcons);
}
if (change.what.cursor_status)
@@ -185,6 +186,7 @@ cons_S_file_changed (cons_notify_t notify, natural_t tickno,
end - size + 1,
0, (size - vis_start)
/ vcons->state.screen.width);
+ _cons_vcons_console_event (vcons, CONS_EVT_OUTPUT);
cons_vcons_update (vcons);
}
vcons->state.screen.cur_line = new_cur_line;
@@ -342,6 +344,7 @@ cons_S_file_changed (cons_notify_t notify, natural_t tickno,
(size - rotate)
/ vcons->state.screen.width);
}
+ _cons_vcons_console_event (vcons, CONS_EVT_OUTPUT);
cons_vcons_update (vcons);
}
}
diff --git a/libcons/opts-std-startup.c b/libcons/opts-std-startup.c
index 29278cc2..3cf81ae7 100644
--- a/libcons/opts-std-startup.c
+++ b/libcons/opts-std-startup.c
@@ -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,2005 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-on */
+#define OPT_MOUSE_HIDE 608 /* --mouse-hide-on */
+#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_MOUSE_SENS)
+
/* 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_VISUAL;
/* 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 = CONS_EVT_MOUSE_MOVE;
+
+/* The type of events that will hide the mouse cursor. */
+int _cons_hide_mouse = CONS_EVT_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-on", 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-on", 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 client.";
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 |= CONS_EVT_MOUSE_MOVE;
+ else if (!strcasecmp ("mousebutton", tok))
+ evmask |= CONS_EVT_MOUSE_BUTTON;
+ else if (!strcasecmp ("keypress", tok))
+ evmask |= CONS_EVT_KEYPRESS;
+ else if (!strcasecmp ("output", tok))
+ evmask |= CONS_EVT_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, struct argp_state *state)
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 --git a/libcons/priv.h b/libcons/priv.h
index a1ec2451..377f021c 100644
--- a/libcons/priv.h
+++ b/libcons/priv.h
@@ -1,5 +1,5 @@
/* Private declarations for cons library
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -29,6 +29,11 @@ typedef enum
BELL_AUDIBLE
} bell_type_t;
+#define CONS_EVT_MOUSE_MOVE (1 << 1)
+#define CONS_EVT_MOUSE_BUTTON (1 << 2)
+#define CONS_EVT_KEYPRESS (1 << 4)
+#define CONS_EVT_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 --git a/libcons/vcons-event.c b/libcons/vcons-event.c
new file mode 100644
index 00000000..d8c31dc0
--- /dev/null
+++ b/libcons/vcons-event.c
@@ -0,0 +1,31 @@
+/* vcons-event.c - Handle console events.
+ Copyright (C) 2004, 2005 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 --git a/libcons/vcons-input.c b/libcons/vcons-input.c
index 95f2b972..e008b9c9 100644
--- a/libcons/vcons-input.c
+++ b/libcons/vcons-input.c
@@ -1,5 +1,5 @@
/* vcons-input.c - Add input to a virtual console.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 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 *buf, size_t size)
}
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, CONS_EVT_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 --git a/libcons/vcons-move-mouse.c b/libcons/vcons-move-mouse.c
new file mode 100644
index 00000000..1e5f7b9f
--- /dev/null
+++ b/libcons/vcons-move-mouse.c
@@ -0,0 +1,103 @@
+/* vcons-move-mouse.c - Catch mouse events.
+ Copyright (C) 2004, 2005 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)
+{
+ char event[CONS_MOUSE_EVENT_LENGTH];
+ uint32_t report_events;
+
+ mutex_lock (&vcons->lock);
+ report_events = vcons->display->flags & CONS_FLAGS_TRACK_MOUSE;
+
+ switch (ev->mouse_movement)
+ {
+ case CONS_VCONS_MOUSE_MOVE_REL:
+ mousepos_x += ((float) ev->x / _cons_mouse_sens);
+ mousepos_y += ((float) ev->y / _cons_mouse_sens);
+ break;
+
+ case CONS_VCONS_MOUSE_MOVE_ABS_PERCENT:
+ mousepos_x = vcons->state.screen.width * ev->x / 100;
+ mousepos_y = vcons->state.screen.height * ev->y / 100;
+
+ case CONS_VCONS_MOUSE_MOVE_ABS:
+ mousepos_x = ev->x;
+ mousepos_y = ev->y;
+ 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, CONS_EVT_MOUSE_MOVE);
+
+ /* Report a mouse button event. */
+ if (ev->mouse_button != CONS_VCONS_MOUSE_BUTTON_NO_OP)
+ _cons_vcons_console_event (vcons, CONS_EVT_MOUSE_BUTTON);
+
+ if (report_events)
+ {
+ switch (ev->mouse_button)
+ {
+ case CONS_VCONS_MOUSE_BUTTON_NO_OP:
+ break;
+
+ case CONS_VCONS_MOUSE_BUTTON_PRESSED:
+ /* Make an 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 CONS_VCONS_MOUSE_BUTTON_RELEASED:
+ /* Make an 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 --git a/libcons/vcons-refresh.c b/libcons/vcons-refresh.c
index 7a572c79..ce6807fe 100644
--- a/libcons/vcons-refresh.c
+++ b/libcons/vcons-refresh.c
@@ -1,5 +1,5 @@
/* vcons-refresh.c - Redraw a virtual console.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 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, CONS_EVT_OUTPUT);
cons_vcons_update (vcons);
}
diff --git a/libcons/vcons-scrollback.c b/libcons/vcons-scrollback.c
index c54303e9..77c8c211 100644
--- a/libcons/vcons-scrollback.c
+++ b/libcons/vcons-scrollback.c
@@ -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, 2005 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, cons_scroll_t type, float value)
mutex_lock (&vcons->lock);
ret = _cons_vcons_scrollback (vcons, type, value);
+ _cons_vcons_console_event (vcons, CONS_EVT_OUTPUT);
cons_vcons_update (vcons);
mutex_unlock (&vcons->lock);
return ret;