changeset 83100:4970ad4995f5

Eliminated updating_frame. src/termhooks.h (cursor_to_hook, raw_cursor_to_hook) (clear_to_end_hook, clear_end_of_line_hook, clear_frame_hook) (ins_del_lines_hook, insert_glyphs_hook, write_glyphs_hook) (delete_glyphs_hook, ring_bell_hook, set_terminal_window_hook): Added frame parameter. src/term.c (ring_bell, tty_ring_bell, set_terminal_window) (tty_set_terminal_window, set_scroll_region, cursor_to) (tty_cursor_to, raw_cursor_to, tty_raw_cursor_to, clear_to_end) (tty_clear_to_end, clear_frame, tty_clear_frame, clear_end_of_line) (tty_clear_end_of_line, write_glyphs, tty_write_glyphs, insert_glyphs) (tty_insert_glyphs, delete_glyphs, tty_delete_glyphs, ins_del_lines) (tty_ins_del_lines): Added frame parameter. src/xterm.c (x_delete_glyphs, x_clear_frame, x_ins_del_lines): Added frame parameter. src/scroll.c (do_direct_scrolling, do_scrolling): Added frame parameter. src/term.c (update_begin, update_end): Don't set updating_frame. src/xfns.c (x_set_tool_bar_lines): Ditto. src/term.c (updating_frame): Removed. src/dispextern.h: Updated prototypes. src/dispnew.c (Fredraw_frame, direct_output_for_insert) (direct_output_forward_char, update_frame_1, update_frame_line) (ding, bitch_at_user): Added frame parameter to calls to redisplay. src/xdisp.c (try_window_id): Ditto. src/scroll.c (do_scrolling, do_direct_scrolling, scrolling_1): Ditto. src/fileio.c (auto_save_error): Ditto. src/term.c (tty_ring_bell): Flush the output stream after beeping. src/dispnew.c (ding, bitch_at_user): Don't fflush CURTTY. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-140
author Karoly Lorentey <lorentey@elte.hu>
date Fri, 16 Apr 2004 15:03:58 +0000
parents 9cb7ecf775c9
children a2e3f695c833
files src/dispextern.h src/dispnew.c src/fileio.c src/scroll.c src/term.c src/termhooks.h src/xdisp.c src/xfns.c src/xterm.c
diffstat 9 files changed, 157 insertions(+), 203 deletions(-) [+]
line wrap: on
line diff
--- a/src/dispextern.h	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/dispextern.h	Fri Apr 16 15:03:58 2004 +0000
@@ -968,10 +968,6 @@
 
 extern struct glyph space_glyph;
 
-/* Frame being updated by update_window/update_frame.  */
-
-extern struct frame *updating_frame;
-
 /* Window being updated by update_window.  This is non-null as long as
    update_window has not finished, and null otherwise.  It's role is
    analogous to updating_frame.  */
@@ -2777,8 +2773,8 @@
 void prepare_desired_row P_ ((struct glyph_row *));
 int line_hash_code P_ ((struct glyph_row *));
 void set_window_update_flags P_ ((struct window *, int));
-void write_glyphs P_ ((struct glyph *, int));
-void insert_glyphs P_ ((struct glyph *, int));
+void write_glyphs P_ ((struct frame *, struct glyph *, int));
+void insert_glyphs P_ ((struct frame *, struct glyph *, int));
 void redraw_frame P_ ((struct frame *));
 void redraw_garbaged_frames P_ ((void));
 int scroll_cost P_ ((struct frame *, int, int, int));
@@ -2797,20 +2793,20 @@
 
 /* Defined in term.c */
 
-extern void ring_bell P_ ((void));
+extern void ring_bell P_ ((struct frame *));
 extern void update_begin P_ ((struct frame *));
 extern void update_end P_ ((struct frame *));
-extern void set_terminal_window P_ ((int));
-extern void set_scroll_region P_ ((int, int));
+extern void set_terminal_window P_ ((struct frame *, int));
+extern void set_scroll_region P_ ((struct frame *, int, int));
 extern void turn_off_insert P_ ((struct tty_display_info *));
 extern void turn_off_highlight P_ ((struct tty_display_info *));
 extern void background_highlight P_ ((struct tty_display_info *));
-extern void clear_frame P_ ((void));
-extern void clear_end_of_line P_ ((int));
-extern void clear_end_of_line_raw P_ ((int));
-extern void tty_clear_end_of_line P_ ((int));
-extern void delete_glyphs P_ ((int));
-extern void ins_del_lines P_ ((int, int));
+extern void clear_frame P_ ((struct frame *));
+extern void clear_end_of_line P_ ((struct frame *, int));
+extern void clear_end_of_line_raw P_ ((struct frame *, int));
+extern void tty_clear_end_of_line P_ ((struct frame *, int));
+extern void delete_glyphs P_ ((struct frame *, int));
+extern void ins_del_lines P_ ((struct frame *, int, int));
 extern int string_cost P_ ((char *));
 extern int per_line_cost P_ ((char *));
 extern void calculate_costs P_ ((struct frame *));
