]> code.delx.au - gnu-emacs/blobdiff - src/frame.h
Merge from origin/emacs-24
[gnu-emacs] / src / frame.h
index bc49cfa44ecf0f9dc078b41b089b0224716dac8e..d4dfd1c8f949a6389a0f02fcdf56a4643a11225d 100644 (file)
@@ -36,16 +36,22 @@ enum vertical_scroll_bar_type
   vertical_scroll_bar_right
 };
 
+#ifdef HAVE_WINDOW_SYSTEM
+
 enum fullscreen_type
 {
   FULLSCREEN_NONE,
-  FULLSCREEN_WIDTH     = 0x001,
-  FULLSCREEN_HEIGHT    = 0x002,
-  FULLSCREEN_BOTH      = 0x003,
-  FULLSCREEN_MAXIMIZED = 0x013,
-  FULLSCREEN_WAIT      = 0x100
+  FULLSCREEN_WIDTH     = 0x1,
+  FULLSCREEN_HEIGHT    = 0x2,
+  FULLSCREEN_BOTH      = 0x3, /* Not a typo but means "width and height".  */
+  FULLSCREEN_MAXIMIZED = 0x4,
+#ifdef HAVE_NTGUI
+  FULLSCREEN_WAIT      = 0x8
+#endif
 };
 
+#endif /* HAVE_WINDOW_SYSTEM */
+
 /* The structure representing a frame.  */
 
 struct frame
@@ -155,21 +161,41 @@ struct frame
   /* Desired and current 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.  */
+#ifdef USE_GTK
+  /* Where tool bar is, can be left, right, top or bottom.
+     Except with GTK, the only supported position is `top'.  */
   Lisp_Object tool_bar_position;
+#endif
+
+#if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
+  /* List of data specific to font-driver and frame, but common to faces.  */
+  Lisp_Object font_data;
+#endif
 
   /* Beyond here, there should be no more Lisp_Object components.  */
 
   /* Cache of realized faces.  */
   struct face_cache *face_cache;
 
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+  /* Tool-bar item index of the item on which a mouse button was pressed.  */
+  int last_tool_bar_item;
+#endif
+
   /* Number of elements in `menu_bar_vector' that have meaningful data.  */
   int menu_bar_items_used;
 
-  /* A buffer to hold the frame's name.  We can't use the Lisp
-     string's pointer (`name', above) because it might get relocated.  */
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
+  /* A buffer to hold the frame's name.  Since this is used by the
+     window system toolkit, we can't use the Lisp string's pointer
+     (`name', above) because it might get relocated.  */
   char *namebuf;
+#endif
+
+#ifdef USE_X_TOOLKIT
+  /* Used to pass geometry parameters to toolkit functions.  */
+  char *shell_position;
+#endif
 
   /* Glyph pool and matrix.  */
   struct glyph_pool *current_pool;
@@ -177,6 +203,8 @@ struct frame
   struct glyph_matrix *desired_matrix;
   struct glyph_matrix *current_matrix;
 
+  /* Bitfield area begins here.  Keep them together to avoid extra padding.  */
+
   /* True means that glyphs on this frame have been initialized so it can
      be used for output.  */
   bool_bf glyphs_initialized_p : 1;
@@ -218,10 +246,105 @@ struct frame
   /* True if it needs to be redisplayed.  */
   bool_bf redisplay : 1;
 
