diff options
| author | Karoly Lorentey | 2004-01-23 21:48:58 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-01-23 21:48:58 +0000 |
| commit | d448e98221f74c780d5163ed819b782ee32f7d74 (patch) | |
| tree | e4957b71e9a3aa7732f23b5c2bd1b2f1f884809a /src | |
| parent | 6c3d443b13f9db58f54057b1061b1853c47cc6b8 (diff) | |
| download | emacs-d448e98221f74c780d5163ed819b782ee32f7d74.tar.gz emacs-d448e98221f74c780d5163ed819b782ee32f7d74.zip | |
Fixed tty faces during combo sessions. Plus other assorted bugfixes.
lisp/startup.el (command-line): Always call tty-register-default-colors.
src/dispextern.h (delete_tty): Added missing prototype.
src/keyboard.c (read_avail_input): Close display gracefully if needed.
Kill Emacs if the last display is to be closed.
(tty_read_avail_input): Don't call delete_tty and don't signal hangup here;
return -2 instead to indicate the non-transient failure to read_avail_input.
src/term.c (delete_tty): Removed superflous wiping of the deleted
frames' output_data field.
(delete_display): Check for and close live frames that are still on the display.
src/termhooks.h (read_socket_hook, delete_display_hook): Added detailed comment.
src/xfaces.c (realize_face): Create a dummy face for the initial frame.
(Reported by Robert J. Chassell (bob at rattlenake dot com).)
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-61
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispextern.h | 1 | ||||
| -rw-r--r-- | src/keyboard.c | 57 | ||||
| -rw-r--r-- | src/term.c | 14 | ||||
| -rw-r--r-- | src/termhooks.h | 36 | ||||
| -rw-r--r-- | src/xfaces.c | 7 |
5 files changed, 80 insertions, 35 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 79b949b6337..8c86967c538 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2797,6 +2797,7 @@ extern void tty_setup_colors P_ ((struct tty_display_info *, int)); | |||
| 2797 | extern struct display *get_named_tty_display P_ ((char *)); | 2797 | extern struct display *get_named_tty_display P_ ((char *)); |
| 2798 | extern struct display *init_initial_display P_ ((void)); | 2798 | extern struct display *init_initial_display P_ ((void)); |
| 2799 | extern struct display *term_init P_ ((char *, char *, int)); | 2799 | extern struct display *term_init P_ ((char *, char *, int)); |
| 2800 | extern void delete_tty P_ ((struct display *)); | ||
| 2800 | extern void fatal P_ ((/* char *, ... */)); | 2801 | extern void fatal P_ ((/* char *, ... */)); |
| 2801 | extern void cursor_to P_ ((int, int)); | 2802 | extern void cursor_to P_ ((int, int)); |
| 2802 | extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); | 2803 | extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); |
diff --git a/src/keyboard.c b/src/keyboard.c index cdf28bd5e66..dae54ad8a79 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -6580,14 +6580,36 @@ read_avail_input (expected) | |||
| 6580 | for (i = 0; i < KBD_BUFFER_SIZE; i++) | 6580 | for (i = 0; i < KBD_BUFFER_SIZE; i++) |
| 6581 | EVENT_INIT (buf[i]); | 6581 | EVENT_INIT (buf[i]); |
| 6582 | 6582 | ||
| 6583 | for (d = display_list; d; d = d->next_display) | 6583 | d = display_list; |
| 6584 | while (d) | ||
| 6584 | { | 6585 | { |
| 6586 | struct display *next = d->next_display; | ||
| 6587 | |||
| 6585 | if (d->read_socket_hook) | 6588 | if (d->read_socket_hook) |
| 6586 | /* No need for FIONREAD or fcntl; just say don't wait. */ | 6589 | /* No need for FIONREAD or fcntl; just say don't wait. */ |
| 6587 | nread = (*d->read_socket_hook) (d, buf, KBD_BUFFER_SIZE, expected); | 6590 | nread = (*d->read_socket_hook) (d, buf, KBD_BUFFER_SIZE, expected); |
| 6588 | 6591 | ||
| 6589 | if (nread > 0) | 6592 | if (nread == -2) |
| 6590 | break; | 6593 | { |
| 6594 | /* The display device terminated; it should be closed. */ | ||
| 6595 | |||
| 6596 | /* Kill Emacs if this was our last display. */ | ||
| 6597 | if (! display_list->next_display) | ||
| 6598 | kill (getpid (), SIGHUP); | ||
| 6599 | |||
| 6600 | /* XXX Is calling delete_display safe here? It calls Fdelete_frame. */ | ||
| 6601 | if (d->delete_display_hook) | ||
| 6602 | (*d->delete_display_hook) (d); | ||
| 6603 | else | ||
| 6604 | delete_display (d); | ||
| 6605 | } | ||
| 6606 | else if (nread > 0) | ||
| 6607 | { | ||
| 6608 | /* We've got input. */ | ||
| 6609 | break; | ||
| 6610 | } | ||
| 6611 | |||
| 6612 | d = next; | ||
| 6591 | } | 6613 | } |
| 6592 | 6614 | ||
| 6593 | /* Scan the chars for C-g and store them in kbd_buffer. */ | 6615 | /* Scan the chars for C-g and store them in kbd_buffer. */ |
| @@ -6609,6 +6631,7 @@ read_avail_input (expected) | |||
| 6609 | Note that each terminal device has its own `struct display' object, | 6631 | Note that each terminal device has its own `struct display' object, |
| 6610 | and so this function is called once for each individual termcap | 6632 | and so this function is called once for each individual termcap |
| 6611 | display. The first parameter indicates which device to read from. */ | 6633 | display. The first parameter indicates which device to read from. */ |
| 6634 | |||
| 6612 | int | 6635 | int |
| 6613 | tty_read_avail_input (struct display *display, | 6636 | tty_read_avail_input (struct display *display, |
| 6614 | struct input_event *buf, | 6637 | struct input_event *buf, |
| @@ -6650,23 +6673,9 @@ tty_read_avail_input (struct display *display, | |||
| 6650 | if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0) | 6673 | if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0) |
| 6651 | { | 6674 | { |
| 6652 | if (! noninteractive) | 6675 | if (! noninteractive) |
| 6653 | { | 6676 | return -2; /* Close this display. */ |
| 6654 | delete_tty (tty); /* XXX I wonder if this is safe here. */ | ||
| 6655 | |||
| 6656 | /* Formerly simply reported no input, but that sometimes led to | ||
| 6657 | a failure of Emacs to terminate. | ||
| 6658 | SIGHUP seems appropriate if we can't reach the terminal. */ | ||
| 6659 | /* ??? Is it really right to send the signal just to this process | ||
| 6660 | rather than to the whole process group? | ||
| 6661 | Perhaps on systems with FIONREAD Emacs is alone in its group. */ | ||
| 6662 | /* It appears to be the case, see narrow_foreground_group. */ | ||
| 6663 | if (! tty_list->next) | ||
| 6664 | kill (getpid (), SIGHUP); /* This was the last terminal. */ | ||
| 6665 | } | ||
| 6666 | else | 6677 | else |
| 6667 | { | 6678 | n_to_read = 0; |
| 6668 | n_to_read = 0; | ||
| 6669 | } | ||
| 6670 | } | 6679 | } |
| 6671 | if (n_to_read == 0) | 6680 | if (n_to_read == 0) |
| 6672 | return 0; | 6681 | return 0; |
| @@ -6694,10 +6703,7 @@ tty_read_avail_input (struct display *display, | |||
| 6694 | Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ | 6703 | Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ |
| 6695 | if (nread == -1 && errno == EIO) | 6704 | if (nread == -1 && errno == EIO) |
| 6696 | { | 6705 | { |
| 6697 | if (! tty_list->next) | 6706 | return -2; /* Close this display. */ |
| 6698 | kill (0, SIGHUP); /* This was the last terminal. */ | ||
| 6699 | else | ||
| 6700 | delete_tty (tty); /* XXX I wonder if this is safe here. */ | ||
| 6701 | } | 6707 | } |
| 6702 | #if defined (AIX) && (! defined (aix386) && defined (_BSD)) | 6708 | #if defined (AIX) && (! defined (aix386) && defined (_BSD)) |
| 6703 | /* The kernel sometimes fails to deliver SIGHUP for ptys. | 6709 | /* The kernel sometimes fails to deliver SIGHUP for ptys. |
| @@ -6706,10 +6712,7 @@ tty_read_avail_input (struct display *display, | |||
| 6706 | and that causes a value other than 0 when there is no input. */ | 6712 | and that causes a value other than 0 when there is no input. */ |
| 6707 | if (nread == 0) | 6713 | if (nread == 0) |
| 6708 | { | 6714 | { |
| 6709 | if (! tty_list->next) | 6715 | return -2; /* Close this display. */ |
| 6710 | kill (0, SIGHUP); /* This was the last terminal. */ | ||
| 6711 | else | ||
| 6712 | delete_tty (tty); /* XXX I wonder if this is safe here. */ | ||
| 6713 | } | 6716 | } |
| 6714 | #endif | 6717 | #endif |
| 6715 | } | 6718 | } |
diff --git a/src/term.c b/src/term.c index c6782efa606..f63c6c68774 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2843,7 +2843,6 @@ delete_tty (struct display *display) | |||
| 2843 | if (FRAME_TERMCAP_P (f) && FRAME_LIVE_P (f) && FRAME_TTY (f) == tty) | 2843 | if (FRAME_TERMCAP_P (f) && FRAME_LIVE_P (f) && FRAME_TTY (f) == tty) |
| 2844 | { | 2844 | { |
| 2845 | Fdelete_frame (frame, Qt); | 2845 | Fdelete_frame (frame, Qt); |
| 2846 | f->output_data.tty = 0; | ||
| 2847 | } | 2846 | } |
| 2848 | } | 2847 | } |
| 2849 | 2848 | ||
| @@ -2968,6 +2967,19 @@ void | |||
| 2968 | delete_display (struct display *dev) | 2967 | delete_display (struct display *dev) |
| 2969 | { | 2968 | { |
| 2970 | struct display **dp; | 2969 | struct display **dp; |
| 2970 | Lisp_Object tail, frame; | ||
| 2971 | |||
| 2972 | /* Check for and close live frames that are still on this | ||
| 2973 | display. */ | ||
| 2974 | FOR_EACH_FRAME (tail, frame) | ||
| 2975 | { | ||
| 2976 | struct frame *f = XFRAME (frame); | ||
| 2977 | if (FRAME_LIVE_P (f) && f->display == dev) | ||
| 2978 | { | ||
| 2979 | Fdelete_frame (frame, Qt); | ||
| 2980 | } | ||
| 2981 | } | ||
| 2982 | |||
| 2971 | for (dp = &display_list; *dp != dev; dp = &(*dp)->next_display) | 2983 | for (dp = &display_list; *dp != dev; dp = &(*dp)->next_display) |
| 2972 | if (! *dp) | 2984 | if (! *dp) |
| 2973 | abort (); | 2985 | abort (); |
diff --git a/src/termhooks.h b/src/termhooks.h index 7dda9e2ef07..8a0c37434e1 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -472,8 +472,27 @@ struct display | |||
| 472 | void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME)); | 472 | void (*judge_scroll_bars_hook) P_ ((struct frame *FRAME)); |
| 473 | 473 | ||
| 474 | 474 | ||
| 475 | /* Called to read input events. */ | 475 | /* Called to read input events. |
| 476 | int (*read_socket_hook) P_ ((struct display *, struct input_event *, int, int)); | 476 | |
| 477 | DISPLAY indicates which display to read from. Input events | ||
| 478 | should be read into BUF, the size of which is given in SIZE. | ||
| 479 | EXPECTED is non-zero if the caller suspects that new input is | ||
| 480 | available. | ||
| 481 | |||
| 482 | A positive return value indicates that that many input events | ||
| 483 | where read into BUF. | ||
| 484 | Zero means no events were immediately available. | ||
| 485 | A value of -1 means a transient read error, while -2 indicates | ||
| 486 | that the display was closed (hangup), and it should be deleted. | ||
| 487 | |||
| 488 | XXX Please note that a non-zero value of EXPECTED only means that | ||
| 489 | there is available input on at least one of the currently opened | ||
| 490 | display devices -- but not necessarily on this device. | ||
| 491 | Therefore, in most cases EXPECTED should be simply ignored. | ||
| 492 | */ | ||
| 493 | int (*read_socket_hook) P_ ((struct display *display, | ||
| 494 | struct input_event *buf, | ||
| 495 | int size, int expected)); | ||
| 477 | 496 | ||
| 478 | /* Called when a frame's display becomes entirely up to date. */ | 497 | /* Called when a frame's display becomes entirely up to date. */ |
| 479 | void (*frame_up_to_date_hook) P_ ((struct frame *)); | 498 | void (*frame_up_to_date_hook) P_ ((struct frame *)); |
| @@ -483,11 +502,16 @@ struct display | |||
| 483 | on this display. */ | 502 | on this display. */ |
| 484 | void (*delete_frame_hook) P_ ((struct frame *)); | 503 | void (*delete_frame_hook) P_ ((struct frame *)); |
| 485 | 504 | ||
| 486 | /* Called after the last frame on this display is deleted. | 505 | /* Called after the last frame on this display is deleted, or when |
| 487 | If this is NULL, then the generic delete_frame() is called. | 506 | the display device was closed (hangup). |
| 507 | |||
| 508 | If this is NULL, then the generic delete_frame() is called | ||
| 509 | instead. | ||
| 488 | 510 | ||
| 489 | Fdelete_frame ensures that there are no live frames on the | 511 | The hook must check for and close any live frames that are still |
| 490 | display when it calls this hook. */ | 512 | on the display. Fdelete_frame ensures that there are no live |
| 513 | frames on the display when it calls this hook, so infinite | ||
| 514 | recursion is prevented. */ | ||
| 491 | void (*delete_display_hook) P_ ((struct display *)); | 515 | void (*delete_display_hook) P_ ((struct display *)); |
| 492 | 516 | ||
| 493 | }; | 517 | }; |
diff --git a/src/xfaces.c b/src/xfaces.c index 94474ec94cd..fc23b3e2b24 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -6830,8 +6830,13 @@ realize_face (cache, attrs, c, base_face, former_face_id) | |||
| 6830 | 6830 | ||
| 6831 | if (FRAME_WINDOW_P (cache->f)) | 6831 | if (FRAME_WINDOW_P (cache->f)) |
| 6832 | face = realize_x_face (cache, attrs, c, base_face); | 6832 | face = realize_x_face (cache, attrs, c, base_face); |
| 6833 | else if (FRAME_INITIAL_P (cache->f) || FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) | 6833 | else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) |
| 6834 | face = realize_tty_face (cache, attrs, c); | 6834 | face = realize_tty_face (cache, attrs, c); |
| 6835 | else if (FRAME_INITIAL_P (cache->f)) | ||
| 6836 | { | ||
| 6837 | /* Create a dummy face. */ | ||
| 6838 | face = make_realized_face (attrs); | ||
| 6839 | } | ||
| 6835 | else | 6840 | else |
| 6836 | abort (); | 6841 | abort (); |
| 6837 | 6842 | ||