* frame.c (x_set_font): Remove unused variable.
[bpt/emacs.git] / src / frame.c
index cebec92..6cf46f1 100644 (file)
@@ -1,6 +1,8 @@
 /* Generic frame functions.
-   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
-     2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
+  2004, 2005, 2006, 2007, 2008, 2009, 2010
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -119,7 +121,7 @@ Lisp_Object Qparent_id;
 Lisp_Object Qtitle, Qname;
 Lisp_Object Qexplicit_name;
 Lisp_Object Qunsplittable;
-Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
+Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
 Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
 Lisp_Object Qleft_fringe, Qright_fringe;
 Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
@@ -198,21 +200,15 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 \f
 Lisp_Object Vframe_list;
 
-extern Lisp_Object Vminibuffer_list;
-extern Lisp_Object get_minibuffer (int);
-extern Lisp_Object Fhandle_switch_frame (Lisp_Object event);
-extern Lisp_Object Fredirect_frame_focus (Lisp_Object frame, Lisp_Object focus_frame);
-extern Lisp_Object x_get_focus_frame (struct frame *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'.  */)
   (Lisp_Object object)
 {
@@ -254,10 +250,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.  */)
   (Lisp_Object frame)
 {
   Lisp_Object type;
@@ -323,6 +327,7 @@ make_frame (int mini_p)
   f->menu_bar_window = Qnil;
   f->tool_bar_window = Qnil;
   f->tool_bar_items = Qnil;
+  f->tool_bar_position = Qtop;
   f->desired_tool_bar_string = f->current_tool_bar_string = Qnil;
   f->n_tool_bar_items = 0;
   f->left_fringe_width = f->right_fringe_width = 0;
@@ -553,7 +558,9 @@ make_initial_frame (void)
 
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
-  FRAME_MENU_BAR_LINES(f) = NILP (Vmenu_bar_mode) ? 0 : 1;
+
+  /* The default value of menu-bar-mode is t.  */
+  set_menu_bar_lines (f, make_number (1), Qnil);
 
 #ifdef CANNOT_DUMP
   if (!noninteractive)
@@ -1278,16 +1285,6 @@ other_visible_frames (FRAME_PTR f)
   return 1;
 }
 
-/* Error handler for `delete-frame-functions'. */
-static Lisp_Object
-delete_frame_handler (Lisp_Object arg)
-{
-  add_to_log ("Error during `delete-frame': %s", arg, Qnil);
-  return Qnil;
-}
-
-extern Lisp_Object Qrun_hook_with_args;
-
 /* Delete FRAME.  When FORCE equals Qnoelisp, delete FRAME
   unconditionally.  x_connection_closed and delete_terminal use
   this.  Any other value of FORCE implements the semantics
@@ -1297,7 +1294,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
      /* If we use `register' here, gcc-4.0.2 on amd64 using
        -DUSE_LISP_UNION_TYPE complains further down that we're getting the
        address of `force'.  Go figure.  */
-                              
+
 {
   struct frame *f;
   struct frame *sf = SELECTED_FRAME ();
@@ -2663,6 +2660,28 @@ If FRAME is omitted, the selected frame is used.  */)
 #endif
     return make_number (FRAME_COLS (f));
 }
+
+DEFUN ("tool-bar-pixel-width", Ftool_bar_pixel_width,
+       Stool_bar_pixel_width, 0, 1, 0,
+       doc: /* Return width in pixels of FRAME's tool bar.
+The result is greater than zero only when the tool bar is on the left
+or right side of FRAME.  If FRAME is omitted, the selected frame is
+used.  */)
+  (Lisp_Object frame)
+{
+  struct frame *f;
+
+  if (NILP (frame))
+    frame = selected_frame;
+  CHECK_FRAME (frame);
+  f = XFRAME (frame);
+
+#ifdef FRAME_TOOLBAR_WIDTH
+  if (FRAME_WINDOW_P (f))
+    return make_number (FRAME_TOOLBAR_WIDTH (f));
+#endif
+  return make_number (0);
+}
 \f
 DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0,
        doc: /* Specify that the frame FRAME has LINES lines.
@@ -2784,11 +2803,11 @@ the rightmost or bottommost possible position (that stays within the screen).  *
    that is an index in this table.  */
 
 struct frame_parm_table {
-  char *name;
+  const char *name;
   Lisp_Object *variable;
 };
 
-static struct frame_parm_table frame_parms[] =
+static const struct frame_parm_table frame_parms[] =
 {
   {"auto-raise",               &Qauto_raise},
   {"auto-lower",               &Qauto_lower},
@@ -2822,13 +2841,11 @@ static struct frame_parm_table frame_parms[] =
   {"font-backend",             &Qfont_backend},
   {"alpha",                    &Qalpha},
   {"sticky",                   &Qsticky},
+  {"tool-bar-position",                &Qtool_bar_position},
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-extern Lisp_Object Qbox;
-extern Lisp_Object Qtop;
-
 /* Calculate fullscreen size.  Return in *TOP_POS and *LEFT_POS the
    wanted positions of the WM window (not Emacs window).
    Return in *WIDTH and *HEIGHT the wanted width and height of Emacs
@@ -3215,6 +3232,7 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
     XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc);
   store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
   store_in_alist (alistptr, Qparent_id, tem);
+  store_in_alist (alistptr, Qtool_bar_position, f->tool_bar_position);
 }
 
 
@@ -3293,7 +3311,7 @@ x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
 void
 x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-  Lisp_Object frame, font_object, font_param = Qnil;
+  Lisp_Object font_object, font_param = Qnil;
   int fontset = -1;
 
   /* Set the frame parameter back to the old value because we may
@@ -3447,6 +3465,11 @@ void
 x_set_fringe_width (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
 {
   compute_fringe_widths (f, 1);
+#ifdef HAVE_X_WINDOWS
+  /* Must adjust this so window managers report correct number of columns.  */
+  if (FRAME_X_WINDOW (f) != 0)
+    x_wm_set_size_hint (f, 0, 0);
+#endif
 }
 
 void