-  /* Margin at the top of the frame.  Used to display the tool-bar.  */
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)    \
+    || defined (HAVE_NS) || defined (USE_GTK)
+  /* True means using a menu bar that comes from the X toolkit.  */
+  bool_bf external_menu_bar : 1;
+#endif
+
+  /* Next two bitfields are mutually exclusive.  They might both be
+     zero if the frame has been made invisible without an icon.  */
+
+  /* Nonzero if the frame is currently displayed; we check
+     it to see if we should bother updating the frame's contents.
+
+     On ttys and on Windows NT/9X, to avoid wasting effort updating
+     visible frames that are actually completely obscured by other
+     windows on the display, we bend the meaning of visible slightly:
+     if equal to 2, then the frame is obscured - we still consider
+     it to be "visible" as seen from lisp, but we don't bother
+     updating it.  */
+  unsigned visible : 2;
+
+  /* True if the frame is currently iconified.  Do not
+     set this directly, use SET_FRAME_ICONIFIED instead.  */
+  bool_bf iconified : 1;
+
+  /* True if this frame should be fully redisplayed.  Disables all
+     optimizations while rebuilding matrices and redrawing.  */
+  bool_bf garbaged : 1;
+
+  /* False means, if this frame has just one window,
+     show no modeline for that window.  */
+  bool_bf wants_modeline : 1;
+
+  /* True means raise this frame to the top of the heap when selected.  */
+  bool_bf auto_raise : 1;
+
+  /* True means lower this frame to the bottom of the stack when left.  */
+  bool_bf auto_lower : 1;
+
+  /* True if frame's root window can't be split.  */
+  bool_bf 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.  */
+  bool_bf explicit_name : 1;
+
+  /* True if size of some window on this frame has changed.  */
+  bool_bf window_sizes_changed : 1;
+
+  /* True if the mouse has moved on this display device
+     since the last time we checked.  */
+  bool_bf mouse_moved : 1;
+
+  /* True means that the pointer is invisible.  */
+  bool_bf pointer_invisible : 1;
+
+  /* True means that all windows except mini-window and
+     selected window on this frame have frozen window starts.  */
+  bool_bf frozen_window_starts : 1;
+
+  /* The output method says how the contents of this frame are
+     displayed.  It could be using termcap, or using an X window.
+     This must be the same as the terminal->type. */
+  ENUM_BF (output_method) output_method : 3;
+
+#ifdef HAVE_WINDOW_SYSTEM
+  /* See FULLSCREEN_ enum on top.  */
+  ENUM_BF (fullscreen_type) want_fullscreen : 4;
+
+  /* If not vertical_scroll_bar_none, we should actually
+     display the scroll bars of this type on this frame.  */
+  ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
+
+  /* Nonzero if we should actually display horizontal scroll bars on this frame.  */
+  bool_bf horizontal_scroll_bars : 1;
+#endif /* HAVE_WINDOW_SYSTEM */
+
+  /* Whether new_height and new_width shall be interpreted
+     in pixels.  */
+  bool_bf new_pixelwise : 1;
+
+  /* True means x_set_window_size requests can be processed for this
+     frame.  */
+  bool_bf can_x_set_window_size : 1;
+
+  /* Set to true after this frame was made by `make-frame'.  */
+  bool_bf after_make_frame : 1;
+
+  /* True means tool bar has been redisplayed at least once in current
+     session.  */
+  bool_bf tool_bar_redisplayed_once : 1;
+
+  /* Bitfield area ends here.  */
+
+  /* Number of lines (rounded up) of tool bar.  REMOVE THIS  */
   int tool_bar_lines;
 
-  /* Pixel height of tool bar.  */
+  /* Height of frame internal tool bar in pixels.  */
   int tool_bar_height;
 
   int n_tool_bar_rows;
@@ -240,18 +363,22 @@ struct frame
   /* Cost of deleting n lines on this frame.  */
   int *delete_n_lines_cost;
 
-  /* Text width of this frame (excluding fringes, scroll bars and
-     internal border width) and text height (excluding internal border
-     width) in units of canonical characters.  */
+  /* Text width of this frame (excluding fringes, vertical scroll bar
+     and internal border widths) and text height (excluding menu bar,
+     tool bar, horizontal scroll bar and internal border widths) in
+     units of canonical characters.  */
   int text_cols, text_lines;
 
-  /* Total width of this frame (including fringes and scroll bars) in
+  /* Total width of this frame (including fringes, vertical scroll bar
+     and internal border widths) and total height (including menu bar,
+     tool bar, horizontal scroll bar and internal border widths) in
      units of canonical characters.  */
-  int total_cols;
+  int total_cols, total_lines;
 
-  /* Text width of this frame (excluding fringes, scroll bars and
-     internal border width) and text height (excluding internal border
-     width) in pixels.  */
+  /* Text width of this frame (excluding fringes, vertical scroll bar
+     and internal border widths) and text height (excluding menu bar,
+     tool bar, horizontal scroll bar and internal border widths) in
+     pixels.  */
   int text_width, text_height;
 
   /* New text height and width for pending size change.  0 if no change
@@ -260,21 +387,15 @@ struct frame
      text width/height of the frame.  */
   int new_width, new_height;
 
-  /* Whether new_height and new_width shall be interpreted
-     in pixels.  */
-  bool new_pixelwise;
-
   /* Pixel position of the frame window (x and y offsets in root window).  */
   int left_pos, top_pos;
 
-  /* Size of the frame window (including internal border widths) in
-     pixels.  */
+  /* Total width of this frame (including fringes, vertical scroll bar
+     and internal border widths) and total height (including internal
+     menu and tool bars, horizontal scroll bar and internal border
+     widths) in pixels.  */
   int pixel_width, pixel_height;
 
