]> code.delx.au - gnu-emacs/blobdiff - src/frame.c
(lgrep, rgrep): Use add-to-history.
[gnu-emacs] / src / frame.c
index 69651ad81ff2c2b3c5783756d09f3085e07ba4e6..c08d5a6f84d327bfcdc5fb5278c6a024100b6ea7 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic frame functions.
-   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001
-   Free Software Foundation.
+   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
+                 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -16,8 +16,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include <config.h>
 
@@ -114,6 +114,7 @@ Lisp_Object Qface_set_after_frame_default;
 
 Lisp_Object Vterminal_frame;
 Lisp_Object Vdefault_frame_alist;
+Lisp_Object Vdefault_frame_scroll_bars;
 Lisp_Object Vmouse_position_function;
 Lisp_Object Vmouse_highlight;
 Lisp_Object Vdelete_frame_functions;
@@ -126,13 +127,13 @@ set_menu_bar_lines_1 (window, n)
   struct window *w = XWINDOW (window);
 
   XSETFASTINT (w->last_modified, 0);
-  XSETFASTINT (w->top, XFASTINT (w->top) + n);
-  XSETFASTINT (w->height, XFASTINT (w->height) - n);
+  XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
+  XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
 
-  if (INTEGERP (w->orig_top))
-    XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);
-  if (INTEGERP (w->orig_height))
-    XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);
+  if (INTEGERP (w->orig_top_line))
+    XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
+  if (INTEGERP (w->orig_total_lines))
+    XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
 
   /* Handle just the top child in a vertical split.  */
   if (!NILP (w->vchild))
@@ -285,6 +286,19 @@ make_frame (mini_p)
   f->tool_bar_items = Qnil;
   f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
   f->n_tool_bar_items = 0;
+  f->left_fringe_width = f->right_fringe_width = 0;
+  f->fringe_cols = 0;
+  f->scroll_bar_actual_width = 0;
+  f->border_width = 0;
+  f->internal_border_width = 0;
+  f->column_width = 1;  /* !FRAME_WINDOW_P value */
+  f->line_height = 1;  /* !FRAME_WINDOW_P value */
+  f->x_pixels_diff = f->y_pixels_diff = 0;
+#ifdef HAVE_WINDOW_SYSTEM
+  f->want_fullscreen = FULLSCREEN_NONE;
+#endif
+  f->size_hint_flags = 0;
+  f->win_gravity = 0;
 
   root_window = make_window ();
   if (mini_p)
@@ -309,17 +323,17 @@ make_frame (mini_p)
      just so that there is "something there."
      Correct size will be set up later with change_frame_size.  */
 
-  SET_FRAME_WIDTH (f, 10);
-  f->height = 10;
+  SET_FRAME_COLS (f, 10);
+  FRAME_LINES (f) = 10;
 
-  XSETFASTINT (XWINDOW (root_window)->width, 10);
-  XSETFASTINT (XWINDOW (root_window)->height, (mini_p ? 9 : 10));
+  XSETFASTINT (XWINDOW (root_window)->total_cols, 10);
+  XSETFASTINT (XWINDOW (root_window)->total_lines, (mini_p ? 9 : 10));
 
   if (mini_p)
     {
-      XSETFASTINT (XWINDOW (mini_window)->width, 10);
-      XSETFASTINT (XWINDOW (mini_window)->top, 9);
-      XSETFASTINT (XWINDOW (mini_window)->height, 1);
+      XSETFASTINT (XWINDOW (mini_window)->total_cols, 10);
+      XSETFASTINT (XWINDOW (mini_window)->top_line, 9);
+      XSETFASTINT (XWINDOW (mini_window)->total_lines, 1);
     }
 
   /* Choose a buffer for the frame's root window.  */
@@ -339,7 +353,7 @@ make_frame (mini_p)
        don't have the right size, glyph matrices aren't initialized
        etc.  Running Lisp functions at this point surely ends in a
        SEGV.  */
-    set_window_buffer (root_window, buf, 0);
+    set_window_buffer (root_window, buf, 0, 0);
     f->buffer_list = Fcons (buf, Qnil);
   }
 
@@ -350,14 +364,17 @@ make_frame (mini_p)
                         (NILP (Vminibuffer_list)
                          ? get_minibuffer (0)
                          : Fcar (Vminibuffer_list)),
-                        0);
+                        0, 0);
     }
 
   f->root_window = root_window;
   f->selected_window = root_window;
   /* Make sure this window seems more recently used than
      a newly-created, never-selected window.  */
-  XSETFASTINT (XWINDOW (f->selected_window)->use_time, ++window_select_count);
+  ++window_select_count;
+  XSETFASTINT (XWINDOW (f->selected_window)->use_time, window_select_count);
+
+  f->default_face_done_p = 0;
 
   return f;
 }
@@ -382,7 +399,7 @@ make_frame_without_minibuffer (mini_window, kb, display)
 #ifdef MULTI_KBOARD
   if (!NILP (mini_window)
       && XFRAME (XWINDOW (mini_window)->frame)->kboard != kb)
-    error ("frame and minibuffer must be on the same display");
+    error ("Frame and minibuffer must be on the same display");
 #endif
 
   /* Make a frame containing just a root window.  */
@@ -415,7 +432,7 @@ make_frame_without_minibuffer (mini_window, kb, display)
     Fset_window_buffer (mini_window,
                        (NILP (Vminibuffer_list)
                         ? get_minibuffer (0)
-                        : Fcar (Vminibuffer_list)));
+                        : Fcar (Vminibuffer_list)), Qnil);
   return f;
 }
 
@@ -453,7 +470,7 @@ make_minibuffer_frame ()
   Fset_window_buffer (mini_window,
                      (NILP (Vminibuffer_list)
                       ? get_minibuffer (0)
-                      : Fcar (Vminibuffer_list)));
+                      : Fcar (Vminibuffer_list)), Qnil);
   return f;
 }
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -573,8 +590,8 @@ Note that changing the size of one terminal frame automatically affects all.  */
 
   f = make_terminal_frame ();
 
