* simple.el (list-processes): Doc fix.
[bpt/emacs.git] / src / frame.h
index 3d2b820..22c0125 100644 (file)
@@ -1,5 +1,5 @@
 /* Define frame-object for GNU Emacs.
-   Copyright (C) 1993-1994, 1999-2011 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 1999-2012 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -80,6 +80,10 @@ struct terminal;
 
 struct font_driver_list;
 
+/* Most code should use this macro to access Lisp fields in struct frame.  */
+
+#define FVAR(frame, field) ((frame)->INTERNAL_FIELD (field))
+
 struct frame
 {
   struct vectorlike_header header;
@@ -89,15 +93,15 @@ struct frame
 
   /* Name of this frame: a Lisp string.  It is used for looking up resources,
      as well as for the title in some cases.  */
-  Lisp_Object name;
+  Lisp_Object INTERNAL_FIELD (name);
 
   /* The name to use for the icon, the last time
      it was refreshed.  nil means not explicitly specified.  */
-  Lisp_Object icon_name;
+  Lisp_Object INTERNAL_FIELD (icon_name);
 
   /* This is the frame title specified explicitly, if any.
      Usually it is nil.  */
-  Lisp_Object title;
+  Lisp_Object INTERNAL_FIELD (title);
 
   /* The frame which should receive keystrokes that occur in this
      frame, or nil if they should go to the frame itself.  This is
@@ -110,29 +114,29 @@ struct frame
      to shift from one frame to the other, any redirections to the
      original frame are shifted to the newly selected frame; if
      focus_frame is nil, Fselect_frame will leave it alone.  */
-  Lisp_Object focus_frame;
+  Lisp_Object INTERNAL_FIELD (focus_frame);
 
   /* This frame's root window.  Every frame has one.
      If the frame has only a minibuffer window, this is it.
      Otherwise, if the frame has a minibuffer window, this is its sibling.  */
-  Lisp_Object root_window;
+  Lisp_Object INTERNAL_FIELD (root_window);
 
   /* This frame's selected window.
      Each frame has its own window hierarchy
      and one of the windows in it is selected within the frame.
      The selected window of the selected frame is Emacs's selected window.  */
-  Lisp_Object selected_window;
+  Lisp_Object INTERNAL_FIELD (selected_window);
 
   /* This frame's minibuffer window.
      Most frames have their own minibuffer windows,
      but only the selected frame's minibuffer window
      can actually appear to exist.  */
-  Lisp_Object minibuffer_window;
+  Lisp_Object INTERNAL_FIELD (minibuffer_window);
 
   /* Parameter alist of this frame.
      These are the parameters specified when creating the frame
      or modified with modify-frame-parameters.  */
-  Lisp_Object param_alist;
+  Lisp_Object INTERNAL_FIELD (param_alist);
 
   /* List of scroll bars on this frame.
      Actually, we don't specify exactly what is stored here at all; the
@@ -141,50 +145,51 @@ struct frame
      instead of in the `device' structure so that the garbage
      collector doesn't need to look inside the window-system-dependent
      structure.  */
-  Lisp_Object scroll_bars;
-  Lisp_Object condemned_scroll_bars;
+  Lisp_Object INTERNAL_FIELD (scroll_bars);
+  Lisp_Object INTERNAL_FIELD (condemned_scroll_bars);
 
   /* Vector describing the items to display in the menu bar.
      Each item has four elements in this vector.
      They are KEY, STRING, SUBMAP, and HPOS.
      (HPOS is not used in when the X toolkit is in use.)
      There are four additional elements of nil at the end, to terminate.  */
-  Lisp_Object menu_bar_items;
+  Lisp_Object INTERNAL_FIELD (menu_bar_items);
 
   /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA).  */
-  Lisp_Object face_alist;
+  Lisp_Object INTERNAL_FIELD (face_alist);
 
   /* A vector that records the entire structure of this frame's menu bar.
      For the format of the data, see extensive comments in xmenu.c.
      Only the X toolkit version uses this.  */
-  Lisp_Object menu_bar_vector;
+  Lisp_Object INTERNAL_FIELD (menu_bar_vector);
 
   /* Predicate for selecting buffers for other-buffer.  */
-  Lisp_Object buffer_predicate;
+  Lisp_Object INTERNAL_FIELD (buffer_predicate);
 
   /* List of buffers viewed in this frame, for other-buffer.  */
-  Lisp_Object buffer_list;
+  Lisp_Object INTERNAL_FIELD (buffer_list);
 
   /* List of buffers that were viewed, then buried in this frame.  The
      most recently buried buffer is first.  For last-buffer.  */
-  Lisp_Object buried_buffer_list;
+  Lisp_Object INTERNAL_FIELD (buried_buffer_list);
 
   /* A dummy window used to display menu bars under X when no X
      toolkit support is available.  */
-  Lisp_Object menu_bar_window;
+  Lisp_Object INTERNAL_FIELD (menu_bar_window);
 
   /* A window used to display the tool-bar of a frame.  */