-  /* These many pixels are the difference between the outer window (i.e. the
-     left and top of the window manager decoration) and FRAME_X_WINDOW.  */
-  int x_pixels_diff, y_pixels_diff;
-
   /* This is the gravity value for the specified window position.  */
   int win_gravity;
 
@@ -289,9 +410,21 @@ struct frame
      a highlighting is displayed inside the internal border.  */
   int internal_border_width;
 
-  /* Width of borders between this frame's windows.  */
-  int right_divider_width;
-  int bottom_divider_width;
+  /* Widths of dividers between this frame's windows in pixels.  */
+  int right_divider_width, bottom_divider_width;
+
+  /* Widths of fringes in pixels.  */
+  int left_fringe_width, right_fringe_width;
+
+  /* Total width of fringes reserved for drawing truncation bitmaps,
+     continuation bitmaps and alike - REMOVE THIS !!!!.    */
+  int fringe_cols;
+
+  /* Number of lines of menu bar.  */
+  int menu_bar_lines;
+
+  /* Pixel height of menubar.  */
+  int menu_bar_height;
 
   /* Canonical X unit.  Width of default font, in pixels.  */
   int column_width;
@@ -299,11 +432,6 @@ struct frame
   /* Canonical Y unit.  Height of a line, in pixels.  */
   int line_height;
 
-  /* The output method says how the contents of this frame are
-     displayed.  It could be using termcap, or using an X window.
-     This must be the same as the terminal->type. */
-  enum output_method output_method;
-
   /* The terminal device that this frame uses.  If this is NULL, then
      the frame has been deleted.  */
   struct terminal *terminal;
@@ -323,98 +451,12 @@ struct frame
 
   /* List of font-drivers available on the frame.  */
   struct font_driver_list *font_driver_list;
-  /* List of data specific to font-driver and frame, but common to
-     faces.  */
-  struct font_data_list *font_data_list;
-
-  /* Total width of fringes reserved for drawing truncation bitmaps,
-     continuation bitmaps and alike.  The width is in canonical char
-     units of the frame.  This must currently be the case because window
-     sizes aren't pixel values.  If it weren't the case, we wouldn't be
-     able to split windows horizontally nicely.  */
-  int fringe_cols;
-
-  /* The extra width (in pixels) currently allotted for fringes.  */
-  int left_fringe_width, right_fringe_width;
-
-  /* See FULLSCREEN_ enum below.  */
-  enum fullscreen_type want_fullscreen;
-
-  /* Number of lines of menu bar.  */
-  int menu_bar_lines;
-
-  /* Pixel height of menubar.  */
-  int menu_bar_height;
 
 #if defined (HAVE_X_WINDOWS)
   /* Used by x_wait_for_event when watching for an X event on this frame.  */
   int wait_event_type;
 #endif
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
-  /* True means using a menu bar that comes from the X toolkit.  */
-  bool_bf external_menu_bar : 1;
-#endif
-
-  /* Next two bitfields are mutually exclusive.  They might both be
-     zero if the frame has been made invisible without an icon.  */
-
-  /* Nonzero if the frame is currently displayed; we check
-     it to see if we should bother updating the frame's contents.
-
-     On ttys and on Windows NT/9X, to avoid wasting effort updating
-     visible frames that are actually completely obscured by other
-     windows on the display, we bend the meaning of visible slightly:
-     if equal to 2, then the frame is obscured - we still consider
-     it to be "visible" as seen from lisp, but we don't bother
-     updating it.  */
-  unsigned visible : 2;
-
-  /* True if the frame is currently iconified.  Do not
-     set this directly, use SET_FRAME_ICONIFIED instead.  */
-  bool_bf iconified : 1;
-
-  /* True if this frame should be fully redisplayed.  Disables all
-     optimizations while rebuilding matrices and redrawing.  */
-  bool_bf garbaged : 1;
-
-  /* False means, if this frame has just one window,
-     show no modeline for that window.  */
-  bool_bf wants_modeline : 1;
-
-  /* True means raise this frame to the top of the heap when selected.  */
-  bool_bf auto_raise : 1;
-
-  /* True means lower this frame to the bottom of the stack when left.  */
-  bool_bf auto_lower : 1;
-
-  /* True if frame's root window can't be split.  */
-  bool_bf 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.  */
-  bool_bf explicit_name : 1;
-
-  /* True if size of some window on this frame has changed.  */
-  bool_bf window_sizes_changed : 1;
-
-  /* True if the mouse has moved on this display device
-     since the last time we checked.  */
-  bool_bf mouse_moved : 1;
-
-  /* True means that the pointer is invisible.  */
-  bool_bf pointer_invisible : 1;
-
-  /* True means that all windows except mini-window and
-     selected window on this frame have frozen window starts.  */
-  bool_bf frozen_window_starts : 1;
-
-  /* Nonzero if we should actually display the scroll bars on this frame.  */
-  enum vertical_scroll_bar_type vertical_scroll_bar_type;
-
   /* What kind of text cursor should we draw in the future?
      This should always be filled_box_cursor or bar_cursor.  */
   enum text_cursor_kinds desired_cursor;