-  change_frame_size (f, FRAME_HEIGHT (sf),
-                    FRAME_WIDTH (sf), 0, 0, 0);
+  change_frame_size (f, FRAME_LINES (sf),
+                    FRAME_COLS (sf), 0, 0, 0);
   adjust_glyphs (f);
   calculate_costs (f);
   XSETFRAME (frame, f);
@@ -682,7 +699,7 @@ do_switch_frame (frame, track, for_deletion)
   if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
     last_nonminibuf_frame = XFRAME (selected_frame);
 
-  Fselect_window (XFRAME (frame)->selected_window);
+  Fselect_window (XFRAME (frame)->selected_window, Qnil);
 
 #ifndef WINDOWSNT
   /* Make sure to switch the tty color mode to that of the newly
@@ -712,20 +729,25 @@ do_switch_frame (frame, track, for_deletion)
   return frame;
 }
 
-DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
+DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 1, "e",
        doc: /* Select the frame FRAME.
 Subsequent editing commands apply to its selected window.
 The selection of FRAME lasts until the next time the user does
 something to select a different frame, or until the next time this
-function is called.  */)
-  (frame, no_enter)
-    Lisp_Object frame, no_enter;
+function is called.  If you are using a window system, the previously
+selected frame may be restored as the selected frame after return to
+the command loop, because it still may have the window system's input
+focus.  On a text-only terminal, the next redisplay will display FRAME.
+
+This function returns FRAME, or nil if FRAME has been deleted.  */)
+  (frame)
+    Lisp_Object frame;
 {
   return do_switch_frame (frame, 1, 0);
 }
 
 
-DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e",
+DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "e",
        doc: /* Handle a switch-frame event EVENT.
 Switch-frame events are usually bound to this function.
 A switch-frame event tells Emacs that the window manager has requested
@@ -734,8 +756,8 @@ This function selects the selected window of the frame of EVENT.
 
 If EVENT is frame object, handle it as if it were a switch-frame event
 to that frame.  */)
-     (event, no_enter)
-     Lisp_Object event, no_enter;
+     (event)
+     Lisp_Object event;
 {
   /* Preserve prefix arg that the command loop just cleared.  */
   current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
@@ -743,15 +765,6 @@ to that frame.  */)
   return do_switch_frame (event, 0, 0);
 }
 
-DEFUN ("ignore-event", Fignore_event, Signore_event, 0, 0, "",
-       doc: /* Do nothing, but preserve any prefix argument already specified.
-This is a suitable binding for iconify-frame and make-frame-visible.  */)
-     ()
-{
-  current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
-  return Qnil;
-}
-
 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
        doc: /* Return the frame that is now selected.  */)
      ()
@@ -845,6 +858,7 @@ If omitted, FRAME defaults to the currently selected frame.  */)
 DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
        Sset_frame_selected_window, 2, 2, 0,
        doc: /* Set the selected window of frame object FRAME to WINDOW.
+Return WINDOW.
 If FRAME is nil, the selected frame is used.
 If FRAME is the selected frame, this makes WINDOW the selected window.  */)
      (frame, window)
@@ -860,7 +874,7 @@ If FRAME is the selected frame, this makes WINDOW the selected window.  */)
     error ("In `set-frame-selected-window', WINDOW is not on FRAME");
 
   if (EQ (frame, selected_frame))
-    return Fselect_window (window);
+    return Fselect_window (window, Qnil);
 
   return XFRAME (frame)->selected_window = window;
 }
@@ -887,7 +901,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
    If MINIBUF is 0, include all visible and iconified frames.
    Otherwise, include all frames.  */
 
-Lisp_Object
+static Lisp_Object
 next_frame (frame, minibuf)
      Lisp_Object frame;
      Lisp_Object minibuf;
@@ -964,7 +978,7 @@ next_frame (frame, minibuf)
    If MINIBUF is 0, include all visible and iconified frames.
    Otherwise, include all frames.  */
 
-Lisp_Object
+static Lisp_Object
 prev_frame (frame, minibuf)
      Lisp_Object frame;
      Lisp_Object minibuf;
@@ -1228,13 +1242,13 @@ The functions are run with one arg, the frame to be deleted.  */)
   if (EQ (f->minibuffer_window, minibuf_window))
     {
       Fset_window_buffer (sf->minibuffer_window,
-                         XWINDOW (minibuf_window)->buffer);
+                         XWINDOW (minibuf_window)->buffer, Qnil);
       minibuf_window = sf->minibuffer_window;
 
       /* If the dying minibuffer window was selected,
         select the new one.  */
       if (minibuffer_selected)
-       Fselect_window (minibuf_window);
+       Fselect_window (minibuf_window, Qnil);
     }
 
   /* Don't let echo_area_window to remain on a deleted frame.  */
@@ -1246,6 +1260,10 @@ The functions are run with one arg, the frame to be deleted.  */)
   if (FRAME_X_P (f))
     x_clear_frame_selections (f);
 #endif
+#ifdef MAC_OS
+  if (FRAME_MAC_P (f))
+    x_clear_frame_selections (f);
+#endif
 
   /* Free glyphs.
      This function must be called before the window tree of the
@@ -1263,6 +1281,8 @@ The functions are run with one arg, the frame to be deleted.  */)
 
   if (f->namebuf)
     xfree (f->namebuf);
+  if (f->decode_mode_spec_buffer)
+    xfree (f->decode_mode_spec_buffer);
   if (FRAME_INSERT_COST (f))
     xfree (FRAME_INSERT_COST (f));
   if (FRAME_DELETEN_COST (f))
@@ -1309,6 +1329,36 @@ The functions are run with one arg, the frame to be deleted.  */)
        }
     }
 