@@ -2822,7 +2818,7 @@
 extern struct display *term_init P_ ((char *, char *, int));
 extern void delete_tty P_ ((struct display *));
 extern void fatal P_ ((/* char *, ... */));
-extern void cursor_to P_ ((int, int));
+extern void cursor_to P_ ((struct frame *, int, int));
 extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
 extern void tty_set_terminal_modes P_ ((struct display *));
 extern void tty_reset_terminal_modes P_ ((struct display *));
--- a/src/dispnew.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/dispnew.c	Fri Apr 16 15:03:58 2004 +0000
@@ -3312,7 +3312,7 @@
   if (FRAME_MSDOS_P (f))
     set_terminal_modes (FRAME_DISPLAY (f));
 #endif
-  clear_frame ();
+  clear_frame (f);
   clear_current_matrices (f);
   update_end (f);
   if (FRAME_TERMCAP_P (f))
@@ -3622,9 +3622,9 @@
   else
     {
       if (glyphs == end - n)
-	write_glyphs (glyphs, n);
+	write_glyphs (f, glyphs, n);
       else
-	insert_glyphs (glyphs, n);
+	insert_glyphs (f, glyphs, n);
     }
 
   w->cursor.hpos += n;
@@ -3647,7 +3647,7 @@
 	      ? XFASTINT (w->left_margin_cols)
 	      : 0));
       y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
-      cursor_to (y, x);
+      cursor_to (f, y, x);
     }
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -3747,7 +3747,7 @@
 	      ? XFASTINT (w->left_margin_cols)
 	      : 0));
       y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
-      cursor_to (y, x);
+      cursor_to (f, y, x);
     }
 
   if (FRAME_TERMCAP_P (f))
@@ -5234,7 +5234,7 @@
 		}
 	    }
 
-	  cursor_to (row, col);
+	  cursor_to (f, row, col);
 	}
       else
 	{
@@ -5256,7 +5256,7 @@
 		x += XFASTINT (w->left_margin_cols);
 
 	      /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
-	      cursor_to (y, x);
+	      cursor_to (f, y, x);
 	    }
 	}
     }
@@ -5472,8 +5472,8 @@
       /* Write the contents of the desired line.  */
       if (nlen)
 	{
-          cursor_to (vpos, 0);
-	  write_glyphs (nbody, nlen);
+          cursor_to (f, vpos, 0);
+	  write_glyphs (f, nbody, nlen);
 	}
 
       /* Don't call clear_end_of_line if we already wrote the whole
@@ -5481,13 +5481,13 @@
 	 case but in the line below.  */
       if (nlen < FRAME_TOTAL_COLS (f))
 	{
-	  cursor_to (vpos, nlen);
-          clear_end_of_line (FRAME_TOTAL_COLS (f));
+	  cursor_to (f, vpos, nlen);
+          clear_end_of_line (f, FRAME_TOTAL_COLS (f));
 	}
       else
 	/* Make sure we are in the right row, otherwise cursor movement
 	   with cmgoto might use `ch' in the wrong row.  */
-	cursor_to (vpos, 0);
+	cursor_to (f, vpos, 0);
 
       make_current (desired_matrix, current_matrix, vpos);
       return;
@@ -5519,8 +5519,8 @@
 		++j;
 
 	      /* Output this run of non-matching chars.  */
-	      cursor_to (vpos, i);
-	      write_glyphs (nbody + i, j - i);
+	      cursor_to (f, vpos, i);
+	      write_glyphs (f, nbody + i, j - i);
 	      i = j - 1;
 
 	      /* Now find the next non-match.  */
@@ -5530,8 +5530,8 @@
       /* Clear the rest of the line, or the non-clear part of it.  */
       if (olen > nlen)
 	{
-	  cursor_to (vpos, nlen);
-	  clear_end_of_line (olen);
+	  cursor_to (f, vpos, nlen);
+	  clear_end_of_line (f, olen);
 	}
 
       /* Make current row = desired row.  */
@@ -5553,8 +5553,8 @@
 
       if (nlen > nsp)
 	{
-	  cursor_to (vpos, nsp);
-	  write_glyphs (nbody + nsp, nlen - nsp);
+	  cursor_to (f, vpos, nsp);
+	  write_glyphs (f, nbody + nsp, nlen - nsp);
 	}
 
       /* Exchange contents between current_frame and new_frame.  */