-  Lisp_Object tool_bar_window;
+  Lisp_Object INTERNAL_FIELD (tool_bar_window);
 
   /* Desired and current tool-bar items.  */
-  Lisp_Object tool_bar_items;
+  Lisp_Object INTERNAL_FIELD (tool_bar_items);
 
   /* Where tool bar is, can be left, right, top or bottom.  The native
      tool bar only supports top.  */
-  Lisp_Object tool_bar_position;
+  Lisp_Object INTERNAL_FIELD (tool_bar_position);
 
   /* Desired and current contents displayed in tool_bar_window.  */
-  Lisp_Object desired_tool_bar_string, current_tool_bar_string;
+  Lisp_Object INTERNAL_FIELD (desired_tool_bar_string);
+  Lisp_Object INTERNAL_FIELD (current_tool_bar_string);
 
   /* Beyond here, there should be no more Lisp_Object components.  */
 
@@ -371,7 +376,7 @@ struct frame
      if greater than 1, then the frame is obscured - we still consider
      it to be "visible" as seen from lisp, but we don't bother
      updating it.  We must take care to garbage the frame when it
-     ceaces to be obscured though.
+     ceases to be obscured though.
 
      iconified is nonzero if the frame is currently iconified.
 
@@ -501,11 +506,12 @@ struct frame
 
 typedef struct frame *FRAME_PTR;
 
-#define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p))
+#define XFRAME(p) \
+  (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
 
 /* Given a window, return its frame as a Lisp_Object.  */
-#define WINDOW_FRAME(w) (w)->frame
+#define WINDOW_FRAME(w) WVAR (w, frame)
 
 /* Test a frame for particular kinds of display methods.  */
 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
@@ -538,12 +544,12 @@ typedef struct frame *FRAME_PTR;
    does not have FRAME_X_DISPLAY_INFO.  */
 #ifdef HAVE_WINDOW_SYSTEM
 # define MOUSE_HL_INFO(F)                                      \
-   (FRAME_WINDOW_P(F)                                          \
-    ? &(FRAME_X_DISPLAY_INFO(F)->mouse_highlight)              \
-    : &(((F)->output_data.tty->display_info)->mouse_highlight))
+  (FRAME_WINDOW_P(F)                                           \
+   ? &FRAME_X_DISPLAY_INFO(F)->mouse_highlight                 \
+   : &(F)->output_data.tty->display_info->mouse_highlight)
 #else
 # define MOUSE_HL_INFO(F)                                      \
-    (&(((F)->output_data.tty->display_info)->mouse_highlight))
+  (&(F)->output_data.tty->display_info->mouse_highlight)
 #endif
 
 /* Nonzero if frame F is still alive (not deleted).  */
@@ -594,7 +600,7 @@ typedef struct frame *FRAME_PTR;
 /* Lines above the top-most window in frame F.  */
 
 #define FRAME_TOP_MARGIN(F) \
-     (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
+  (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
 
 /* Pixel height of the top margin above.  */
 
@@ -634,13 +640,13 @@ typedef struct frame *FRAME_PTR;
 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
 
 /* The minibuffer window of frame F, if it has one; otherwise nil.  */
-#define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
+#define FRAME_MINIBUF_WINDOW(f) FVAR (f, minibuffer_window)
 
 /* The root window of the window tree of frame F.  */
-#define FRAME_ROOT_WINDOW(f) (f)->root_window
+#define FRAME_ROOT_WINDOW(f) FVAR (f, root_window)
 
 /* The currently selected window of the window tree of frame F.  */
-#define FRAME_SELECTED_WINDOW(f) (f)->selected_window
+#define FRAME_SELECTED_WINDOW(f) FVAR (f, selected_window)
 
 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
@@ -648,7 +654,7 @@ typedef struct frame *FRAME_PTR;
 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
-#define FRAME_FOCUS_FRAME(f) (f)->focus_frame
+#define FRAME_FOCUS_FRAME(f) FVAR (f, focus_frame)
 
 /* Nonzero if frame F supports scroll bars.
    If this is zero, then it is impossible to enable scroll bars
@@ -659,11 +665,11 @@ typedef struct frame *FRAME_PTR;
    and which side they are on.  */
 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
-     ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
+  ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
-     ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
+  ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
-     ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
+  ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
 
 /* Width that a scroll bar in frame F should have, if there is one.
    Measured in pixels.
@@ -680,13 +686,13 @@ typedef struct frame *FRAME_PTR;
    the right in this frame, or there are no scroll bars, value is 0.  */
 
 #define FRAME_LEFT_SCROLL_BAR_COLS(f)                  \
-     (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)       \
-      ? FRAME_CONFIG_SCROLL_BAR_COLS (f)               \
-      : 0)
+  (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)          \
+   ? FRAME_CONFIG_SCROLL_BAR_COLS (f)                  \
+   : 0)
 
 /* Width of a left scroll bar in frame F, measured in pixels */
 
-#define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f)                                    \
+#define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f)                            \
   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)                          \
    ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))       \
    : 0)