+  /* If there's no other frame on the same kboard, get out of
+     single-kboard state if we're in it for this kboard.  */
+  {
+    Lisp_Object frames;
+    /* Some frame we found on the same kboard, or nil if there are none.  */
+    Lisp_Object frame_on_same_kboard;
+
+    frame_on_same_kboard = Qnil;
+
+    for (frames = Vframe_list;
+        CONSP (frames);
+        frames = XCDR (frames))
+      {
+       Lisp_Object this;
+       struct frame *f1;
+
+       this = XCAR (frames);
+       if (!FRAMEP (this))
+         abort ();
+       f1 = XFRAME (this);
+
+       if (FRAME_KBOARD (f) == FRAME_KBOARD (f1))
+         frame_on_same_kboard = this;
+      }
+
+    if (NILP (frame_on_same_kboard))
+      not_single_kboard_state (FRAME_KBOARD (f));
+  }
+
+
   /* If we've deleted this keyboard's default_minibuffer_frame, try to
      find another one.  Prefer minibuffer-only frames, but also notice
      frames with other windows.  */
@@ -1480,7 +1530,7 @@ before calling this function on it, like this.
 #if defined (MSDOS) && defined (HAVE_MOUSE)
   if (FRAME_MSDOS_P (XFRAME (frame)))
     {
-      Fselect_frame (frame, Qnil);
+      Fselect_frame (frame);
       mouse_moveto (XINT (x), XINT (y));
     }
 #endif
@@ -1512,7 +1562,7 @@ before calling this function on it, like this.
 #if defined (MSDOS) && defined (HAVE_MOUSE)
   if (FRAME_MSDOS_P (XFRAME (frame)))
     {
-      Fselect_frame (frame, Qnil);
+      Fselect_frame (frame);
       mouse_moveto (XINT (x), XINT (y));
     }
 #endif
@@ -1603,7 +1653,7 @@ but if the second optional argument FORCE is non-nil, you may do so.  */)
     {
       struct frame *sf = XFRAME (selected_frame);
       Fset_window_buffer (sf->minibuffer_window,
-                         XWINDOW (minibuf_window)->buffer);
+                         XWINDOW (minibuf_window)->buffer, Qnil);
       minibuf_window = sf->minibuffer_window;
     }
 
@@ -1634,7 +1684,7 @@ If omitted, FRAME defaults to the currently selected frame.  */)
 #if 0 /* This isn't logically necessary, and it can do GC.  */
   /* Don't let the frame remain selected.  */
   if (EQ (frame, selected_frame))
-    Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
+    Fhandle_switch_frame (next_frame (frame, Qt));
 #endif
 
   /* Don't allow minibuf_window to remain on a deleted frame.  */
@@ -1642,7 +1692,7 @@ If omitted, FRAME defaults to the currently selected frame.  */)
     {
       struct frame *sf = XFRAME (selected_frame);
       Fset_window_buffer (sf->minibuffer_window,
-                         XWINDOW (minibuf_window)->buffer);
+                         XWINDOW (minibuf_window)->buffer, Qnil);
       minibuf_window = sf->minibuffer_window;
     }
 
@@ -1663,7 +1713,11 @@ DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
        doc: /* Return t if FRAME is now \"visible\" (actually in use for display).
 A frame that is not \"visible\" is not updated and, if it works through
 a window system, it may not show at all.
-Return the symbol `icon' if frame is visible only as an icon.  */)
+Return the symbol `icon' if frame is visible only as an icon.
+
+On a text-only terminal, all frames are considered visible, whether
+they are currently being displayed or not, and this function returns t
+for all frames.  */)
      (frame)
      Lisp_Object frame;
 {
@@ -1703,7 +1757,7 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
 
 DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
        doc: /* Bring FRAME to the front, so it occludes any frames it overlaps.
-If FRAME is invisible, make it visible.
+If FRAME is invisible or iconified, make it visible.
 If you don't specify a frame, the selected frame is used.
 If Emacs is displaying on an ordinary terminal or some other device which
 doesn't support multiple overlapping frames, this function does nothing.  */)
@@ -1759,7 +1813,7 @@ Focus redirection is useful for temporarily redirecting keystrokes to
 a surrogate minibuffer frame when a frame doesn't have its own
 minibuffer window.
 
-A frame's focus redirection can be changed by select-frame.  If frame
+A frame's focus redirection can be changed by `select-frame'.  If frame
 FOO is selected, and then a different frame BAR is selected, any
 frames redirecting their focus to FOO are shifted to redirect their
 focus to BAR.  This allows focus redirection to work properly when the
@@ -1767,7 +1821,7 @@ user switches from one frame to another using `select-window'.
 
 This means that a frame whose focus is redirected to itself is treated
 differently from a frame whose focus is redirected to nil; the former
-is affected by select-frame, while the latter is not.
+is affected by `select-frame', while the latter is not.
 
 The redirection lasts until `redirect-frame-focus' is called to change it.  */)
      (frame, focus_frame)
@@ -1898,7 +1952,7 @@ frame_name_fnn_p (str, len)
 /* Set the name of the terminal frame.  Also used by MSDOS frames.
    Modeled after x_set_name which is used for WINDOW frames.  */
 
-void
+static void
 set_term_frame_name (f, name)
      struct frame *f;
      Lisp_Object name;
@@ -2000,7 +2054,7 @@ store_frame_param (f, prop, val)
   if (EQ (prop, Qminibuffer) && WINDOWP (val))
     {
       if (! MINI_WINDOW_P (XWINDOW (val)))
-       error ("Surrogate minibuffer windows must be minibuffer windows.");
+       error ("Surrogate minibuffer windows must be minibuffer windows");
 
       if ((FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
          && !EQ (val, f->minibuffer_window))
@@ -2080,9 +2134,9 @@ If FRAME is omitted, return information on the currently selected frame.  */)
                                    :"tty"));
     }
   store_in_alist (&alist, Qname, f->name);
-  height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
+  height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
   store_in_alist (&alist, Qheight, make_number (height));
-  width = (FRAME_NEW_WIDTH (f) ? FRAME_NEW_WIDTH (f) : FRAME_WIDTH (f));
+  width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
   store_in_alist (&alist, Qwidth, make_number (width));
   store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil));
   store_in_alist (&alist, Qminibuffer,
@@ -2259,6 +2313,12 @@ enabled such bindings for that variable with `make-variable-frame-local'.  */)
          prop = parms[i];
          val = values[i];
          store_frame_param (f, prop, val);
