(FRAMEP): Macro deleted.
[bpt/emacs.git] / src / frame.c
index ca48c73..e75278b 100644 (file)
@@ -80,9 +80,9 @@ Lisp_Object Qicon;
 Lisp_Object Qminibuffer;
 Lisp_Object Qmodeline;
 Lisp_Object Qname;
-Lisp_Object Qnone;
 Lisp_Object Qonly;
 Lisp_Object Qunsplittable;
+Lisp_Object Qmenu_bar_lines;
 Lisp_Object Qwidth;
 Lisp_Object Qx;
 
@@ -158,11 +158,11 @@ make_frame (mini_p)
   f->has_minibuffer = mini_p;
   f->focus_frame = Qnil;
   f->explicit_name = 0;
-  f->can_have_scrollbars = 0;
-  f->has_vertical_scrollbars = 0;
+  f->can_have_scroll_bars = 0;
+  f->has_vertical_scroll_bars = 0;
   f->param_alist = Qnil;
-  f->scrollbars = Qnil;
-  f->condemned_scrollbars = Qnil;
+  f->scroll_bars = Qnil;
+  f->condemned_scroll_bars = Qnil;
 
   root_window = make_window ();
   if (mini_p)
@@ -391,6 +391,14 @@ Changing the selected frame can change focus redirections.  See\n\
 #endif
   choose_minibuf_frame ();
 
+  /* We want to make sure that the next event generates a frame-switch
+     event to the appropriate frame.  This seems kludgey to me, but
+     before you take it out, make sure that evaluating something like
+     (select-window (frame-root-window (new-frame))) doesn't end up
+     with your typing being interpreted in the new frame instead of
+     the one you're actually typing in.  */
+  internal_last_event_frame = Qnil;
+
   return frame;
 }
 
@@ -603,7 +611,7 @@ A frame may not be deleted if its minibuffer is used by other frames.")
     }
 
   if (! FRAME_LIVE_P (f))
-    return;
+    return Qnil;
 
   /* Are there any other frames besides this one?  */
   if (f == selected_frame && EQ (next_frame (frame, Qt), frame))
@@ -740,7 +748,7 @@ and nil for X and Y.")
 {
   FRAME_PTR f;
   Lisp_Object lispy_dummy;
-  enum scrollbar_part party_dummy;
+  enum scroll_bar_part party_dummy;
   Lisp_Object x, y;
   unsigned long long_dummy;
 
@@ -779,62 +787,6 @@ WARNING:  If you use this under X, you should do `unfocus-frame' afterwards.")
   return Qnil;
 }
 \f
-#if 0
-/* ??? Can this be replaced with a Lisp function?
-   It is used in minibuf.c.  Can we get rid of that?
-   Yes.  All uses in minibuf.c are gone, and parallels to these
-   functions have been defined in frame.el.  */
-
-DEFUN ("frame-configuration", Fframe_configuration, Sframe_configuration,
-       0, 0, 0,
-  "Return object describing current frame configuration.\n\
-The frame configuration is the current mouse position and selected frame.\n\
-This object can be given to `restore-frame-configuration'\n\
-to restore this frame configuration.")
-  ()
-{
-  Lisp_Object c, time;
-  
-  c = Fmake_vector (make_number(4), Qnil);
-  XVECTOR (c)->contents[0] = Fselected_frame();
-  if (mouse_position_hook)
-    (*mouse_position_hook) (&XVECTOR (c)->contents[1]
-                           &XVECTOR (c)->contents[2],
-                           &XVECTOR (c)->contents[3],
-                           &time);
-  return c;
-}
-
-DEFUN ("restore-frame-configuration", Frestore_frame_configuration,
-       Srestore_frame_configuration,
-       1, 1, 0,
-  "Restores frame configuration CONFIGURATION.")
-  (config)
-  Lisp_Object config;
-{
-  Lisp_Object x_pos, y_pos, frame;
-
-  CHECK_VECTOR (config, 0);
-  if (XVECTOR (config)->size != 3)
-    {
-      error ("Wrong size vector passed to restore-frame-configuration");
-    }
-  frame = XVECTOR (config)->contents[0];
-  CHECK_LIVE_FRAME (frame, 0);
-
-  Fselect_frame (frame, Qnil);
-
-#if 0
-  /* This seems to interfere with the frame selection mechanism. jla */
-  x_pos = XVECTOR (config)->contents[2];
-  y_pos = XVECTOR (config)->contents[3];
-  set_mouse_position (frame, XINT (x_pos), XINT (y_pos));
-#endif
-
-  return frame;
-}    
-#endif
-\f
 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
        0, 1, 0,
   "Make the frame FRAME visible (assuming it is an X-window).\n\
@@ -1110,10 +1062,11 @@ If FRAME is omitted, return information on the currently selected frame.")
   store_in_alist (&alist, Qwidth, make_number (f->width));
   store_in_alist (&alist, Qmodeline, (f->wants_modeline ? Qt : Qnil));
   store_in_alist (&alist, Qminibuffer,
-                 (! FRAME_HAS_MINIBUF_P (f) ? Qnone
+                 (! FRAME_HAS_MINIBUF_P (f) ? Qnil
                   : (FRAME_MINIBUF_ONLY_P (f) ? Qonly
                    : FRAME_MINIBUF_WINDOW (f))));
   store_in_alist (&alist, Qunsplittable, (f->no_split ? Qt : Qnil));
+  store_in_alist (&alist, Qmenu_bar_lines, (FRAME_MENU_BAR_LINES (f)));
 
   /* I think this should be done with a hook.  */
 #ifdef HAVE_X_WINDOWS
@@ -1163,47 +1116,113 @@ The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
   return Qnil;
 }
 \f