@@ -437,6 +479,14 @@ struct frame
   int config_scroll_bar_width;
   int config_scroll_bar_cols;
 
+  /* Configured height of the scroll bar, in pixels and in characters.
+     config_scroll_bar_lines tracks config_scroll_bar_height if the
+     latter is positive; a zero value in config_scroll_bar_height means
+     to compute the actual width on the fly, using
+     config_scroll_bar_lines and the current font width.  */
+  int config_scroll_bar_height;
+  int config_scroll_bar_lines;
+
   /* The baud rate that was used to calculate costs for this frame.  */
   int cost_calculation_baud_rate;
 
@@ -543,11 +593,13 @@ fset_tool_bar_items (struct frame *f, Lisp_Object val)
 {
   f->tool_bar_items = val;
 }
+#ifdef USE_GTK
 INLINE void
 fset_tool_bar_position (struct frame *f, Lisp_Object val)
 {
   f->tool_bar_position = val;
 }
+#endif /* USE_GTK */
 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
 INLINE void
 fset_tool_bar_window (struct frame *f, Lisp_Object val)
@@ -682,8 +734,7 @@ default_pixels_per_inch_y (void)
 /* Pixel width of frame F.  */
 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
 
-/* Pixel height of frame F, including non-toolkit menu bar and
-   non-toolkit tool bar lines.  */
+/* Pixel height of frame F.  */
 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
 
 /* Width of frame F, measured in canonical character columns,
@@ -699,7 +750,7 @@ default_pixels_per_inch_y (void)
 #define FRAME_TEXT_WIDTH(f) (f)->text_width
 
 /* Height of frame F, measured in pixels not including the height
-   for internal borders.  */
+   for scroll bar and internal borders.  */
 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
 
 /* Number of lines of frame F used for menu bar.
@@ -719,6 +770,13 @@ default_pixels_per_inch_y (void)
 #define FRAME_EXTERNAL_TOOL_BAR(f) false
 #endif
 
+/* This is really supported only with GTK.  */
+#ifdef USE_GTK
+#define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
+#else
+#define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
+#endif
+
 /* Number of lines of frame F used for the tool-bar.  */
 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
 
@@ -741,6 +799,8 @@ default_pixels_per_inch_y (void)
 #else
 #define FRAME_EXTERNAL_MENU_BAR(f) false
 #endif
+
+/* True if frame F is currently visible.  */
 #define FRAME_VISIBLE_P(f) (f)->visible
 
 /* True if frame F is currently visible but hidden.  */
@@ -786,6 +846,8 @@ default_pixels_per_inch_y (void)
 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
 #define FRAME_FOCUS_FRAME(f) f->focus_frame
 
+#ifdef HAVE_WINDOW_SYSTEM
+
 /* This frame slot says whether scroll bars are currently enabled for frame F,
    and which side they are on.  */
 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
@@ -796,66 +858,108 @@ default_pixels_per_inch_y (void)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
   ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
 
+#else /* not HAVE_WINDOW_SYSTEM */
+
+/* If there is no window system, there are no scroll bars.  */
+#define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
+#define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
+#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
+#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
+
+#endif /* HAVE_WINDOW_SYSTEM */
+
+/* Whether horizontal scroll bars are currently enabled for frame F.  */
+#if USE_HORIZONTAL_SCROLL_BARS
+#define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
+  ((f)->horizontal_scroll_bars)
+#else
+#define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
+#endif
+
 /* Width that a scroll bar in frame F should have, if there is one.
    Measured in pixels.
    If scroll bars are turned off, this is still nonzero.  */
 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
 
+/* Height that a scroll bar in frame F should have, if there is one.
+   Measured in pixels.
+   If scroll bars are turned off, this is still nonzero.  */
+#define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
+
 /* Width that a scroll bar in frame F should have, if there is one.
    Measured in columns (characters).
    If scroll bars are turned off, this is still nonzero.  */
 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
 
