(run_msdos_command): Support redirection of stderr.
[bpt/emacs.git] / src / frame.c
index 304fe8a..173f84e 100644 (file)
@@ -76,10 +76,14 @@ Lisp_Object Qunsplittable;
 Lisp_Object Qmenu_bar_lines;
 Lisp_Object Qwidth;
 Lisp_Object Qx;
+Lisp_Object Qwin32;
 Lisp_Object Qvisible;
 Lisp_Object Qbuffer_predicate;
 
 Lisp_Object Vterminal_frame;
+Lisp_Object Vdefault_frame_alist;
+
+Lisp_Object Qmouse_leave_buffer_hook;
 
 static void
 syms_of_frame_1 ()
@@ -109,10 +113,28 @@ syms_of_frame_1 ()
   staticpro (&Qwidth);
   Qx = intern ("x");
   staticpro (&Qx);
+  Qwin32 = intern ("win32");
+  staticpro (&Qwin32);
   Qvisible = intern ("visible");
   staticpro (&Qvisible);
   Qbuffer_predicate = intern ("buffer-predicate");
   staticpro (&Qbuffer_predicate);
+
+  Qmouse_leave_buffer_hook = intern ("mouse-leave-buffer-hook");
+  staticpro (&Qmouse_leave_buffer_hook);
+
+  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
@@ -122,6 +144,7 @@ set_menu_bar_lines_1 (window, n)
 {
   struct window *w = XWINDOW (window);
 
+  XSETFASTINT (w->last_modified, 0);
   XSETFASTINT (w->top, XFASTINT (w->top) + n);
   XSETFASTINT (w->height, XFASTINT (w->height) - n);
 
@@ -157,8 +180,13 @@ set_menu_bar_lines (f, value, oldval)
   else
     nlines = 0;
 
-  FRAME_MENU_BAR_LINES (f) = nlines;
-  set_menu_bar_lines_1 (f->root_window, nlines - olines);
+  if (nlines != olines)
+    {
+      windows_or_buffers_changed++;
+      FRAME_WINDOW_SIZES_CHANGED (f) = 1;
+      FRAME_MENU_BAR_LINES (f) = nlines;
+      set_menu_bar_lines_1 (f->root_window, nlines - olines);
+    }
 }
 \f
 #ifdef MULTI_FRAME
@@ -171,7 +199,6 @@ set_menu_bar_lines (f, value, oldval)
 
 Lisp_Object Vemacs_iconified;
 Lisp_Object Vframe_list;
-Lisp_Object Vdefault_frame_alist;
 
 extern Lisp_Object Vminibuffer_list;
 extern Lisp_Object get_minibuffer ();
@@ -196,6 +223,8 @@ See also `frame-live-p'.")
       return Qt;
     case output_x_window:
       return Qx;
+    case output_win32:
+      return Qwin32;
       /* The `pc' case is in the Fframep below.  */
     default:
       abort ();
@@ -542,8 +571,8 @@ do_switch_frame (frame, no_enter, track)
     }
 #else /* ! 0 */
   /* Instead, apply it only to the frame we're pointing to.  */
-#ifdef HAVE_X_WINDOWS
-  if (track && FRAME_X_P (XFRAME (frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (track && (FRAME_WINDOW_P (XFRAME (frame))))
     {
       Lisp_Object focus, xfocus;
 
@@ -602,6 +631,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 (frame, no_enter, 0);
 }
 
@@ -962,8 +992,8 @@ other_visible_frames (f)
          /* Verify that the frame's window still exists
             and we can still talk to it.  And note any recent change
             in visibility.  */
-#ifdef HAVE_X_WINDOWS
-         if (FRAME_X_P (XFRAME (this)))
+#ifdef HAVE_WINDOW_SYSTEM
+         if (FRAME_WINDOW_P (XFRAME (this)))
            {
              x_sync (XFRAME (this));
              FRAME_SAMPLE_VISIBILITY (XFRAME (this));
@@ -974,7 +1004,7 @@ other_visible_frames (f)
              || FRAME_ICONIFIED_P (XFRAME (this))
              /* Allow deleting the terminal frame when at least
                 one X frame exists!  */
-             || (FRAME_X_P (XFRAME (this)) && !FRAME_X_P (f)))
+             || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f)))
            count++;
        }
       return count > 1;
@@ -1106,8 +1136,8 @@ but if the second optional argument FORCE is non-nil, you may do so.")
      called the window-system-dependent frame destruction routine.  */
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     x_destroy_window (f);
 #endif
 