-
-#if 0
-/* This function isn't useful enough by itself to include; we need to
-   add functions to allow the user to find the size of a font before
-   this is actually useful.  */
-
-DEFUN ("frame-pixel-size", Fframe_pixel_size, 
-       Sframe_pixel_size, 1, 1, 0,
-  "Return a cons (width . height) of FRAME's size in pixels.")
+DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
+  0, 1, 0,
+  "Height in pixels of a line in the font in frame FRAME.\n\
+If FRAME is omitted, the selected frame is used.\n\
+For a terminal frame, the value is always 1.")
   (frame)
      Lisp_Object frame;
 {
-  register struct frame *f;
-  int width, height;
+  struct frame *f;
 
-  CHECK_LIVE_FRAME (frame, 0);
-  f = XFRAME (frame);
-  
-  return Fcons (make_number (x_pixel_width (f)),
-               make_number (x_pixel_height (f)));
-}
+  if (NILP (frame))
+    f = selected_frame;
+  else
+    {
+      CHECK_FRAME (frame, 0);
+      f = XFRAME (frame);
+    }
+
+#ifdef HAVE_X_WINDOWS
+  if (FRAME_X_P (f))
+    return make_number (x_char_height (f));
+  else
 #endif
+    return make_number (1);
+}
 
-#if 0
-/* These functions have no C callers, and can be written nicely in lisp.  */
 
-DEFUN ("frame-height", Fframe_height, Sframe_height, 0, 0, 0,
-  "Return number of lines available for display on selected frame.")
-  ()
+DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
+  0, 1, 0,
+  "Width in pixels of characters in the font in frame FRAME.\n\
+If FRAME is omitted, the selected frame is used.\n\
+The width is the same for all characters, because\n\
+currently Emacs supports only fixed-width fonts.\n\
+For a terminal screen, the value is always 1.")
+  (frame)
+     Lisp_Object frame;
 {
-  return make_number (FRAME_HEIGHT (selected_frame));
+  struct frame *f;
+
+  if (NILP (frame))
+    f = selected_frame;
+  else
+    {
+      CHECK_FRAME (frame, 0);
+      f = XFRAME (frame);
+    }
+
+#ifdef HAVE_X_WINDOWS
+  if (FRAME_X_P (f))
+    return make_number (x_char_width (f));
+  else
+#endif
+    return make_number (1);
 }
 
-DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 0, 0,
-  "Return number of columns available for display on selected frame.")
-  ()
+DEFUN ("frame-pixel-height", Fframe_pixel_height, 
+       Sframe_pixel_height, 0, 1, 0,
+  "Return a FRAME's heightin pixels.\n\
+For a terminal frame, the result really gives the sizes in characters.\n\
+If FRAME is omitted, the selected frame is used.")
+  (frame)
+     Lisp_Object frame;
 {
-  return make_number (FRAME_WIDTH (selected_frame));
-}
+  struct frame *f;
+
+  if (NILP (frame))
+    f = selected_frame;
+  else
+    {
+      CHECK_FRAME (frame, 0);
+      f = XFRAME (frame);
+    }
+
+#ifdef HAVE_X_WINDOWS
+  if (FRAME_X_P (f))
+    return make_number (x_pixel_height (f));
+  else
 #endif
+    return make_number (FRAME_HEIGHT (f));
+}
 