+
+         /* Changing the background color might change the background
+            mode, so that we have to load new defface specs.
+            Call frame-set-background-mode to do that.  */
+         if (EQ (prop, Qbackground_color))
+           call1 (Qframe_set_background_mode, frame);
        }
     }
 
@@ -2293,8 +2353,7 @@ DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
        0, 1, 0,
        doc: /* Width in pixels of characters in the font in frame FRAME.
 If FRAME is omitted, the selected frame is used.
-The width is the same for all characters, because
-currently Emacs supports only fixed-width fonts.
+On a graphical screen, the width is the standard width of the default font.
 For a terminal screen, the value is always 1.  */)
      (frame)
      Lisp_Object frame;
@@ -2336,7 +2395,7 @@ If FRAME is omitted, the selected frame is used.  */)
     return make_number (x_pixel_height (f));
   else
 #endif
-    return make_number (FRAME_HEIGHT (f));
+    return make_number (FRAME_LINES (f));
 }
 
 DEFUN ("frame-pixel-width", Fframe_pixel_width,
@@ -2359,7 +2418,7 @@ If FRAME is omitted, the selected frame is used.  */)
     return make_number (x_pixel_width (f));
   else
 #endif
-    return make_number (FRAME_WIDTH (f));
+    return make_number (FRAME_COLS (f));
 }
 \f
 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
@@ -2381,8 +2440,8 @@ but that the idea of the actual height of the frame should not be changed.  */)
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f))
     {
-      if (XINT (lines) != f->height)
-       x_set_window_size (f, 1, f->width, XINT (lines));
+      if (XINT (lines) != FRAME_LINES (f))
+       x_set_window_size (f, 1, FRAME_COLS (f), XINT (lines));
       do_pending_window_change (0);
     }
   else
@@ -2409,8 +2468,8 @@ but that the idea of the actual width of the frame should not be changed.  */)
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f))
     {
-      if (XINT (cols) != f->width)
-       x_set_window_size (f, 1, XINT (cols), f->height);
+      if (XINT (cols) != FRAME_COLS (f))
+       x_set_window_size (f, 1, XINT (cols), FRAME_LINES (f));
       do_pending_window_change (0);
     }
   else
@@ -2435,8 +2494,9 @@ DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f))
     {
-      if (XINT (rows) != f->height || XINT (cols) != f->width
-         || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
+      if (XINT (rows) != FRAME_LINES (f)
+         || XINT (cols) != FRAME_COLS (f)
+         || f->new_text_lines || f->new_text_cols)
        x_set_window_size (f, 1, XINT (cols), XINT (rows));
       do_pending_window_change (0);
     }
@@ -2541,32 +2601,31 @@ x_fullscreen_adjust (f, width, height, top_pos, left_pos)
      int *top_pos;
      int *left_pos;
 {
-  int newwidth = f->width, newheight = f->height;
+  int newwidth = FRAME_COLS (f);
+  int newheight = FRAME_LINES (f);
 
-  *top_pos = FRAME_X_OUTPUT (f)->top_pos;
-  *left_pos = FRAME_X_OUTPUT (f)->left_pos;
+  *top_pos = f->top_pos;
+  *left_pos = f->left_pos;
 
-  if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_HEIGHT)
+  if (f->want_fullscreen & FULLSCREEN_HEIGHT)
     {
       int ph;
 
       ph = FRAME_X_DISPLAY_INFO (f)->height;
-      newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
-      ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
-        - FRAME_X_OUTPUT (f)->y_pixels_diff;
-      newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
+      newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
+      ph = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, newheight) - f->y_pixels_diff;
+      newheight = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, ph);
       *top_pos = 0;
     }
 
-  if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_WIDTH)
+  if (f->want_fullscreen & FULLSCREEN_WIDTH)
     {
       int pw;
 
       pw = FRAME_X_DISPLAY_INFO (f)->width;
-      newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
-      pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
-        - FRAME_X_OUTPUT (f)->x_pixels_diff;
-      newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
+      newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
+      pw = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, newwidth) - f->x_pixels_diff;
+      newwidth = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pw);
       *left_pos = 0;
     }
 
@@ -2575,33 +2634,6 @@ x_fullscreen_adjust (f, width, height, top_pos, left_pos)
 }
 
 
-/* Really try to move where we want to be in case of fullscreen.  Some WMs
-   moves the window where we tell them.  Some (mwm, twm) moves the outer
-   window manager window there instead.
-   Try to compensate for those WM here. */
-
-static void
-x_fullscreen_move (f, new_top, new_left)
-     struct frame *f;
-     int new_top;
-     int new_left;
-{
-  if (new_top != FRAME_X_OUTPUT (f)->top_pos
-      || new_left != FRAME_X_OUTPUT (f)->left_pos)
-    {
-      int move_x = new_left;
-      int move_y = new_top;
-
-#ifdef HAVE_X_WINDOWS
-      move_x += FRAME_X_OUTPUT (f)->x_pixels_outer_diff;
-      move_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff;
-#endif
-
-      FRAME_X_OUTPUT (f)->want_fullscreen |= FULLSCREEN_MOVE_WAIT;
-      x_set_offset (f, move_x, move_y, 1);
-    }
-}
-
 /* Change the parameters of frame F as specified by ALIST.
    If a parameter is not specially recognized, do nothing special;
    otherwise call the `x_set_...' function for that parameter.
@@ -2668,15 +2700,8 @@ x_set_frame_parameters (f, alist)
   icon_left = icon_top = Qunbound;
 
   /* Provide default values for HEIGHT and WIDTH.  */
