]> code.delx.au - gnu-emacs/blobdiff - src/frame.c
(Fset_text_properties): Fix newline in doc string.
[gnu-emacs] / src / frame.c
index b4afa56803b4d58a0fe5e36d86ee9a2fdbd9ee90..204eec30830180b9ee235cf49d12fcb5f6b7a8b3 100644 (file)
@@ -29,6 +29,9 @@ Boston, MA 02111-1307, USA.  */
 #ifdef WINDOWSNT
 #include "w32term.h"
 #endif
+#ifdef macintosh
+#include "macterm.h"
+#endif
 #include "buffer.h"
 /* These help us bind and responding to switch-frame events.  */
 #include "commands.h"
@@ -45,45 +48,6 @@ Boston, MA 02111-1307, USA.  */
 #include "dosfns.h"
 #endif
 
-#ifdef macintosh
-extern struct mac_output *NewMacWindow ();
-extern void DisposeMacWindow (struct mac_output *);
-#endif
-
-/* Evaluate this expression to rebuild the section of syms_of_frame
-   that initializes and staticpros the symbols declared below.  Note
-   that Emacs 18 has a bug that keeps C-x C-e from being able to
-   evaluate this expression.
-
-(progn
-  ;; Accumulate a list of the symbols we want to initialize from the
-  ;; declarations at the top of the file.
-  (goto-char (point-min))
-  (search-forward "/\*&&& symbols declared here &&&*\/\n")
-  (let (symbol-list)
-    (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
-      (setq symbol-list
-           (cons (buffer-substring (match-beginning 1) (match-end 1))
-                 symbol-list))
-      (forward-line 1))
-    (setq symbol-list (nreverse symbol-list))
-    ;; Delete the section of syms_of_... where we initialize the symbols.
-    (search-forward "\n  /\*&&& init symbols here &&&*\/\n")
-    (let ((start (point)))
-      (while (looking-at "^  Q")
-       (forward-line 2))
-      (kill-region start (point)))
-    ;; Write a new symbol initialization section.
-    (while symbol-list
-      (insert (format "  %s = intern (\"" (car symbol-list)))
-      (let ((start (point)))
-       (insert (substring (car symbol-list) 1))
-       (subst-char-in-region start (point) ?_ ?-))
-      (insert (format "\");\n  staticpro (&%s);\n" (car symbol-list)))
-      (setq symbol-list (cdr symbol-list)))))
-  */        
-
-/*&&& symbols declared here &&&*/
 Lisp_Object Qframep;
 Lisp_Object Qframe_live_p;
 Lisp_Object Qheight;
@@ -106,73 +70,11 @@ Lisp_Object Qbuffer_list;
 Lisp_Object Qtitle;
 Lisp_Object Qdisplay_type;
 Lisp_Object Qbackground_mode;
+Lisp_Object Qinhibit_default_face_x_resources;
 
 Lisp_Object Vterminal_frame;
 Lisp_Object Vdefault_frame_alist;
 Lisp_Object Vmouse_position_function;
