* NEWS: New functions eshell/su and eshell/sudo.
[bpt/emacs.git] / src / frame.c
index 448f6ba..4a9d30d 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic frame functions.
    Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+     2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
 #include <ctype.h>
+#include <setjmp.h>
 #include "lisp.h"
 #include "character.h"
 #ifdef HAVE_X_WINDOWS
@@ -52,6 +53,9 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #endif
 
 
+/* If we shall make pointer invisible when typing or not.  */
+Lisp_Object Vmake_pointer_invisible;
+
 #ifdef HAVE_WINDOW_SYSTEM
 
 /* The name we're using in resource queries.  Most often "emacs".  */
@@ -69,6 +73,10 @@ Lisp_Object Vframe_alpha_lower_limit;
 
 #endif
 
+#ifdef HAVE_NS
+Lisp_Object Qns_parse_geometry;
+#endif
+
 Lisp_Object Qframep, Qframe_live_p;
 Lisp_Object Qicon, Qmodeline;
 Lisp_Object Qonly;
@@ -116,7 +124,8 @@ Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
 Lisp_Object Qtty_color_mode;
 Lisp_Object Qtty, Qtty_type;
 
-Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
+Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
+Lisp_Object Qsticky;
 Lisp_Object Qfont_backend;
 Lisp_Object Qalpha;
 
@@ -189,7 +198,6 @@ set_menu_bar_lines (f, value, oldval)
     }
 }
 \f
-Lisp_Object Vemacs_iconified;
 Lisp_Object Vframe_list;
 
 extern Lisp_Object Vminibuffer_list;
@@ -197,6 +205,8 @@ extern Lisp_Object get_minibuffer ();
 extern Lisp_Object Fhandle_switch_frame ();
 extern Lisp_Object Fredirect_frame_focus ();
 extern Lisp_Object x_get_focus_frame ();
+extern Lisp_Object QCname, Qfont_param;
+
 \f
 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
        doc: /* Return non-nil if OBJECT is a frame.
@@ -535,7 +545,7 @@ make_initial_frame (void)
   Vframe_list = Fcons (frame, Vframe_list);
 
   tty_frame_count = 1;
-  f->name = build_string ("F1");
+  f->name = make_pure_c_string ("F1");
 
   f->visible = 1;
   f->async_visible = 1;
@@ -581,56 +591,32 @@ make_terminal_frame (struct terminal *terminal)
 
   f->visible = 1;              /* FRAME_SET_VISIBLE wd set frame_garbaged. */
   f->async_visible = 1;                /* Don't let visible be cleared later. */
+  f->terminal = terminal;
+  f->terminal->reference_count++;
 #ifdef MSDOS
-  f->output_data.x = &the_only_x_display;
+  f->output_data.tty->display_info = &the_only_display_info;
   if (!inhibit_window_system
       && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
          || XFRAME (selected_frame)->output_method == output_msdos_raw))
-    {
-      f->output_method = output_msdos_raw;
-      /* This initialization of foreground and background pixels is
-        only important for the initial frame created in temacs.  If
-        we don't do that, we get black background and foreground in
-        the dumped Emacs because the_only_x_display is a static
-        variable, hence it is born all-zeroes, and zero is the code
-        for the black color.  Other frames all inherit their pixels
-        from what's already in the_only_x_display.  */
-      if ((!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
-         && FRAME_BACKGROUND_PIXEL (f) == 0
-         && FRAME_FOREGROUND_PIXEL (f) == 0)
-       {
-         FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
-         FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
-       }
-    }
+    f->output_method = output_msdos_raw;
   else
     f->output_method = output_termcap;
-#else
-  {
-    f->output_method = output_termcap;
-    f->terminal = terminal;
-    f->terminal->reference_count++;
-    create_tty_output (f);
-
-    FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
-    FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
-
-    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
-    FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
+#else /* not MSDOS */
+  f->output_method = output_termcap;
+  create_tty_output (f);
+  FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
+  FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
+#endif /* not MSDOS */
 
-    /* Set the top frame to the newly created frame. */
-    if (FRAMEP (FRAME_TTY (f)->top_frame)
-        && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
-      XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */
+  FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
+  FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
 
-    FRAME_TTY (f)->top_frame = frame;
-  }
+  /* Set the top frame to the newly created frame. */
+  if (FRAMEP (FRAME_TTY (f)->top_frame)
+      && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
+    XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */
 
-#ifdef CANNOT_DUMP
-  FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
-  FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR;
-#endif
-#endif /* MSDOS */
+  FRAME_TTY (f)->top_frame = frame;
 
   if (!noninteractive)
     init_frame_faces (f);
@@ -696,7 +682,7 @@ affects all frames on the same terminal device.  */)
     abort ();
 #else /* not MSDOS */
 
-#if 0                           /* This should work now! */
+#ifdef WINDOWSNT                           /* This should work now! */
   if (sf->output_method != output_termcap)
     error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
 #endif
@@ -711,6 +697,13 @@ affects all frames on the same terminal device.  */)
         terminal = XCDR (terminal);
         t = get_terminal (terminal, 1);
       }
+#ifdef MSDOS
+    if (t && t != the_only_display_info.terminal)
+      /* msdos.c assumes a single tty_display_info object.  */
+      error ("Multiple terminals are not supported on this platform");
+    if (!t)
+      t = the_only_display_info.terminal;
+#endif
   }
 
   if (!t)
@@ -789,11 +782,13 @@ affects all frames on the same terminal device.  */)
 
    FOR_DELETION non-zero means that the selected frame is being
    deleted, which includes the possibility that the frame's terminal
