Merge from trunk
[bpt/emacs.git] / src / frame.h
index 1a1f887..7bf76c2 100644 (file)
@@ -25,11 +25,16 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "dispextern.h"
 
+INLINE_HEADER_BEGIN
+#ifndef FRAME_INLINE
+# define FRAME_INLINE INLINE
+#endif
+
 \f
 /* Miscellanea.  */
 
 /* Nonzero means there is at least one garbaged frame. */
-extern int frame_garbaged;
+extern bool frame_garbaged;
 
 \f
 /* The structure representing a frame.  */
@@ -76,13 +81,6 @@ enum fullscreen_type
 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
 
-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
 {
@@ -93,15 +91,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 INTERNAL_FIELD (name);
+  Lisp_Object name;
 
   /* The name to use for the icon, the last time
      it was refreshed.  nil means not explicitly specified.  */
-  Lisp_Object INTERNAL_FIELD (icon_name);
+  Lisp_Object icon_name;
 
   /* This is the frame title specified explicitly, if any.
      Usually it is nil.  */
-  Lisp_Object INTERNAL_FIELD (title);
+  Lisp_Object title;
 
   /* The frame which should receive keystrokes that occur in this
      frame, or nil if they should go to the frame itself.  This is
@@ -114,29 +112,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 INTERNAL_FIELD (focus_frame);
+  Lisp_Object 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 INTERNAL_FIELD (root_window);
+  Lisp_Object 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 INTERNAL_FIELD (selected_window);
+  Lisp_Object 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 INTERNAL_FIELD (minibuffer_window);
+  Lisp_Object minibuffer_window;
 
   /* Parameter alist of this frame.
      These are the parameters specified when creating the frame
      or modified with modify-frame-parameters.  */
-  Lisp_Object INTERNAL_FIELD (param_alist);
+  Lisp_Object param_alist;
 
   /* List of scroll bars on this frame.
      Actually, we don't specify exactly what is stored here at all; the
@@ -145,51 +143,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 INTERNAL_FIELD (scroll_bars);
-  Lisp_Object INTERNAL_FIELD (condemned_scroll_bars);
+  Lisp_Object scroll_bars;
+  Lisp_Object 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 INTERNAL_FIELD (menu_bar_items);
+  Lisp_Object menu_bar_items;
 
   /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA).  */
-  Lisp_Object INTERNAL_FIELD (face_alist);
+  Lisp_Object 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 INTERNAL_FIELD (menu_bar_vector);
+  Lisp_Object menu_bar_vector;
 
   /* Predicate for selecting buffers for other-buffer.  */
-  Lisp_Object INTERNAL_FIELD (buffer_predicate);
+  Lisp_Object buffer_predicate;
 
   /* List of buffers viewed in this frame, for other-buffer.  */
-  Lisp_Object INTERNAL_FIELD (buffer_list);
+  Lisp_Object 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 INTERNAL_FIELD (buried_buffer_list);
+  Lisp_Object buried_buffer_list;
 
   /* A dummy window used to display menu bars under X when no X
      toolkit support is available.  */
-  Lisp_Object INTERNAL_FIELD (menu_bar_window);
+  Lisp_Object menu_bar_window;
 
   /* A window used to display the tool-bar of a frame.  */
-  Lisp_Object INTERNAL_FIELD (tool_bar_window);
+  Lisp_Object tool_bar_window;
 
   /* Desired and current tool-bar items.  */
-  Lisp_Object INTERNAL_FIELD (tool_bar_items);
+  Lisp_Object tool_bar_items;
 
   /* Where tool bar is, can be left, right, top or bottom.  The native
      tool bar only supports top.  */
-  Lisp_Object INTERNAL_FIELD (tool_bar_position);
+  Lisp_Object tool_bar_position;
 
   /* Desired and current contents displayed in tool_bar_window.  */
-  Lisp_Object INTERNAL_FIELD (desired_tool_bar_string);
-  Lisp_Object INTERNAL_FIELD (current_tool_bar_string);
+  Lisp_Object desired_tool_bar_string;
+  Lisp_Object current_tool_bar_string;
 
   /* Beyond here, there should be no more Lisp_Object components.  */
 
@@ -360,7 +358,7 @@ struct frame
 #endif
 
   /* Nonzero if last attempt at redisplay on this frame was preempted.  */
-  unsigned char display_preempted : 1;
+  unsigned display_preempted : 1;
 
   /* visible is nonzero if the frame is currently displayed; we check
      it to see if we should bother updating the frame's contents.
@@ -390,8 +388,8 @@ struct frame
 
      These two are mutually exclusive.  They might both be zero, if the
      frame has been made invisible without an icon.  */
-  unsigned char visible : 2;
-  unsigned char iconified : 1;
+  unsigned visible : 2;
+  unsigned iconified : 1;
 
   /* Let's not use bitfields for volatile variables.  */
 
@@ -405,40 +403,40 @@ struct frame
 
   /* True if frame actually has a minibuffer window on it.
      0 if using a minibuffer window that isn't on this frame.  */
-  unsigned char has_minibuffer : 1;
+  unsigned has_minibuffer : 1;
 
   /* 0 means, if this frame has just one window,
      show no modeline for that window.  */
-  unsigned char wants_modeline : 1;
+  unsigned wants_modeline : 1;
 
   /* Non-zero if the hardware device this frame is displaying on can
      support scroll bars.  */
   char can_have_scroll_bars;
 
   /* Non-0 means raise this frame to the top of the heap when selected.  */
-  unsigned char auto_raise : 1;
+  unsigned auto_raise : 1;
 
   /* Non-0 means lower this frame to the bottom of the stack when left.  */
-  unsigned char auto_lower : 1;
+  unsigned auto_lower : 1;
 
   /* True if frame's root window can't be split.  */
-  unsigned char no_split : 1;
+  unsigned no_split : 1;
 
   /* If this is set, then Emacs won't change the frame name to indicate
      the current buffer, etcetera.  If the user explicitly sets the frame
      name, this gets set.  If the user sets the name to Qnil, this is
      cleared.  */
-  unsigned char explicit_name : 1;
+  unsigned explicit_name : 1;
 
   /* Nonzero if size of some window on this frame has changed.  */
-  unsigned char window_sizes_changed : 1;
+  unsigned window_sizes_changed : 1;
 
   /* Nonzero if the mouse has moved on this display device
      since the last time we checked.  */
-  unsigned char mouse_moved :1;
+  unsigned mouse_moved :1;
 
   /* Nonzero means that the pointer is invisible. */
-  unsigned char pointer_invisible :1;
+  unsigned pointer_invisible :1;
 
   /* If can_have_scroll_bars is non-zero, this is non-zero if we should
      actually display them on this frame.  */
@@ -499,6 +497,109 @@ struct frame
   unsigned long foreground_pixel;
 };
 
