From 38fc4e4d1cef98a8b3d60b717647a9c65d91307f Mon Sep 17 00:00:00 2001 From: Marco Gerards Date: Thu, 6 Jan 2005 21:43:53 +0000 Subject: 2005-01-06 Marco Gerards * Makefile (SRCS): Add `trans.c'. (LCLHDRS): Add `mach-inputdev.h'. (HURDLIBS): Add `netfs', `fshelp' and `iohelp'. (modules): Add `pc_mouse'. (pc_kbd.so.$(hurd-version)): Add `kdioctlServer.o' and `kbd-repeat.c'. (pc_mouse.so.$(hurd-version)): New variable. * console.c: Include . (DEFAULT_CONSOLE_NODE): New macro. (saved_id, saved_cons, consnode_path): New variables. (console_move_mouse): New function. (console_switch_away): New function. (console_switch_back): Likewise. (cons_vcons_set_mousecursor_pos): Likewise. (cons_vcons_set_mousecursor_status): Likewise. (options): Add the option `--console-node'. (parse_opt): Parse the options that were added to `options'. (main): Setup the console client translator node. * display.h (display_ops): New members `set_mousecursor_pos' and `set_mousecursor_status'. * driver.c (driver_start): Change the type of `i' to `unsigned int'. * driver.h (driver_ops): New members `save_status' and `restore_status'. * input.h (console_switch_away): New prototype. (console_switch_back): Likewise. (console_move_mouse): Likewise. * kbd-repeat.c: New file. * mach-inputdev.h: Likewise. * pc-mouse.c: Likewise. * trans.c: Likewise. * trans.h: Likewise. * pc-kbd.c: Include and "mach-inputdev.h". (DEFAULT_REPEATER_NODE): New macro. (repeater_node, cnode): New variables. (kev_type, mouse_motion, Scancode, m_deltaX, m_deltaY, MOUSE_LEFT) (MOUSE_MIDDLE, MOUSE_RIGHT, MOUSE_MOTION, KEYBD_EVENT) (IOCPARM_MASK, IOC_OUT, IOC_IN, _IOC, _IOR, _IOW, KDSKBDMODE, (KB_EVENT, KB_ASCII, KDGKBDTYPE, KB_VANILLAKB, KDSETLEDS): Removed. (gnumach_v1_input_next): Call the repeater when repeating is active. (doc, options, argp): New variables. (parse_opt): New function. (pc_kbd_init): Function rewritten. (pc_kbd_start): Initialize the repeater, when it is active. (pc_kbd_fini): Destroy the console node. * vga.c (vga_mousecursor): New struct. (vga_mousecursor_t): New type. (mousecursor): New variable. (hide_mousecursor): New function. (draw_mousecursor): Likewise. (vga_display_restore_status): Likewise. (vga_display_update): Likewise. (vga_set_mousecursor_pos): Likewise. (vga_set_mousecursor_status): Likewise. (vga_display_scroll): Update the mousecursor state. (driver_vga_ops): Add `vga_display_restore_status'. (vga_display_op): Add `vga_display_update', `vga_set_mousecursor_pos' and `vga_set_mousecursor_status'. --- console-client/console.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) (limited to 'console-client/console.c') diff --git a/console-client/console.c b/console-client/console.c index 4bc9d6f4..ec518ddb 100644 --- a/console-client/console.c +++ b/console-client/console.c @@ -1,5 +1,5 @@ /* console.c -- A pluggable console client. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Written by Marcus Brinkmann. This program is free software; you can redistribute it and/or @@ -34,10 +34,14 @@ #include "driver.h" #include "timer.h" +#include "trans.h" const char *cons_client_name = "console"; const char *cons_client_version = HURD_VERSION; +/* The default node on which the console node is started. */ +#define DEFAULT_CONSOLE_NODE "/dev/cons" + /* The global lock protects the active_vcons variable, and thus all operations on the virtual console that is currently active. */ @@ -47,6 +51,15 @@ static struct mutex global_lock; displayed. */ static vcons_t active_vcons = NULL; +/* Contains the VT id when switched away. */ +static int saved_id = 0; + +/* The console, used to switch back. */ +static cons_t saved_cons; + +/* The pathname of the node on which the translator is set. */ +static char *consnode_path; + /* Callbacks for input source drivers. */ @@ -121,6 +134,37 @@ console_input (char *buf, size_t size) } +/* Report the mouse event EV to the currently active console. This + can be called by the input driver at any time. */ +error_t +console_move_mouse (mouse_event_t ev) +{ + error_t err; + vcons_t vcons; + + mutex_lock (&global_lock); + + vcons = active_vcons; + if (!vcons) + { + mutex_unlock (&global_lock); + return EINVAL; + } + ports_port_ref (vcons); + mutex_unlock (&global_lock); + + if (vcons) + { + err = cons_vcons_move_mouse (vcons, ev); + ports_port_deref (vcons); + } + + mutex_unlock (&global_lock); + + return 0; +} + + /* Scroll the active console by TYPE and VALUE as specified by cons_vcons_scrollback. */ int @@ -148,6 +192,62 @@ console_scrollback (cons_scroll_t type, float value) } +/* Switch away from the console an external use of the console like + XFree. */ +void +console_switch_away (void) +{ + mutex_lock (&global_lock); + + driver_iterate + if (driver->ops->save_status) + driver->ops->save_status (driver->handle); + + saved_id = active_vcons->id; + saved_cons = active_vcons->cons; + cons_vcons_close (active_vcons); + active_vcons = NULL; + mutex_unlock (&global_lock); +} + +/* Switch back to the console client from an external user of the + console like XFree. */ +void +console_switch_back (void) +{ + vcons_list_t conslist; + mutex_lock (&global_lock); + + driver_iterate + if (driver->ops->restore_status) + driver->ops->restore_status (driver->handle); + + if (saved_cons) + { + error_t err; + + err = cons_lookup (saved_cons, saved_id, 1, &conslist); + if (err) + { + mutex_unlock (&global_lock); + return; + } + + err = cons_vcons_open (saved_cons, conslist, &active_vcons); + if (err) + { + mutex_unlock (&global_lock); + return; + } + + conslist->vcons = active_vcons; + saved_cons = NULL; + mutex_unlock (&active_vcons->lock); + } + mutex_unlock (&global_lock); +} + + /* Exit the console client. Does not return. */ void console_exit (void) @@ -371,6 +471,33 @@ cons_vcons_set_dimension (vcons_t vcons, uint32_t col, uint32_t row) return 0; } + +error_t +cons_vcons_set_mousecursor_pos (vcons_t vcons, float x, float y) +{ + mutex_lock (&global_lock); + if (vcons == active_vcons) + display_iterate + if (display->ops->set_mousecursor_pos) + display->ops->set_mousecursor_pos (display->handle, x, y); + mutex_unlock (&global_lock); + return 0; +} + + +error_t +cons_vcons_set_mousecursor_status (vcons_t vcons, int status) +{ + mutex_lock (&global_lock); + if (vcons == active_vcons) + display_iterate + if (display->ops->set_mousecursor_status) + display->ops->set_mousecursor_status (display->handle, status); + mutex_unlock (&global_lock); + return 0; + +} + /* Console-specific options. */ static const struct argp_option @@ -378,6 +505,8 @@ options[] = { {"driver-path", 'D', "PATH", 0, "Specify search path for driver modules" }, {"driver", 'd', "NAME", 0, "Add driver NAME to the console" }, + {"console-node", 'c', "FILE", OPTION_ARG_OPTIONAL, + "Set a translator on the node FILE (default: " DEFAULT_CONSOLE_NODE ")" }, {0} }; @@ -426,6 +555,12 @@ parse_opt (int key, char *arg, struct argp_state *state) devcount++; break; + case 'c': + consnode_path = arg ? arg : DEFAULT_CONSOLE_NODE; + if (!consnode_path) + return ENOMEM; + break; + case ARGP_KEY_SUCCESS: if (!devcount) { @@ -477,6 +612,9 @@ main (int argc, char *argv[]) error (1, err, "Timer thread initialization failed"); } + if (consnode_path) + console_setup_node (consnode_path); + cons_server_loop (); /* Never reached. */ -- cgit v1.2.3