-   is dead.  */
+   is dead.
+
+   The value of NORECORD is passed as argument to Fselect_window.  */
 
 Lisp_Object
-do_switch_frame (frame, track, for_deletion)
-     Lisp_Object frame;
+do_switch_frame (frame, track, for_deletion, norecord)
+     Lisp_Object frame, norecord;
      int track, for_deletion;
 {
   struct frame *sf = SELECTED_FRAME ();
@@ -863,7 +858,7 @@ 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 (frame)))
+  if (FRAME_TERMCAP_P (XFRAME (frame)) || FRAME_MSDOS_P (XFRAME (frame)))
     {
       if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame))
        /* Mark previously displayed frame as now obscured.  */
@@ -876,13 +871,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, Qnil);
-
-#ifdef NS_IMPL_COCOA
-  /* term gets no other notification of this */
-  if (for_deletion)
-    Fraise_frame(Qnil);
-#endif
+  Fselect_window (XFRAME (frame)->selected_window, norecord);
 
   /* We want to make sure that the next event generates a frame-switch
      event to the appropriate frame.  This seems kludgy to me, but
@@ -895,21 +884,25 @@ do_switch_frame (frame, track, for_deletion)
   return frame;
 }
 
-DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 1, "e",
-       doc: /* Select the frame FRAME.
+DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
+       doc: /* Select FRAME.
 Subsequent editing commands apply to its selected window.
+Optional argument NORECORD means to neither change the order of
+recently selected windows nor the buffer list.
+
 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.  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.
+something to select a different frame, or until the next time
+this function is called.  If you are using a window system, the
+previously selected frame may be restored as the selected frame
+when returning 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;
+     (frame, norecord)
+     Lisp_Object frame, norecord;
 {
-  return do_switch_frame (frame, 1, 0);
+  return do_switch_frame (frame, 1, 0, norecord);
 }
 
 
@@ -928,7 +921,7 @@ to that frame.  */)
   /* Preserve prefix arg that the command loop just cleared.  */
   current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
   call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
-  return do_switch_frame (event, 0, 0);
+  return do_switch_frame (event, 0, 0, Qnil);
 }
 
 DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
@@ -1003,8 +996,8 @@ If omitted, FRAME defaults to the currently selected frame.  */)
 
 DEFUN ("frame-selected-window", Fframe_selected_window,
        Sframe_selected_window, 0, 1, 0,
-       doc: /* Return the selected window of frame object FRAME.
-If omitted, FRAME defaults to the currently selected frame.  */)
+       doc: /* Return the selected window of FRAME.
+FRAME defaults to the currently selected frame.  */)
      (frame)
      Lisp_Object frame;
 {
@@ -1022,13 +1015,15 @@ 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)
-     Lisp_Object frame, window;
+       Sset_frame_selected_window, 2, 3, 0,
+       doc: /* Set selected window of FRAME to WINDOW.
+If FRAME is nil, use the selected frame.  If FRAME is the
+selected frame, this makes WINDOW the selected window.
+Optional argument NORECORD non-nil means to neither change the
+order of recently selected windows nor the buffer list.
+Return WINDOW.  */)
+     (frame, window, norecord)
+     Lisp_Object frame, window, norecord;
 {
   if (NILP (frame))
     frame = selected_frame;
@@ -1040,7 +1035,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, Qnil);
+    return Fselect_window (window, norecord);
 
   return XFRAME (frame)->selected_window = window;
 }
@@ -1048,7 +1043,7 @@ If FRAME is the selected frame, this makes WINDOW the selected window.  */)
 \f
 DEFUN ("frame-list", Fframe_list, Sframe_list,
        0, 0, 0,
-       doc: /* Return a list of all frames.  */)
+       doc: /* Return a list of all live frames.  */)
      ()
 {
   Lisp_Object frames;
@@ -1319,19 +1314,15 @@ delete_frame_handler (Lisp_Object arg)
 
 extern Lisp_Object Qrun_hook_with_args;
 
-DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
-       doc: /* Delete FRAME, permanently eliminating it from use.
-If omitted, FRAME defaults to the selected frame.
-A frame may not be deleted if its minibuffer is used by other frames.
-Normally, you may not delete a frame if all other frames are invisible,
-but if the second optional argument FORCE is non-nil, you may do so.
-
-This function runs `delete-frame-functions' before actually deleting the
-frame, unless the frame is a tooltip.
-The functions are run with one arg, the frame to be deleted.
-But FORCE inhibits this too.  */)
-/* FORCE is non-nil when handling a disconnected terminal.  */
-     (frame, force)
+/* Delete FRAME.  When FORCE equals Qnoelisp, delete FRAME
+  unconditionally.  x_connection_closed and delete_terminal use
+  this.  Any other value of FORCE implements the semantics
+  described for Fdelete_frame.  */
+Lisp_Object
+delete_frame (frame, force)
+     /* If we use `register' here, gcc-4.0.2 on amd64 using
+       -DUSE_LISP_UNION_TYPE complains further down that we're getting the
+       address of `force'.  Go figure.  */
      Lisp_Object frame, force;
 {
   struct frame *f;
@@ -1357,12 +1348,10 @@ But FORCE inhibits this too.  */)
   if (NILP (force) && !other_visible_frames (f))
     error ("Attempt to delete the sole visible or iconified frame");
 
-#if 0
-  /* This is a nice idea, but x_connection_closed needs to be able
+  /* x_connection_closed must have set FORCE to `noelisp' in order
      to delete the last frame, if it is gone.  */
-  if (NILP (XCDR (Vframe_list)))
+  if (NILP (XCDR (Vframe_list)) && !EQ (force, Qnoelisp))
     error ("Attempt to delete the only frame");