-/* Width of a scroll bar in frame F, measured in columns (characters),
-   but only if scroll bars are on the left.  If scroll bars are on
-   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)
+/* Height that a scroll bar in frame F should have, if there is one.
+   Measured in lines (characters).
+   If scroll bars are turned off, this is still nonzero.  */
+#define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
 
 /* Width of a left scroll bar in frame F, measured in pixels */
-
 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f)                            \
   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)                          \
    ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)                                 \
    : 0)
 
-/* Width of a scroll bar in frame F, measured in columns (characters),
-   but only if scroll bars are on the right.  If scroll bars are on
-   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)
-
 /* Width of a right scroll bar area in frame F, measured in pixels */
-
 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f)                           \
   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)                         \
    ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)                                 \
    : 0)
 
-/* Actual width of a scroll bar in frame F, measured in columns.  */
+/* Width of a left scroll bar in frame F, measured in columns
+   (characters), but only if scroll bars are on the left.  If scroll
+   bars are on 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)
 
-#define FRAME_SCROLL_BAR_COLS(f)                       \
-  (FRAME_HAS_VERTICAL_SCROLL_BARS (f)                  \
+/* Width of a right scroll bar in frame F, measured in columns
+   (characters), but only if scroll bars are on the right.  If scroll
+   bars are on 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)
 
-/* Actual width of a scroll bar area in frame F, measured in pixels.  */
+/* Width of a vertical scroll bar area in frame F, measured in
+   pixels.  */
+#define FRAME_SCROLL_BAR_AREA_WIDTH(f)         \
+  (FRAME_HAS_VERTICAL_SCROLL_BARS (f)          \
+   ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)         \
+   : 0)
 
-#define FRAME_SCROLL_BAR_AREA_WIDTH(f)                                 \
-  (FRAME_HAS_VERTICAL_SCROLL_BARS (f)                                  \
-   ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)                                 \
+/* Height of horizontal scroll bar area in frame F, measured in
+   pixels.  */
+#define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
+  (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
+   ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
+   : 0)
+
+/* Width of vertical 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)
+
+/* Height of horizontal scroll bar in frame F, measured in lines.  */
+#define FRAME_SCROLL_BAR_LINES(f)      \
+  (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
+   ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
    : 0)
 
 /* Total width of frame F, in columns (characters),
    including the width used by scroll bars if any.  */
 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
 
+/* Total height of frame F, in lines (characters),
+   including the height used by scroll bars if any.  */
+#define FRAME_TOTAL_LINES(f) ((f)->total_lines)
+
 /* Set the character widths of frame F.  WIDTH specifies a nominal
    character text width.  */
 #define SET_FRAME_COLS(f, width)                                       \
@@ -864,8 +968,16 @@ default_pixels_per_inch_y (void)
                      + FRAME_SCROLL_BAR_COLS (f)                       \
                      + FRAME_FRINGE_COLS (f)))
 
