* src/keymap.c (Fsingle_key_description): Use make_specified_string
[bpt/emacs.git] / src / frame.c
index 323bfc1..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;
@@ -205,14 +206,17 @@ extern Lisp_Object get_minibuffer ();
 extern Lisp_Object Fhandle_switch_frame ();
 extern Lisp_Object Fredirect_frame_focus ();
 extern Lisp_Object x_get_focus_frame ();
+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;
@@ -256,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;
 {
@@ -1327,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))
     {
@@ -1379,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);
@@ -1631,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;
 }
@@ -2591,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;
@@ -3359,7 +3372,7 @@ x_set_font (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  Lisp_Object frame, font_object;
+  Lisp_Object frame, font_object, font_param = Qnil;
   int fontset = -1;
 
   /* Set the frame parameter back to the old value because we may
@@ -3371,6 +3384,7 @@ x_set_font (f, arg, oldval)
      never fail.  */
   if (STRINGP (arg))
     {
+      font_param = arg;
       fontset = fs_query_fontset (arg, 0);
       if (fontset < 0)
        {
@@ -3401,10 +3415,12 @@ x_set_font (f, arg, oldval)
        error ("Unknown fontset: %s", SDATA (XCAR (arg)));
       font_object = XCDR (arg);
       arg = AREF (font_object, FONT_NAME_INDEX);
+      font_param = Ffont_get (font_object, QCname);
     }
   else if (FONT_OBJECT_P (arg))
     {
       font_object = arg;
+      font_param = Ffont_get (font_object, QCname);
       /* This is to store the XLFD font name in the frame parameter for
         backward compatibility.  We should store the font-object
         itself in the future.  */
@@ -3429,6 +3445,9 @@ x_set_font (f, arg, oldval)
 
   x_new_font (f, font_object, fontset);
   store_frame_param (f, Qfont, arg);
+#ifdef HAVE_X_WINDOWS
+  store_frame_param (f, Qfont_param, font_param);
+#endif
   /* Recalculate toolbar height.  */
   f->n_tool_bar_rows = 0;
   /* Ensure we redraw it.  */
@@ -3997,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)));
 
@@ -4183,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
@@ -4369,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)
         {
@@ -4385,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;
+
+  if (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)))
+    return;
 
-  struct frame *f = SELECTED_FRAME ();
+  f = SELECTED_FRAME ();
   if (f && f->pointer_invisible && f->mouse_moved
       && FRAME_TERMINAL (f)->toggle_invisible_pointer_hook)
     {
@@ -4428,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");
@@ -4634,7 +4670,7 @@ This variable is local to the current terminal and cannot be buffer-local.  */);
               doc: /* Non-nil if window system changes focus when you move the mouse.
 You should set this variable to tell Emacs how your window manager
 handles focus, since there is no way in general for Emacs to find out
-automatically.  */);
+automatically.  See also `mouse-autoselect-window'.  */);
 #ifdef HAVE_WINDOW_SYSTEM
 #if defined(HAVE_NTGUI) || defined(HAVE_NS)
   focus_follows_mouse = 0;