-#endif
 
   /* Does this frame have a minibuffer, and is it the surrogate
      minibuffer for any other frame?  */
@@ -1382,19 +1371,20 @@ But FORCE inhibits this too.  */)
                     WINDOW_FRAME (XWINDOW
                                   (FRAME_MINIBUF_WINDOW (XFRAME (this))))))
            {
-             /* If we MUST delete this frame, delete the other first.  */
-             if (!NILP (force))
-               Fdelete_frame (this, force);
+             /* If we MUST delete this frame, delete the other first.
+                But do this only if FORCE equals `noelisp'.  */
+             if (EQ (force, Qnoelisp))
+               delete_frame (this, Qnoelisp);
              else
                error ("Attempt to delete a surrogate minibuffer frame");
            }
        }
     }
 
-  /* Run `delete-frame-functions'
-     unless FORCE is `noelisp' or frame is a tooltip.
-     FORCE is set to `noelisp' when handling a disconnect from the terminal,
-     so we don't dare call Lisp code.  */
+  /* Run `delete-frame-functions' unless FORCE is `noelisp' or
+     frame is a tooltip.  FORCE is set to `noelisp' when handling
+     a disconnect from the terminal, so we don't dare call Lisp
+     code.  */
   if (NILP (Vrun_hooks) || !NILP (Fframe_parameter (frame, intern ("tooltip"))))
     ;
   if (EQ (force, Qnoelisp))
@@ -1430,8 +1420,17 @@ But FORCE inhibits this too.  */)
                break;
            }
        }
+#ifdef NS_IMPL_COCOA
+      else
+       /* Under NS, there is no system mechanism for choosing a new
+          window to get focus -- it is left to application code.
+          So the portion of THIS application interfacing with NS
+          needs to know about it.  We call Fraise_frame, but the
+          purpose is really to transfer focus.  */
+       Fraise_frame (frame1);
+#endif
 
-      do_switch_frame (frame1, 0, 1);
+      do_switch_frame (frame1, 0, 1, Qnil);
       sf = SELECTED_FRAME ();
     }
 
@@ -1477,6 +1476,13 @@ But FORCE inhibits this too.  */)
   Vframe_list = Fdelq (frame, Vframe_list);
   FRAME_SET_VISIBLE (f, 0);
 
+  /* Allow the vector of menu bar contents to be freed in the next
+     garbage collection.  The frame object itself may not be garbage
+     collected until much later, because recent_keys and other data
+     structures can still refer to it.  */
+  f->menu_bar_vector = Qnil;
+
+  free_font_driver_list (f);
   xfree (f->namebuf);
   xfree (f->decode_mode_spec_buffer);
   xfree (FRAME_INSERT_COST (f));
@@ -1631,6 +1637,24 @@ But FORCE inhibits this too.  */)
 
   return Qnil;
 }
+
+DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
+       doc: /* Delete FRAME, permanently eliminating it from use.
+FRAME defaults to the selected frame.
+
+A frame may not be deleted if its minibuffer is used by other frames.
+Normally, you may not delete a frame if all other frames are invisible,
+but if the second optional argument FORCE is non-nil, you may do so.
+
+This function runs `delete-frame-functions' before actually
+deleting the frame, unless the frame is a tooltip.
+The functions are run with one argument, the frame to be deleted.  */)
+     (frame, force)
+     Lisp_Object frame, force;
+{
+  return delete_frame (frame, !NILP (force) ? Qt : Qnil);
+}
+
 \f
 /* Return mouse position in character cell units.  */
 
@@ -1744,13 +1768,13 @@ before calling this function on it, like this.
 #if defined (MSDOS) && defined (HAVE_MOUSE)
   if (FRAME_MSDOS_P (XFRAME (frame)))
     {
-      Fselect_frame (frame);
+      Fselect_frame (frame, Qnil);
       mouse_moveto (XINT (x), XINT (y));
     }
 #else
 #ifdef HAVE_GPM
     {
-      Fselect_frame (frame);
+      Fselect_frame (frame, Qnil);
       term_mouse_moveto (XINT (x), XINT (y));
     }
 #endif
@@ -1786,13 +1810,13 @@ before calling this function on it, like this.
 #if defined (MSDOS) && defined (HAVE_MOUSE)
   if (FRAME_MSDOS_P (XFRAME (frame)))
     {
-      Fselect_frame (frame);
+      Fselect_frame (frame, Qnil);
       mouse_moveto (XINT (x), XINT (y));
     }
 #else
 #ifdef HAVE_GPM
     {
-      Fselect_frame (frame);
+      Fselect_frame (frame, Qnil);
       term_mouse_moveto (XINT (x), XINT (y));
     }
 #endif
@@ -1858,10 +1882,17 @@ make_frame_visible_1 (window)
 
 DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible,
        0, 2, "",
-       doc: /* Make the frame FRAME invisible (assuming it is an X window).
+       doc: /* Make the frame FRAME invisible.
 If omitted, FRAME defaults to the currently selected frame.
+On graphical displays, invisible frames are not updated and are
+usually not displayed at all, even in a window system's \"taskbar\".
+
 Normally you may not make FRAME invisible if all other frames are invisible,
-but if the second optional argument FORCE is non-nil, you may do so.  */)
+but if the second optional argument FORCE is non-nil, you may do so.
+
+This function has no effect on text-only terminal frames.  Such frames
+are always considered visible, whether or not they are currently being
+displayed in the terminal.  */)
   (frame, force)
      Lisp_Object frame, force;
 {
@@ -1876,7 +1907,7 @@ but if the second optional argument FORCE is non-nil, you may do so.  */)
 #if 0 /* This isn't logically necessary, and it can do GC.  */
   /* Don't let the frame remain selected.  */
   if (EQ (frame, selected_frame))
