Unify FRAME_window_system_DISPLAY_INFO macros between all ports.
[bpt/emacs.git] / src / window.h
index 4f6374b..a419bf7 100644 (file)
@@ -41,14 +41,13 @@ They are deleted only by calling delete-window on them (but
 this can be done implicitly).  Combination windows can be created
 and deleted at any time.
 
-A leaf window has a non-nil buffer field, and also
- has markers in its start and pointm fields.  Non-leaf windows
- have nil in these fields.
+A leaf window has a buffer stored in contents field and markers in its start
+and pointm fields.  Non-leaf windows have nil in the latter two fields.
 
 Non-leaf windows are either vertical or horizontal combinations.
 
 A vertical combination window has children that are arranged on the frame
-one above the next.  Its vchild field points to the uppermost child.
+one above the next.  Its contents field points to the uppermost child.
 The parent field of each of the children points to the vertical
 combination window.  The next field of each child points to the
 child below it, or is nil for the lowest child.  The prev field
@@ -56,7 +55,7 @@ of each child points to the child above it, or is nil for the
 highest child.
 
 A horizontal combination window has children that are side by side.
-Its hchild field points to the leftmost child.  In each child
+Its contents field points to the leftmost child.  In each child
 the next field points to the child to the right and the prev field
 points to the child to the left.
 
@@ -78,7 +77,7 @@ the root window is the minibuf window.  On minibufferless screens or
 minibuffer-only screens, the root window and the minibuffer window are
 one and the same, so its prev and next members are nil.
 
-A dead window has its buffer, hchild, and vchild windows all nil.  */
+A dead window has its contents field set to nil.  */
 
 struct cursor_pos
 {
@@ -102,13 +101,6 @@ struct window
     Lisp_Object next;
     Lisp_Object prev;
 
-    /* First child of this window: vchild is used if this is a vertical
-       combination, hchild if this is a horizontal combination.  Of the
-       fields vchild, hchild and buffer, one and only one is non-nil
-       unless the window is dead.  */
-    Lisp_Object hchild;
-    Lisp_Object vchild;
-
     /* The window this one is a child of.  */
     Lisp_Object parent;
 
@@ -123,10 +115,8 @@ struct window
     Lisp_Object new_total;
     Lisp_Object new_normal;
 
-    /* The buffer displayed in this window.  Of the fields vchild,
-       hchild and buffer, one and only one is non-nil unless the window
-       is dead.  */
-    Lisp_Object buffer;
+    /* May be buffer, window, or nil.  */
+    Lisp_Object contents;
 
     /* A marker pointing to where in the text to start displaying.
        BIDI Note: This is the _logical-order_ start, i.e. the smallest
@@ -151,32 +141,10 @@ struct window
        it yet, or if the frame doesn't have any scroll bars, this is nil.  */
     Lisp_Object vertical_scroll_bar;
 
-    /* Width of left and right marginal areas.  A value of nil means
-       no margin.  */
-    Lisp_Object left_margin_cols;
-    Lisp_Object right_margin_cols;
-
-    /* Width of left and right fringes.
-       A value of nil or t means use frame values.  */
-    Lisp_Object left_fringe_width;
-    Lisp_Object right_fringe_width;
-
-    /* Pixel width of scroll bars.
-       A value of nil or t means use frame values.  */
-    Lisp_Object scroll_bar_width;
-
     /* Type of vertical scroll bar.  A value of nil means
        no scroll bar.  A value of t means use frame value.  */
     Lisp_Object vertical_scroll_bar_type;
 
-    /* Z - the buffer position of the last glyph in the current
-       matrix of W.  Only valid if window_end_valid is nonzero.  */
-    Lisp_Object window_end_pos;
-
-    /* Glyph matrix row of the last glyph in the current matrix
-       of W.  Only valid if window_end_valid is nonzero.  */
-    Lisp_Object window_end_vpos;
-
     /* Display-table to use for displaying chars in this window.
        Nil means use the buffer's own display-table.  */
     Lisp_Object display_table;
@@ -261,10 +229,6 @@ struct window
        as the normal  may yield a matrix which is too small.  */
     int nrows_scale_factor, ncols_scale_factor;
 
-    /* Cursor position as of last update that completed without
-       pause.  This is the position of last_point.  */
-    struct cursor_pos last_cursor;
-
     /* Intended cursor position.   This is a position within the
        glyph matrix.  */
     struct cursor_pos cursor;
@@ -272,6 +236,13 @@ struct window
     /* Where the cursor actually is.  */
     struct cursor_pos phys_cursor;
 
+    /* Internally used for redisplay purposes.  */
+    struct cursor_pos output_cursor;
+
+    /* Vertical cursor position as of last update that completed
+       without pause.  This is the position of last_point.  */
+    int last_cursor_vpos;
+
     /* Cursor type and width of last cursor drawn on the window.
        Used for X and w32 frames; -1 initially.  */
     int phys_cursor_type, phys_cursor_width;
@@ -279,9 +250,41 @@ struct window
     /* This is handy for undrawing the cursor.  */
     int phys_cursor_ascent, phys_cursor_height;
 
+    /* Width of left and right fringes, in pixels.
+       A value of -1 means use frame values.  */
+    int left_fringe_width;
+    int right_fringe_width;
+
+    /* Width of left and right marginal areas in columns.
+       A value of 0 means no margin.  */
+    int left_margin_cols;
+    int right_margin_cols;
+
+    /* Pixel width of scroll bars.
+       A value of -1 means use frame values.  */
+    int scroll_bar_width;
+
+    /* Effective height of the mode line, or -1 if not known.  */
+    int mode_line_height;
+
+    /* Effective height of the header line, or -1 if not known.  */
+    int header_line_height;
+
+    /* Z - the buffer position of the last glyph in the current
+       matrix of W.  Only valid if window_end_valid is nonzero.  */
+    ptrdiff_t window_end_pos;
+
+    /* Glyph matrix row of the last glyph in the current matrix
+       of W.  Only valid if window_end_valid is nonzero.  */
+    int window_end_vpos;
+
     /* Non-zero if this window is a minibuffer window.  */
     unsigned mini : 1;
 
+    /* Meaningful only if contents is a window, non-zero if this
+       internal window is used in horizontal combination.  */
+    unsigned horizontal : 1;
+
     /* Non-zero means must regenerate mode line of this window.  */
     unsigned update_mode_line : 1;
 
@@ -322,11 +325,6 @@ struct window
        Currently only used for menu bar windows of frames.  */
     unsigned pseudo_window_p : 1;
 
-    /* 1 means the window start of this window is frozen and may not
-       be changed during redisplay.  If point is not in the window,
-       accept that.  */
-    unsigned frozen_window_start_p : 1;
-
     /* Non-zero means fringes are drawn outside display margins.
        Otherwise draw them between margin areas and text.  */
     unsigned fringes_outside_margins : 1;
@@ -377,16 +375,6 @@ wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
   w->vertical_scroll_bar = val;
 }
 WINDOW_INLINE void