@@ -5626,8 +5626,8 @@
 
   if (osp > nsp)
     {
-      cursor_to (vpos, nsp);
-      delete_glyphs (osp - nsp);
+      cursor_to (f, vpos, nsp);
+      delete_glyphs (f, osp - nsp);
     }
   else if (nsp > osp)
     {
@@ -5636,12 +5636,12 @@
 	 must delete first to avoid losing data in the insert */
       if (endmatch && nlen < olen + nsp - osp)
 	{
-	  cursor_to (vpos, nlen - endmatch + osp - nsp);
-	  delete_glyphs (olen + nsp - osp - nlen);
+	  cursor_to (f, vpos, nlen - endmatch + osp - nsp);
+	  delete_glyphs (f, olen + nsp - osp - nlen);
 	  olen = nlen - (nsp - osp);
 	}
-      cursor_to (vpos, osp);
-      insert_glyphs (0, nsp - osp);
+      cursor_to (f, vpos, osp);
+      insert_glyphs (f, 0, nsp - osp);
     }
   olen += nsp - osp;
 
@@ -5662,8 +5662,8 @@
 	     unnecessary cursor movement.  */
 	  if (nlen - tem > 0)
 	    {
-	      cursor_to (vpos, nsp + begmatch);
-	      write_glyphs (nbody + nsp + begmatch, nlen - tem);
+	      cursor_to (f, vpos, nsp + begmatch);
+	      write_glyphs (f, nbody + nsp + begmatch, nlen - tem);
 	    }
 	}
       else if (nlen > olen)
@@ -5678,27 +5678,27 @@
 	  int out = olen - tem;	/* Columns to be overwritten originally.  */
 	  int del;
 
-	  cursor_to (vpos, nsp + begmatch);
+	  cursor_to (f, vpos, nsp + begmatch);
 
 	  /* Calculate columns we can actually overwrite.  */
 	  while (CHAR_GLYPH_PADDING_P (nbody[nsp + begmatch + out]))
 	    out--;
-	  write_glyphs (nbody + nsp + begmatch, out);
+	  write_glyphs (f, nbody + nsp + begmatch, out);
 
 	  /* If we left columns to be overwritten, we must delete them.  */
 	  del = olen - tem - out;
 	  if (del > 0)
-	    delete_glyphs (del);
+	    delete_glyphs (f, del);
 
 	  /* At last, we insert columns not yet written out.  */
-	  insert_glyphs (nbody + nsp + begmatch + out, nlen - olen + del);
+	  insert_glyphs (f, nbody + nsp + begmatch + out, nlen - olen + del);
 	  olen = nlen;
 	}
       else if (olen > nlen)
 	{
-	  cursor_to (vpos, nsp + begmatch);
-	  write_glyphs (nbody + nsp + begmatch, nlen - tem);
-	  delete_glyphs (olen - nlen);
+	  cursor_to (f, vpos, nsp + begmatch);
+	  write_glyphs (f, nbody + nsp + begmatch, nlen - tem);
+	  delete_glyphs (f, olen - nlen);
 	  olen = nlen;
 	}
     }
@@ -5707,8 +5707,8 @@
   /* If any unerased characters remain after the new line, erase them.  */
   if (olen > nlen)
     {
-      cursor_to (vpos, nlen);
-      clear_end_of_line (olen);
+      cursor_to (f, vpos, nlen);
+      clear_end_of_line (f, olen);
     }
 
   /* Exchange contents between current_frame and new_frame.  */
@@ -6275,9 +6275,7 @@
       if (noninteractive)
 	putchar (07);
       else
-	ring_bell ();
-      if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
-        fflush (CURTTY ()->output);
+	ring_bell (XFRAME (selected_frame));
     }
   else
     bitch_at_user ();
@@ -6293,9 +6291,7 @@
   else if (!INTERACTIVE)  /* Stop executing a keyboard macro.  */
     error ("Keyboard macro terminated by a command ringing the bell");
   else
-    ring_bell ();
-  if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
-    fflush (CURTTY ()->output);
+    ring_bell (XFRAME (selected_frame));
 }
 
 
--- a/src/fileio.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/fileio.c	Fri Apr 16 15:03:58 2004 +0000
@@ -78,6 +78,8 @@
 #include "charset.h"
 #include "coding.h"
 #include "window.h"
+#include "frame.h"
+#include "dispextern.h"
 
 #ifdef WINDOWSNT
 #define NOMINMAX 1
@@ -5619,7 +5621,7 @@
   int i, nbytes;
   struct gcpro gcpro1;
 