-    do_switch_frame (next_frame (frame, Qt), 0, 0)
+    do_switch_frame (next_frame (frame, Qt), 0, 0, Qnil)
 #endif
 
   /* Don't allow minibuf_window to remain on a deleted frame.  */
@@ -1941,14 +1972,15 @@ If omitted, FRAME defaults to the currently selected frame.  */)
 
 DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p,
        1, 1, 0,
-       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.
-
-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.  */)
+       doc: /* Return t if FRAME is \"visible\" (actually in use for display).
+Return the symbol `icon' if FRAME is iconified or \"minimized\".
+Return nil if FRAME was made invisible, via `make-frame-invisible'.
+On graphical displays, invisible frames are not updated and are
+usually not displayed at all, even in a window system's \"taskbar\".
+
+If FRAME is a text-only terminal frame, this always returns t.
+Such frames are always considered visible, whether or not they are
+currently being displayed on the terminal.  */)
      (frame)
      Lisp_Object frame;
 {
@@ -1991,7 +2023,7 @@ DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
 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.  */)
+doesn't support multiple overlapping frames, this function selects FRAME.  */)
      (frame)
      Lisp_Object frame;
 {
@@ -2003,8 +2035,12 @@ doesn't support multiple overlapping frames, this function does nothing.  */)
 
   f = XFRAME (frame);
 
-  /* Do like the documentation says. */
-  Fmake_frame_visible (frame);
+  if (FRAME_TERMCAP_P (f))
+    /* On a text-only terminal select FRAME.  */
+    Fselect_frame (frame, Qnil);
+  else
+    /* Do like the documentation says. */
+    Fmake_frame_visible (frame);
 
   if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
     (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
@@ -2271,7 +2307,6 @@ store_frame_param (f, prop, val)
        swap_in_global_binding (prop);
     }
 
-#ifndef WINDOWSNT
   /* 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.  */
@@ -2279,7 +2314,6 @@ store_frame_param (f, prop, val)
       && f == FRAME_TTY (f)->previous_frame)
     /* Force redisplay of this tty.  */
     FRAME_TTY (f)->previous_frame = NULL;
-#endif
 
   /* Update the frame parameter alist.  */
   old_alist_elt = Fassq (prop, f->param_alist);