-
-static void
-syms_of_frame_1 ()
-{
-  /*&&& init symbols here &&&*/
-  Qframep = intern ("framep");
-  staticpro (&Qframep);
-  Qframe_live_p = intern ("frame-live-p");
-  staticpro (&Qframe_live_p);
-  Qheight = intern ("height");
-  staticpro (&Qheight);
-  Qicon = intern ("icon");
-  staticpro (&Qicon);
-  Qminibuffer = intern ("minibuffer");
-  staticpro (&Qminibuffer);
-  Qmodeline = intern ("modeline");
-  staticpro (&Qmodeline);
-  Qname = intern ("name");
-  staticpro (&Qname);
-  Qonly = intern ("only");
-  staticpro (&Qonly);
-  Qunsplittable = intern ("unsplittable");
-  staticpro (&Qunsplittable);
-  Qmenu_bar_lines = intern ("menu-bar-lines");
-  staticpro (&Qmenu_bar_lines);
-  Qtool_bar_lines = intern ("tool-bar-lines");
-  staticpro (&Qtool_bar_lines);
-  Qwidth = intern ("width");
-  staticpro (&Qwidth);
-  Qx = intern ("x");
-  staticpro (&Qx);
-  Qw32 = intern ("w32");
-  staticpro (&Qw32);
-  Qpc = intern ("pc");
-  staticpro (&Qpc);
-  Qmac = intern ("mac");
-  staticpro (&Qmac);
-  Qvisible = intern ("visible");
-  staticpro (&Qvisible);
-  Qbuffer_predicate = intern ("buffer-predicate");
-  staticpro (&Qbuffer_predicate);
-  Qbuffer_list = intern ("buffer-list");
-  staticpro (&Qbuffer_list);
-  Qtitle = intern ("title");
-  staticpro (&Qtitle);
-  Qdisplay_type = intern ("display-type");
-  staticpro (&Qdisplay_type);
-  Qbackground_mode = intern ("background-mode");
-  staticpro (&Qbackground_mode);
-
-  DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
-    "Alist of default values for frame creation.\n\
-These may be set in your init file, like this:\n\
-  (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
-These override values given in window system configuration data,\n\
- including X Windows' defaults database.\n\
-For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
-For values specific to the separate minibuffer frame, see\n\
- `minibuffer-frame-alist'.\n\
-The `menu-bar-lines' element of the list controls whether new frames\n\
- have menu bars; `menu-bar-mode' works by altering this element.");
-  Vdefault_frame_alist = Qnil;
-}
 \f
 static void
 set_menu_bar_lines_1 (window, n)
@@ -344,9 +246,9 @@ make_frame (mini_p)
   f->title = Qnil;
   f->menu_bar_window = Qnil;
   f->tool_bar_window = Qnil;
-  f->desired_tool_bar_items = f->current_tool_bar_items = Qnil;
+  f->tool_bar_items = Qnil;
   f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
-  f->n_desired_tool_bar_items = f->n_current_tool_bar_items = 0;
+  f->n_tool_bar_items = 0;
 
   root_window = make_window ();
   if (mini_p)
@@ -581,26 +483,21 @@ make_terminal_frame ()
   else
     f->output_method = output_termcap;
 #else
+#ifdef WINDOWSNT
+  f->output_method = output_termcap;
+  f->output_data.x = &tty_display;
+#else
 #ifdef macintosh
-  f->output_data.mac = NewMacWindow(f);
-  f->output_data.mac->background_pixel = 0xffffff;
-  f->output_data.mac->foreground_pixel = 0;
-  f->output_data.mac->n_param_faces = 0;
-  f->output_data.mac->n_computed_faces = 0;
-  f->output_data.mac->size_computed_faces = 0;  
-  f->output_method = output_mac;
-  f->auto_raise = 1;
-  f->auto_lower = 1;
-  init_frame_faces (f);
-#else  /* !macintosh */
+  make_mac_terminal_frame (f);
+#else
   f->output_data.x = &tty_display;
-#endif /* !macintosh */
+#endif /* macintosh */
+#endif /* WINDOWSNT */
 #endif /* MSDOS */
 
-#ifndef macintosh
   if (!noninteractive)
     init_frame_faces (f);
-#endif
+
   return f;
 }
 
@@ -723,6 +620,9 @@ do_switch_frame (frame, no_enter, track)
 #endif /* HAVE_X_WINDOWS */
 #endif /* ! 0 */
 
+  if (FRAME_HAS_MINIBUF_P (sf))
+    resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1);
+
   selected_frame = frame;
   if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame)))
     last_nonminibuf_frame = XFRAME (selected_frame);
@@ -1149,7 +1049,10 @@ DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "",
 If omitted, FRAME defaults to the selected frame.\n\
 A frame may not be deleted if its minibuffer is used by other frames.\n\
 Normally, you may not delete a frame if all other frames are invisible,\n\