+/* Most code should use these functions to set Lisp fields in struct frame.  */
+
+FRAME_INLINE void
+fset_buffer_list (struct frame *f, Lisp_Object val)
+{
+  f->buffer_list = val;
+}
+FRAME_INLINE void
+fset_buried_buffer_list (struct frame *f, Lisp_Object val)
+{
+  f->buried_buffer_list = val;
+}
+FRAME_INLINE void
+fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
+{
+  f->condemned_scroll_bars = val;
+}
+FRAME_INLINE void
+fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
+{
+  f->current_tool_bar_string = val;
+}
+FRAME_INLINE void
+fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
+{
+  f->desired_tool_bar_string = val;
+}
+FRAME_INLINE void
+fset_face_alist (struct frame *f, Lisp_Object val)
+{
+  f->face_alist = val;
+}
+FRAME_INLINE void
+fset_focus_frame (struct frame *f, Lisp_Object val)
+{
+  f->focus_frame = val;
+}
+FRAME_INLINE void
+fset_icon_name (struct frame *f, Lisp_Object val)
+{
+  f->icon_name = val;
+}
+FRAME_INLINE void
+fset_menu_bar_items (struct frame *f, Lisp_Object val)
+{
+  f->menu_bar_items = val;
+}
+FRAME_INLINE void
+fset_menu_bar_vector (struct frame *f, Lisp_Object val)
+{
+  f->menu_bar_vector = val;
+}
+FRAME_INLINE void
+fset_menu_bar_window (struct frame *f, Lisp_Object val)
+{
+  f->menu_bar_window = val;
+}
+FRAME_INLINE void
+fset_name (struct frame *f, Lisp_Object val)
+{
+  f->name = val;
+}
+FRAME_INLINE void
+fset_param_alist (struct frame *f, Lisp_Object val)
+{
+  f->param_alist = val;
+}
+FRAME_INLINE void
+fset_root_window (struct frame *f, Lisp_Object val)
+{
+  f->root_window = val;
+}
+FRAME_INLINE void
+fset_scroll_bars (struct frame *f, Lisp_Object val)
+{
+  f->scroll_bars = val;
+}
+FRAME_INLINE void
+fset_selected_window (struct frame *f, Lisp_Object val)
+{
+  f->selected_window = val;
+}
+FRAME_INLINE void
+fset_title (struct frame *f, Lisp_Object val)
+{
+  f->title = val;
+}
+FRAME_INLINE void
+fset_tool_bar_items (struct frame *f, Lisp_Object val)
+{
+  f->tool_bar_items = val;
+}
+FRAME_INLINE void
+fset_tool_bar_position (struct frame *f, Lisp_Object val)
+{
+  f->tool_bar_position = val;
+}
+FRAME_INLINE void
+fset_tool_bar_window (struct frame *f, Lisp_Object val)
+{
+  f->tool_bar_window = val;
+}
+
 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
 
 /* Return a pointer to the image cache of frame F.  */
