changeset 12761:bffb5ea6fb43

Move various Q... vars to top of file, unconditional. (Vterminal_frame): Just one definition, at top of file, unconditional. (syms_of_frame_1): New function. (syms_of_frame. both definitions): Call syms_of_frame_1. (set_menu_bar_lines, set_menu_bar_lines_1): New functions. (store_frame_parameter): Call set_menu_bar_lines. [!MULTI_FRAME] (Fmodify_frame_parameters): Call set_menu_bar_lines.
author Richard M. Stallman <rms@gnu.org>
date Thu, 03 Aug 1995 09:05:09 +0000
parents 4bb9477d762a
children b616982e679b
files src/frame.c
diffstat 1 files changed, 113 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/src/frame.c	Thu Aug 03 05:12:54 1995 +0000
+++ b/src/frame.c	Thu Aug 03 09:05:09 1995 +0000
@@ -28,19 +28,6 @@
 #include "msdos.h"
 #endif
 
-#ifdef MULTI_FRAME
-
-#include "buffer.h"
-
-/* These help us bind and responding to switch-frame events.  */
-#include "commands.h"
-#include "keyboard.h"
-
-Lisp_Object Vemacs_iconified;
-Lisp_Object Vframe_list;
-Lisp_Object Vterminal_frame;
-Lisp_Object Vdefault_frame_alist;
-
 /* 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
@@ -74,6 +61,8 @@
       (setq symbol-list (cdr symbol-list)))))
   */        
 
+/* We need most of these symbols even if not MULTI_FRAME;
+   easiest to define them all, all of the time.  */
 /*&&& symbols declared here &&&*/
 Lisp_Object Qframep;
 Lisp_Object Qframe_live_p;
@@ -90,6 +79,100 @@
 Lisp_Object Qvisible;
 Lisp_Object Qbuffer_predicate;
 
+Lisp_Object Vterminal_frame;
+
+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);
+  Qwidth = intern ("width");
+  staticpro (&Qwidth);
+  Qx = intern ("x");
+  staticpro (&Qx);
+  Qvisible = intern ("visible");
+  staticpro (&Qvisible);
+  Qbuffer_predicate = intern ("buffer-predicate");
+  staticpro (&Qbuffer_predicate);
+}
+
+static void
+set_menu_bar_lines_1 (window, n)
+  Lisp_Object window;
+  int n;
+{
+  struct window *w = XWINDOW (window);
+
+  XSETFASTINT (w->top, XFASTINT (w->top) + n);
+  XSETFASTINT (w->height, XFASTINT (w->height) - n);
+
+  /* Handle just the top child in a vertical split.  */
+  if (!NILP (w->vchild))
+    set_menu_bar_lines_1 (w->vchild, n);
+
+  /* Adjust all children in a horizontal split.  */
+  for (window = w->hchild; !NILP (window); window = w->next)
+    {
+      w = XWINDOW (window);
+      set_menu_bar_lines_1 (window, n);
+    }
+}
+
+static void
+set_menu_bar_lines (f, value, oldval)
+     struct frame *f;
+     Lisp_Object value, oldval;
+{
+  int nlines;
+  int olines = FRAME_MENU_BAR_LINES (f);
+
+  /* Right now, menu bars don't work properly in minibuf-only frames;
+     most of the commands try to apply themselves to the minibuffer
+     frame itslef, and get an error because you can't switch buffers
+     in or split the minibuffer window.  */
+  if (FRAME_MINIBUF_ONLY_P (f))
+    return;
+
+  if (INTEGERP (value))
+    nlines = XINT (value);
+  else
+    nlines = 0;
+
+  FRAME_MENU_BAR_LINES (f) = nlines;
+  set_menu_bar_lines_1 (f->root_window, nlines - olines);
+}
+
+#ifdef MULTI_FRAME
+
+#include "buffer.h"
+
+/* These help us bind and responding to switch-frame events.  */
+#include "commands.h"
+#include "keyboard.h"
+
+Lisp_Object Vemacs_iconified;
+Lisp_Object Vframe_list;
+Lisp_Object Vdefault_frame_alist;
+
 extern Lisp_Object Vminibuffer_list;
 extern Lisp_Object get_minibuffer ();
 extern Lisp_Object Fhandle_switch_frame ();
@@ -1546,6 +1629,9 @@
   if (EQ (prop, Qbuffer_predicate))
     f->buffer_predicate = val;
 
+  if (EQ (prop, Qmenu_bar_lines))
+    set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f)));
+
   if (EQ (prop, Qminibuffer) && WINDOWP (val))
     {
       if (! MINI_WINDOW_P (XWINDOW (val)))
@@ -1888,35 +1974,7 @@
 
 syms_of_frame ()
 {
-  /*&&& 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);
-  Qwidth = intern ("width");
-  staticpro (&Qwidth);
-  Qx = intern ("x");
-  staticpro (&Qx);
-  Qvisible = intern ("visible");
-  staticpro (&Qvisible);
-  Qbuffer_predicate = intern ("buffer-predicate");
-  staticpro (&Qbuffer_predicate);
+  syms_of_frame_1 ();
 
   staticpro (&Vframe_list);
 
@@ -2012,16 +2070,6 @@
 /* If we're not using multi-frame stuff, we still need to provide some
    support functions.  */
 
-Lisp_Object Qheight;
-Lisp_Object Qminibuffer;
-Lisp_Object Qmodeline;
-Lisp_Object Qname;
-Lisp_Object Qunsplittable;
-Lisp_Object Qmenu_bar_lines;
-Lisp_Object Qwidth;
-
-Lisp_Object Vterminal_frame;
-
 /* Unless this function is defined, providing set-frame-height and
    set-frame-width doesn't help compatibility any, since they both
    want this as their first argument.  */
@@ -2317,10 +2365,22 @@
   (frame, alist)
      Lisp_Object frame, alist;
 {
+  Lisp_Object tail, elt, prop, val;
+
 #ifdef MSDOS
   if (FRAME_X_P (frame))
     IT_set_frame_parameters (XFRAME (frame), alist);
+  else
 #endif
+    for (tail = alist; !EQ (tail, Qnil); tail = Fcdr (tail))
+      {
+	elt = Fcar (tail);
+	prop = Fcar (elt);
+	val = Fcdr (elt);
+	if (EQ (prop, Qmenu_bar_lines))
+	  set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f)));
+      }
+
   return Qnil;
 }
 
@@ -2345,20 +2405,7 @@
 
 syms_of_frame ()
 {
-  Qheight = intern ("height");
-  staticpro (&Qheight);
-  Qminibuffer = intern ("minibuffer");
-  staticpro (&Qminibuffer);
-  Qmodeline = intern ("modeline");
-  staticpro (&Qmodeline);
-  Qname = intern ("name");
-  staticpro (&Qname);
-  Qunsplittable = intern ("unsplittable");
-  staticpro (&Qunsplittable);
-  Qmenu_bar_lines = intern ("menu-bar-lines");
-  staticpro (&Qmenu_bar_lines);
-  Qwidth = intern ("width");
-  staticpro (&Qwidth);
+  syms_of_frame_1 ();
 
   DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
   /* Don't confuse make-docfile by having two doc strings for this variable.