-  ring_bell ();
+  ring_bell (XFRAME (selected_frame));
 
   args[0] = build_string ("Auto-saving %s: %s");
   args[1] = current_buffer->name;
--- a/src/scroll.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/scroll.c	Fri Apr 16 15:03:58 2004 +0000
@@ -58,10 +58,12 @@
     unsigned char writecount;
   };
 
-static void do_direct_scrolling P_ ((struct glyph_matrix *,
+static void do_direct_scrolling P_ ((struct frame *,
+                                     struct glyph_matrix *,
 				     struct matrix_elt *,
 				     int, int));
-static void do_scrolling P_ ((struct glyph_matrix *,
+static void do_scrolling P_ ((struct frame *,
+                              struct glyph_matrix *,
 			      struct matrix_elt *,
 			      int, int));
 
@@ -242,7 +244,8 @@
    of lines.  */
 
 static void
-do_scrolling (current_matrix, matrix, window_size, unchanged_at_top)
+do_scrolling (frame, current_matrix, matrix, window_size, unchanged_at_top)
+     struct frame *frame;
      struct glyph_matrix *current_matrix;
      struct matrix_elt *matrix;
      int window_size;
@@ -309,12 +312,12 @@
 	  /* Set the terminal window, if not done already.  */
  	  if (! terminal_window_p)
 	    {
-	      set_terminal_window (window_size + unchanged_at_top);
+	      set_terminal_window (frame, window_size + unchanged_at_top);
 	      terminal_window_p = 1;
 	    }
 
 	  /* Delete lines on the terminal.  */
-	  ins_del_lines (j + unchanged_at_top, - p->deletecount);
+	  ins_del_lines (frame, j + unchanged_at_top, - p->deletecount);
 	}
       else
 	{
@@ -339,7 +342,7 @@
       /* Set the terminal window if not yet done.  */
       if (!terminal_window_p)
 	{
-	  set_terminal_window (window_size + unchanged_at_top);
+	  set_terminal_window (frame, window_size + unchanged_at_top);
 	  terminal_window_p = 1;
 	}
 
@@ -348,7 +351,7 @@
 	  --queue;
 
 	  /* Do the deletion on the terminal.  */
-	  ins_del_lines (queue->pos, queue->count);
+	  ins_del_lines (frame, queue->pos, queue->count);
 
 	  /* All lines in the range deleted become empty in the glyph
 	     matrix.  Assign to them glyph rows that are not retained.
@@ -381,7 +384,7 @@
   CHECK_MATRIX (current_matrix);
 
   if (terminal_window_p)
-    set_terminal_window (0);
+    set_terminal_window (frame, 0);
 }
 
 
@@ -652,8 +655,9 @@
    the cost matrix for this approach is constructed. */
 
 static void
-do_direct_scrolling (current_matrix, cost_matrix, window_size,
-		     unchanged_at_top)
+do_direct_scrolling (frame, current_matrix, cost_matrix,
+                     window_size, unchanged_at_top)
+     struct frame *frame;
      struct glyph_matrix *current_matrix;
      struct matrix_elt *cost_matrix;
      int window_size;
@@ -744,9 +748,9 @@
 	  if (i > j)
 	    {
 	      /* Immediately insert lines */
-	      set_terminal_window (i + unchanged_at_top);
+	      set_terminal_window (frame, i + unchanged_at_top);
 	      terminal_window_p = 1;
-	      ins_del_lines (j - n_to_write + unchanged_at_top, i - j);
+	      ins_del_lines (frame, j - n_to_write + unchanged_at_top, i - j);
 	    }
 	  else if (i < j)
 	    {
@@ -776,9 +780,9 @@
 	  --queue;
 	  if (queue->count)
 	    {
-	      set_terminal_window (queue->window);
+	      set_terminal_window (frame, queue->window);
 	      terminal_window_p = 1;
-	      ins_del_lines (queue->pos, queue->count);
+	      ins_del_lines (frame, queue->pos, queue->count);
 	    }
 	  else
 	    {
@@ -801,7 +805,7 @@
 		       copy_from, retained_p);
 
   if (terminal_window_p)
-    set_terminal_window (0);
+    set_terminal_window (frame, 0);
 }
 
 
@@ -827,7 +831,7 @@
 				  unchanged_at_bottom,
 				  draw_cost, old_draw_cost,
 				  old_hash, new_hash, free_at_end);
-      do_direct_scrolling (frame->current_matrix,
+      do_direct_scrolling (frame, frame->current_matrix,
 			   matrix, window_size, unchanged_at_top);
     }
   else
@@ -835,7 +839,8 @@
       calculate_scrolling (frame, matrix, window_size, unchanged_at_bottom,
 			   draw_cost, old_hash, new_hash,
 			   free_at_end);
-      do_scrolling (frame->current_matrix, matrix, window_size,
+      do_scrolling (frame,
+                    frame->current_matrix, matrix, window_size,
 		    unchanged_at_top);
     }
 }
--- a/src/term.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/term.c	Fri Apr 16 15:03:58 2004 +0000
@@ -171,11 +171,6 @@
 
 int max_frame_lines;
 
-/* Frame currently being redisplayed; 0 if not currently redisplaying.
-   (Direct output does not count).  */
-
-FRAME_PTR updating_frame;
-
 /* Non-zero if we have dropped our controlling tty and therefore
    should not open a frame on stdout. */
 static int no_controlling_tty;
@@ -201,10 +196,8 @@
 #endif /* WINDOWSNT */
 
 void
-ring_bell ()
+ring_bell (struct frame *f)
 {
-  struct frame *f = XFRAME (selected_frame);
-
   if (!NILP (Vring_bell_function))
     {
       Lisp_Object function;
@@ -225,20 +218,20 @@
       Vring_bell_function = function;
     }
   else if (FRAME_DISPLAY (f)->ring_bell_hook)
-    (*FRAME_DISPLAY (f)->ring_bell_hook) ();
+    (*FRAME_DISPLAY (f)->ring_bell_hook) (f);
 }
 
 /* Ring the bell on a tty. */
 
 void
-tty_ring_bell ()
+tty_ring_bell (struct frame *f)
 {
-  struct frame *f = XFRAME (selected_frame);
   struct tty_display_info *tty = FRAME_TTY (f);
 
   OUTPUT (tty, (tty->TS_visible_bell && visible_bell
                 ? tty->TS_visible_bell
                 : tty->TS_bell));
+  fflush (tty->output);
 }
 
 /* Set up termcap modes for Emacs. */
@@ -282,7 +275,6 @@
 update_begin (f)
      struct frame *f;
 {
-  updating_frame = f;
   if (FRAME_DISPLAY (f)->update_begin_hook)
     (*FRAME_DISPLAY (f)->update_begin_hook) (f);
 }
@@ -293,7 +285,6 @@
 {
   if (FRAME_DISPLAY (f)->update_end_hook)
     (*FRAME_DISPLAY (f)->update_end_hook) (f);
-  updating_frame = NULL;
 }
 
 /* Flag the end of a display update on a termcap display. */
@@ -315,36 +306,32 @@
    that is bounded by calls to update_begin and update_end.  */
 
 void
-set_terminal_window (size)
+set_terminal_window (f, size)
+     struct frame *f;
      int size;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->set_terminal_window_hook)
-    (*FRAME_DISPLAY (f)->set_terminal_window_hook) (size);
+    (*FRAME_DISPLAY (f)->set_terminal_window_hook) (f, size);
 }
 
 /* The implementation of set_terminal_window for termcap frames. */
 
 void