-/* Set the pixel widths of frame F.  WIDTH specifies a nominal pixel
-   text width.  */
+/* Set the character heights of frame F.  HEIGHT specifies a nominal
+   character text height.  */
+#define SET_FRAME_LINES(f, height)                                     \
+  ((f)->text_lines = (height),                                         \
+   (f)->total_lines = ((height)                                                \
+                      + FRAME_TOP_MARGIN (f)                           \
+                      + FRAME_SCROLL_BAR_LINES (f)))
+
+/* Set the widths of frame F.  WIDTH specifies a nominal pixel text
+   width.  */
 #define SET_FRAME_WIDTH(f, width)                                      \
   ((f)->text_width = (width),                                          \
    (f)->pixel_width = ((width)                                         \
@@ -873,21 +985,23 @@ default_pixels_per_inch_y (void)
                       + FRAME_TOTAL_FRINGE_WIDTH (f)                   \
                       + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
 
-/* Set the pixel heights of frame F.  HEIGHT specifies a nominal pixel
-   text width.  */
+/* Set the heights of frame F.  HEIGHT specifies a nominal pixel text
+   height.  */
 #define SET_FRAME_HEIGHT(f, height)                                    \
   ((f)->text_height = (height),                                                \
    (f)->pixel_height = ((height)                                       \
-                      + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
+                       + FRAME_TOP_MARGIN_HEIGHT (f)                   \
+                       + FRAME_SCROLL_BAR_AREA_HEIGHT (f)              \
+                       + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
 
 /* Maximum + 1 legitimate value for FRAME_CURSOR_X.  */
-
 #define FRAME_CURSOR_X_LIMIT(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_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)
 
@@ -947,6 +1061,11 @@ default_pixels_per_inch_y (void)
       }                                                                \
   } while (false)
 
+/* Handy macro to construct an argument to Fmodify_frame_parameters.  */
+
+#define AUTO_FRAME_ARG(name, parameter, value) \
+  AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
+
 /* False means there are no visible garbaged frames.  */
 extern bool frame_garbaged;
 
@@ -975,13 +1094,11 @@ SET_FRAME_VISIBLE (struct frame *f, int v)
   (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
 
 extern Lisp_Object selected_frame;
-extern Lisp_Object Qframep, Qframe_live_p;
-extern Lisp_Object Qtty, Qtty_type;
-extern Lisp_Object Qtty_color_mode;
-extern Lisp_Object Qterminal;
-extern Lisp_Object Qnoelisp;
 
-extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+#if ! (defined USE_GTK || defined HAVE_NS)
+extern int frame_default_tool_bar_height;
+#endif
+
 extern struct frame *decode_window_system_frame (Lisp_Object);
 extern struct frame *decode_live_frame (Lisp_Object);
 extern struct frame *decode_any_frame (Lisp_Object);
@@ -992,12 +1109,18 @@ extern struct frame *make_minibuffer_frame (void);
 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
                                                     struct kboard *,
                                                     Lisp_Object);
-#endif /* HAVE_WINDOW_SYSTEM */
 extern bool window_system_available (struct frame *);
+#else /* not HAVE_WINDOW_SYSTEM */
+#define window_system_available(f) ((void) (f), false)
+#endif /* HAVE_WINDOW_SYSTEM */
 extern void check_window_system (struct frame *);
-extern void frame_make_pointer_invisible (void);
-extern void frame_make_pointer_visible (void);
+extern void frame_make_pointer_invisible (struct frame *);
+extern void frame_make_pointer_visible (struct frame *);
 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
+extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
+extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
+extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
+                                   int width, int height, Lisp_Object rest);
 
 extern Lisp_Object Vframe_list;
 
@@ -1018,12 +1141,10 @@ extern Lisp_Object Vframe_list;
 /* Canonical y-unit on frame F.
    This value currently equals the line height of the frame (which is
    the height of the default font of F).  */
-
 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
 
 /* Canonical x-unit on frame F.
    This value currently equals the average width of the default font of F.  */
-
 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
 
 /* Pixel width of areas used to display truncation marks, continuation
@@ -1036,7 +1157,6 @@ extern Lisp_Object Vframe_list;
    units of the frame.  This must currently be the case because window
    sizes aren't pixel values.  If it weren't the case, we wouldn't be
    able to split windows horizontally nicely.  */
-
 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
 
 /* Pixel-width of the left and right fringe.  */
@@ -1079,7 +1199,6 @@ extern Lisp_Object Vframe_list;
 /* Convert canonical value X to pixels.  F is the frame whose
    canonical char width is to be used.  X must be a Lisp integer or
    float.  Value is a C integer.  */
-
 #define FRAME_PIXEL_X_FROM_CANON_X(F, X)               \
   (INTEGERP (X)                                                \
    ? XINT (X) * FRAME_COLUMN_WIDTH (F)                 \
@@ -1088,7 +1207,6 @@ extern Lisp_Object Vframe_list;
 /* 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)                  \
@@ -1098,7 +1216,6 @@ extern Lisp_Object Vframe_list;
    canonical character width is to be used.  X is a C integer.  Result
    is a Lisp float if X is not a multiple of the canon width,
    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))                \
@@ -1108,7 +1225,6 @@ extern Lisp_Object Vframe_list;
    canonical character height is to be used.  Y is a C integer.
    Result is a Lisp float if Y is not a multiple of the canon width,
    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))         \
@@ -1122,7 +1238,6 @@ extern Lisp_Object Vframe_list;
 
    Return the upper/left pixel position of the character cell on frame F
    at ROW/COL.  */
-
 #define FRAME_LINE_TO_PIXEL_Y(f, row)                                  \
   (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f))        \
    + (row) * FRAME_LINE_HEIGHT (f))
@@ -1133,25 +1248,27 @@ extern Lisp_Object Vframe_list;
 
 /* Return the pixel width/height of frame F if it has
    COLS columns/LINES rows.  */
-
 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