+DEFUN ("frame-pixel-width", Fframe_pixel_width, 
+       Sframe_pixel_width, 0, 1, 0,
+  "Return FRAME's width in pixels.\n\
+For a terminal frame, the result really gives the sizes in characters.\n\
+If FRAME is omitted, the selected frame is used.")
+  (frame)
+     Lisp_Object frame;
+{
+  struct frame *f;
+
+  if (NILP (frame))
+    f = selected_frame;
+  else
+    {
+      CHECK_FRAME (frame, 0);
+      f = XFRAME (frame);
+    }
+
+#ifdef HAVE_X_WINDOWS
+  if (FRAME_X_P (f))
+    return make_number (x_pixel_width (f));
+  else
+#endif
+    return make_number (FRAME_WIDTH (f));
+}
+\f
 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
   "Specify that the frame FRAME has LINES lines.\n\
 Optional third arg non-nil means that redisplay should use LINES lines\n\
@@ -1396,8 +1415,6 @@ syms_of_frame ()
   staticpro (&Qmodeline);
   Qname = intern ("name");
   staticpro (&Qname);
-  Qnone = intern ("none");
-  staticpro (&Qnone);
   Qonly = intern ("only");
   staticpro (&Qonly);
   Qunsplittable = intern ("unsplittable");
@@ -1406,6 +1423,8 @@ syms_of_frame ()
   staticpro (&Qwidth);
   Qx = intern ("x");
   staticpro (&Qx);
+  Qmenu_bar_lines = intern ("menu-bar-lines");
+  staticpro (&Qmenu_bar_lines);
 
   staticpro (&Vframe_list);
 
@@ -1468,11 +1487,10 @@ For values specific to the separate minibuffer frame, see\n\
   defsubr (&Sframe_focus);
   defsubr (&Sframe_parameters);
   defsubr (&Smodify_frame_parameters);
-#if 0
-  defsubr (&Sframe_pixel_size);
-  defsubr (&Sframe_height);
-  defsubr (&Sframe_width);
-#endif
+  defsubr (&Sframe_char_height);
+  defsubr (&Sframe_char_width);
+  defsubr (&Sframe_pixel_height);
+  defsubr (&Sframe_pixel_width);
   defsubr (&Sset_frame_height);
   defsubr (&Sset_frame_width);
   defsubr (&Sset_frame_size);
@@ -1486,7 +1504,7 @@ keys_of_frame ()
 {
   initial_define_lispy_key (global_map, "switch-frame", "select-frame");
 }
-
+\f
 #else /* not MULTI_FRAME */
 
 /* If we're not using multi-frame stuff, we still need to provide some
@@ -1557,6 +1575,53 @@ DEFUN ("frame-width", Fframe_width, Sframe_width, 0, 0, 0,
   return make_number (FRAME_WIDTH (selected_frame));
 }
 
+DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height,
+  0, 1, 0,
+  "Height in pixels of a line in the font in frame FRAME.\n\
+If FRAME is omitted, the selected frame is used.\n\
+For a terminal frame, the value is always 1.")
+  (frame)
+     Lisp_Object frame;
+{
+  return make_number (1);
+}
+
+
+DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width,
+  0, 1, 0,
+  "Width in pixels of characters in the font in frame FRAME.\n\
+If FRAME is omitted, the selected frame is used.\n\
+The width is the same for all characters, because\n\
+currently Emacs supports only fixed-width fonts.\n\
+For a terminal screen, the value is always 1.")
+  (frame)
+     Lisp_Object frame;
+{
+  return make_number (1);
+}
+
+DEFUN ("frame-pixel-height", Fframe_pixel_height, 
+       Sframe_pixel_height, 0, 1, 0,
+  "Return FRAME's height in pixels.\n\
+For a terminal frame, the result really gives the height in characters.\n\
+If FRAME is omitted, the selected frame is used.")
+  (frame)
+     Lisp_Object frame;
+{
+  return make_number (FRAME_HEIGHT (f));
+}
+
+DEFUN ("frame-pixel-width", Fframe_pixel_width, 
+       Sframe_pixel_width, 0, 1, 0,
+  "Return FRAME's width in pixels.\n\
+For a terminal frame, the result really gives the width in characters.\n\
+If FRAME is omitted, the selected frame is used.")
+  (frame)
+     Lisp_Object frame;
+{
+  return make_number (FRAME_WIDTH (f));
+}
+
 /* These are for backward compatibility with Emacs 18.  */
 
 DEFUN ("set-screen-height", Fset_screen_height, Sset_screen_height, 1, 2, 0,
@@ -1587,6 +1652,11 @@ but that the idea of the actual width of the screen should not be changed.")
 
 syms_of_frame ()
 {
+  defsubr (&Sselected_frame);
+  defsubr (&Sframe_char_height);
+  defsubr (&Sframe_char_width);
+  defsubr (&Sframe_pixel_height);
+  defsubr (&Sframe_pixel_width);
   defsubr (&Sset_frame_height);
   defsubr (&Sset_frame_width);
   defsubr (&Sset_frame_size);