-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.\n\
+\n\
+This function runs `delete-frame-hook' before actually deleting the\n\
+frame.  The hook is called with one argument FRAME.")
   (frame, force)
      Lisp_Object frame, force;
 {
@@ -1171,7 +1074,13 @@ but if the second optional argument FORCE is non-nil, you may do so.")
   if (! FRAME_LIVE_P (f))
     return Qnil;
 
-  if (NILP (force) && !other_visible_frames (f))
+  if (NILP (force) && !other_visible_frames (f)
+#ifdef macintosh
+      /* Terminal frame deleted before any other visible frames are
+        created.  */
+      && strcmp (XSTRING (f->name)->data, "F1") != 0
+#endif
+     )
     error ("Attempt to delete the sole visible or iconified frame");
 
 #if 0
@@ -1202,6 +1111,15 @@ but if the second optional argument FORCE is non-nil, you may do so.")
        }
     }
 
+  /* Run `delete-frame-hook'.  */
+  if (!NILP (Vrun_hooks))
+    {
+      Lisp_Object args[2];
+      args[0] = intern ("delete-frame-hook");
+      args[1] = frame;
+      Frun_hook_with_args (2, args);
+    }
+
   minibuffer_selected = EQ (minibuf_window, selected_window);
 
   /* Don't let the frame remain selected.  */
@@ -1288,14 +1206,6 @@ but if the second optional argument FORCE is non-nil, you may do so.")
     x_destroy_window (f);
 #endif
 
-/* Done by x_destroy_window above already */
-#if 0
-#ifdef macintosh
-  if (FRAME_MAC_P (f))
-    DisposeMacWindow (f->output_data.mac);
-#endif
-#endif
-
   f->output_data.nothing = 0;
 
   /* If we've deleted the last_nonminibuf_frame, then try to find
@@ -2067,27 +1977,38 @@ If FRAME is omitted, return information on the currently selected frame.")
         unspecified and reversed, take the frame's background pixel
         for foreground and vice versa.  */
       elt = Fassq (Qforeground_color, alist);
-      if (!NILP (elt) && CONSP (elt)
-         && STRINGP (XCDR (elt))
-         && strncmp (XSTRING (XCDR (elt))->data,
-                     unspecified_bg,
-                     XSTRING (XCDR (elt))->size) == 0)
-       store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
+      if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
+       {
+         if (strncmp (XSTRING (XCDR (elt))->data,
+                      unspecified_bg,
+                      XSTRING (XCDR (elt))->size) == 0)
+           store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
+         else if (strncmp (XSTRING (XCDR (elt))->data,
+                           unspecified_fg,
+                           XSTRING (XCDR (elt))->size) == 0)
+           store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
+       }
       else
        store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
       elt = Fassq (Qbackground_color, alist);
-      if (!NILP (elt) && CONSP (elt)
-         && STRINGP (XCDR (elt))
-         && strncmp (XSTRING (XCDR (elt))->data,
-                     unspecified_fg,
-                     XSTRING (XCDR (elt))->size) == 0)
-       store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
+      if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt)))
+       {
+         if (strncmp (XSTRING (XCDR (elt))->data,
+                      unspecified_fg,
+                      XSTRING (XCDR (elt))->size) == 0)
+           store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
+         else if (strncmp (XSTRING (XCDR (elt))->data,
+                           unspecified_bg,
+                           XSTRING (XCDR (elt))->size) == 0)
+           store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
+       }
       else
        store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
       store_in_alist (&alist, intern ("font"),
                      build_string (FRAME_MSDOS_P (f)
                                    ? "ms-dos"
-                                   : FRAME_W32_P (f) ? "w32term" : "tty"));
+                                   : FRAME_W32_P (f) ? "w32term"
+                                   :"tty"));
     }
   store_in_alist (&alist, Qname, f->name);
   height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
@@ -2212,6 +2133,15 @@ enabled such bindings for that variable with `make-variable-frame-local'.")
 {
   FRAME_PTR f;
   register Lisp_Object tail, prop, val;
+  int count = BINDING_STACK_SIZE ();
+
+  /* Bind this to t to inhibit initialization of the default face from
+     X resources in face-set-after-frame-default.  If we don't inhibit
+     this, modifying the `font' frame parameter, for example, while
+     there is a `default.attributeFont' X resource, won't work,
+     because `default's font is reset to the value of the X resource
+     and that resets the `font' frame parameter.  */
+  specbind (Qinhibit_default_face_x_resources, Qt);
 
   if (EQ (frame, Qnil))
     frame = selected_frame;
@@ -2229,11 +2159,6 @@ enabled such bindings for that variable with `make-variable-frame-local'.")
     IT_set_frame_parameters (f, alist);
   else
 #endif