-tty_set_terminal_window (int size)
+tty_set_terminal_window (struct frame *f, int size)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   struct tty_display_info *tty = FRAME_TTY (f);
 
   tty->specified_window = size ? size : FRAME_LINES (f);
   if (FRAME_SCROLL_REGION_OK (f))
-    set_scroll_region (0, tty->specified_window);
+    set_scroll_region (f, 0, tty->specified_window);
 }
 
 void
-set_scroll_region (start, stop)
+set_scroll_region (f, start, stop)
+     struct frame *f;
      int start, stop;
 {
   char *buf;
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   struct tty_display_info *tty = FRAME_TTY (f);
 
   if (tty->TS_set_scroll_region)
@@ -463,20 +450,17 @@
    frame-relative coordinates.  */
 
 void
-cursor_to (vpos, hpos)
+cursor_to (f, vpos, hpos)
+     struct frame *f;
      int vpos, hpos;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->cursor_to_hook)
-    (*FRAME_DISPLAY (f)->cursor_to_hook) (vpos, hpos);
+    (*FRAME_DISPLAY (f)->cursor_to_hook) (f, vpos, hpos);
 }
 
 void
-tty_cursor_to (int vpos, int hpos)
+tty_cursor_to (struct frame *f, int vpos, int hpos)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  
   struct tty_display_info *tty = FRAME_TTY (f);
 
   /* Detect the case where we are called from reset_sys_modes
@@ -497,20 +481,17 @@
 /* Similar but don't take any account of the wasted characters.  */
 
 void
-raw_cursor_to (row, col)
+raw_cursor_to (f, row, col)
+     struct frame *f;
      int row, col;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->raw_cursor_to_hook)
-    (*FRAME_DISPLAY (f)->raw_cursor_to_hook) (row, col);  
+    (*FRAME_DISPLAY (f)->raw_cursor_to_hook) (f, row, col);  
 }
 
 void