-  (FRAME_COL_TO_PIXEL_X (f, cols)              \
+  ((cols) * FRAME_COLUMN_WIDTH (f)             \
    + FRAME_SCROLL_BAR_AREA_WIDTH (f)           \
    + FRAME_TOTAL_FRINGE_WIDTH (f)              \
-   + FRAME_INTERNAL_BORDER_WIDTH (f))
+   + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
   ((lines) * FRAME_LINE_HEIGHT (f)                \
+   + FRAME_TOP_MARGIN_HEIGHT (f)                  \
+   + FRAME_SCROLL_BAR_AREA_HEIGHT (f)             \
    + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
 /* Return the row/column (zero-based) of the character cell containing
    the pixel on FRAME at Y/X.  */
-
 #define FRAME_PIXEL_Y_TO_LINE(f, y)                                    \
   (((y) < FRAME_TOP_MARGIN_HEIGHT (f)                                  \
     ? (y)                                                              \
-    : ((y) < FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
-       ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
+    : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f)                              \
+             + FRAME_INTERNAL_BORDER_WIDTH (f))                        \
+       ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f)                            \
+               + FRAME_INTERNAL_BORDER_WIDTH (f)                       \
                /* Arrange for the division to round down.  */          \
                + FRAME_LINE_HEIGHT (f) - 1)                            \
        : (y) - FRAME_INTERNAL_BORDER_WIDTH (f)))                       \
@@ -1162,21 +1279,23 @@ extern Lisp_Object Vframe_list;
    / FRAME_COLUMN_WIDTH (f))
 
 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
-   frame F?  */
-
+   frame F (so we round down)?  */
 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width)                       \
-  (FRAME_PIXEL_X_TO_COL (f, ((width)                                   \
-                            - FRAME_INTERNAL_BORDER_WIDTH (f)          \
-                            - FRAME_TOTAL_FRINGE_WIDTH (f)             \
-                            - FRAME_SCROLL_BAR_AREA_WIDTH (f))))       \
+  (((width)                                                            \
+    - FRAME_TOTAL_FRINGE_WIDTH (f)                                     \
+    - FRAME_SCROLL_BAR_AREA_WIDTH (f)                                  \
+    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))                             \
+   / FRAME_COLUMN_WIDTH (f))                                           \
 
 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height)                    \
-  (FRAME_PIXEL_Y_TO_LINE (f, ((height)                                 \
-                             - FRAME_INTERNAL_BORDER_WIDTH (f))))
+  (((height)                                                           \
+    - FRAME_TOP_MARGIN_HEIGHT (f)                                      \
+    - FRAME_SCROLL_BAR_AREA_HEIGHT (f)                                 \
+    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))                             \
+   / FRAME_LINE_HEIGHT (f))
 
 /* Return the pixel width/height of frame F with a text size of
    width/height.  */
-
 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width)      \
   ((width)                                       \
    + FRAME_SCROLL_BAR_AREA_WIDTH (f)             \
@@ -1184,11 +1303,13 @@ extern Lisp_Object Vframe_list;
    + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height)       \