-wset_window_end_pos (struct window *w, Lisp_Object val)
-{
-  w->window_end_pos = val;
-}
-WINDOW_INLINE void
-wset_window_end_vpos (struct window *w, Lisp_Object val)
-{
-  w->window_end_vpos = val;
-}
-WINDOW_INLINE void
 wset_prev_buffers (struct window *w, Lisp_Object val)
 {
   w->prev_buffers = val;
@@ -428,6 +416,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 
 /* A handy macro.  */
 
+/* Non-zero if W is leaf (carry the buffer).  */
+
+#define WINDOW_LEAF_P(W) \
+  (BUFFERP ((W)->contents))
+
+/* Non-zero if W is a member of horizontal combination.  */
+
+#define WINDOW_HORIZONTAL_COMBINATION_P(W) \
+  (WINDOWP ((W)->contents) && (W)->horizontal)
+
+/* Non-zero if W is a member of vertical combination.  */
+
+#define WINDOW_VERTICAL_COMBINATION_P(W) \
+  (WINDOWP ((W)->contents) && !(W)->horizontal)
+
 #define WINDOW_XFRAME(W) \
   (XFRAME (WINDOW_FRAME ((W))))
 
@@ -512,15 +515,23 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 
 /* 1 if W is a menu bar window.  */
 
+#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
 #define WINDOW_MENU_BAR_P(W) \
   (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
    && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
+#else
+/* No menu bar windows if X toolkit is in use.  */
+#define WINDOW_MENU_BAR_P(W) (0)
+#endif
 
 /* 1 if W is a tool bar window.  */
-
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
 #define WINDOW_TOOL_BAR_P(W) \
   (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
    && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
+#else
+#define WINDOW_TOOL_BAR_P(W) (0)
+#endif
 
 /* Return the frame y-position at which window W starts.
    This includes a header line, if any.  */
@@ -591,33 +602,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 
 /* Width of left margin area in columns.  */
 
-#define WINDOW_LEFT_MARGIN_COLS(W)     \
-  (NILP (W->left_margin_cols)          \
-   ? 0                                 \
-   : XINT (W->left_margin_cols))
+#define WINDOW_LEFT_MARGIN_COLS(W) (W->left_margin_cols)
 
 /* Width of right marginal area in columns.  */
 
-#define WINDOW_RIGHT_MARGIN_COLS(W)    \
-  (NILP (W->right_margin_cols)         \
-   ? 0                                 \
-   : XINT (W->right_margin_cols))
+#define WINDOW_RIGHT_MARGIN_COLS(W) (W->right_margin_cols)
 
 /* Width of left margin area in pixels.  */
 
-#define WINDOW_LEFT_MARGIN_WIDTH(W)    \
-  (NILP (W->left_margin_cols)          \
-   ? 0                                 \
-   : (XINT (W->left_margin_cols)       \
-      * WINDOW_FRAME_COLUMN_WIDTH (W)))
+#define WINDOW_LEFT_MARGIN_WIDTH(W)                    \
+  (W->left_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
 
 /* Width of right marginal area in pixels.  */
 
-#define WINDOW_RIGHT_MARGIN_WIDTH(W)   \
-  (NILP (W->right_margin_cols)         \
-   ? 0                                 \
-   : (XINT (W->right_margin_cols)      \
-      * WINDOW_FRAME_COLUMN_WIDTH (W)))
+#define WINDOW_RIGHT_MARGIN_WIDTH(W)                   \
+  (W->right_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
 
 /* Total width of fringes reserved for drawing truncation bitmaps,
    continuation bitmaps and alike.  The width is in canonical char
@@ -626,10 +625,10 @@ wset_next_buffers (struct window *w, Lisp_Object val)
    able to split windows horizontally nicely.  */
 
 #define WINDOW_FRINGE_COLS(W)                  \
-  ((INTEGERP (W->left_fringe_width)            \
-    || INTEGERP (W->right_fringe_width))       \
-   ? ((WINDOW_LEFT_FRINGE_WIDTH (W)            \
-       + WINDOW_RIGHT_FRINGE_WIDTH (W)         \
+  ((W->left_fringe_width >= 0                  \
+    && W->right_fringe_width >= 0)             \
+   ? ((W->left_fringe_width                    \
+       + W->right_fringe_width                 \
        + WINDOW_FRAME_COLUMN_WIDTH (W) - 1)    \
       / WINDOW_FRAME_COLUMN_WIDTH (W))         \
    : FRAME_FRINGE_COLS (WINDOW_XFRAME (W)))
@@ -649,13 +648,11 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 /* Pixel-width of the left and right fringe.  */
 
 #define WINDOW_LEFT_FRINGE_WIDTH(W)                    \
-  (INTEGERP (W->left_fringe_width)                     \
-   ? XFASTINT (W->left_fringe_width)                   \
+  (W->left_fringe_width >= 0 ? W->left_fringe_width    \
    : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
 
 #define WINDOW_RIGHT_FRINGE_WIDTH(W)                   \
-  (INTEGERP (W->right_fringe_width)                    \
-   ? XFASTINT (W->right_fringe_width)                  \
+  (W->right_fringe_width >= 0 ? W->right_fringe_width  \
    : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
 
 /* Total width of fringes in pixels.  */
@@ -700,8 +697,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
    nonzero.  */
 
 #define WINDOW_CONFIG_SCROLL_BAR_WIDTH(w)              \
-  (INTEGERP (w->scroll_bar_width)                      \
-   ? XFASTINT (w->scroll_bar_width)                    \
+  (w->scroll_bar_width >= 0 ? w->scroll_bar_width      \
    : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (w)))
 
 /* Width that a scroll bar in window W should have, if there is one.
@@ -709,8 +705,8 @@ wset_next_buffers (struct window *w, Lisp_Object val)
    this is still nonzero.  */
 
 #define WINDOW_CONFIG_SCROLL_BAR_COLS(w)               \
-  (INTEGERP (w->scroll_bar_width)                      \
-   ? ((XFASTINT (w->scroll_bar_width)                  \
+  (w->scroll_bar_width >= 0                            \
+   ? ((w->scroll_bar_width                             \
        + WINDOW_FRAME_COLUMN_WIDTH (w) - 1)            \
       / WINDOW_FRAME_COLUMN_WIDTH (w))                 \
    : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (w)))
@@ -833,13 +829,25 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X)     \
   (window_box_left ((W), TEXT_AREA) + (X))
 
-/* This is the window in which the terminal's cursor should
-   be left when nothing is being done with it.  This must
-   always be a leaf window, and its buffer is selected by
-   the top level editing loop at the end of each command.
+/* Nonzero if the background of the window W's fringe that is adjacent to
+   a scroll bar is extended to the gap between the fringe and the bar.  */
 
-   This value is always the same as
-    FRAME_SELECTED_WINDOW (selected_frame).  */
+#define WINDOW_FRINGE_EXTENDED_P(w)                    \
+  (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)          \
+   ? (WINDOW_LEFTMOST_P (w)                            \
+      && WINDOW_LEFT_FRINGE_WIDTH (w)                  \
+      && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)       \
+         || WINDOW_LEFT_MARGIN_COLS (w) == 0))         \
+   : (WINDOW_RIGHTMOST_P (w)                           \
+      && WINDOW_RIGHT_FRINGE_WIDTH (w)                 \
+      && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)       \
+         || WINDOW_RIGHT_MARGIN_COLS (w) == 0)))
+
+/* This is the window in which the terminal's cursor should be left when
+   nothing is being done with it.  This must always be a leaf window, and its
+   buffer is selected by the top level editing loop at the end of each command.
+
+   This value is always the same as FRAME_SELECTED_WINDOW (selected_frame).  */
 
 extern Lisp_Object selected_window;
 
@@ -860,20 +868,12 @@ extern Lisp_Object minibuf_window;
 
 extern Lisp_Object minibuf_selected_window;
 
-/* Window that the mouse is over (nil if no mouse support).  */
-
-extern Lisp_Object Vmouse_window;
-
-/* Last mouse-click event (nil if no mouse support).  */
-
-extern Lisp_Object Vmouse_event;
-
 extern Lisp_Object make_window (void);
 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
                                             enum window_part *, bool);
 extern void resize_frame_windows (struct frame *, int, bool);
+extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
-extern void freeze_window_starts (struct frame *, bool);
 extern void grow_mini_window (struct window *, int);
 extern void shrink_mini_window (struct window *);
 extern int window_relative_x_coord (struct window *, enum window_part, int);
@@ -910,10 +910,6 @@ extern int update_mode_lines;
 
 extern int windows_or_buffers_changed;
 
-/* Nonzero means a frame's cursor type has been changed.  */
-
-extern int cursor_type_changed;
-
 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
    minimum allowable size.  */
 
@@ -926,20 +922,17 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols);
 struct glyph *get_phys_cursor_glyph (struct window *w);
 
 /* Value is non-zero if WINDOW is a valid window.  */
-#define WINDOW_VALID_P(WINDOW)                         \
-  (WINDOWP (WINDOW)                                    \
-   && (!NILP (XWINDOW (WINDOW)->buffer)                        \
-       || !NILP (XWINDOW (WINDOW)->vchild)             \
-       || !NILP (XWINDOW (WINDOW)->hchild)))
-
-/* A window of any sort, leaf or interior, is "valid" if one
-   of its buffer, vchild, or hchild members is non-nil.  */
+#define WINDOW_VALID_P(WINDOW)                                 \
+  (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents))     \
+
+/* A window of any sort, leaf or interior, is "valid" if its
+   contents slot is non-nil.  */
 #define CHECK_VALID_WINDOW(WINDOW)                             \
   CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
 
 /* Value is non-zero if WINDOW is a live window.  */
 #define WINDOW_LIVE_P(WINDOW)                                  \
-  (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer))
+  (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
 
 /* A window is "live" if and only if it shows a buffer.  */
 #define CHECK_LIVE_WINDOW(WINDOW)                              \
@@ -947,7 +940,7 @@ struct glyph *get_phys_cursor_glyph (struct window *w);
 
 /* These used to be in lisp.h.  */
 
-extern Lisp_Object Qwindowp, Qwindow_live_p;
+extern Lisp_Object Qwindow_live_p;
 extern Lisp_Object Vwindow_list;
 
 extern struct window *decode_live_window (Lisp_Object);
@@ -961,11 +954,28 @@ extern void replace_buffer_in_windows (Lisp_Object);
 extern void replace_buffer_in_windows_safely (Lisp_Object);
 /* This looks like a setter, but it is a bit special.  */
 extern void wset_buffer (struct window *, Lisp_Object);
+extern bool window_outdated (struct window *);
 extern void init_window_once (void);
 extern void init_window (void);
 extern void syms_of_window (void);
 extern void keys_of_window (void);
 
+/* Move cursor to row/column position VPOS/HPOS, pixel coordinates
+   Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y
+   are window-relative pixel positions.  This is always done during
+   window update, so the position is the future output cursor position
+   for currently updated window W.  */
+
+WINDOW_INLINE void
+output_cursor_to (struct window *w, int vpos, int hpos, int y, int x)
+{
+  eassert (w);
+  w->output_cursor.hpos = hpos;
+  w->output_cursor.vpos = vpos;
+  w->output_cursor.x = x;
+  w->output_cursor.y = y;
+}
+
 INLINE_HEADER_END
 
 #endif /* not WINDOW_H_INCLUDED */