aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.h
diff options
context:
space:
mode:
authorDmitry Antipov2013-03-28 18:04:49 +0400
committerDmitry Antipov2013-03-28 18:04:49 +0400
commite74aeda863cd6896e06e92586f87b45d63d67d15 (patch)
treeb6a57d0d39f085274c0953623f7d2924f4813db4 /src/window.h
parent9d42d31f24040706fe965e7c586b640471b12861 (diff)
downloademacs-e74aeda863cd6896e06e92586f87b45d63d67d15.tar.gz
emacs-e74aeda863cd6896e06e92586f87b45d63d67d15.zip
* window.h (struct window): Replace hchild, vchild and buffer slots
with the only contents slot. This is possible because each valid window may have either the child window (in vertical or horizontal combination) or buffer to display (for the leaf window). Using that, a lof of operations to traverse and/or change window hierarchies may be simplified. New member horizontal is used to distinguish between horizontal and vertical combinations of internal windows. (WINDOW_LEAF_P, WINDOW_HORIZONTAL_COMBINATION_P) (WINDOW_VERTICAL_COMBINATION_P): New macros. (WINDOW_VALID_P, WINDOW_LIVE_P): Adjust to match struct window changes. * window.c (wset_hchild, wset_vchild): Remove. Adjust all users. Use contents slot, not buffer, where appropriate. (wset_combination): New function. (wset_buffer): Add eassert. (Fframe_first_window): Simplify the loop reaching first window. (Fwindow_buffer): Use WINDOW_LEAF_P. (Fwindow_top_child): Use WINDOW_VERTICAL_COMBINATION_P. (Fwindow_left_child): Use WINDOW_HORIZONTAL_COMBINATION_P. (unshow_buffer): Convert initial debugging check to eassert. (replace_window, recombine_windows, Fdelete_other_windows_internal) (make_parent_window, window_resize_check, window_resize_apply) (resize_frame_windows, Fsplit_window_internal, Fdelete_window_internal) (Fset_window_configuration, delete_all_child_windows, save_window_save): Adjust to match struct window changes. (window_loop): Check for broken markers in CHECK_ALL_WINDOWS. (mark_window_cursors_off, count_windows, get_leaf_windows) (foreach_window_1): Simplify the loop. * alloc.c (mark_object): Do not check for the leaf window because internal windows has no glyph matrices anyway. * dispnew.c (clear_window_matrices, showing_window_margins_p) (allocate_matrices_for_window_redisplay, fake_current_matrices) (allocate_matrices_for_frame_redisplay, free_window_matrices) (build_frame_matrix_from_window_tree, mirror_make_current) (frame_row_to_window, mirror_line_dance, check_window_matrix_pointers) (update_window_tree, set_window_update_flags): Simplify the loop. (sync_window_with_frame_matrix_rows): Enforce live window. Use contents slot, not buffer, where appropriate. * frame.c (set_menu_bar_lines_1): Use WINDOW_VERTICAL_COMBINATION_P and WINDOW_HORIZONTAL_COMBINATION_P. (make_frame_visible_1): Simplify the loop. Use contents slot, not buffer, where appropriate. * xdisp.c (hscroll_window_tree, mark_window_display_accurate) (redisplay_windows, redisplay_mode_lines, update_cursor_in_window_tree) (expose_window_tree): Likewise. Use contents slot, not buffer, where appropriate. * textprop.c (get_char_property_and_overlay): Add CHECK_LIVE_WINDOW to avoid deleted windows. Use contents slot instead of buffer. * buffer.c, dispextern.h, editfns.c, fileio.c, font.c, fringe.c: * indent.c, insdel.c, keyboard.c, keymap.c, minibuf.c, msdos.c: * nsfns.m, nsmenu.m, nsterm.m, print.c, w32fns.c, w32menu.c, xfaces.c: * xfns.c, xmenu.c: Use contents slot, not buffer, where appropriate.
Diffstat (limited to 'src/window.h')
-rw-r--r--src/window.h58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/window.h b/src/window.h
index 71c438ff7f2..411756f045e 100644
--- a/src/window.h
+++ b/src/window.h
@@ -41,14 +41,13 @@ They are deleted only by calling delete-window on them (but
41this can be done implicitly). Combination windows can be created 41this can be done implicitly). Combination windows can be created
42and deleted at any time. 42and deleted at any time.
43 43
44A leaf window has a non-nil buffer field, and also 44A leaf window has a buffer stored in contents field and markers in its start
45 has markers in its start and pointm fields. Non-leaf windows 45and pointm fields. Non-leaf windows have nil in the latter two fields.
46 have nil in these fields.
47 46
48Non-leaf windows are either vertical or horizontal combinations. 47Non-leaf windows are either vertical or horizontal combinations.
49 48
50A vertical combination window has children that are arranged on the frame 49A vertical combination window has children that are arranged on the frame
51one above the next. Its vchild field points to the uppermost child. 50one above the next. Its contents field points to the uppermost child.
52The parent field of each of the children points to the vertical 51The parent field of each of the children points to the vertical
53combination window. The next field of each child points to the 52combination window. The next field of each child points to the
54child below it, or is nil for the lowest child. The prev field 53child 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
56highest child. 55highest child.
57 56
58A horizontal combination window has children that are side by side. 57A horizontal combination window has children that are side by side.
59Its hchild field points to the leftmost child. In each child 58Its contents field points to the leftmost child. In each child
60the next field points to the child to the right and the prev field 59the next field points to the child to the right and the prev field
61points to the child to the left. 60points to the child to the left.
62 61
@@ -78,7 +77,7 @@ the root window is the minibuf window. On minibufferless screens or
78minibuffer-only screens, the root window and the minibuffer window are 77minibuffer-only screens, the root window and the minibuffer window are
79one and the same, so its prev and next members are nil. 78one and the same, so its prev and next members are nil.
80 79
81A dead window has its buffer, hchild, and vchild windows all nil. */ 80A dead window has its contents field set to nil. */
82 81
83struct cursor_pos 82struct cursor_pos
84{ 83{
@@ -102,13 +101,6 @@ struct window
102 Lisp_Object next; 101 Lisp_Object next;
103 Lisp_Object prev; 102 Lisp_Object prev;
104 103
105 /* First child of this window: vchild is used if this is a vertical
106 combination, hchild if this is a horizontal combination. Of the
107 fields vchild, hchild and buffer, one and only one is non-nil
108 unless the window is dead. */
109 Lisp_Object hchild;
110 Lisp_Object vchild;
111
112 /* The window this one is a child of. */ 104 /* The window this one is a child of. */
113 Lisp_Object parent; 105 Lisp_Object parent;
114 106
@@ -123,10 +115,8 @@ struct window
123 Lisp_Object new_total; 115 Lisp_Object new_total;
124 Lisp_Object new_normal; 116 Lisp_Object new_normal;
125 117
126 /* The buffer displayed in this window. Of the fields vchild, 118 /* May be buffer, window, or nil. */
127 hchild and buffer, one and only one is non-nil unless the window 119 Lisp_Object contents;
128 is dead. */
129 Lisp_Object buffer;
130 120
131 /* A marker pointing to where in the text to start displaying. 121 /* A marker pointing to where in the text to start displaying.
132 BIDI Note: This is the _logical-order_ start, i.e. the smallest 122 BIDI Note: This is the _logical-order_ start, i.e. the smallest
@@ -282,6 +272,10 @@ struct window
282 /* Non-zero if this window is a minibuffer window. */ 272 /* Non-zero if this window is a minibuffer window. */
283 unsigned mini : 1; 273 unsigned mini : 1;
284 274
275 /* Meaningful only if contents is a window, non-zero if this
276 internal window is used in horizontal combination. */
277 unsigned horizontal : 1;
278
285 /* Non-zero means must regenerate mode line of this window. */ 279 /* Non-zero means must regenerate mode line of this window. */
286 unsigned update_mode_line : 1; 280 unsigned update_mode_line : 1;
287 281
@@ -428,6 +422,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
428 422
429/* A handy macro. */ 423/* A handy macro. */
430 424
425/* Non-zero if W is leaf (carry the buffer). */
426
427#define WINDOW_LEAF_P(W) \
428 (BUFFERP ((W)->contents))
429
430/* Non-zero if W is a member of horizontal combination. */
431
432#define WINDOW_HORIZONTAL_COMBINATION_P(W) \
433 (WINDOWP ((W)->contents) && (W)->horizontal)
434
435/* Non-zero if W is a member of vertical combination. */
436
437#define WINDOW_VERTICAL_COMBINATION_P(W) \
438 (WINDOWP ((W)->contents) && !(W)->horizontal)
439
431#define WINDOW_XFRAME(W) \ 440#define WINDOW_XFRAME(W) \
432 (XFRAME (WINDOW_FRAME ((W)))) 441 (XFRAME (WINDOW_FRAME ((W))))
433 442
@@ -931,20 +940,17 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols);
931struct glyph *get_phys_cursor_glyph (struct window *w); 940struct glyph *get_phys_cursor_glyph (struct window *w);
932 941
933/* Value is non-zero if WINDOW is a valid window. */ 942/* Value is non-zero if WINDOW is a valid window. */
934#define WINDOW_VALID_P(WINDOW) \ 943#define WINDOW_VALID_P(WINDOW) \
935 (WINDOWP (WINDOW) \ 944 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \
936 && (!NILP (XWINDOW (WINDOW)->buffer) \ 945
937 || !NILP (XWINDOW (WINDOW)->vchild) \ 946/* A window of any sort, leaf or interior, is "valid" if its
938 || !NILP (XWINDOW (WINDOW)->hchild))) 947 contents slot is non-nil. */
939
940/* A window of any sort, leaf or interior, is "valid" if one
941 of its buffer, vchild, or hchild members is non-nil. */
942#define CHECK_VALID_WINDOW(WINDOW) \ 948#define CHECK_VALID_WINDOW(WINDOW) \
943 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) 949 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
944 950
945/* Value is non-zero if WINDOW is a live window. */ 951/* Value is non-zero if WINDOW is a live window. */
946#define WINDOW_LIVE_P(WINDOW) \ 952#define WINDOW_LIVE_P(WINDOW) \
947 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) 953 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
948 954
949/* A window is "live" if and only if it shows a buffer. */ 955/* A window is "live" if and only if it shows a buffer. */
950#define CHECK_LIVE_WINDOW(WINDOW) \ 956#define CHECK_LIVE_WINDOW(WINDOW) \