-tty_raw_cursor_to (int row, int col)
+tty_raw_cursor_to (struct frame *f, int row, int col)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   struct tty_display_info *tty = FRAME_TTY (f);
 
   if (curY (tty) == row
@@ -527,21 +508,18 @@
 
 /* Clear from cursor to end of frame. */
 void
-clear_to_end ()
+clear_to_end (struct frame *f)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->clear_to_end_hook)
-    (*FRAME_DISPLAY (f)->clear_to_end_hook) ();
+    (*FRAME_DISPLAY (f)->clear_to_end_hook) (f);
 }
 
 /* Clear from cursor to end of frame on a termcap device. */
 
 void
-tty_clear_to_end (void)
+tty_clear_to_end (struct frame *f)
 {
   register int i;
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
   struct tty_display_info *tty = FRAME_TTY (f);
 
   if (tty->TS_clr_to_bottom)
@@ -553,8 +531,8 @@
     {
       for (i = curY (tty); i < FRAME_LINES (f); i++)
 	{
-	  cursor_to (i, 0);
-	  clear_end_of_line (FRAME_COLS (f));
+	  cursor_to (f, i, 0);
+	  clear_end_of_line (f, FRAME_COLS (f));
 	}
     }
 }
@@ -562,21 +540,17 @@
 /* Clear entire frame */
 
 void
-clear_frame ()
+clear_frame (struct frame *f)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->clear_frame_hook)
-    (*FRAME_DISPLAY (f)->clear_frame_hook) ();
+    (*FRAME_DISPLAY (f)->clear_frame_hook) (f);
 }
 
 /* Clear an entire termcap frame. */
 
 void
-tty_clear_frame ()
+tty_clear_frame (struct frame *f)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   struct tty_display_info *tty = FRAME_TTY (f);
 
   if (tty->TS_clr_frame)
@@ -587,8 +561,8 @@
     }
   else
     {
-      cursor_to (0, 0);
-      clear_to_end ();
+      cursor_to (f, 0, 0);
+      clear_to_end (f);
     }
 }
 
@@ -598,13 +572,12 @@
    Note that the cursor may be moved, on terminals lacking a `ce' string.  */
 
 void
-clear_end_of_line (first_unused_hpos)
+clear_end_of_line (f, first_unused_hpos)
+     struct frame *f;
      int first_unused_hpos;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->clear_end_of_line_hook)
-    (*FRAME_DISPLAY (f)->clear_end_of_line_hook) (first_unused_hpos);
+    (*FRAME_DISPLAY (f)->clear_end_of_line_hook) (f, first_unused_hpos);
 }
 
 /* An implementation of clear_end_of_line for termcap frames.
@@ -612,10 +585,9 @@
    Note that the cursor may be moved, on terminals lacking a `ce' string.  */
 
 void
-tty_clear_end_of_line (int first_unused_hpos)
+tty_clear_end_of_line (struct frame *f, int first_unused_hpos)
 {
   register int i;
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
   struct tty_display_info *tty = FRAME_TTY (f);
 
   /* Detect the case where we are called from reset_sys_modes
@@ -763,27 +735,24 @@
    Advance the nominal cursor over the text.  */
 
 void
-write_glyphs (string, len)
+write_glyphs (f, string, len)
+     struct frame *f;
      register struct glyph *string;
      register int len;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->write_glyphs_hook)
-    (*FRAME_DISPLAY (f)->write_glyphs_hook) (string, len);
+    (*FRAME_DISPLAY (f)->write_glyphs_hook) (f, string, len);
 }
 
 /* An implementation of write_glyphs for termcap frames. */
 
 void
-tty_write_glyphs (struct glyph *string, int len)
+tty_write_glyphs (struct frame *f, struct glyph *string, int len)
 {
   int produced, consumed;
   unsigned char conversion_buffer[1024];
   int conversion_buffer_size = sizeof conversion_buffer;
 
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   struct tty_display_info *tty = FRAME_TTY (f);
 
   turn_off_insert (tty);
@@ -873,27 +842,25 @@
    If start is zero, insert blanks instead of a string at start */
 
 void
-insert_glyphs (start, len)
+insert_glyphs (f, start, len)
+     struct frame *f;
      register struct glyph *start;
      register int len;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (len <= 0)
     return;
 
   if (FRAME_DISPLAY (f)->insert_glyphs_hook)
-    (*FRAME_DISPLAY (f)->insert_glyphs_hook) (start, len);
+    (*FRAME_DISPLAY (f)->insert_glyphs_hook) (f, start, len);
 }
 
 /* An implementation of insert_glyphs for termcap frames. */
 
 void