-#ifdef macintosh
-  if (FRAME_MAC_P (f))
-    mac_set_frame_parameters (f, alist);
-  else
-#endif
 
     {
       int length = XINT (Flength (alist));
@@ -2265,7 +2190,7 @@ enabled such bindings for that variable with `make-variable-frame-local'.")
        }
     }
 
-  return Qnil;
+  return unbind_to (count, Qnil);
 }
 \f
 DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
@@ -2479,9 +2404,67 @@ the rightmost or bottommost possible position (that stays within the screen).")
 void
 syms_of_frame ()
 {
-  syms_of_frame_1 ();
+  Qframep = intern ("framep");
+  staticpro (&Qframep);
+  Qframe_live_p = intern ("frame-live-p");
+  staticpro (&Qframe_live_p);
+  Qheight = intern ("height");
+  staticpro (&Qheight);
+  Qicon = intern ("icon");
+  staticpro (&Qicon);
+  Qminibuffer = intern ("minibuffer");
+  staticpro (&Qminibuffer);
+  Qmodeline = intern ("modeline");
+  staticpro (&Qmodeline);
+  Qname = intern ("name");
+  staticpro (&Qname);
+  Qonly = intern ("only");
+  staticpro (&Qonly);
+  Qunsplittable = intern ("unsplittable");
+  staticpro (&Qunsplittable);
+  Qmenu_bar_lines = intern ("menu-bar-lines");
+  staticpro (&Qmenu_bar_lines);
+  Qtool_bar_lines = intern ("tool-bar-lines");
+  staticpro (&Qtool_bar_lines);
+  Qwidth = intern ("width");
+  staticpro (&Qwidth);
+  Qx = intern ("x");
+  staticpro (&Qx);
+  Qw32 = intern ("w32");
+  staticpro (&Qw32);
+  Qpc = intern ("pc");
+  staticpro (&Qpc);
+  Qmac = intern ("mac");
+  staticpro (&Qmac);
+  Qvisible = intern ("visible");
+  staticpro (&Qvisible);
+  Qbuffer_predicate = intern ("buffer-predicate");
+  staticpro (&Qbuffer_predicate);
+  Qbuffer_list = intern ("buffer-list");
+  staticpro (&Qbuffer_list);
+  Qtitle = intern ("title");
+  staticpro (&Qtitle);
+  Qdisplay_type = intern ("display-type");
+  staticpro (&Qdisplay_type);
+  Qbackground_mode = intern ("background-mode");
+  staticpro (&Qbackground_mode);
 
-  staticpro (&Vframe_list);
+  DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
+    "Alist of default values for frame creation.\n\
+These may be set in your init file, like this:\n\
+  (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1))\n\
+These override values given in window system configuration data,\n\
+ including X Windows' defaults database.\n\
+For values specific to the first Emacs frame, see `initial-frame-alist'.\n\
+For values specific to the separate minibuffer frame, see\n\
+ `minibuffer-frame-alist'.\n\
+The `menu-bar-lines' element of the list controls whether new frames\n\
+ have menu bars; `menu-bar-mode' works by altering this element.");
+  Vdefault_frame_alist = Qnil;
+
+  Qinhibit_default_face_x_resources
+    = intern ("inhibit-default-face-x-resources");
+  staticpro (&Qinhibit_default_face_x_resources);
 
   DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
     "The initial frame-object, which represents Emacs's stdout.");
@@ -2509,6 +2492,8 @@ this variable doesn't necessarily say anything meaningful about the\n\
 current set of frames, or where the minibuffer is currently being\n\
 displayed.");
 
+  staticpro (&Vframe_list);
+
   defsubr (&Sactive_minibuffer_window);
   defsubr (&Sframep);
   defsubr (&Sframe_live_p);