@@ -511,17 +612,27 @@ typedef struct frame *FRAME_PTR;
 #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) w->frame
 
 /* Test a frame for particular kinds of display methods.  */
 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
+#ifndef HAVE_NTGUI
+#define FRAME_W32_P(f) (0)
+#else
 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
+#endif
+#ifndef MSDOS
+#define FRAME_MSDOS_P(f) (0)
+#else
 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
-#define FRAME_MAC_P(f) ((f)->output_method == output_mac)
+#endif
+#ifndef HAVE_NS
+#define FRAME_NS_P(f) (0)
+#else
 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
-
+#endif
 /* FRAME_WINDOW_P tests whether the frame is a window, and is
    defined to be the predicate for the window system being used.  */
 
@@ -640,13 +751,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) FVAR (f, minibuffer_window)
+#define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
 
 /* The root window of the window tree of frame F.  */
-#define FRAME_ROOT_WINDOW(f) FVAR (f, root_window)
+#define FRAME_ROOT_WINDOW(f) f->root_window
 
 /* The currently selected window of the window tree of frame F.  */
-#define FRAME_SELECTED_WINDOW(f) FVAR (f, selected_window)
+#define FRAME_SELECTED_WINDOW(f) f->selected_window
 
 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
@@ -654,7 +765,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) FVAR (f, focus_frame)
+#define FRAME_FOCUS_FRAME(f) f->focus_frame
 
 /* Nonzero if frame F supports scroll bars.
    If this is zero, then it is impossible to enable scroll bars
@@ -755,10 +866,10 @@ typedef struct frame *FRAME_PTR;
 
 /* Nonzero if frame F has scroll bars.  */
 
-#define FRAME_SCROLL_BARS(f) (FVAR (f, scroll_bars))
+#define FRAME_SCROLL_BARS(f) (f->scroll_bars)
 