@@ -1283,8 +1313,8 @@ before calling this function on it, like this.\n\
   CHECK_NUMBER (y, 1);
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (XFRAME (frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (XFRAME (frame)))
     /* Warping the mouse will cause  enternotify and focus events. */
     x_set_mouse_position (XFRAME (frame), x, y);
 #endif
@@ -1307,8 +1337,8 @@ before calling this function on it, like this.\n\
   CHECK_NUMBER (y, 1);
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (XFRAME (frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (XFRAME (frame)))
     /* Warping the mouse will cause  enternotify and focus events. */
     x_set_mouse_pixel_position (XFRAME (frame), x, y);
 #endif
@@ -1329,8 +1359,8 @@ If omitted, FRAME defaults to the currently selected frame.")
   CHECK_LIVE_FRAME (frame, 0);
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (XFRAME (frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (XFRAME (frame)))
     {
       FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
       x_make_frame_visible (XFRAME (frame));
@@ -1375,8 +1405,8 @@ but if the second optional argument FORCE is non-nil, you may do so.")
     }
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (XFRAME (frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (XFRAME (frame)))
     x_make_frame_invisible (XFRAME (frame));
 #endif
 
@@ -1413,8 +1443,8 @@ If omitted, FRAME defaults to the currently selected frame.")
     }
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (XFRAME (frame)))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (XFRAME (frame)))
       x_iconify_frame (XFRAME (frame));
 #endif
 
@@ -1550,9 +1580,9 @@ The redirection lasts until `redirect-frame-focus' is called to change it.")
   XFRAME (frame)->focus_frame = focus_frame;
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_WINDOW_SYSTEM
   if (!NILP (focus_frame) && ! EQ (focus_frame, frame)
-      && FRAME_X_P (XFRAME (focus_frame)))
+      && (FRAME_WINDOW_P (XFRAME (focus_frame))))
     Ffocus_frame (focus_frame);
 #endif
 
@@ -1633,7 +1663,7 @@ store_frame_param (f, prop, val)
   if (EQ (prop, Qbuffer_predicate))
     f->buffer_predicate = val;
 
-  if (! FRAME_X_P (f))
+  if (! FRAME_WINDOW_P (f))
     if (EQ (prop, Qmenu_bar_lines))
       set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f)));
 
@@ -1684,8 +1714,8 @@ If FRAME is omitted, return information on the currently selected frame.")
   store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil));
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     x_report_frame_params (f, &alist);
   else
 #endif
@@ -1719,8 +1749,8 @@ The meaningful PARMs depend on the kind of frame; undefined PARMs are ignored.")
     }
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     x_set_frame_parameters (f, alist);
   else
 #endif
@@ -1753,8 +1783,8 @@ For a terminal frame, the value is always 1.")
       f = XFRAME (frame);
     }
 
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     return make_number (x_char_height (f));
   else
 #endif
@@ -1782,8 +1812,8 @@ For a terminal screen, the value is always 1.")
       f = XFRAME (frame);
     }
 
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     return make_number (x_char_width (f));
   else
 #endif
@@ -1808,8 +1838,8 @@ If FRAME is omitted, the selected frame is used.")
       f = XFRAME (frame);
     }
 
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     return make_number (x_pixel_height (f));
   else
 #endif
@@ -1834,8 +1864,8 @@ If FRAME is omitted, the selected frame is used.")
       f = XFRAME (frame);
     }
 
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     return make_number (x_pixel_width (f));
   else
 #endif
@@ -1861,8 +1891,8 @@ but that the idea of the actual height of the frame should not be changed.")
     }
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     {
       if (XINT (rows) != f->height)
        x_set_window_size (f, 1, f->width, XINT (rows));
@@ -1891,8 +1921,8 @@ but that the idea of the actual width of the frame should not be changed.")
     }
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     {
       if (XINT (cols) != f->width)
        x_set_window_size (f, 1, XINT (cols), f->height);
@@ -1917,8 +1947,8 @@ DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0,
   f = XFRAME (frame);
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     {
       if (XINT (rows) != f->height || XINT (cols) != f->width)
        x_set_window_size (f, 1, XINT (cols), XINT (rows));
@@ -1948,8 +1978,8 @@ the rightmost or bottommost possible position (that stays within the screen).")
   f = XFRAME (frame);
 
   /* I think this should be done with a hook.  */
-#ifdef HAVE_X_WINDOWS
-  if (FRAME_X_P (f))
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f))
     x_set_offset (f, XINT (xoffset), XINT (yoffset), 1);
 #endif
 
@@ -1957,26 +1987,6 @@ the rightmost or bottommost possible position (that stays within the screen).")
 }
 
 \f
-/* Put minibuf on currently selected frame's minibuffer.
-   We do this whenever the user starts a new minibuffer
-   or when a minibuffer exits.  */
-
-choose_minibuf_frame ()
-{
-  if (selected_frame != 0
-      && !EQ (minibuf_window, selected_frame->minibuffer_window))
-    {
-      /* I don't think that any frames may validly have a null minibuffer
-        window anymore.  */
-      if (NILP (selected_frame->minibuffer_window))
-       abort ();
-
-      Fset_window_buffer (selected_frame->minibuffer_window,
-                         XWINDOW (minibuf_window)->buffer);
-      minibuf_window = selected_frame->minibuffer_window;
-    }
-}
-\f
 syms_of_frame ()
 {
   syms_of_frame_1 ();
@@ -2003,19 +2013,6 @@ this variable doesn't necessarily say anything meaningful about the\n\
 current set of frames, or where the minibuffer is currently being\n\
 displayed.");
 
-  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;
-
   defsubr (&Sactive_minibuffer_window);
   defsubr (&Sframep);
   defsubr (&Sframe_live_p);
@@ -2381,6 +2378,15 @@ DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
      Lisp_Object frame, alist;
 {
   Lisp_Object tail, elt, prop, val;
+  FRAME_PTR f;
+
+  if (NILP (frame))
+    f = selected_frame;
+  else
+    {
+      CHECK_LIVE_FRAME (frame, 0);
+      f = XFRAME (frame);
+    }
 
 #ifdef MSDOS
   if (FRAME_X_P (frame))
@@ -2427,7 +2433,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list, 0, 0, 0,
 {
   return Fcons (Fselected_frame (), Qnil);
 }
-
+\f
 syms_of_frame ()
 {
   syms_of_frame_1 ();