]> code.delx.au - gnu-emacs/blobdiff - src/frame.c
(Fwhile): If mocklisp, test for nonzeroness.
[gnu-emacs] / src / frame.c
index 8eea8d43ca25b3e7ab8ca6a3ab7460bc6db1db67..e706283a0b243d4bd7b05893b26f64fb4c6f4ef7 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic frame functions.
-   Copyright (C) 1989, 1992, 1993 Free Software Foundation.
+   Copyright (C) 1993 Free Software Foundation.
 
 This file is part of GNU Emacs.
 
@@ -163,6 +163,7 @@ make_frame (mini_p)
   f->param_alist = Qnil;
   f->scroll_bars = Qnil;
   f->condemned_scroll_bars = Qnil;
+  f->face_alist = Qnil;
 
   root_window = make_window ();
   if (mini_p)
@@ -325,7 +326,7 @@ make_terminal_frame ()
 \f
 DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
   "Select the frame FRAME.\n\
-Subseqent editing commands apply to its selected window.\n\
+Subsequent editing commands apply to its selected window.\n\
 The selection of FRAME lasts until the next time the user does\n\
 something to select a different frame, or until the next time this\n\
 function is called.")
@@ -390,19 +391,10 @@ to that frame.")
     last_nonminibuf_frame = selected_frame;
 
   Fselect_window (XFRAME (frame)->selected_window);
-
-  /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (XFRAME (frame))
-      && NILP (no_enter))
-    {
-      Ffocus_frame (frame);
-    }
-#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
+     event to the appropriate frame.  This seems kludgy 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
@@ -751,6 +743,8 @@ A frame may not be deleted if its minibuffer is used by other frames.")
 
 DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0,
   "Return a list (FRAME X . Y) giving the current mouse frame and position.\n\
+The position is given in character cells, where (0, 0) is the\n\
+upper-left corner.\n\
 If Emacs is running on a mouseless terminal or hasn't been programmed\n\
 to read the mouse position, it returns the selected frame for FRAME\n\
 and nil for X and Y.")
@@ -762,23 +756,22 @@ and nil for X and Y.")
   Lisp_Object x, y;
   unsigned long long_dummy;
 
+  f = selected_frame;
+  x = y = Qnil;
+
+  /* It's okay for the hook to refrain from storing anything.  */
   if (mouse_position_hook)
     (*mouse_position_hook) (&f,
                            &lispy_dummy, &party_dummy,
                            &x, &y,
                            &long_dummy);
-  else
-    {
-      f = selected_frame;
-      x = y = Qnil;
-    }
 
   XSET (lispy_dummy, Lisp_Frame, f);
-  return Fcons (lispy_dummy, Fcons (make_number (x), make_number (y)));
+  return Fcons (lispy_dummy, Fcons (x, y));
 }
 
 DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0,
-  "Move the mouse pointer to the center of cell (X,Y) in FRAME.\n\
+  "Move the mouse pointer to the center of character cell (X,Y) in FRAME.\n\
 WARNING:  If you use this under X, you should do `unfocus-frame' afterwards.")
   (frame, x, y)
      Lisp_Object frame, x, y;
@@ -798,7 +791,7 @@ WARNING:  If you use this under X, you should do `unfocus-frame' afterwards.")
 }
 \f
 DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
-       0, 1, 0,
+       0, 1, "",
   "Make the frame FRAME visible (assuming it is an X-window).\n\
 Also raises the frame so that nothing obscures it.\n\
 If omitted, FRAME defaults to the currently selected frame.")
@@ -831,6 +824,18 @@ If omitted, FRAME defaults to the currently selected frame.")
 
   CHECK_LIVE_FRAME (frame, 0);
 
+  /* Don't let the frame remain selected.  */
+  if (XFRAME (frame) == selected_frame)
+    Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
+
+  /* Don't allow minibuf_window to remain on a deleted frame.  */
+  if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
+    {
+      Fset_window_buffer (selected_frame->minibuffer_window,
+                         XWINDOW (minibuf_window)->buffer);
+      minibuf_window = selected_frame->minibuffer_window;
+    }
+
   /* I think this should be done with a hook.  */
 #ifdef HAVE_X_WINDOWS
   if (FRAME_X_P (XFRAME (frame)))
@@ -852,6 +857,18 @@ If omitted, FRAME defaults to the currently selected frame.")
   
   CHECK_LIVE_FRAME (frame, 0);
 
+  /* Don't let the frame remain selected.  */
+  if (XFRAME (frame) == selected_frame)
+    Fhandle_switch_frame (next_frame (frame, Qt), Qnil);
+
+  /* Don't allow minibuf_window to remain on a deleted frame.  */
+  if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window))
+    {
+      Fset_window_buffer (selected_frame->minibuffer_window,
+                         XWINDOW (minibuf_window)->buffer);
+      minibuf_window = selected_frame->minibuffer_window;
+    }
+
   /* I think this should be done with a hook.  */
 #ifdef HAVE_X_WINDOWS
   if (FRAME_X_P (XFRAME (frame)))