-  if (FRAME_NEW_WIDTH (f))
-    width = FRAME_NEW_WIDTH (f);
-  else
-    width = FRAME_WIDTH (f);
-
-  if (FRAME_NEW_HEIGHT (f))
-    height = FRAME_NEW_HEIGHT (f);
-  else
-    height = FRAME_HEIGHT (f);
+  width = (f->new_text_cols ? f->new_text_cols : FRAME_COLS (f));
+  height = (f->new_text_lines ? f->new_text_lines : FRAME_LINES (f));
 
   /* Process foreground_color and background_color before anything else.
      They are independent of other properties, but other properties (e.g.,
@@ -2760,18 +2785,18 @@ x_set_frame_parameters (f, alist)
   if (EQ (left, Qunbound))
     {
       left_no_change = 1;
-      if (FRAME_X_OUTPUT (f)->left_pos < 0)
-       left = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->left_pos), Qnil));
+      if (f->left_pos < 0)
+       left = Fcons (Qplus, Fcons (make_number (f->left_pos), Qnil));
       else
-       XSETINT (left, FRAME_X_OUTPUT (f)->left_pos);
+       XSETINT (left, f->left_pos);
     }
   if (EQ (top, Qunbound))
     {
       top_no_change = 1;
-      if (FRAME_X_OUTPUT (f)->top_pos < 0)
-       top = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->top_pos), Qnil));
+      if (f->top_pos < 0)
+       top = Fcons (Qplus, Fcons (make_number (f->top_pos), Qnil));
       else
-       XSETINT (top, FRAME_X_OUTPUT (f)->top_pos);
+       XSETINT (top, f->top_pos);
     }
 
   /* If one of the icon positions was not set, preserve or default it.  */
@@ -2790,8 +2815,6 @@ x_set_frame_parameters (f, alist)
        XSETINT (icon_top, 0);
     }
 
-#ifndef HAVE_CARBON
-  /* MAC_TODO: fullscreen */
   if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)
     {
       /* If the frame is visible already and the fullscreen parameter is
@@ -2804,9 +2827,9 @@ x_set_frame_parameters (f, alist)
       int new_left, new_top;
 
       x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
-      x_fullscreen_move (f, new_top, new_left);
+      if (new_top != f->top_pos || new_left != f->left_pos)
+        x_set_offset (f, new_left, new_top, 1);
     }
-#endif
 
   /* Don't set these parameters unless they've been explicitly
      specified.  The window might be mapped or resized while we're in
@@ -2823,35 +2846,35 @@ x_set_frame_parameters (f, alist)
 
     XSETFRAME (frame, f);
 
-    if (width != FRAME_WIDTH (f)
-       || height != FRAME_HEIGHT (f)
-       || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))
+    if (width != FRAME_COLS (f)
+       || height != FRAME_LINES (f)
+       || f->new_text_lines || f->new_text_cols)
       Fset_frame_size (frame, make_number (width), make_number (height));
 
     if ((!NILP (left) || !NILP (top))
        && ! (left_no_change && top_no_change)
-       && ! (NUMBERP (left) && XINT (left) == FRAME_X_OUTPUT (f)->left_pos
-             && NUMBERP (top) && XINT (top) == FRAME_X_OUTPUT (f)->top_pos))
+       && ! (NUMBERP (left) && XINT (left) == f->left_pos
+             && NUMBERP (top) && XINT (top) == f->top_pos))
       {
        int leftpos = 0;
        int toppos = 0;
 
        /* Record the signs.  */
-       FRAME_X_OUTPUT (f)->size_hint_flags &= ~ (XNegative | YNegative);
+       f->size_hint_flags &= ~ (XNegative | YNegative);
        if (EQ (left, Qminus))
-         FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
+         f->size_hint_flags |= XNegative;
        else if (INTEGERP (left))
          {
            leftpos = XINT (left);
            if (leftpos < 0)
-             FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
+             f->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qminus)
                 && CONSP (XCDR (left))
                 && INTEGERP (XCAR (XCDR (left))))
          {
            leftpos = - XINT (XCAR (XCDR (left)));
-           FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative;
+           f->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qplus)
                 && CONSP (XCDR (left))
@@ -2861,19 +2884,19 @@ x_set_frame_parameters (f, alist)
          }
 
        if (EQ (top, Qminus))
-         FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
+         f->size_hint_flags |= YNegative;
        else if (INTEGERP (top))
          {
            toppos = XINT (top);
            if (toppos < 0)
-             FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
+             f->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qminus)
                 && CONSP (XCDR (top))
                 && INTEGERP (XCAR (XCDR (top))))
          {
            toppos = - XINT (XCAR (XCDR (top)));
-           FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative;
+           f->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qplus)
                 && CONSP (XCDR (top))
@@ -2884,10 +2907,10 @@ x_set_frame_parameters (f, alist)
 
 
        /* Store the numeric value of the position.  */
-       FRAME_X_OUTPUT (f)->top_pos = toppos;
-       FRAME_X_OUTPUT (f)->left_pos = leftpos;
+       f->top_pos = toppos;
+       f->left_pos = leftpos;
 
-       FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity;
+       f->win_gravity = NorthWestGravity;
 
        /* Actually set that position, and convert to absolute.  */
        x_set_offset (f, leftpos, toppos, -1);
@@ -2918,31 +2941,31 @@ x_report_frame_params (f, alistptr)
 
   /* Represent negative positions (off the top or left screen edge)
      in a way that Fmodify_frame_parameters will understand correctly.  */
-  XSETINT (tem, FRAME_X_OUTPUT (f)->left_pos);
-  if (FRAME_X_OUTPUT (f)->left_pos >= 0)
+  XSETINT (tem, f->left_pos);
+  if (f->left_pos >= 0)
     store_in_alist (alistptr, Qleft, tem);
   else
     store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));
 