-tty_insert_glyphs (struct glyph *start, int len)
+tty_insert_glyphs (struct frame *f, struct glyph *start, int len)
 {
   char *buf;
   struct glyph *glyph = NULL;
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
 
   struct tty_display_info *tty = FRAME_TTY (f);
 
@@ -903,7 +870,7 @@
       OUTPUT1 (tty, buf);
       xfree (buf);
       if (start)
-	write_glyphs (start, len);
+	write_glyphs (f, start, len);
       return;
     }
 
@@ -972,23 +939,21 @@
 /* Delete N glyphs at the nominal cursor position. */
 
 void
-delete_glyphs (n)
+delete_glyphs (f, n)
+     struct frame *f;
      register int n;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   if (FRAME_DISPLAY (f)->delete_glyphs_hook)
-    (*FRAME_DISPLAY (f)->delete_glyphs_hook) (n);
+    (*FRAME_DISPLAY (f)->delete_glyphs_hook) (f, n);
 }
 
 /* An implementation of delete_glyphs for termcap frames. */
 
 void
-tty_delete_glyphs (int n)
+tty_delete_glyphs (struct frame *f, int n)
 {
   char *buf;
   register int i;
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
 
   struct tty_display_info *tty = FRAME_TTY (f);
 
@@ -1018,22 +983,19 @@
 /* Insert N lines at vpos VPOS.  If N is negative, delete -N lines.  */
 
 void
-ins_del_lines (vpos, n)
+ins_del_lines (f, vpos, n)
+     struct frame *f;
      int vpos, n;
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  
   if (FRAME_DISPLAY (f)->ins_del_lines_hook)
-    (*FRAME_DISPLAY (f)->ins_del_lines_hook) (vpos, n);
+    (*FRAME_DISPLAY (f)->ins_del_lines_hook) (f, vpos, n);
 }
 
 /* An implementation of ins_del_lines for termcap frames. */
 
 void
-tty_ins_del_lines (int vpos, int n)
+tty_ins_del_lines (struct frame *f, int vpos, int n)
 {
-  struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-
   struct tty_display_info *tty = FRAME_TTY (f);
   char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines;
   char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
@@ -1075,7 +1037,7 @@
     }
   else
     {
-      set_scroll_region (vpos, tty->specified_window);
+      set_scroll_region (f, vpos, tty->specified_window);
       if (n < 0)
         raw_cursor_to (tty->specified_window - 1, 0);
       else
@@ -1083,15 +1045,15 @@
       background_highlight (tty);
       while (--i >= 0)
         OUTPUTL (tty, scroll, tty->specified_window - vpos);
-      set_scroll_region (0, tty->specified_window);
+      set_scroll_region (f, 0, tty->specified_window);
     }
   
   if (!FRAME_SCROLL_REGION_OK (f)
       && FRAME_MEMORY_BELOW_FRAME (f)
       && n < 0)
     {
-      cursor_to (FRAME_LINES (f) + n, 0);
-      clear_to_end ();
+      cursor_to (f, FRAME_LINES (f) + n, 0);
+      clear_to_end (f);
     }
 }
 
--- a/src/termhooks.h	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/termhooks.h	Fri Apr 16 15:03:58 2004 +0000
@@ -329,26 +329,27 @@
   
   /* Text display hooks.  */
 
-  void (*cursor_to_hook) P_ ((int vpos, int hpos));
-  void (*raw_cursor_to_hook) P_ ((int, int));
+  void (*cursor_to_hook) P_ ((struct frame *f, int vpos, int hpos));
+  void (*raw_cursor_to_hook) P_ ((struct frame *, int, int));
   
-  void (*clear_to_end_hook) P_ ((void));
-  void (*clear_frame_hook) P_ ((void));
-  void (*clear_end_of_line_hook) P_ ((int));
+  void (*clear_to_end_hook) P_ ((struct frame *));
+  void (*clear_frame_hook) P_ ((struct frame *));
+  void (*clear_end_of_line_hook) P_ ((struct frame *, int));
   
-  void (*ins_del_lines_hook) P_ ((int, int));
+  void (*ins_del_lines_hook) P_ ((struct frame *f, int, int));
   
-  void (*insert_glyphs_hook) P_ ((struct glyph *s, int n));
-  void (*write_glyphs_hook) P_ ((struct glyph *s, int n));
-  void (*delete_glyphs_hook) P_ ((int));
+  void (*insert_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n));
+  void (*write_glyphs_hook) P_ ((struct frame *f, struct glyph *s, int n));
+  void (*delete_glyphs_hook) P_ ((struct frame *, int));
   