@@ -2505,7 +2539,9 @@ so that `frame-parameters' will return them.
 
 The value of frame parameter FOO can also be accessed
 as a frame-local binding for the variable FOO, if you have
-enabled such bindings for that variable with `make-variable-frame-local'.  */)
+enabled such bindings for that variable with `make-variable-frame-local'.
+Note that this functionality is obsolete as of Emacs 22.2, and its
+use is not recommended.  Explicitly check for a frame-parameter instead.  */)
      (frame, alist)
      Lisp_Object frame, alist;
 {
@@ -2618,10 +2654,22 @@ For a terminal screen, the value is always 1.  */)
 DEFUN ("frame-pixel-height", Fframe_pixel_height,
        Sframe_pixel_height, 0, 1, 0,
        doc: /* Return a FRAME's height in pixels.
-This counts only the height available for text lines,
-not menu bars on window-system Emacs frames.
-For a terminal frame, the result really gives the height in characters.
-If FRAME is omitted, the selected frame is used.  */)
+If FRAME is omitted, the selected frame is used.  The exact value
+of the result depends on the window-system and toolkit in use:
+
+In the Gtk+ version of Emacs, it includes only any window (including
+the minibuffer or eacho area), mode line, and header line.  It does not
+include the tool bar or menu bar.
+
+With the Motif or Lucid toolkits, it also includes the tool bar (but
+not the menu bar).
+
+In a graphical version with no toolkit, it includes both the tool bar
+and menu bar.
+
+For a text-only terminal, it includes the menu bar.  In this case, the
+result is really in characters rather than pixels (i.e., is identical
+to `frame-height'). */)
      (frame)
      Lisp_Object frame;
 {
@@ -2823,7 +2871,8 @@ static struct frame_parm_table frame_parms[] =
   {"wait-for-wm",              &Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
   {"font-backend",             &Qfont_backend},
-  {"alpha",                    &Qalpha}
+  {"alpha",                    &Qalpha},
+  {"sticky",                   &Qsticky},
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -2847,6 +2896,7 @@ x_fullscreen_adjust (f, width, height, top_pos, left_pos)
 {
   int newwidth = FRAME_COLS (f);
   int newheight = FRAME_LINES (f);
+  Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
 
   *top_pos = f->top_pos;
   *left_pos = f->left_pos;
@@ -2855,7 +2905,7 @@ x_fullscreen_adjust (f, width, height, top_pos, left_pos)
     {
       int ph;
 
-      ph = FRAME_X_DISPLAY_INFO (f)->height;
+      ph = x_display_pixel_height (dpyinfo);
       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);
@@ -2866,7 +2916,7 @@ x_fullscreen_adjust (f, width, height, top_pos, left_pos)
     {
       int pw;
 
-      pw = FRAME_X_DISPLAY_INFO (f)->width;
+      pw = x_display_pixel_width (dpyinfo);
       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);
@@ -2908,8 +2958,7 @@ x_set_frame_parameters (f, alist)
   int i, p;
   int left_no_change = 0, top_no_change = 0;
   int icon_left_no_change = 0, icon_top_no_change = 0;
-  int fullscreen_is_being_set = 0;
-
+  int size_changed = 0;
   struct gcpro gcpro1, gcpro2;
 
   i = 0;
@@ -2951,7 +3000,6 @@ x_set_frame_parameters (f, alist)
      They are independent of other properties, but other properties (e.g.,
      cursor_color) are dependent upon them.  */
   /* Process default font as well, since fringe widths depends on it.  */
-  /* Also, process fullscreen, width and height depend upon that */
   for (p = 0; p < i; p++)
     {
       Lisp_Object prop, val;
@@ -2960,13 +3008,11 @@ x_set_frame_parameters (f, alist)
       val = values[p];
       if (EQ (prop, Qforeground_color)
          || EQ (prop, Qbackground_color)
-         || EQ (prop, Qfont)
-          || EQ (prop, Qfullscreen))
+         || EQ (prop, Qfont))
        {
          register Lisp_Object param_index, old_value;
 
          old_value = get_frame_param (f, prop);
-         fullscreen_is_being_set |= EQ (prop, Qfullscreen);
          if (NILP (Fequal (val, old_value)))
            {
              store_frame_param (f, prop, val);
@@ -2990,9 +3036,15 @@ x_set_frame_parameters (f, alist)
       val = values[i];
 
       if (EQ (prop, Qwidth) && NATNUMP (val))
-       width = XFASTINT (val);
+        {
+          size_changed = 1;
+          width = XFASTINT (val);
+        }
       else if (EQ (prop, Qheight) && NATNUMP (val))
-       height = XFASTINT (val);
+        {
+          size_changed = 1;
+          height = XFASTINT (val);
+        }
       else if (EQ (prop, Qtop))
        top = val;
       else if (EQ (prop, Qleft))
@@ -3003,8 +3055,7 @@ x_set_frame_parameters (f, alist)
        icon_left = val;
       else if (EQ (prop, Qforeground_color)
               || EQ (prop, Qbackground_color)
-              || EQ (prop, Qfont)
-               || EQ (prop, Qfullscreen))
+              || EQ (prop, Qfont))
        /* Processed above.  */
        continue;
       else
@@ -3058,22 +3109,6 @@ x_set_frame_parameters (f, alist)
        XSETINT (icon_top, 0);
     }
 
-  if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)
-    {
-      /* If the frame is visible already and the fullscreen parameter is
-         being set, it is too late to set WM manager hints to specify
-         size and position.
-         Here we first get the width, height and position that applies to
-         fullscreen.  We then move the frame to the appropriate
-         position.  Resize of the frame is taken care of in the code after
-         this if-statement. */
-      int new_left, new_top;
-
-      x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
-      if (new_top != f->top_pos || new_left != f->left_pos)
-        x_set_offset (f, new_left, new_top, 1);
-    }
-
   /* Don't set these parameters unless they've been explicitly
      specified.  The window might be mapped or resized while we're in
      this function, and we don't want to override that unless the lisp
@@ -3089,10 +3124,11 @@ x_set_frame_parameters (f, alist)
 
     XSETFRAME (frame, 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 (size_changed
+        && (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)
@@ -3252,12 +3288,14 @@ x_set_fullscreen (f, new_value, old_value)
 {
   if (NILP (new_value))
     f->want_fullscreen = FULLSCREEN_NONE;
-  else if (EQ (new_value, Qfullboth))
+  else if (EQ (new_value, Qfullboth) || EQ (new_value, Qfullscreen))
     f->want_fullscreen = FULLSCREEN_BOTH;
   else if (EQ (new_value, Qfullwidth))
     f->want_fullscreen = FULLSCREEN_WIDTH;
   else if (EQ (new_value, Qfullheight))
     f->want_fullscreen = FULLSCREEN_HEIGHT;
+  else if (EQ (new_value, Qmaximized))
+    f->want_fullscreen = FULLSCREEN_MAXIMIZED;
 
   if (FRAME_TERMINAL (f)->fullscreen_hook != NULL)
     FRAME_TERMINAL (f)->fullscreen_hook (f);
@@ -3323,18 +3361,19 @@ x_set_font (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  Lisp_Object frame;
+  Lisp_Object frame, font_object, font_param = Qnil;
   int fontset = -1;
-  Lisp_Object font_object;
 
   /* Set the frame parameter back to the old value because we may
      fail to use ARG as the new parameter value.  */
   store_frame_param (f, Qfont, oldval);
 
-  /* ARG is a fontset name, a font name, or a font object.
-     In the last case, this function never fail.  */
+  /* ARG is a fontset name, a font name, a cons of fontset name and a
+     font object, or a font object.  In the last case, this function
+     never fail.  */
   if (STRINGP (arg))
     {
+      font_param = arg;
       fontset = fs_query_fontset (arg, 0);
       if (fontset < 0)
        {
@@ -3350,26 +3389,54 @@ x_set_font (f, arg, oldval)
          font_object = font_open_by_name (f, SDATA (ascii_font));
          if (NILP (font_object))
            error ("Font `%s' is not defined", SDATA (arg));
-         arg = fontset_name (fontset);
+         arg = AREF (font_object, FONT_NAME_INDEX);
        }
       else
        error ("The default fontset can't be used for a frame font");
     }
+  else if (CONSP (arg) && STRINGP (XCAR (arg)) && FONT_OBJECT_P (XCDR (arg)))
+    {
+      /* This is the case that the ASCII font of F's fontset XCAR
+        (arg) is changed to the font XCDR (arg) by
+        `set-fontset-font'.  */
+      fontset = fs_query_fontset (XCAR (arg), 0);
+      if (fontset < 0)
+       error ("Unknown fontset: %s", SDATA (XCAR (arg)));
+      font_object = XCDR (arg);
+      arg = AREF (font_object, FONT_NAME_INDEX);
+      font_param = Ffont_get (font_object, QCname);
+    }
   else if (FONT_OBJECT_P (arg))
     {
       font_object = arg;
-      /* This is store the XLFD font name in the frame parameter for
-        backward compatiblity.  We should store the font-object
+      font_param = Ffont_get (font_object, QCname);
+      /* This is to store the XLFD font name in the frame parameter for
+        backward compatibility.  We should store the font-object
         itself in the future.  */
       arg = AREF (font_object, FONT_NAME_INDEX);
+      fontset = FRAME_FONTSET (f);
+      /* Check if we can use the current fontset.  If not, set FONTSET
+        to -1 to generate a new fontset from FONT-OBJECT.  */
+      if (fontset >= 0)
+       {
+         Lisp_Object ascii_font = fontset_ascii (fontset);
+         Lisp_Object spec = font_spec_from_name (ascii_font);
+
+         if (! font_match_p (spec, font_object))
+           fontset = -1;
+       }
     }
   else
     signal_error ("Invalid font", arg);
 
   if (! NILP (Fequal (font_object, oldval)))
     return;
+
   x_new_font (f, font_object, fontset);
   store_frame_param (f, Qfont, arg);
+#ifdef HAVE_X_WINDOWS
+  store_frame_param (f, Qfont_param, font_param);
+#endif
   /* Recalculate toolbar height.  */
   f->n_tool_bar_rows = 0;
   /* Ensure we redraw it.  */
@@ -3397,7 +3464,7 @@ x_set_font_backend (f, new_value, old_value)
       && !CONSP (new_value))
     {
       char *p0, *p1;
-       
+
       CHECK_STRING (new_value);
       p0 = p1 = SDATA (new_value);
       new_value = Qnil;
@@ -3644,32 +3711,31 @@ x_set_alpha (f, arg, oldval)
       else
         item = arg;
 
-      if (! NILP (item))
-        {
-          if (FLOATP (item))
-            {
-              alpha = XFLOAT_DATA (item);
-              if (alpha < 0.0 || 1.0 < alpha)
-                args_out_of_range (make_float (0.0), make_float (1.0));
-            }
-          else if (INTEGERP (item))
-            {
-              ialpha = XINT (item);
-              if (ialpha < 0 || 100 < ialpha)
-                args_out_of_range (make_number (0), make_number (100));
-              else
-                alpha = ialpha / 100.0;
-            }
-          else
-            wrong_type_argument (Qnumberp, item);
-        }
+      if (NILP (item))
+       alpha = - 1.0;
+      else if (FLOATP (item))
+       {
+         alpha = XFLOAT_DATA (item);
+         if (alpha < 0.0 || 1.0 < alpha)
+           args_out_of_range (make_float (0.0), make_float (1.0));
+       }
+      else if (INTEGERP (item))
+       {
+         ialpha = XINT (item);
+         if (ialpha < 0 || 100 < ialpha)
+           args_out_of_range (make_number (0), make_number (100));
+         else
+           alpha = ialpha / 100.0;
+       }
+      else
+       wrong_type_argument (Qnumberp, item);
       newval[i] = alpha;
     }
 
   for (i = 0; i < 2; i++)
     f->alpha[i] = newval[i];
 
-#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
   BLOCK_INPUT;
   x_set_frame_alpha (f);
   UNBLOCK_INPUT;
@@ -3816,7 +3882,7 @@ xrdb_get_resource (rdb, attribute, class, component, subclass)
 
   value = x_get_string_resource (rdb, name_key, class_key);
 
-  if (value != (char *) 0)
+  if (value != (char *) 0 && *value)
     return build_string (value);
   else
     return Qnil;
@@ -3855,8 +3921,9 @@ display_x_get_resource (dpyinfo, attribute, class, component, subclass)
                            attribute, class, component, subclass);
 }
 
