* src/keymap.c (Fsingle_key_description): Use make_specified_string
[bpt/emacs.git] / src / frame.c
index 4a9d30d..a568342 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic frame functions.
    Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
-     2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -43,8 +43,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "termhooks.h"
 #include "dispextern.h"
 #include "window.h"
-#ifdef HAVE_WINDOW_SYSTEM
 #include "font.h"
+#ifdef HAVE_WINDOW_SYSTEM
 #include "fontset.h"
 #endif
 #ifdef MSDOS
@@ -100,6 +100,7 @@ Lisp_Object Qgeometry;  /* Not used */
 Lisp_Object Qheight, Qwidth;
 Lisp_Object Qleft, Qright;
 Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name;
+Lisp_Object Qtooltip;
 Lisp_Object Qinternal_border_width;
 Lisp_Object Qmouse_color;
 Lisp_Object Qminibuffer;
@@ -210,11 +211,12 @@ extern Lisp_Object QCname, Qfont_param;
 \f
 DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
        doc: /* Return non-nil if OBJECT is a frame.
-Value is t for a termcap frame (a character-only terminal),
-`x' for an Emacs frame that is really an X window,
-`w32' for an Emacs frame that is a window on MS-Windows display,
-`ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
-`pc' for a direct-write MS-DOS frame.
+Value is:
+  t for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
 See also `frame-live-p'.  */)
      (object)
      Lisp_Object object;
@@ -258,10 +260,18 @@ return values.  */)
 
 DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
        doc: /* The name of the window system that FRAME is displaying through.
-The value is a symbol---for instance, 'x' for X windows.
-The value is nil if Emacs is using a text-only terminal.
-
-FRAME defaults to the currently selected frame.  */)
+The value is a symbol:
+ nil for a termcap frame (a character-only terminal),
+ 'x' for an Emacs frame that is really an X window,
+ 'w32' for an Emacs frame that is a window on MS-Windows display,
+ 'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
+ 'pc' for a direct-write MS-DOS frame.
+
+FRAME defaults to the currently selected frame.
+
+Use of this function as a predicate is deprecated.  Instead,
+use `display-graphic-p' or any of the other `display-*-p'
+predicates which report frame's specific UI-related capabilities.  */)
   (frame)
      Lisp_Object frame;
 {
@@ -1329,7 +1339,7 @@ delete_frame (frame, force)
   struct frame *sf = SELECTED_FRAME ();
   struct kboard *kb;
 
-  int minibuffer_selected;
+  int minibuffer_selected, tooltip_frame;
 
   if (EQ (frame, Qnil))
     {
@@ -1381,13 +1391,15 @@ delete_frame (frame, force)
        }
     }
 
+  tooltip_frame = !NILP (Fframe_parameter (frame, intern ("tooltip")));
+
   /* Run `delete-frame-functions' unless FORCE is `noelisp' or
      frame is a tooltip.  FORCE is set to `noelisp' when handling
      a disconnect from the terminal, so we don't dare call Lisp
      code.  */
-  if (NILP (Vrun_hooks) || !NILP (Fframe_parameter (frame, intern ("tooltip"))))
+  if (NILP (Vrun_hooks) || tooltip_frame)
     ;
-  if (EQ (force, Qnoelisp))
+  else if (EQ (force, Qnoelisp))
     pending_funcalls
       = Fcons (list3 (Qrun_hook_with_args, Qdelete_frame_functions, frame),
               pending_funcalls);
@@ -1633,7 +1645,8 @@ delete_frame (frame, force)
     }
 
   /* Cause frame titles to update--necessary if we now have just one frame.  */
-  update_mode_lines = 1;
+  if (!tooltip_frame)
+    update_mode_lines = 1;
 
   return Qnil;
 }
@@ -2593,11 +2606,9 @@ use is not recommended.  Explicitly check for a frame-parameter instead.  */)
          val = values[i];
          store_frame_param (f, prop, val);
 
-         /* Changing the background color might change the background
-            mode, so that we have to load new defface specs.
-            Call frame-set-background-mode to do that.  */
-         if (EQ (prop, Qbackground_color))
-           call1 (Qframe_set_background_mode, frame);
+         if (EQ (prop, Qforeground_color)
+             || EQ (prop, Qbackground_color))
+           update_face_from_frame_parameter (f, prop, val);
        }
     }
   return Qnil;
@@ -4005,6 +4016,13 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type)
            case RES_TYPE_NUMBER:
              return make_number (atoi (SDATA (tem)));
 
+           case RES_TYPE_BOOLEAN_NUMBER:
+             if (!strcmp (SDATA (tem), "on")
+                 || !strcmp (SDATA (tem), "true"))
+               return make_number (1);
+             return make_number (atoi (SDATA (tem)));
+              break;
+
            case RES_TYPE_FLOAT:
              return make_float (atof (SDATA (tem)));
 
@@ -4191,7 +4209,7 @@ On Nextstep, this just calls `ns-parse-geometry'.  */)
 
    This function does not make the coordinates positive.  */
 
-#define DEFAULT_ROWS 40
+#define DEFAULT_ROWS 35
 #define DEFAULT_COLS 80
 
 int
@@ -4377,7 +4395,11 @@ frame_make_pointer_invisible ()
 {
   if (! NILP (Vmake_pointer_invisible))
     {
-      struct frame *f = SELECTED_FRAME ();
+      struct frame *f;
+      if (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
+        return;
+
+      f = SELECTED_FRAME ();
       if (f && !f->pointer_invisible
           && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
         {
@@ -4393,8 +4415,12 @@ frame_make_pointer_visible ()
 {
   /* We don't check Vmake_pointer_invisible here in case the
      pointer was invisible when Vmake_pointer_invisible was set to nil.  */
+  struct frame *f;
 
-  struct frame *f = SELECTED_FRAME ();
+  if (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
+    return;
+
+  f = SELECTED_FRAME ();
   if (f && f->pointer_invisible && f->mouse_moved
       && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
     {
@@ -4436,6 +4462,8 @@ syms_of_frame ()
   staticpro (&Qicon_left);
   Qicon_top = intern_c_string ("icon-top");
   staticpro (&Qicon_top);
+  Qtooltip = intern_c_string ("tooltip");
+  staticpro (&Qtooltip);
   Qleft = intern_c_string ("left");
   staticpro (&Qleft);
   Qright = intern_c_string ("right");