-  ((height) + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
+  ((height)                                         \
+   + FRAME_TOP_MARGIN_HEIGHT (f)                    \
+   + FRAME_SCROLL_BAR_AREA_HEIGHT (f)               \
+   + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
 /* Return the text width/height of frame F with a pixel size of
    width/height.  */
-
 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width)      \
   ((width)                                       \
    - FRAME_SCROLL_BAR_AREA_WIDTH (f)             \
@@ -1196,15 +1317,26 @@ extern Lisp_Object Vframe_list;
    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height)          \
-  ((height) - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
+  ((height)                                            \
+   - FRAME_TOP_MARGIN_HEIGHT (f)                       \
+   - FRAME_SCROLL_BAR_AREA_HEIGHT (f)                  \
+   - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
-/* Value is the smallest width of any character in any font on frame F.  */
+/* Return the width/height reserved for the windows of frame F.  */
+#define FRAME_WINDOWS_WIDTH(f)                 \
+  (FRAME_PIXEL_WIDTH (f)                       \
+   - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
 
+#define FRAME_WINDOWS_HEIGHT(f)                        \
+  (FRAME_PIXEL_HEIGHT (f)                      \
+   - FRAME_TOP_MARGIN_HEIGHT (f)               \
+   - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
+
+/* Value is the smallest width of any character in any font on frame F.  */
 #define FRAME_SMALLEST_CHAR_WIDTH(f)           \
   FRAME_DISPLAY_INFO (f)->smallest_char_width
 
 /* Value is the smallest height of any font on frame F.  */
-
 #define FRAME_SMALLEST_FONT_HEIGHT(f)          \
   FRAME_DISPLAY_INFO (f)->smallest_font_height
 
@@ -1212,78 +1344,25 @@ extern Lisp_Object Vframe_list;
                                Frame Parameters
  ***********************************************************************/
 
-extern Lisp_Object Qauto_raise, Qauto_lower;
-extern Lisp_Object Qborder_color, Qborder_width;
-extern Lisp_Object Qbuffer_predicate;
-extern Lisp_Object Qcursor_color, Qcursor_type;
-extern Lisp_Object Qfont;
-extern Lisp_Object Qbackground_color, Qforeground_color;
-extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
-extern Lisp_Object Qinternal_border_width;
-extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
-extern Lisp_Object Qtooltip;
-extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
-extern Lisp_Object Qmouse_color;
-extern Lisp_Object Qname, Qtitle;
-extern Lisp_Object Qparent_id;
-extern Lisp_Object Qunsplittable, Qvisibility;
-extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
-extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
-extern Lisp_Object Qscreen_gamma;
-extern Lisp_Object Qline_spacing;
-extern Lisp_Object Qwait_for_wm;
-extern Lisp_Object Qfullscreen;
-extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
-extern Lisp_Object Qsticky;
-extern Lisp_Object Qfont_backend;
-extern Lisp_Object Qalpha;
-
-extern Lisp_Object Qleft_fringe, Qright_fringe;
-extern Lisp_Object Qheight, Qwidth;
-extern Lisp_Object Qminibuffer, Qmodeline;
-extern Lisp_Object Qx, Qw32, Qpc, Qns;
-extern Lisp_Object Qvisible;
-extern Lisp_Object Qdisplay_type;
-
-extern Lisp_Object Qx_resource_name;
-
-extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom;
-extern Lisp_Object Qdisplay;
-
-extern Lisp_Object Qrun_hook_with_args;
-
 #ifdef HAVE_WINDOW_SYSTEM
 
 /* The class of this X application.  */
 #define EMACS_CLASS "Emacs"
 
-/* These are in xterm.c, w32term.c, etc.  */
-
 extern void x_set_scroll_bar_default_width (struct frame *);
+extern void x_set_scroll_bar_default_height (struct frame *);
 extern void x_set_offset (struct frame *, int, int, int);
 extern void x_wm_set_size_hint (struct frame *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 HAVE_NTGUI
-extern void x_fullscreen_adjust (struct frame *f, int *, int *,
-                                 int *, int *);
-#endif
-
 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
-
 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_internal_border_width (struct frame *, Lisp_Object,
-                                         Lisp_Object);
 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
                                       Lisp_Object);
 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
@@ -1292,10 +1371,10 @@ extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object,
-                                        Lisp_Object);
-extern void x_set_scroll_bar_width (struct frame *, Lisp_Object,
-                                    Lisp_Object);
+extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
 
 extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
 
@@ -1310,17 +1389,14 @@ extern Lisp_Object display_x_get_resource (Display_Info *,
                                           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,
+extern void x_set_window_size (struct frame *f, bool change_gravity,
                               int width, int height, bool pixelwise);
 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 frame_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 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 *, Lisp_Object, Lisp_Object);
 extern void x_activate_menubar (struct frame *);
 extern void x_real_positions (struct frame *, int *, int *);
 extern void free_frame_menubar (struct frame *);
@@ -1340,7 +1416,7 @@ extern void x_focus_frame (struct frame *);
 
 #ifndef HAVE_NS
 
-extern int x_bitmap_icon (struct frame *, Lisp_Object);
+extern bool x_bitmap_icon (struct frame *, Lisp_Object);
 
 /* Set F's bitmap icon, if specified among F's parameters.  */
 
@@ -1354,7 +1430,6 @@ x_set_bitmap_icon (struct frame *f)
 }
 
 #endif /* !HAVE_NS */
-
 #endif /* HAVE_WINDOW_SYSTEM */
 
 INLINE void
@@ -1390,4 +1465,11 @@ extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
 
 INLINE_HEADER_END
 
+/* Suppress -Wsuggest-attribute=const if there are no scroll bars.
+   This is for functions like x_set_horizontal_scroll_bars that have
+   no effect in this case.  */
+#if ! USE_HORIZONTAL_SCROLL_BARS && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
+#endif
+
 #endif /* not EMACS_FRAME_H */