-#define FRAME_CONDEMNED_SCROLL_BARS(f) (FVAR (f, condemned_scroll_bars))
-#define FRAME_MENU_BAR_ITEMS(f) (FVAR (f, menu_bar_items))
+#define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
+#define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
 
 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
@@ -826,10 +937,10 @@ typedef struct frame *FRAME_PTR;
    supported.  An alternate definition of the macro would expand to
    something which executes the statement once.  */
 
-#define FOR_EACH_FRAME(list_var, frame_var)                    \
-  for ((list_var) = Vframe_list;                               \
-       (CONSP (list_var)                                       \
-       && (frame_var = XCAR (list_var), 1));           \
+#define FOR_EACH_FRAME(list_var, frame_var)    \
+  for ((list_var) = Vframe_list;               \
+       (CONSP (list_var)                       \
+       && (frame_var = XCAR (list_var), 1));   \
        list_var = XCDR (list_var))
 
 
@@ -867,7 +978,7 @@ extern Lisp_Object selected_frame;
      ((FRAMEP (selected_frame)                         \
        && FRAME_LIVE_P (XFRAME (selected_frame)))      \
       ? XFRAME (selected_frame)                                \
-      : (abort (), (struct frame *) 0))
+      : (emacs_abort (), (struct frame *) 0))
 
 \f
 /***********************************************************************
@@ -1092,13 +1203,14 @@ extern Lisp_Object Qrun_hook_with_args;
 extern void x_set_scroll_bar_default_width (struct frame *);
 extern void x_set_offset (struct frame *, int, int, int);
 extern void x_wm_set_icon_position (struct frame *, int, int);
+extern void x_wm_set_size_hint (FRAME_PTR f, long flags, bool user_position);
 
 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
 
 
 extern Lisp_Object Qface_set_after_frame_default;
 
-#ifdef WINDOWSNT
+#ifdef HAVE_NTGUI
 extern void x_fullscreen_adjust (struct frame *f, int *, int *,
                                  int *, int *);
 #endif
@@ -1137,13 +1249,43 @@ extern Lisp_Object display_x_get_resource (Display_Info *,
                                           Lisp_Object component,
                                           Lisp_Object subclass);
 
+extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
+extern void x_set_window_size (struct frame *f, int change_grav,
+                              int cols, int rows);
+extern void x_sync (struct frame *);
+extern Lisp_Object x_get_focus_frame (struct frame *);
+extern void x_set_mouse_position (struct frame *f, int h, int v);
+extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
+extern void x_make_frame_visible (struct frame *f);
+extern void x_make_frame_invisible (struct frame *f);
+extern void x_iconify_frame (struct frame *f);
+extern int x_char_width (struct frame *f);
+extern int x_char_height (struct frame *f);
+extern int x_pixel_width (struct frame *f);
+extern int x_pixel_height (struct frame *f);
+extern void x_set_frame_alpha (struct frame *f);
+extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_tool_bar_lines (struct frame *f,
+                                  Lisp_Object value,
+                                  Lisp_Object oldval);
+extern void x_activate_menubar (struct frame *);
+extern void x_real_positions (struct frame *, int *, int *);
+extern int x_bitmap_icon (struct frame *, Lisp_Object);
+extern void x_set_menu_bar_lines (struct frame *,
+                                  Lisp_Object,
+                                  Lisp_Object);
+extern void free_frame_menubar (struct frame *);
+extern void x_free_frame_resources (struct frame *);
+
 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
 extern char *x_get_resource_string (const char *, const char *);
 #endif
 
-/* In xmenu.c */
-extern void set_frame_menubar (FRAME_PTR, int, int);
+extern void x_query_colors (struct frame *f, XColor *, int);
+extern void x_query_color (struct frame *f, XColor *);
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
+INLINE_HEADER_END
+
 #endif /* not EMACS_FRAME_H */