-  XSETINT (tem, FRAME_X_OUTPUT (f)->top_pos);
-  if (FRAME_X_OUTPUT (f)->top_pos >= 0)
+  XSETINT (tem, f->top_pos);
+  if (f->top_pos >= 0)
     store_in_alist (alistptr, Qtop, tem);
   else
     store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));
 
   store_in_alist (alistptr, Qborder_width,
-                 make_number (FRAME_X_OUTPUT (f)->border_width));
+                 make_number (f->border_width));
   store_in_alist (alistptr, Qinternal_border_width,
-                 make_number (FRAME_X_OUTPUT (f)->internal_border_width));
+                 make_number (FRAME_INTERNAL_BORDER_WIDTH (f)));
   store_in_alist (alistptr, Qleft_fringe,
-                 make_number (FRAME_X_OUTPUT (f)->left_fringe_width));
+                 make_number (FRAME_LEFT_FRINGE_WIDTH (f)));
   store_in_alist (alistptr, Qright_fringe,
-                 make_number (FRAME_X_OUTPUT (f)->right_fringe_width));
+                 make_number (FRAME_RIGHT_FRINGE_WIDTH (f)));
   store_in_alist (alistptr, Qscroll_bar_width,
                  (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
                   ? make_number (0)
-                  : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
-                  ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
+                  : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
+                  ? make_number (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
                   /* nil means "use default width"
                      for non-toolkit scroll bar.
                      ruler-mode.el depends on this.  */
@@ -2983,16 +3006,14 @@ x_set_fullscreen (f, new_value, old_value)
      struct frame *f;
      Lisp_Object new_value, old_value;
 {
-#ifndef HAVE_CARBON
   if (NILP (new_value))
-    FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_NONE;
+    f->want_fullscreen = FULLSCREEN_NONE;
   else if (EQ (new_value, Qfullboth))
-    FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_BOTH;
+    f->want_fullscreen = FULLSCREEN_BOTH;
   else if (EQ (new_value, Qfullwidth))
-    FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_WIDTH;
+    f->want_fullscreen = FULLSCREEN_WIDTH;
   else if (EQ (new_value, Qfullheight))
-    FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_HEIGHT;
-#endif
+    f->want_fullscreen = FULLSCREEN_HEIGHT;
 }
 
 
@@ -3063,6 +3084,7 @@ x_set_font (f, arg, oldval)
     error ("The characters of the given font have varying widths");
   else if (STRINGP (result))
     {
+      set_default_ascii_font (result);
       if (STRINGP (fontset_name))
        {
          /* Fontset names are built from ASCII font names, so the
@@ -3073,6 +3095,11 @@ x_set_font (f, arg, oldval)
       else if (!NILP (Fequal (result, oldval)))
         return;
 
+      /* Recalculate toolbar height.  */
+      f->n_tool_bar_rows = 0;
+      /* Ensure we redraw it.  */
+      clear_current_matrices (f);
+
       store_frame_param (f, Qfont, result);
       recompute_basic_faces (f);
     }
@@ -3109,15 +3136,15 @@ x_set_border_width (f, arg, oldval)
 {
   CHECK_NUMBER (arg);
 
-  if (XINT (arg) == FRAME_X_OUTPUT (f)->border_width)
+  if (XINT (arg) == f->border_width)
     return;
 
-#ifndef HAVE_CARBON
+#ifndef MAC_OS
   if (FRAME_X_WINDOW (f) != 0)
     error ("Cannot change the border width of a window");
 #endif /* MAC_TODO */
 
-  FRAME_X_OUTPUT (f)->border_width = XINT (arg);
+  f->border_width = XINT (arg);
 }
 
 void
@@ -3125,24 +3152,24 @@ x_set_internal_border_width (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  int old = FRAME_X_OUTPUT (f)->internal_border_width;
+  int old = FRAME_INTERNAL_BORDER_WIDTH (f);
 
   CHECK_NUMBER (arg);
-  FRAME_X_OUTPUT (f)->internal_border_width = XINT (arg);
-  if (FRAME_X_OUTPUT (f)->internal_border_width < 0)
-    FRAME_X_OUTPUT (f)->internal_border_width = 0;
+  FRAME_INTERNAL_BORDER_WIDTH (f) = XINT (arg);
+  if (FRAME_INTERNAL_BORDER_WIDTH (f) < 0)
+    FRAME_INTERNAL_BORDER_WIDTH (f) = 0;
 
 #ifdef USE_X_TOOLKIT
   if (FRAME_X_OUTPUT (f)->edit_widget)
     widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
 #endif
 
-  if (FRAME_X_OUTPUT (f)->internal_border_width == old)
+  if (FRAME_INTERNAL_BORDER_WIDTH (f) == old)
     return;
 
   if (FRAME_X_WINDOW (f) != 0)
     {
-      x_set_window_size (f, 0, f->width, f->height);
+      x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
       SET_FRAME_GARBAGED (f);
       do_pending_window_change (0);
     }
@@ -3207,20 +3234,18 @@ x_set_vertical_scroll_bars (f, arg, oldval)
           ? vertical_scroll_bar_left
           : EQ (Qright, arg)
           ? vertical_scroll_bar_right
-#ifdef HAVE_NTGUI
-          /* MS-Windows has scroll bars on the right by default.  */
-          : vertical_scroll_bar_right
-#else
-          : vertical_scroll_bar_left
-#endif
-          );
+          : EQ (Qleft, Vdefault_frame_scroll_bars)
+          ? vertical_scroll_bar_left
+          : EQ (Qright, Vdefault_frame_scroll_bars)
+          ? vertical_scroll_bar_right
+          : vertical_scroll_bar_none);
 
       /* We set this parameter before creating the X window for the
         frame, so we can get the geometry right from the start.
         However, if the window hasn't been created yet, we shouldn't
         call x_set_window_size.  */
       if (FRAME_X_WINDOW (f))
-       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
+       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
       do_pending_window_change (0);
     }
 }
@@ -3230,30 +3255,30 @@ x_set_scroll_bar_width (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  int wid = FONT_WIDTH (FRAME_FONT (f));
+  int wid = FRAME_COLUMN_WIDTH (f);
 
   if (NILP (arg))
     {
       x_set_scroll_bar_default_width (f);
 
       if (FRAME_X_WINDOW (f))
-        x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
+        x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
       do_pending_window_change (0);
     }
   else if (INTEGERP (arg) && XINT (arg) > 0
-          && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
+          && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
     {
       if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
        XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
 
-      FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);
-      FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
+      FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFASTINT (arg);
+      FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;
       if (FRAME_X_WINDOW (f))
-       x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
+       x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
       do_pending_window_change (0);
     }
 
-  change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
+  change_frame_size (f, 0, FRAME_COLS (f), 0, 0, 0);
   XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
   XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
 }
@@ -3353,7 +3378,7 @@ extern char *x_get_string_resource P_ ((XrmDatabase, char *, char *));
 extern Display_Info *check_x_display_info P_ ((Lisp_Object));
 
 
-/* Get specified attribute from resource database RDB.  
+/* Get specified attribute from resource database RDB.
    See Fx_get_resource below for other parameters.  */
 
 static Lisp_Object
@@ -3490,7 +3515,7 @@ x_get_resource_string (attribute, class)
 
 Lisp_Object
 x_get_arg (dpyinfo, alist, param, attribute, class, type)
-     Display_Info *dpyinfo; 
+     Display_Info *dpyinfo;
      Lisp_Object alist, param;
      char *attribute;
      char *class;
@@ -3499,8 +3524,27 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type)
   register Lisp_Object tem;
 
   tem = Fassq (param, alist);