-  void (*ring_bell_hook) P_ ((void));
+  void (*ring_bell_hook) P_ ((struct frame *f));
   
   void (*reset_terminal_modes_hook) P_ ((struct display *));
   void (*set_terminal_modes_hook) P_ ((struct display *));
+
   void (*update_begin_hook) P_ ((struct frame *));
   void (*update_end_hook) P_ ((struct frame *));
-  void (*set_terminal_window_hook) P_ ((int));
+  void (*set_terminal_window_hook) P_ ((struct frame *, int));
 
   /* Multi-frame and mouse support hooks.  */
 
@@ -548,7 +549,6 @@
 #define FRAME_WINDOW_P(f) (0)
 #endif
 
-
 extern struct display *create_display P_ ((void));
 extern void delete_display P_ ((struct display *));
 
--- a/src/xdisp.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/xdisp.c	Fri Apr 16 15:03:58 2004 +0000
@@ -13347,36 +13347,36 @@
 	    {
 	      /* Scroll last_unchanged_at_beg_row to the end of the
 		 window down dvpos lines.  */
-	      set_terminal_window (end);
+	      set_terminal_window (f, end);
 
 	      /* On dumb terminals delete dvpos lines at the end
 		 before inserting dvpos empty lines.  */
 	      if (!FRAME_SCROLL_REGION_OK (f))
-		ins_del_lines (end - dvpos, -dvpos);
+		ins_del_lines (f, end - dvpos, -dvpos);
 
 	      /* Insert dvpos empty lines in front of
                  last_unchanged_at_beg_row.  */
-	      ins_del_lines (from, dvpos);
+	      ins_del_lines (f, from, dvpos);
 	    }
 	  else if (dvpos < 0)
 	    {
 	      /* Scroll up last_unchanged_at_beg_vpos to the end of
 		 the window to last_unchanged_at_beg_vpos - |dvpos|.  */
-	      set_terminal_window (end);
+	      set_terminal_window (f, end);
 
 	      /* Delete dvpos lines in front of
 		 last_unchanged_at_beg_vpos.  ins_del_lines will set
 		 the cursor to the given vpos and emit |dvpos| delete
 		 line sequences.  */
-	      ins_del_lines (from + dvpos, dvpos);
+	      ins_del_lines (f, from + dvpos, dvpos);
 
 	      /* On a dumb terminal insert dvpos empty lines at the
                  end.  */
 	      if (!FRAME_SCROLL_REGION_OK (f))
-		ins_del_lines (end + dvpos, -dvpos);
-	    }
-
-	  set_terminal_window (0);
+		ins_del_lines (f, end + dvpos, -dvpos);
+	    }
+
+	  set_terminal_window (f, 0);
 	}
 
       update_end (f);
--- a/src/xfns.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/xfns.c	Fri Apr 16 15:03:58 2004 +0000
@@ -1370,10 +1370,8 @@
      below the menu bar.  */
   if (FRAME_X_WINDOW (f) && FRAME_TOOL_BAR_LINES (f) == 0)
     {
-      updating_frame = f;
-      clear_frame ();
+      clear_frame (f);
       clear_current_matrices (f);
-      updating_frame = NULL;
     }
 
   /* If the tool bar gets smaller, the internal border below it
--- a/src/xterm.c	Fri Apr 16 13:36:07 2004 +0000
+++ b/src/xterm.c	Fri Apr 16 15:03:58 2004 +0000
@@ -344,7 +344,7 @@
 static void XTframe_up_to_date P_ ((struct frame *));
 static void XTset_terminal_modes P_ ((struct display *));
 static void XTreset_terminal_modes P_ ((struct display *));
-static void x_clear_frame P_ ((void));
+static void x_clear_frame P_ ((struct frame *));
 static void frame_highlight P_ ((struct frame *));
 static void frame_unhighlight P_ ((struct frame *));
 static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
@@ -2747,7 +2747,8 @@
    for X frames.  */
 
 static void
-x_delete_glyphs (n)
+x_delete_glyphs (f, n)
+     struct frame *f;
      register int n;
 {
   abort ();
@@ -2774,15 +2775,8 @@
    frame.  Otherwise clear the selected frame.  */
 
 static void
-x_clear_frame ()
-{
-  struct frame *f;
-
-  if (updating_frame)
-    f = updating_frame;
-  else
-    f = SELECTED_FRAME ();
-
+x_clear_frame (struct frame *f)
+{
   /* Clearing the frame will erase any cursor, so mark them all as no
      longer visible.  */
   mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
@@ -3032,7 +3026,8 @@
    lines or deleting -N lines at vertical position VPOS.  */
 
 static void
-x_ins_del_lines (vpos, n)
+x_ins_del_lines (f, vpos, n)
+     struct frame *f;
      int vpos, n;
 {
   abort ();