+#if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
 /* Used when C code wants a resource value.  */
-
+/* Called from oldXMenu/Create.c.  */
 char *
 x_get_resource_string (attribute, class)
      char *attribute, *class;
@@ -3878,7 +3945,7 @@ x_get_resource_string (attribute, class)
   return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
                                name_key, class_key);
 }
-
+#endif
 
 /* Return the value of parameter PARAM.
 
@@ -3907,7 +3974,6 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type)
     {
       /* 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,
@@ -3916,7 +3982,6 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type)
        if (CONSP (XCAR (tail))
            && EQ (XCAR (XCAR (tail)), param))
          XSETCAR (XCAR (tail), Qnil);
-#endif
     }
   else
     tem = Fassq (param, Vdefault_frame_alist);
@@ -3925,7 +3990,7 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type)
      look in the X resources.  */
   if (EQ (tem, Qnil))
     {
-      if (attribute)
+      if (attribute && dpyinfo)
        {
          tem = display_x_get_resource (dpyinfo,
                                        build_string (attribute),
@@ -4050,16 +4115,28 @@ x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)
 
 
 \f
+/* NS used to define x-parse-geometry in ns-win.el, but that confused
+   make-docfile: the documentation string in ns-win.el was used for
+   x-parse-geometry even in non-NS builds.
+
+   With two definitions of x-parse-geometry in this file, various
+   things still get confused (eg M-x apropos documentation), so that
+   it is best if the two definitions just share the same doc-string.
+*/
 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,
-       doc: /* Parse an X-style geometry string STRING.
+       doc: /* Parse a display geometry string STRING.
 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).
 The properties returned may include `top', `left', `height', and `width'.
-The value of `left' or `top' may be an integer,
+For X, the value of `left' or `top' may be an integer,
 or a list (+ N) meaning N pixels relative to top/left corner,
-or a list (- N) meaning -N pixels relative to bottom/right corner.  */)
+or a list (- N) meaning -N pixels relative to bottom/right corner.
+On Nextstep, this just calls `ns-parse-geometry'.  */)
      (string)
      Lisp_Object string;
 {
+#ifdef HAVE_NS
+  call1 (Qns_parse_geometry, string);
+#else
   int geometry, x, y;
   unsigned int width, height;
   Lisp_Object result;
@@ -4068,12 +4145,6 @@ or a list (- N) meaning -N pixels relative to bottom/right corner.  */)
 
   geometry = XParseGeometry ((char *) SDATA (string),
                             &x, &y, &width, &height);
-
-#if 0
-  if (!!(geometry & XValue) != !!(geometry & YValue))
-    error ("Must specify both x and y position, or neither");
-#endif
-
   result = Qnil;
   if (geometry & XValue)
     {
@@ -4107,8 +4178,10 @@ or a list (- N) meaning -N pixels relative to bottom/right corner.  */)
     result = Fcons (Fcons (Qheight, make_number (height)), result);
 
   return result;
+#endif /* HAVE_NS */
 }
 
+
 /* Calculate the desired size and position of frame F.
    Return the flags saying which aspects were specified.
 
@@ -4275,22 +4348,6 @@ x_figure_window_size (f, parms, toolbar_p)
        window_prompting |= PPosition;
     }
 
-  if (f->want_fullscreen != FULLSCREEN_NONE)
-    {
-      int left, top;
-      int width, height;
-
-      /* 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);
-      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)
@@ -4315,6 +4372,37 @@ x_figure_window_size (f, parms, toolbar_p)
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
+void
+frame_make_pointer_invisible ()
+{
+  if (! NILP (Vmake_pointer_invisible))
+    {
+      struct frame *f = SELECTED_FRAME ();
+      if (f && !f->pointer_invisible
+          && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
+        {
+          f->mouse_moved = 0;
+          FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 1);
+          f->pointer_invisible = 1;
+        }
+    }
+}
+
+void
+frame_make_pointer_visible ()
+{
+  /* We don't check Vmake_pointer_invisible here in case the
+     pointer was invisible when Vmake_pointer_invisible was set to nil.  */
+
+  struct frame *f = SELECTED_FRAME ();
+  if (f && f->pointer_invisible && f->mouse_moved
+      && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
+    {
+      FRAME_TERMINAL (f)->toggle_invisible_pointer_hook (f, 0);
+      f->pointer_invisible = 0;
+    }
+}
+
 
 \f
 /***********************************************************************
@@ -4324,103 +4412,110 @@ x_figure_window_size (f, parms, toolbar_p)
 void
 syms_of_frame ()
 {
-  Qframep = intern ("framep");
+  Qframep = intern_c_string ("framep");
   staticpro (&Qframep);
-  Qframe_live_p = intern ("frame-live-p");
+  Qframe_live_p = intern_c_string ("frame-live-p");
   staticpro (&Qframe_live_p);
-  Qexplicit_name = intern ("explicit-name");
+  Qexplicit_name = intern_c_string ("explicit-name");
   staticpro (&Qexplicit_name);
-  Qheight = intern ("height");
+  Qheight = intern_c_string ("height");
   staticpro (&Qheight);
-  Qicon = intern ("icon");
+  Qicon = intern_c_string ("icon");
   staticpro (&Qicon);
-  Qminibuffer = intern ("minibuffer");
+  Qminibuffer = intern_c_string ("minibuffer");
   staticpro (&Qminibuffer);
-  Qmodeline = intern ("modeline");
+  Qmodeline = intern_c_string ("modeline");
   staticpro (&Qmodeline);
-  Qonly = intern ("only");
+  Qonly = intern_c_string ("only");
   staticpro (&Qonly);
-  Qwidth = intern ("width");
+  Qwidth = intern_c_string ("width");
   staticpro (&Qwidth);
-  Qgeometry = intern ("geometry");
+  Qgeometry = intern_c_string ("geometry");
   staticpro (&Qgeometry);
-  Qicon_left = intern ("icon-left");
+  Qicon_left = intern_c_string ("icon-left");
   staticpro (&Qicon_left);
-  Qicon_top = intern ("icon-top");
+  Qicon_top = intern_c_string ("icon-top");
   staticpro (&Qicon_top);
-  Qleft = intern ("left");
+  Qleft = intern_c_string ("left");
   staticpro (&Qleft);
-  Qright = intern ("right");
+  Qright = intern_c_string ("right");
   staticpro (&Qright);
-  Quser_position = intern ("user-position");
+  Quser_position = intern_c_string ("user-position");
   staticpro (&Quser_position);
-  Quser_size = intern ("user-size");
+  Quser_size = intern_c_string ("user-size");
   staticpro (&Quser_size);
-  Qwindow_id = intern ("window-id");
+  Qwindow_id = intern_c_string ("window-id");
   staticpro (&Qwindow_id);
 #ifdef HAVE_X_WINDOWS
-  Qouter_window_id = intern ("outer-window-id");
+  Qouter_window_id = intern_c_string ("outer-window-id");
   staticpro (&Qouter_window_id);
 #endif
-  Qparent_id = intern ("parent-id");
+  Qparent_id = intern_c_string ("parent-id");
   staticpro (&Qparent_id);
-  Qx = intern ("x");
+  Qx = intern_c_string ("x");
   staticpro (&Qx);
-  Qw32 = intern ("w32");
+  Qw32 = intern_c_string ("w32");
   staticpro (&Qw32);
-  Qpc = intern ("pc");
+  Qpc = intern_c_string ("pc");
   staticpro (&Qpc);
-  Qmac = intern ("mac");
+  Qmac = intern_c_string ("mac");
   staticpro (&Qmac);
-  Qns = intern ("ns");
+  Qns = intern_c_string ("ns");
   staticpro (&Qns);
-  Qvisible = intern ("visible");
+  Qvisible = intern_c_string ("visible");
   staticpro (&Qvisible);
-  Qbuffer_predicate = intern ("buffer-predicate");
+  Qbuffer_predicate = intern_c_string ("buffer-predicate");
   staticpro (&Qbuffer_predicate);
-  Qbuffer_list = intern ("buffer-list");
+  Qbuffer_list = intern_c_string ("buffer-list");
   staticpro (&Qbuffer_list);
-  Qburied_buffer_list = intern ("buried-buffer-list");
+  Qburied_buffer_list = intern_c_string ("buried-buffer-list");
   staticpro (&Qburied_buffer_list);
-  Qdisplay_type = intern ("display-type");
+  Qdisplay_type = intern_c_string ("display-type");
   staticpro (&Qdisplay_type);
-  Qbackground_mode = intern ("background-mode");
+  Qbackground_mode = intern_c_string ("background-mode");
   staticpro (&Qbackground_mode);
-  Qnoelisp = intern ("noelisp");
+  Qnoelisp = intern_c_string ("noelisp");
   staticpro (&Qnoelisp);
-  Qtty_color_mode = intern ("tty-color-mode");
+  Qtty_color_mode = intern_c_string ("tty-color-mode");
   staticpro (&Qtty_color_mode);
-  Qtty = intern ("tty");
+  Qtty = intern_c_string ("tty");
   staticpro (&Qtty);
-  Qtty_type = intern ("tty-type");
+  Qtty_type = intern_c_string ("tty-type");
   staticpro (&Qtty_type);
 
-  Qface_set_after_frame_default = intern ("face-set-after-frame-default");
+  Qface_set_after_frame_default = intern_c_string ("face-set-after-frame-default");
   staticpro (&Qface_set_after_frame_default);
 
-  Qfullwidth = intern ("fullwidth");
+  Qfullwidth = intern_c_string ("fullwidth");
   staticpro (&Qfullwidth);
-  Qfullheight = intern ("fullheight");
+  Qfullheight = intern_c_string ("fullheight");
   staticpro (&Qfullheight);
-  Qfullboth = intern ("fullboth");
+  Qfullboth = intern_c_string ("fullboth");
   staticpro (&Qfullboth);
-  Qx_resource_name = intern ("x-resource-name");
+  Qmaximized = intern_c_string ("maximized");
+  staticpro (&Qmaximized);
+  Qx_resource_name = intern_c_string ("x-resource-name");
   staticpro (&Qx_resource_name);
 
-  Qx_frame_parameter = intern ("x-frame-parameter");
+  Qx_frame_parameter = intern_c_string ("x-frame-parameter");
   staticpro (&Qx_frame_parameter);
 
-  Qterminal = intern ("terminal");
+  Qterminal = intern_c_string ("terminal");
   staticpro (&Qterminal);
-  Qterminal_live_p = intern ("terminal-live-p");
+  Qterminal_live_p = intern_c_string ("terminal-live-p");
   staticpro (&Qterminal_live_p);
 
+#ifdef HAVE_NS
+  Qns_parse_geometry = intern_c_string ("ns-parse-geometry");
+  staticpro (&Qns_parse_geometry);
+#endif
+
   {
     int i;
 
     for (i = 0; i < sizeof (frame_parms) / sizeof (frame_parms[0]); i++)
       {
-       Lisp_Object v = intern (frame_parms[i].name);
+       Lisp_Object v = intern_c_string (frame_parms[i].name);
        if (frame_parms[i].variable)
          {
            *frame_parms[i].variable = v;
@@ -4494,10 +4589,6 @@ Setting this variable does not affect existing frames, only new ones.  */);
   DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
                doc: /* The initial frame-object, which represents Emacs's stdout.  */);
 
-  DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
-              doc: /* Non-nil if all of Emacs is iconified and frame updates are not needed.  */);
-  Vemacs_iconified = Qnil;
-
   DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function,
               doc: /* If non-nil, function to transform normal value of `mouse-position'.
 `mouse-position' calls this function, passing its usual return value as
@@ -4514,6 +4605,11 @@ is over the clickable text.  However, the mouse shape still indicates
 when the mouse is over clickable text.  */);
   Vmouse_highlight = Qt;
 
+  DEFVAR_LISP ("make-pointer-invisible", &Vmake_pointer_invisible,
+               doc: /* If non-nil, make pointer invisible while typing.
+The pointer becomes visible again when the mouse is moved.  */);
+  Vmake_pointer_invisible = Qt;
+
   DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions,
               doc: /* Functions to be run before deleting a frame.
 The functions are run with one arg, the frame to be deleted.
@@ -4524,7 +4620,7 @@ actually deleted, or some time later (or even both when an earlier function
 in `delete-frame-functions' (indirectly) calls `delete-frame'
 recursively).  */);
   Vdelete_frame_functions = Qnil;
-  Qdelete_frame_functions = intern ("delete-frame-functions");
+  Qdelete_frame_functions = intern_c_string ("delete-frame-functions");
   staticpro (&Qdelete_frame_functions);
 
   DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
@@ -4546,7 +4642,7 @@ This variable is local to the current terminal and cannot be buffer-local.  */);
               doc: /* Non-nil if window system changes focus when you move the mouse.
 You should set this variable to tell Emacs how your window manager
 handles focus, since there is no way in general for Emacs to find out
-automatically.  */);
+automatically.  See also `mouse-autoselect-window'.  */);
 #ifdef HAVE_WINDOW_SYSTEM
 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
   focus_follows_mouse = 0;