-  if (EQ (tem, Qnil))
+
+  if (!NILP (tem))
+    {
+      /* If we find this parm in ALIST, clear it out
+        so that it won't be "left over" at the end.  */
+#ifndef WINDOWSNT /* w32fns.c has not yet been changed to cope with this.  */
+      Lisp_Object tail;
+      XSETCAR (tem, Qnil);
+      /* In case the parameter appears more than once in the alist,
+        clear it out.  */
+      for (tail = alist; CONSP (tail); tail = XCDR (tail))
+       if (CONSP (XCAR (tail))
+           && EQ (XCAR (XCAR (tail)), param))
+         XSETCAR (XCAR (tail), Qnil);
+#endif
+    }
+  else
     tem = Fassq (param, Vdefault_frame_alist);
+
+  /* If it wasn't specified in ALIST or the Lisp-level defaults,
+     look in the X resources.  */
   if (EQ (tem, Qnil))
     {
       if (attribute)
@@ -3584,7 +3628,7 @@ x_frame_get_and_record_arg (f, alist, param, attribute, class, type)
 
   value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,
                     attribute, class, type);
-  if (! NILP (value))
+  if (! NILP (value) && ! EQ (value, Qunbound))
     store_frame_param (f, param, value);
 
   return value;
@@ -3703,18 +3747,17 @@ x_figure_window_size (f, parms, toolbar_p)
   /* Default values if we fall through.
      Actually, if that happens we should get
      window manager prompting.  */
-  SET_FRAME_WIDTH (f, DEFAULT_COLS);
-  f->height = DEFAULT_ROWS;
+  SET_FRAME_COLS (f, DEFAULT_COLS);
+  FRAME_LINES (f) = DEFAULT_ROWS;
   /* Window managers expect that if program-specified
      positions are not (0,0), they're intentional, not defaults.  */
-  FRAME_X_OUTPUT (f)->top_pos = 0;
-  FRAME_X_OUTPUT (f)->left_pos = 0;
+  f->top_pos = 0;
+  f->left_pos = 0;
 
-  /* Ensure that old new_width and new_height will not override the
+  /* Ensure that old new_text_cols and new_text_lines will not override the
      values set here.  */
   /* ++KFS: This was specific to W32, but seems ok for all platforms */
-  FRAME_NEW_WIDTH (f) = 0;
-  FRAME_NEW_HEIGHT (f) = 0;
+  f->new_text_cols = f->new_text_lines = 0;
 
   tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
   tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
@@ -3724,12 +3767,12 @@ x_figure_window_size (f, parms, toolbar_p)
       if (!EQ (tem0, Qunbound))
        {
          CHECK_NUMBER (tem0);
-         f->height = XINT (tem0);
+         FRAME_LINES (f) = XINT (tem0);
        }
       if (!EQ (tem1, Qunbound))
        {
          CHECK_NUMBER (tem1);
-         SET_FRAME_WIDTH (f, XINT (tem1));
+         SET_FRAME_COLS (f, XINT (tem1));
        }
       if (!NILP (tem2) && !EQ (tem2, Qunbound))
        window_prompting |= USSize;
@@ -3737,15 +3780,8 @@ x_figure_window_size (f, parms, toolbar_p)
        window_prompting |= PSize;
     }
 