@@ -963,13 +980,23 @@ The redirection lasts until `redirect-frame-focus' is called to change it.")
   (frame, focus_frame)
     Lisp_Object frame, focus_frame;
 {
-  CHECK_LIVE_FRAME (frame, 0);
+  /* Note that we don't check for a live frame here.  It's reasonable
+     to redirect the focus of a frame you're about to delete, if you
+     know what other frame should receive those keystrokes.  */
+  CHECK_FRAME (frame, 0);
 
   if (! NILP (focus_frame))
     CHECK_LIVE_FRAME (focus_frame, 1);
 
   XFRAME (frame)->focus_frame = focus_frame;
 
+  /* I think this should be done with a hook.  */
+#ifdef HAVE_X_WINDOWS
+  if (!NILP (focus_frame) && ! EQ (focus_frame, frame)
+      && FRAME_X_P (XFRAME (focus_frame)))
+    Ffocus_frame (focus_frame);
+#endif
+
   if (frame_rehighlight_hook)
     (*frame_rehighlight_hook) ();
   
@@ -1038,7 +1065,7 @@ store_frame_param (f, prop, val)
        error ("Surrogate minibuffer windows must be minibuffer windows.");
 
       if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f))
-       error ("Can't change the surrogate minibuffer of a frame with its own minibuffer.");
+       error ("can't change the surrogate minibuffer of a frame with its own minibuffer");
 
       /* Install the chosen minibuffer window, with proper buffer.  */
       f->minibuffer_window = val;
@@ -1184,8 +1211,8 @@ For a terminal screen, the value is always 1.")
 
 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\
+  "Return a 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;
@@ -1211,7 +1238,7 @@ If FRAME is omitted, the selected frame is used.")
 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\
+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;
@@ -1348,46 +1375,6 @@ off the screen.")
   return Qt;
 }
 
-\f
-#ifndef HAVE_X11
-DEFUN ("rubber-band-rectangle", Frubber_band_rectangle, Srubber_band_rectangle,
-       3, 3, "",
-  "Ask user to specify a window position and size on FRAME with the mouse.\n\
-Arguments are FRAME, NAME and GEO.  NAME is a name to be displayed as\n\
-the purpose of this rectangle.  GEO is an X-windows size spec that can\n\
-specify defaults for some sizes/positions.  If GEO specifies everything,\n\
-the mouse is not used.\n\
-Returns a list of five values: (FRAME LEFT TOP WIDTH HEIGHT).")
-  (frame, name, geo)
-     Lisp_Object frame;
-     Lisp_Object name;
-     Lisp_Object geo;
-{
-  int vals[4];
-  Lisp_Object nums[4];
-  int i;
-
-  CHECK_FRAME (frame, 0);
-  CHECK_STRING (name, 1);
-  CHECK_STRING (geo, 2);
-
-  switch (XFRAME (frame)->output_method)
-    {
-    case output_x_window:
-      x_rubber_band (XFRAME (frame), &vals[0], &vals[1], &vals[2], &vals[3],
-                    XSTRING (geo)->data, XSTRING (name)->data);
-      break;
-
-    default:
-      return Qnil;
-    }
-
-  for (i = 0; i < 4; i++)
-    XFASTINT (nums[i]) = vals[i];
-  return Fcons (frame, Flist (4, nums));
-  return Qnil;
-}
-#endif /* not HAVE_X11 */
 \f
 choose_minibuf_frame ()
 {
@@ -1507,9 +1494,6 @@ For values specific to the separate minibuffer frame, see\n\
   defsubr (&Sset_frame_width);
   defsubr (&Sset_frame_size);
   defsubr (&Sset_frame_position);
-#ifndef HAVE_X11
-  defsubr (&Srubber_band_rectangle);
-#endif /* HAVE_X11 */
 }
 
 keys_of_frame ()
@@ -1533,6 +1517,16 @@ DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
   XFASTINT (tem) = 0;
   return tem;
 }
+DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
+  "Return non-nil if OBJECT is a frame.\n\
+Value is t for a termcap frame (a character-only terminal),\n\
+`x' for an Emacs frame that is really an X window.\n\
+Also see `live-frame-p'.")
+  (object)
+     Lisp_Object object;
+{
+  return Qnil;
+}
 
 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
   "Specify that the frame FRAME has LINES lines.\n\
@@ -1669,6 +1663,7 @@ but that the idea of the actual width of the screen should not be changed.")
 syms_of_frame ()
 {
   defsubr (&Sselected_frame);
+  defsubr (&Sframep);
   defsubr (&Sframe_char_height);
   defsubr (&Sframe_char_width);
   defsubr (&Sframe_pixel_height);