@@ -3676,7 +3699,6 @@ validate_x_resource_name (void)
   if (STRINGP (Vx_resource_name))
     {
       unsigned char *p = SDATA (Vx_resource_name);
-      int i;
 
       len = SBYTES (Vx_resource_name);
 
@@ -3727,7 +3749,7 @@ validate_x_resource_name (void)
 }
 
 
-extern char *x_get_string_resource (XrmDatabase, char *, char *);
+extern char *x_get_string_resource (XrmDatabase, const char *, const char *);
 extern Display_Info *check_x_display_info (Lisp_Object);
 
 
@@ -3829,7 +3851,7 @@ display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute, Lisp_Objec
 /* Used when C code wants a resource value.  */
 /* Called from oldXMenu/Create.c.  */
 char *
-x_get_resource_string (char *attribute, char *class)
+x_get_resource_string (const char *attribute, const char *class)
 {
   char *name_key;
   char *class_key;
@@ -3862,7 +3884,8 @@ x_get_resource_string (char *attribute, char *class)
    and don't let it get stored in any Lisp-visible variables!  */
 
 Lisp_Object
-x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, char *attribute, char *class, enum resource_types type)
+x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
+          const char *attribute, const char *class, enum resource_types type)
 {
   register Lisp_Object tem;
 
@@ -3960,7 +3983,9 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, char *at
 }
 
 Lisp_Object
-x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, char *attribute, char *class, enum resource_types type)
+x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
+                const char *attribute, const char *class,
+                enum resource_types type)
 {
   return x_get_arg (FRAME_X_DISPLAY_INFO (f),
                    alist, param, attribute, class, type);
@@ -3969,7 +3994,10 @@ x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, char *at
 /* Like x_frame_get_arg, but also record the value in f->param_alist.  */
 
 Lisp_Object
-x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, Lisp_Object param, char *attribute, char *class, enum resource_types type)
+x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
+                           Lisp_Object param,
+                           const char *attribute, const char *class,
+                           enum resource_types type)
 {
   Lisp_Object value;
 
@@ -3989,7 +4017,9 @@ x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist, Lisp_Object para
    If that is not found either, use the value DEFLT.  */
 
 Lisp_Object
-x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop, Lisp_Object deflt, char *xprop, char *xclass, enum resource_types type)
+x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop,
+                    Lisp_Object deflt, const char *xprop, const char *xclass,
+                    enum resource_types type)
 {
   Lisp_Object tem;
 
@@ -4295,6 +4325,20 @@ frame_make_pointer_visible (void)
     }
 }
 
+DEFUN ("frame-pointer-visible-p", Fframe_pointer_visible_p,
+       Sframe_pointer_visible_p, 0, 1, 0,
+       doc: /* Return t if the mouse pointer displayed on FRAME is visible.
+Otherwise it returns nil.  FRAME omitted or nil means the
+selected frame.  This is useful when `make-pointer-invisible' is set.  */)
+  (Lisp_Object frame)
+{
+  if (NILP (frame))
+    frame = selected_frame;
+
+  CHECK_FRAME (frame);
+
+  return (XFRAME (frame)->pointer_invisible ? Qnil : Qt);
+}
 
 \f
 /***********************************************************************
@@ -4519,12 +4563,24 @@ recursively).  */);
   staticpro (&Qdelete_frame_functions);
 
   DEFVAR_LISP ("menu-bar-mode", &Vmenu_bar_mode,
-               doc: /* Non-nil if Menu-Bar mode is enabled.  */);
+               doc: /* Non-nil if Menu-Bar mode is enabled.
+See the command `menu-bar-mode' for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `menu-bar-mode'.  */);
   Vmenu_bar_mode = Qt;
 
   DEFVAR_LISP ("tool-bar-mode", &Vtool_bar_mode,
-               doc: /* Non-nil if Tool-Bar mode is enabled.  */);
+               doc: /* Non-nil if Tool-Bar mode is enabled.
+See the command `tool-bar-mode' for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `tool-bar-mode'.  */);
+#ifdef HAVE_WINDOW_SYSTEM
   Vtool_bar_mode = Qt;
+#else
+  Vtool_bar_mode = Qnil;
+#endif
 
   DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame,
                 doc: /* Minibufferless frames use this frame's minibuffer.
@@ -4599,10 +4655,12 @@ automatically.  See also `mouse-autoselect-window'.  */);
   defsubr (&Sframe_char_width);
   defsubr (&Sframe_pixel_height);
   defsubr (&Sframe_pixel_width);
+  defsubr (&Stool_bar_pixel_width);
   defsubr (&Sset_frame_height);
   defsubr (&Sset_frame_width);
   defsubr (&Sset_frame_size);
   defsubr (&Sset_frame_position);
+  defsubr (&Sframe_pointer_visible_p);
 
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sx_get_resource);
@@ -4611,5 +4669,3 @@ automatically.  See also `mouse-autoselect-window'.  */);
 
 }
 
-/* arch-tag: 7dbf2c69-9aad-45f8-8296-db893d6dd039
-   (do not change this comment) */