-  FRAME_X_OUTPUT (f)->vertical_scroll_bar_extra
-    = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
-       ? 0
-#ifndef HAVE_X_WINDOWS
-       /* +KFS: This was specific for W32 and MAC.. why?  */
-       : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0
-       ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f)
-#endif
-       : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (FRAME_X_OUTPUT (f)->font)));
+  f->scroll_bar_actual_width
+    = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
 
   /* This used to be done _before_ calling x_figure_window_size, but
      since the height is reset here, this was really a no-op.  I
@@ -3777,13 +3813,13 @@ x_figure_window_size (f, parms, toolbar_p)
        margin = 0;
 
       bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
-      f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
+      FRAME_LINES (f) += (bar_height + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
     }
 
   compute_fringe_widths (f, 0);
 
-  FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
-  FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
+  FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, FRAME_COLS (f));
+  FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
 
   tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
   tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
@@ -3792,57 +3828,57 @@ x_figure_window_size (f, parms, toolbar_p)
     {
       if (EQ (tem0, Qminus))
        {
-         FRAME_X_OUTPUT (f)->top_pos = 0;
+         f->top_pos = 0;
          window_prompting |= YNegative;
        }
       else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
               && CONSP (XCDR (tem0))
               && INTEGERP (XCAR (XCDR (tem0))))
        {
-         FRAME_X_OUTPUT (f)->top_pos = - XINT (XCAR (XCDR (tem0)));
+         f->top_pos = - XINT (XCAR (XCDR (tem0)));
          window_prompting |= YNegative;
        }
       else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
               && CONSP (XCDR (tem0))
               && INTEGERP (XCAR (XCDR (tem0))))
        {
-         FRAME_X_OUTPUT (f)->top_pos = XINT (XCAR (XCDR (tem0)));
+         f->top_pos = XINT (XCAR (XCDR (tem0)));
        }
       else if (EQ (tem0, Qunbound))
-       FRAME_X_OUTPUT (f)->top_pos = 0;
+       f->top_pos = 0;
       else
        {
          CHECK_NUMBER (tem0);
-         FRAME_X_OUTPUT (f)->top_pos = XINT (tem0);
-         if (FRAME_X_OUTPUT (f)->top_pos < 0)
+         f->top_pos = XINT (tem0);
+         if (f->top_pos < 0)
            window_prompting |= YNegative;
        }
 
       if (EQ (tem1, Qminus))
        {
-         FRAME_X_OUTPUT (f)->left_pos = 0;
+         f->left_pos = 0;
          window_prompting |= XNegative;
        }
       else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
               && CONSP (XCDR (tem1))
               && INTEGERP (XCAR (XCDR (tem1))))
        {
-         FRAME_X_OUTPUT (f)->left_pos = - XINT (XCAR (XCDR (tem1)));
+         f->left_pos = - XINT (XCAR (XCDR (tem1)));
          window_prompting |= XNegative;
        }
       else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
               && CONSP (XCDR (tem1))
               && INTEGERP (XCAR (XCDR (tem1))))
        {
-         FRAME_X_OUTPUT (f)->left_pos = XINT (XCAR (XCDR (tem1)));
+         f->left_pos = XINT (XCAR (XCDR (tem1)));
        }
       else if (EQ (tem1, Qunbound))
-       FRAME_X_OUTPUT (f)->left_pos = 0;
+       f->left_pos = 0;
       else
        {
          CHECK_NUMBER (tem1);
-         FRAME_X_OUTPUT (f)->left_pos = XINT (tem1);
-         if (FRAME_X_OUTPUT (f)->left_pos < 0)
+         f->left_pos = XINT (tem1);
+         if (f->left_pos < 0)
            window_prompting |= XNegative;
        }
 
@@ -3852,7 +3888,7 @@ x_figure_window_size (f, parms, toolbar_p)
        window_prompting |= PPosition;
     }
 
-  if (FRAME_X_OUTPUT (f)->want_fullscreen != FULLSCREEN_NONE)
+  if (f->want_fullscreen != FULLSCREEN_NONE)
     {
       int left, top;
       int width, height;
@@ -3860,30 +3896,30 @@ x_figure_window_size (f, parms, toolbar_p)
       /* It takes both for some WM:s to place it where we want */
       window_prompting = USPosition | PPosition;
       x_fullscreen_adjust (f, &width, &height, &top, &left);
-      f->width = width;
-      f->height = height;
-      FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
-      FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
-      FRAME_X_OUTPUT (f)->left_pos = left;
-      FRAME_X_OUTPUT (f)->top_pos = top;
+      FRAME_COLS (f) = width;
+      FRAME_LINES (f) = height;
+      FRAME_PIXEL_WIDTH (f) = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width);
+      FRAME_PIXEL_HEIGHT (f) = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height);
+      f->left_pos = left;
+      f->top_pos = top;
     }
 
   if (window_prompting & XNegative)
     {
       if (window_prompting & YNegative)
-       FRAME_X_OUTPUT (f)->win_gravity = SouthEastGravity;
+       f->win_gravity = SouthEastGravity;
       else
-       FRAME_X_OUTPUT (f)->win_gravity = NorthEastGravity;
+       f->win_gravity = NorthEastGravity;
     }
   else
     {
       if (window_prompting & YNegative)
-       FRAME_X_OUTPUT (f)->win_gravity = SouthWestGravity;
+       f->win_gravity = SouthWestGravity;
       else
-       FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity;
+       f->win_gravity = NorthWestGravity;
     }
 
-  FRAME_X_OUTPUT (f)->size_hint_flags = window_prompting;
+  f->size_hint_flags = window_prompting;
 
   return window_prompting;
 }
@@ -4019,7 +4055,7 @@ is a reasonable practice.  See also the variable `x-resource-name'.  */);
   DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
               doc: /* Alist of default values for frame creation.
 These may be set in your init file, like this:
-  (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))
+  (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)))
 These override values given in window system configuration data,
  including X Windows' defaults database.
 For values specific to the first Emacs frame, see `initial-frame-alist'.
@@ -4030,6 +4066,19 @@ The `menu-bar-lines' element of the list controls whether new frames
 Setting this variable does not affect existing frames, only new ones.  */);
   Vdefault_frame_alist = Qnil;
 
+  DEFVAR_LISP ("default-frame-scroll-bars", &Vdefault_frame_scroll_bars,
+              doc: /* Default position of scroll bars on this window-system.  */);
+#ifdef HAVE_WINDOW_SYSTEM
+#if defined(HAVE_NTGUI) || defined(MAC_OS)
+  /* MS-Windows has scroll bars on the right by default.  */
+  Vdefault_frame_scroll_bars = Qright;
+#else
+  Vdefault_frame_scroll_bars = Qleft;
+#endif
+#else
+  Vdefault_frame_scroll_bars = Qnil;
+#endif
+
   Qinhibit_default_face_x_resources
     = intern ("inhibit-default-face-x-resources");
   staticpro (&Qinhibit_default_face_x_resources);
@@ -4085,7 +4134,6 @@ This variable is local to the current terminal and cannot be buffer-local.  */);
   defsubr (&Sframe_live_p);
   defsubr (&Smake_terminal_frame);
   defsubr (&Shandle_switch_frame);
-  defsubr (&Signore_event);
   defsubr (&Sselect_frame);
   defsubr (&Sselected_frame);
   defsubr (&Swindow_frame);
@@ -4132,3 +4180,6 @@ This variable is local to the current terminal and cannot be buffer-local.  */);
 #endif
 
 }
+
+/* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
+   (do not change this comment) */