changeset 93883:722fdbc7a012

* 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'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 09 Apr 2008 03:25:14 +0000
parents 9eaa3ee184e9
children b4877813e2df
files src/ChangeLog src/dispextern.h src/frame.c src/term.c src/termchar.h src/xdisp.c
diffstat 6 files changed, 47 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/ChangeLog	Wed Apr 09 03:25:14 2008 +0000
@@ -1,3 +1,15 @@
+2008-04-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* 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  <monnier@iro.umontreal.ca>
 
 	* keymap.c (access_keymap): Remove the value 2 for t_ok which was used
--- a/src/dispextern.h	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/dispextern.h	Wed Apr 09 03:25:14 2008 +0000
@@ -3057,7 +3057,7 @@
 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);
--- a/src/frame.c	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/frame.c	Wed Apr 09 03:25:14 2008 +0000
@@ -869,11 +869,11 @@
   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 @@
 
   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 @@
     }
 
 #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.  */
--- a/src/term.c	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/term.c	Wed Apr 09 03:25:14 2008 +0000
@@ -2161,56 +2161,38 @@
 }
 
 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;
-
-  tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"),
-				       Qnil);
+  Lisp_Object 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;
-
-  if (mode != old_mode)
+  mode = INTEGERP (color_mode) ? XINT (color_mode) : 0;
+
+  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);
     }
 }
 
--- a/src/termchar.h	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/termchar.h	Wed Apr 09 03:25:14 2008 +0000
@@ -70,6 +70,7 @@
   
   /* 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.  */
 
--- a/src/xdisp.c	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/xdisp.c	Wed Apr 09 03:25:14 2008 +0000
@@ -11188,6 +11188,7 @@
 	 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;
     }