2003-08-11 Marco Gerards <metgerards@student.han.nl> * cons.h (struct vcons): New member extern_audible. * file-changed.c (cons_S_file_changed): Use the extern bell. * opt-std-startup.c (OPT_EXTERN_BELL): New macro. (_cons_extern_bell): New variable. (startup_options): Added option "--extern-bell". (parse_startup_opt): ...and parse that new option here. * priv.h (_cons_extern_bell): New external variable. * vcons-refresh.c (cons_vcons_refresh): Setup the extern bell state. Common subdirectories: /home/marco/src/hurdcvs/hurd/libcons/CVS and libcons/CVS diff -up /home/marco/src/hurdcvs/hurd/libcons/cons.h libcons/cons.h --- /home/marco/src/hurdcvs/hurd/libcons/cons.h 2002-09-17 13:47:15.000000000 +0200 +++ libcons/cons.h 2003-08-11 22:46:06.000000000 +0200 @@ -96,6 +96,7 @@ struct vcons { uint32_t audible; uint32_t visible; + uint32_t extern_audible; } bell; struct { diff -up /home/marco/src/hurdcvs/hurd/libcons/file-changed.c libcons/file-changed.c --- /home/marco/src/hurdcvs/hurd/libcons/file-changed.c 2003-08-03 01:54:29.000000000 +0200 +++ libcons/file-changed.c 2003-08-11 23:28:25.000000000 +0200 @@ -209,6 +209,20 @@ cons_S_file_changed (cons_notify_t notif vcons->state.bell.audible++; } } + + if (change.what.extern_bell_audible) + { + while (vcons->state.bell.extern_audible + < vcons->display->bell.extern_audible) + { + if (_cons_extern_bell == BELL_AUDIBLE) + cons_vcons_beep (vcons); + else if (_cons_extern_bell == BELL_VISUAL) + cons_vcons_flash (vcons); + vcons->state.bell.extern_audible++; + } + } + if (change.what.bell_visible) { while (vcons->state.bell.visible diff -up /home/marco/src/hurdcvs/hurd/libcons/opts-std-startup.c libcons/opts-std-startup.c --- /home/marco/src/hurdcvs/hurd/libcons/opts-std-startup.c 2003-08-03 01:54:29.000000000 +0200 +++ libcons/opts-std-startup.c 2003-08-11 23:27:03.000000000 +0200 @@ -33,6 +33,7 @@ #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_EXTERN_BELL 607 /* --external-bell */ /* Common value for diskfs_common_options and diskfs_default_sync_interval. */ #define DEFAULT_SLACK 100 @@ -59,6 +60,9 @@ 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 bell used for the audible bell. */ +bell_type_t _cons_extern_bell = BELL_OFF; + static const struct argp_option startup_options[] = { @@ -76,6 +80,8 @@ startup_options[] = "off, visual, audible" }, { "audible-bell", OPT_AUDIBLE_BELL, "BELL", 0, "Audible bell: on (default), " "off, visual, audible" }, + { "extern-bell", OPT_EXTERN_BELL, "BELL", 0, "Extern audible bell: on, " + "off (default), visual, audible" }, { 0, 0 } }; @@ -131,6 +137,18 @@ 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_EXTERN_BELL: + if (!strcasecmp ("on", arg) || !strcasecmp ("audible", arg)) + _cons_extern_bell = BELL_AUDIBLE; + else if (!strcasecmp ("off", arg)) + _cons_extern_bell = BELL_OFF; + else if (!strcasecmp ("visual", arg)) + _cons_extern_bell = BELL_VISUAL; + else + argp_error (state, "The extern audible bell can be one of: on, off, " + "visual, audible"); + break; case ARGP_KEY_ARG: if (state->arg_num > 0) diff -up /home/marco/src/hurdcvs/hurd/libcons/priv.h libcons/priv.h --- /home/marco/src/hurdcvs/hurd/libcons/priv.h 2003-08-03 01:54:29.000000000 +0200 +++ libcons/priv.h 2003-08-11 23:29:29.000000000 +0200 @@ -49,6 +49,9 @@ 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 bell used for the extern audible bell. */ +extern bell_type_t _cons_extern_bell; + /* Non-locking version of cons_vcons_scrollback. Does also not update the display. */ diff -up /home/marco/src/hurdcvs/hurd/libcons/vcons-refresh.c libcons/vcons-refresh.c --- /home/marco/src/hurdcvs/hurd/libcons/vcons-refresh.c 2002-09-22 04:05:47.000000000 +0200 +++ libcons/vcons-refresh.c 2003-08-11 23:06:14.000000000 +0200 @@ -35,6 +35,7 @@ cons_vcons_refresh (vcons_t vcons) vcons->state.cursor.status = vcons->display->cursor.status; vcons->state.bell.audible = vcons->display->bell.audible; vcons->state.bell.visible = vcons->display->bell.visible; + vcons->state.bell.extern_audible = vcons->display->bell.extern_audible; vcons->state.flags = vcons->display->flags; vcons->state.changes.written = vcons->display->changes.written; 2003-08-11 Marco Gerards <metgerards@student.han.nl> * console.c (cons_display_iterate): New function. * display.c (struct changes): New member. (DISPLAY_CHANGE_BELL_EXTERN): New macro. (display_flush_filechange): New prototype. (cons_display_iterate): Likewise. (display_broadcast_bell): New function. (display_flush_filechange): Broadcast the bell. Handle DISPLAY_CHANGE_BELL_EXTERN. (display_output_some): Initialize the changes for the extern bell. Common subdirectories: /home/marco/src/hurdcvs/hurd/console/CVS and console/CVS diff -up /home/marco/src/hurdcvs/hurd/console/console.c console/console.c --- /home/marco/src/hurdcvs/hurd/console/console.c 2003-06-03 23:19:00.000000000 +0200 +++ console/console.c 2003-08-11 22:40:50.000000000 +0200 @@ -1326,6 +1326,30 @@ netfs_S_file_notice_changes (struct prot } +/* Call for every display FUNC with the display, the VC number and ARG + as arguments. Stop if FUNC returns an error and return that error. + FUN is responsible for locking and unlocking the display. */ +error_t +cons_display_iterate (error_t (*fun)(display_t, int vc, void *), void *arg) +{ + cons_t cons = netfs_root_node->nn->cons; + vcons_t vc; + + mutex_lock (&cons->lock); + for (vc = cons->vcons_list; vc; vc = vc->next) + { + error_t err = (*fun) (vc->display, vc->id, arg); + if (err) + { + mutex_unlock (&cons->lock); + return err; + } + } + mutex_unlock (&cons->lock); + return 0; +} + + static const char *color_names[CONS_COLOR_MAX + 1] = { [CONS_COLOR_BLACK] = "black", diff -up /home/marco/src/hurdcvs/hurd/console/display.c console/display.c --- /home/marco/src/hurdcvs/hurd/console/display.c 2003-06-03 23:19:00.000000000 +0200 +++ console/display.c 2003-08-12 00:05:26.000000000 +0200 @@ -60,6 +60,7 @@ struct changes uint32_t bell_audible; uint32_t bell_visible; + uint32_t bell_extern_audible; off_t start; off_t end; @@ -72,6 +73,8 @@ struct changes #define DISPLAY_CHANGE_BELL_VISIBLE 0x0020 #define DISPLAY_CHANGE_FLAGS 0x0030 #define DISPLAY_CHANGE_MATRIX 0x0040 +#define DISPLAY_CHANGE_BELL_EXTERN 0x0080 + unsigned int which; }; @@ -527,6 +530,29 @@ display_notice_changes (display_t displa return 0; } +static void display_flush_filechange (display_t display, unsigned int type); + +error_t +display_broadcast_bell (display_t display, int id, void *arg) +{ + display_t display_ignore = arg; + struct cons_display *user = display->user; + + /* The console is the broadcaster and doesn't receive the event. */ + if (display_ignore == display) + return 0; + + mutex_lock (&display->lock); + user->bell.extern_audible++; + user->bell.bell_extern_console = id; + + display->changes.which |= DISPLAY_CHANGE_BELL_EXTERN; + display_flush_filechange (display, DISPLAY_CHANGE_BELL_EXTERN); + mutex_unlock (&display->lock); + + return 0; +} + /* Requires DISPLAY to be locked. */ static void display_notice_filechange (display_t display) @@ -576,6 +602,9 @@ display_notice_filechange (display_t dis } } +error_t cons_display_iterate (error_t (*fun)(display_t, int vc, void *), + void *arg); + static void display_flush_filechange (display_t display, unsigned int type) { @@ -649,6 +678,20 @@ display_flush_filechange (display_t disp next->what.bell_audible = 1; bump_written = 1; display->changes.which &= ~DISPLAY_CHANGE_BELL_AUDIBLE; + + /* Broadcast the event to all other virtual consoles. */ + cons_display_iterate (display_broadcast_bell, display); + } + + if (type & DISPLAY_CHANGE_BELL_EXTERN + && display->changes.which & DISPLAY_CHANGE_BELL_EXTERN + && display->changes.bell_extern_audible != user->bell.extern_audible) + { + notify = 1; + next->what.extern_bell_audible = 1; + next->what.extern_bell_console = user->bell.extern_audible; + bump_written = 1; + display->changes.which &= ~DISPLAY_CHANGE_BELL_EXTERN; } if (type & DISPLAY_CHANGE_BELL_VISIBLE @@ -1731,6 +1774,7 @@ display_output_some (display_t display, display->changes.screen.scr_lines = display->user->screen.scr_lines; display->changes.bell_audible = display->user->bell.audible; display->changes.bell_visible = display->user->bell.visible; + display->changes.bell_extern_audible = display->user->bell.extern_audible; display->changes.flags = display->user->flags; display->changes.which = ~DISPLAY_CHANGE_MATRIX; 2003-08-11 Marco Gerards <metgerards@student.han.nl> * console.h (cons_change_t): New members extern_bell_audible and extern_bell_console. Changed _unused its size from 24 to 23 bits. (cons_display): New members extern_audible and bell_extern_console. Common subdirectories: /home/marco/src/hurdcvs/hurd/hurd/CVS and hurd/CVS diff -up /home/marco/src/hurdcvs/hurd/hurd/console.h hurd/console.h --- /home/marco/src/hurdcvs/hurd/hurd/console.h 2002-10-04 12:23:00.000000000 +0200 +++ hurd/console.h 2003-08-12 01:14:03.000000000 +0200 @@ -74,9 +74,11 @@ typedef union uint32_t bell_audible : 1; uint32_t bell_visible : 1; uint32_t flags : 1; - uint32_t _unused : 24; + uint32_t extern_bell_audible : 1; + uint32_t _unused : 23; uint32_t not_matrix : 1; - /* Here are 32 more unused bits. */ + uint16_t extern_bell_console; + /* Here are 16 more unused bits. */ } what; } cons_change_t; @@ -138,6 +140,8 @@ struct cons_display { uint32_t audible; /* Audible bell. */ uint32_t visible; /* Visible bell. */ + uint32_t extern_audible; /* Broadcasted audible bell. */ + uint16_t bell_extern_console; /* The console that broadcasted. */ } bell; struct