@@ -696,13 +702,13 @@ typedef struct frame *FRAME_PTR;
    the left in this frame, or there are no scroll bars, value is 0.  */
 
 #define FRAME_RIGHT_SCROLL_BAR_COLS(f)                 \
-     (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)      \
-      ? FRAME_CONFIG_SCROLL_BAR_COLS (f)               \
-      : 0)
+  (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)         \
+   ? FRAME_CONFIG_SCROLL_BAR_COLS (f)                  \
+   : 0)
 
 /* Width of a right scroll bar area in frame F, measured in pixels */
 
-#define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f)                                   \
+#define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f)                           \
   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)                         \
    ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))       \
    : 0)
@@ -710,9 +716,9 @@ typedef struct frame *FRAME_PTR;
 /* Actual width of a scroll bar in frame F, measured in columns.  */
 
 #define FRAME_SCROLL_BAR_COLS(f)                       \
-     (FRAME_HAS_VERTICAL_SCROLL_BARS (f)               \
-      ? FRAME_CONFIG_SCROLL_BAR_COLS (f)               \
-      : 0)
+  (FRAME_HAS_VERTICAL_SCROLL_BARS (f)                  \
+   ? FRAME_CONFIG_SCROLL_BAR_COLS (f)                  \
+   : 0)
 
 /* Actual width of a scroll bar area in frame F, measured in pixels.  */
 
@@ -731,28 +737,28 @@ typedef struct frame *FRAME_PTR;
    not including scroll bars and fringes.  */
 
 #define SET_FRAME_COLS(f, val)                                         \
-     (FRAME_COLS (f) = (val),                                          \
-      (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
+  (FRAME_COLS (f) = (val),                                             \
+   (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
 
 /* Given a value WIDTH for frame F's nominal width,
    return the value that FRAME_TOTAL_COLS should have.  */
 
 #define FRAME_TOTAL_COLS_ARG(f, width)         \
-     ((width)                                  \
-      + FRAME_SCROLL_BAR_COLS (f)              \
-      + FRAME_FRINGE_COLS (f))
+  ((width)                                     \
+   + FRAME_SCROLL_BAR_COLS (f)                 \
+   + FRAME_FRINGE_COLS (f))
 
 /* Maximum + 1 legitimate value for FRAME_CURSOR_X.  */
 
 #define FRAME_CURSOR_X_LIMIT(f) \
-     (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
+  (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
 
 /* Nonzero if frame F has scroll bars.  */
 
-#define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
+#define FRAME_SCROLL_BARS(f) (FVAR (f, scroll_bars))
 
-#define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
-#define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
+#define FRAME_CONDEMNED_SCROLL_BARS(f) (FVAR (f, condemned_scroll_bars))
+#define FRAME_MENU_BAR_ITEMS(f) (FVAR (f, menu_bar_items))
 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
 
 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
@@ -938,18 +944,18 @@ extern Lisp_Object selected_frame;
    float.  Value is a C integer.  */
 
 #define FRAME_PIXEL_X_FROM_CANON_X(F, X)               \
-     (INTEGERP (X)                                     \
-      ? XINT (X) * FRAME_COLUMN_WIDTH (F)              \
-      : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
+  (INTEGERP (X)                                                \
+   ? XINT (X) * FRAME_COLUMN_WIDTH (F)                 \
+   : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
 
 /* Convert canonical value Y to pixels.  F is the frame whose
    canonical character height is to be used.  X must be a Lisp integer
    or float.  Value is a C integer.  */
 
 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y)               \
-     (INTEGERP (Y)                                     \
-      ? XINT (Y) * FRAME_LINE_HEIGHT (F)               \
-      : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
+  (INTEGERP (Y)                                                \
+   ? XINT (Y) * FRAME_LINE_HEIGHT (F)                  \
+   : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
 
 /* Convert pixel-value X to canonical units.  F is the frame whose
    canonical character width is to be used.  X is a C integer.  Result
@@ -957,9 +963,9 @@ extern Lisp_Object selected_frame;
    otherwise it's a Lisp integer.  */
 
 #define FRAME_CANON_X_FROM_PIXEL_X(F, X)                       \
-     ((X) % FRAME_COLUMN_WIDTH (F) != 0                                \
-      ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F))     \
-      : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
+  ((X) % FRAME_COLUMN_WIDTH (F) != 0                           \
+   ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F))                \
+   : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
 
 /* Convert pixel-value Y to canonical units.  F is the frame whose
    canonical character height is to be used.  Y is a C integer.
@@ -967,9 +973,9 @@ extern Lisp_Object selected_frame;
    otherwise it's a Lisp integer.  */
 
 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y)                       \
-     ((Y) % FRAME_LINE_HEIGHT (F)                              \
-      ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F))      \
-      : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
+  ((Y) % FRAME_LINE_HEIGHT (F)                                 \
+   ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F))         \
+   : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
 
 
 \f