From 9b2cd403209d7fa25b310b29a2f0a570865fbbb3 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 9 Apr 2008 03:25:14 +0000 Subject: [PATCH] * xdisp.c (redisplay_internal): Reset tty's color_mode when switching to another frame. * frame.c (do_switch_frame): Refine the top_frame/async_visible code. Don't call set_tty_color_mode. (store_frame_param): Reset previous_frame rather than call set_tty_color_mode. * term.c (set_tty_color_mode): Rewrite. * dispextern.h (set_tty_color_mode): New type. * termchar.h (struct tty_display_info): Add `previous_color_mode'. --- src/ChangeLog | 12 +++++++++++ src/dispextern.h | 2 +- src/frame.c | 37 ++++++++++---------------------- src/term.c | 56 ++++++++++++++++-------------------------------- src/termchar.h | 1 + src/xdisp.c | 1 + 6 files changed, 45 insertions(+), 64 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e1ef9ffb52a..68e50dd376f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2008-04-09 Stefan Monnier + + * xdisp.c (redisplay_internal): Reset tty's color_mode when switching + to another frame. + * frame.c (do_switch_frame): Refine the top_frame/async_visible code. + Don't call set_tty_color_mode. + (store_frame_param): Reset previous_frame rather than call + set_tty_color_mode. + * term.c (set_tty_color_mode): Rewrite. + * dispextern.h (set_tty_color_mode): New type. + * termchar.h (struct tty_display_info): Add `previous_color_mode'. + 2008-04-08 Stefan Monnier * keymap.c (access_keymap): Remove the value 2 for t_ok which was used diff --git a/src/dispextern.h b/src/dispextern.h index 8e8d8561984..88373c7dddc 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3057,7 +3057,7 @@ extern void calculate_costs P_ ((struct frame *)); extern void produce_glyphs P_ ((struct it *)); extern void produce_special_glyphs P_ ((struct it *, enum display_element_type)); extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); -extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); +extern void set_tty_color_mode (struct tty_display_info *, struct frame *); extern struct terminal *get_tty_terminal P_ ((Lisp_Object, int)); extern struct terminal *get_named_tty P_ ((char *)); EXFUN (Ftty_type, 1); diff --git a/src/frame.c b/src/frame.c index 81b91924d2f..188e1d18717 100644 --- a/src/frame.c +++ b/src/frame.c @@ -869,11 +869,11 @@ do_switch_frame (frame, track, for_deletion) if (!for_deletion && FRAME_HAS_MINIBUF_P (sf)) resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1); - if (FRAME_TERMCAP_P (XFRAME (selected_frame)) - && FRAME_TERMCAP_P (XFRAME (frame)) - && FRAME_TTY (XFRAME (selected_frame)) == FRAME_TTY (XFRAME (frame))) + if (FRAME_TERMCAP_P (XFRAME (frame))) { - XFRAME (selected_frame)->async_visible = 2; /* obscured */ + if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame)) + /* Mark previously displayed frame as now obscured. */ + XFRAME (FRAME_TTY (XFRAME (frame))->top_frame)->async_visible = 2; XFRAME (frame)->async_visible = 1; FRAME_TTY (XFRAME (frame))->top_frame = frame; } @@ -884,23 +884,6 @@ do_switch_frame (frame, track, for_deletion) Fselect_window (XFRAME (frame)->selected_window, Qnil); -#ifndef WINDOWSNT - /* Make sure to switch the tty color mode to that of the newly - selected frame. */ - sf = SELECTED_FRAME (); - if (FRAME_TERMCAP_P (sf)) - { - Lisp_Object color_mode_spec, color_mode; - - color_mode_spec = assq_no_quit (Qtty_color_mode, sf->param_alist); - if (CONSP (color_mode_spec)) - color_mode = XCDR (color_mode_spec); - else - color_mode = make_number (0); - set_tty_color_mode (sf, color_mode); - } -#endif /* !WINDOWSNT */ - /* We want to make sure that the next event generates a frame-switch event to the appropriate frame. This seems kludgy to me, but before you take it out, make sure that evaluating something like @@ -2302,11 +2285,13 @@ store_frame_param (f, prop, val) } #ifndef WINDOWSNT - /* The tty color mode needs to be set before the frame's parameter - alist is updated with the new value, because set_tty_color_mode - wants to look at the old mode. */ - if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode)) - set_tty_color_mode (f, val); + /* The tty color needed to be set before the frame's parameter + alist was updated with the new value. This is not true any more, + but we still do this test early on. */ + if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode) + && f == FRAME_TTY (f)->previous_frame) + /* Force redisplay of this tty. */ + FRAME_TTY (f)->previous_frame = NULL; #endif /* Update the frame parameter alist. */ diff --git a/src/term.c b/src/term.c index 272e8d33326..f76d0a5e5b1 100644 --- a/src/term.c +++ b/src/term.c @@ -2161,56 +2161,38 @@ tty_setup_colors (struct tty_display_info *tty, int mode) } void -set_tty_color_mode (f, val) +set_tty_color_mode (tty, f) + struct tty_display_info *tty; struct frame *f; - Lisp_Object val; { - Lisp_Object color_mode_spec, current_mode_spec; - Lisp_Object color_mode, current_mode; - int mode, old_mode; + Lisp_Object tem, val, color_mode_spec; + Lisp_Object color_mode; + int mode; extern Lisp_Object Qtty_color_mode; - Lisp_Object tty_color_mode_alist; + Lisp_Object tty_color_mode_alist + = Fintern_soft (build_string ("tty-color-mode-alist"), Qnil); - tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"), - Qnil); + tem = assq_no_quit (Qtty_color_mode, XFRAME (val)->param_alist); + val = CONSP (tem) ? XCDR (tem) : Qnil; if (INTEGERP (val)) color_mode = val; else { - if (NILP (tty_color_mode_alist)) - color_mode_spec = Qnil; - else - color_mode_spec = Fassq (val, XSYMBOL (tty_color_mode_alist)->value); - - if (CONSP (color_mode_spec)) - color_mode = XCDR (color_mode_spec); - else - color_mode = Qnil; + tem = (NILP (tty_color_mode_alist) ? Qnil + : Fassq (val, XSYMBOL (tty_color_mode_alist)->value)); + color_mode = CONSP (tem) ? XCDR (tem) : Qnil; } - current_mode_spec = assq_no_quit (Qtty_color_mode, f->param_alist); - - if (CONSP (current_mode_spec)) - current_mode = XCDR (current_mode_spec); - else - current_mode = Qnil; - if (INTEGERP (color_mode)) - mode = XINT (color_mode); - else - mode = 0; /* meaning default */ - if (INTEGERP (current_mode)) - old_mode = XINT (current_mode); - else - old_mode = 0; + mode = INTEGERP (color_mode) ? XINT (color_mode) : 0; - if (mode != old_mode) + if (mode != tty->previous_color_mode) { - tty_setup_colors (FRAME_TTY (f), mode); - /* This recomputes all the faces given the new color - definitions. */ - call0 (intern ("tty-set-up-initial-frame-faces")); - redraw_frame (f); + Lisp_Object funsym = intern ("tty-set-up-initial-frame-faces"); + tty->previous_color_mode = mode; + tty_setup_colors (tty , mode); + /* This recomputes all the faces given the new color definitions. */ + safe_call (1, &funsym); } } diff --git a/src/termchar.h b/src/termchar.h index 390b6490b63..735758ac910 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -70,6 +70,7 @@ struct tty_display_info /* The previous frame we displayed on this tty. */ struct frame *previous_frame; + int previous_color_mode; /* Strings, numbers and flags taken from the termcap entry. */ diff --git a/src/xdisp.c b/src/xdisp.c index d311cc646b7..8b6ed37df91 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11188,6 +11188,7 @@ redisplay_internal (preserve_echo_area) the whole thing. */ windows_or_buffers_changed++; SET_FRAME_GARBAGED (sf); + set_tty_color_mode (FRAME_TTY (sf), sf); FRAME_TTY (sf)->previous_frame = sf; } -- 2.39.2