Separate read and write access to Lisp_Object slots of struct window.
[bpt/emacs.git] / src / window.h
CommitLineData
83b2229f 1/* Window definitions for GNU Emacs.
acaf905b 2 Copyright (C) 1985-1986, 1993, 1995, 1997-2012
8cabe764 3 Free Software Foundation, Inc.
83b2229f
JB
4
5This file is part of GNU Emacs.
6
b9b1cc14 7GNU Emacs is free software: you can redistribute it and/or modify
83b2229f 8it under the terms of the GNU General Public License as published by
b9b1cc14
GM
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
83b2229f
JB
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
b9b1cc14 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
83b2229f 19
f43dd834
GM
20#ifndef WINDOW_H_INCLUDED
21#define WINDOW_H_INCLUDED
22
23#include "dispextern.h"
83b2229f 24
6000501b
KS
25extern Lisp_Object Qleft, Qright;
26
83b2229f
JB
27/* Windows are allocated as if they were vectors, but then the
28Lisp data type is changed to Lisp_Window. They are garbage
29collected along with the vectors.
30
31All windows in use are arranged into a tree, with pointers up and down.
32
33Windows that are leaves of the tree are actually displayed
34and show the contents of buffers. Windows that are not leaves
35are used for representing the way groups of leaf windows are
44fa5b1e 36arranged on the frame. Leaf windows never become non-leaves.
83b2229f
JB
37They are deleted only by calling delete-window on them (but
38this can be done implicitly). Combination windows can be created
39and deleted at any time.
40
41A leaf window has a non-nil buffer field, and also
42 has markers in its start and pointm fields. Non-leaf windows
43 have nil in these fields.
44
45Non-leaf windows are either vertical or horizontal combinations.
46
44fa5b1e 47A vertical combination window has children that are arranged on the frame
83b2229f
JB
48one above the next. Its vchild field points to the uppermost child.
49The parent field of each of the children points to the vertical
50combination window. The next field of each child points to the
51child below it, or is nil for the lowest child. The prev field
52of each child points to the child above it, or is nil for the
53highest child.
54
55A horizontal combination window has children that are side by side.
56Its hchild field points to the leftmost child. In each child
57the next field points to the child to the right and the prev field
58points to the child to the left.
59
60The children of a vertical combination window may be leaf windows
61or horizontal combination windows. The children of a horizontal
62combination window may be leaf windows or vertical combination windows.
63
64At the top of the tree are two windows which have nil as parent.
65The second of these is minibuf_window. The first one manages all
44fa5b1e 66the frame area that is not minibuffer, and is called the root window.
83b2229f
JB
67Different windows can be the root at different times;
68initially the root window is a leaf window, but if more windows
69are created then that leaf window ceases to be root and a newly
70made combination window becomes root instead.
71
fbfed6f0
JB
72In any case, on screens which have an ordinary window and a
73minibuffer, prev of the minibuf window is the root window and next of
74the root window is the minibuf window. On minibufferless screens or
75minibuffer-only screens, the root window and the minibuffer window are
27daff1e 76one and the same, so its prev and next members are nil.
83b2229f 77
27daff1e 78A dead window has its buffer, hchild, and vchild windows all nil. */
83b2229f 79
f43dd834
GM
80struct cursor_pos
81{
82 /* Pixel position. These are always window relative. */
83 int x, y;
84
85 /* Glyph matrix position. */
86 int hpos, vpos;
87};
88
077288cf
DA
89/* Most code should use these macros to access Lisp fields
90 in struct window. WGET should not be used as lvalue. */
3a45383a 91
077288cf
DA
92#define WGET(f, field) \
93 (eassert (offsetof (struct window, field ## _) \
94 < offsetof (struct window, current_matrix)), \
95 ((f)->INTERNAL_FIELD (field)))
96
97#define WSET(w, field, value) ((w)->INTERNAL_FIELD (field) = (value))
3a45383a 98
83b2229f
JB
99struct window
100 {
eab3844f 101 /* This is for Lisp; the terminal code does not refer to it. */
b102ceb1 102 struct vectorlike_header header;
eab3844f 103
44fa5b1e 104 /* The frame this window is on. */
3a45383a 105 Lisp_Object INTERNAL_FIELD (frame);
496e208e 106
496e208e
MR
107 /* Following (to right or down) and preceding (to left or up) child
108 at same level of tree. */
3a45383a
DA
109 Lisp_Object INTERNAL_FIELD (next);
110 Lisp_Object INTERNAL_FIELD (prev);
496e208e
MR
111
112 /* First child of this window: vchild is used if this is a vertical
113 combination, hchild if this is a horizontal combination. Of the
114 fields vchild, hchild and buffer, one and only one is non-nil
115 unless the window is dead. */
3a45383a
DA
116 Lisp_Object INTERNAL_FIELD (hchild);
117 Lisp_Object INTERNAL_FIELD (vchild);
496e208e
MR
118
119 /* The window this one is a child of. */
3a45383a 120 Lisp_Object INTERNAL_FIELD (parent);
496e208e
MR
121
122 /* The upper left corner coordinates of this window, as integers
123 relative to upper left corner of frame = 0, 0. */
3a45383a
DA
124 Lisp_Object INTERNAL_FIELD (left_col);
125 Lisp_Object INTERNAL_FIELD (top_line);
496e208e
MR
126
127 /* The size of the window. */
3a45383a
DA
128 Lisp_Object INTERNAL_FIELD (total_lines);
129 Lisp_Object INTERNAL_FIELD (total_cols);
496e208e
MR
130
131 /* The normal size of the window. */
3a45383a
DA
132 Lisp_Object INTERNAL_FIELD (normal_lines);
133 Lisp_Object INTERNAL_FIELD (normal_cols);
496e208e
MR
134
135 /* New sizes of the window. */
3a45383a
DA
136 Lisp_Object INTERNAL_FIELD (new_total);
137 Lisp_Object INTERNAL_FIELD (new_normal);
496e208e
MR
138
139 /* The buffer displayed in this window. Of the fields vchild,
140 hchild and buffer, one and only one is non-nil unless the window
141 is dead. */
3a45383a 142 Lisp_Object INTERNAL_FIELD (buffer);
496e208e 143
6bff6497
EZ
144 /* A marker pointing to where in the text to start displaying.
145 BIDI Note: This is the _logical-order_ start, i.e. the smallest
146 buffer position visible in the window, not necessarily the
147 character displayed in the top left corner of the window. */
3a45383a 148 Lisp_Object INTERNAL_FIELD (start);
496e208e 149
83b2229f
JB
150 /* A marker pointing to where in the text point is in this window,
151 used only when the window is not selected.
152 This exists so that when multiple windows show one buffer
153 each one can have its own value of point. */
3a45383a 154 Lisp_Object INTERNAL_FIELD (pointm);
496e208e 155
496e208e
MR
156 /* No permanent meaning; used by save-window-excursion's
157 bookkeeping. */
3a45383a 158 Lisp_Object INTERNAL_FIELD (temslot);
496e208e 159
a3c87d4e 160 /* This window's vertical scroll bar. This field is only for use
7c299e7a 161 by the window-system-dependent code which implements the
a3c87d4e
JB
162 scroll bars; it can store anything it likes here. If this
163 window is newly created and we haven't displayed a scroll bar in
164 it yet, or if the frame doesn't have any scroll bars, this is nil. */
3a45383a 165 Lisp_Object INTERNAL_FIELD (vertical_scroll_bar);
20a558dc 166
f43dd834
GM
167 /* Width of left and right marginal areas. A value of nil means
168 no margin. */
3a45383a
DA
169 Lisp_Object INTERNAL_FIELD (left_margin_cols);
170 Lisp_Object INTERNAL_FIELD (right_margin_cols);
6000501b
KS
171
172 /* Width of left and right fringes.
173 A value of nil or t means use frame values. */
3a45383a
DA
174 Lisp_Object INTERNAL_FIELD (left_fringe_width);
175 Lisp_Object INTERNAL_FIELD (right_fringe_width);
6000501b
KS
176
177 /* Pixel width of scroll bars.
178 A value of nil or t means use frame values. */
3a45383a 179 Lisp_Object INTERNAL_FIELD (scroll_bar_width);
496e208e 180
6000501b
KS
181 /* Type of vertical scroll bar. A value of nil means
182 no scroll bar. A value of t means use frame value. */
3a45383a 183 Lisp_Object INTERNAL_FIELD (vertical_scroll_bar_type);
f43dd834 184
f43dd834
GM
185 /* Z - the buffer position of the last glyph in the current matrix
186 of W. Only valid if WINDOW_END_VALID is not nil. */
3a45383a 187 Lisp_Object INTERNAL_FIELD (window_end_pos);
f43dd834
GM
188 /* Glyph matrix row of the last glyph in the current matrix
189 of W. Only valid if WINDOW_END_VALID is not nil. */
3a45383a 190 Lisp_Object INTERNAL_FIELD (window_end_vpos);
83b2229f
JB
191 /* t if window_end_pos is truly valid.
192 This is nil if nontrivial redisplay is preempted
44fa5b1e
JB
193 since in that case the frame image that window_end_pos
194 did not get onto the frame. */
3a45383a 195 Lisp_Object INTERNAL_FIELD (window_end_valid);
496e208e 196
83b2229f
JB
197 /* Display-table to use for displaying chars in this window.
198 Nil means use the buffer's own display-table. */
3a45383a 199 Lisp_Object INTERNAL_FIELD (display_table);
496e208e 200
c98ff5dd
DA
201 /* Non-nil usually means window is marked as dedicated.
202 Note Lisp code may set this to something beyond Qnil
203 and Qt, so bitfield can't be used here. */
3a45383a 204 Lisp_Object INTERNAL_FIELD (dedicated);
496e208e
MR
205
206 /* Line number and position of a line somewhere above the top of the
207 screen. If this field is nil, it means we don't have a base
208 line. */
3a45383a 209 Lisp_Object INTERNAL_FIELD (base_line_number);
e024395e
RS
210 /* If this field is nil, it means we don't have a base line.
211 If it is a buffer, it means don't display the line number
212 as long as the window shows that buffer. */
3a45383a 213 Lisp_Object INTERNAL_FIELD (base_line_pos);
496e208e 214
096855a6
RS
215 /* If we have highlighted the region (or any part of it),
216 this is the mark position that we used, as an integer. */
3a45383a 217 Lisp_Object INTERNAL_FIELD (region_showing);
496e208e 218
1262267a
KH
219 /* The column number currently displayed in this window's mode line,
220 or nil if column numbers are not being displayed. */
3a45383a 221 Lisp_Object INTERNAL_FIELD (column_number_displayed);
496e208e 222
a3bee872
RS
223 /* If redisplay in this window goes beyond this buffer position,
224 must run the redisplay-end-trigger-hook. */
3a45383a 225 Lisp_Object INTERNAL_FIELD (redisplay_end_trigger);
177c0ea7 226
b6f67890 227 /* t means this window's child windows are not (re-)combined. */
3a45383a 228 Lisp_Object INTERNAL_FIELD (combination_limit);
496e208e
MR
229
230 /* Alist of <buffer, window-start, window-point> triples listing
231 buffers previously shown in this window. */
3a45383a 232 Lisp_Object INTERNAL_FIELD (prev_buffers);
496e208e
MR
233
234 /* List of buffers re-shown in this window. */
3a45383a 235 Lisp_Object INTERNAL_FIELD (next_buffers);
496e208e 236
e1dbe924 237 /* An alist with parameters. */
3a45383a 238 Lisp_Object INTERNAL_FIELD (window_parameters);
e6841c3b 239
f43dd834
GM
240 /* No Lisp data may follow below this point without changing
241 mark_object in alloc.c. The member current_matrix must be the
242 first non-Lisp member. */
243
244 /* Glyph matrices. */
245 struct glyph_matrix *current_matrix;
246 struct glyph_matrix *desired_matrix;
247
45942c7d
DA
248 /* Number saying how recently window was selected. */
249 int use_time;
250
251 /* Unique number of window assigned when it was created. */
252 int sequence_number;
253
80b00b08 254 /* Number of columns display within the window is scrolled to the left. */
ea2ac797 255 ptrdiff_t hscroll;
80b00b08
DA
256
257 /* Minimum hscroll for automatic hscrolling. This is the value
258 the user has set, by set-window-hscroll for example. */
ea2ac797 259 ptrdiff_t min_hscroll;
80b00b08
DA
260
261 /* Displayed buffer's text modification events counter as of last time
262 display completed. */
263 EMACS_INT last_modified;
264
265 /* Displayed buffer's overlays modification events counter as of last
266 complete update. */
267 EMACS_INT last_overlay_modified;
268
269 /* Value of point at that time. Since this is a position in a buffer,
270 it should be positive. */
271 ptrdiff_t last_point;
272
71a0ff9a
KS
273 /* Scaling factor for the glyph_matrix size calculation in this window.
274 Used if window contains many small images or uses proportional fonts,
275 as the normal may yield a matrix which is too small. */
276 int nrows_scale_factor, ncols_scale_factor;
277
f43dd834
GM
278 /* Cursor position as of last update that completed without
279 pause. This is the position of last_point. */
280 struct cursor_pos last_cursor;
281
282 /* Intended cursor position. This is a position within the
283 glyph matrix. */
284 struct cursor_pos cursor;
177c0ea7 285
f43dd834
GM
286 /* Where the cursor actually is. */
287 struct cursor_pos phys_cursor;
177c0ea7
JB
288
289 /* Cursor type and width of last cursor drawn on the window.
7e913f91
KS
290 Used for X and w32 frames; -1 initially. */
291 int phys_cursor_type, phys_cursor_width;
f43dd834
GM
292
293 /* This is handy for undrawing the cursor. */
294 int phys_cursor_ascent, phys_cursor_height;
177c0ea7 295
c98ff5dd
DA
296 /* Non-zero if this window is a minibuffer window. */
297 unsigned mini : 1;
298
299 /* Non-zero means must regenerate mode line of this window */
300 unsigned update_mode_line : 1;
301
302 /* Non-nil if the buffer was "modified" when the window
303 was last updated. */
304 unsigned last_had_star : 1;
305
306 /* Non-zero means current value of `start'
307 was the beginning of a line when it was chosen. */
308 unsigned start_at_line_beg : 1;
309
310 /* Non-zero means next redisplay must use the value of start
311 set up for it in advance. Set by scrolling commands. */
312 unsigned force_start : 1;
313
314 /* Non-zero means we have explicitly changed the value of start,
315 but that the next redisplay is not obliged to use the new value.
316 This is used in Fdelete_other_windows to force a call to
317 Vwindow_scroll_functions; also by Frecenter with argument. */
318 unsigned optional_new_start : 1;
319
f43dd834
GM
320 /* Non-zero means the cursor is currently displayed. This can be
321 set to zero by functions overpainting the cursor image. */
322 unsigned phys_cursor_on_p : 1;
323
324 /* 0 means cursor is logically on, 1 means it's off. Used for
325 blinking cursor. */
326 unsigned cursor_off_p : 1;
327
328 /* Value of cursor_off_p as of the last redisplay. */
329 unsigned last_cursor_off_p : 1;
330
331 /* 1 means desired matrix has been build and window must be
332 updated in update_frame. */
333 unsigned must_be_updated_p : 1;
334
335 /* Flag indicating that this window is not a real one.
336 Currently only used for menu bar windows of frames. */
337 unsigned pseudo_window_p : 1;
338
91a47a68
DN
339 /* 1 means the window start of this window is frozen and may not
340 be changed during redisplay. If point is not in the window,
341 accept that. */
342 unsigned frozen_window_start_p : 1;
343
2af3565e
DA
344 /* Non-zero means fringes are drawn outside display margins.
345 Otherwise draw them between margin areas and text. */
346 unsigned fringes_outside_margins : 1;
347
f43dd834
GM
348 /* Amount by which lines of this window are scrolled in
349 y-direction (smooth scrolling). */
350 int vscroll;
177c0ea7 351
2af3565e
DA
352 /* Z_BYTE - the buffer position of the last glyph in the current matrix of W.
353 Should be nonnegative, and only valid if window_end_valid is not nil. */
354 ptrdiff_t window_end_bytepos;
f43dd834 355};
83b2229f
JB
356
357/* 1 if W is a minibuffer window. */
358
c98ff5dd 359#define MINI_WINDOW_P(W) ((W)->mini)
83b2229f 360
6000501b
KS
361/* General window layout:
362
363 LEFT_EDGE_COL RIGHT_EDGE_COL
364 | |
365 | |
366 | BOX_LEFT_EDGE_COL |
367 | | BOX_RIGHT_EDGE_COL |
368 | | | |
369 v v v v
370 <-><-><---><-----------><---><-><->
371 ^ ^ ^ ^ ^ ^ ^
372 | | | | | | |
373 | | | | | | +-- RIGHT_SCROLL_BAR_COLS
374 | | | | | +----- RIGHT_FRINGE_WIDTH
375 | | | | +--------- RIGHT_MARGIN_COLS
376 | | | |
377 | | | +------------------ TEXT_AREA_COLS
378 | | |
379 | | +--------------------------- LEFT_MARGIN_COLS
380 | +------------------------------- LEFT_FRINGE_WIDTH
381 +---------------------------------- LEFT_SCROLL_BAR_COLS
754dc3d8 382
6000501b
KS
383*/
384
385
386/* A handy macro. */
387
388#define WINDOW_XFRAME(W) \
389 (XFRAME (WINDOW_FRAME ((W))))
390
391/* Return the canonical column width of the frame of window W. */
392
393#define WINDOW_FRAME_COLUMN_WIDTH(W) \
394 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
395
396/* Return the canonical column width of the frame of window W. */
397
398#define WINDOW_FRAME_LINE_HEIGHT(W) \
399 (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
400
92f774f3 401/* Return the width of window W in canonical column units.
6000501b 402 This includes scroll bars and fringes. */
8516ba9a 403
6000501b 404#define WINDOW_TOTAL_COLS(W) \
077288cf 405 (XFASTINT (WGET (W, total_cols)))
6000501b 406
92f774f3 407/* Return the height of window W in canonical line units.
6000501b
KS
408 This includes header and mode lines, if any. */
409
410#define WINDOW_TOTAL_LINES(W) \
077288cf 411 (XFASTINT (WGET (W, total_lines)))
6000501b 412
6000501b
KS
413/* Return the total pixel width of window W. */
414
415#define WINDOW_TOTAL_WIDTH(W) \
416 (WINDOW_TOTAL_COLS (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
417
418/* Return the total pixel height of window W. */
419
420#define WINDOW_TOTAL_HEIGHT(W) \
421 (WINDOW_TOTAL_LINES (W) * WINDOW_FRAME_LINE_HEIGHT (W))
422
496e208e
MR
423/* For HORFLAG non-zero the total number of columns of window W. Otherwise
424 the total number of lines of W. */
425
426#define WINDOW_TOTAL_SIZE(w, horflag) \
427 (horflag ? WINDOW_TOTAL_COLS (w) : WINDOW_TOTAL_LINES (w))
428
429/* The smallest acceptable dimensions for a window. Anything smaller
430 might crash Emacs. */
431
432#define MIN_SAFE_WINDOW_WIDTH (2)
433#define MIN_SAFE_WINDOW_HEIGHT (1)
6000501b
KS
434
435/* Return the canonical frame column at which window W starts.
436 This includes a left-hand scroll bar, if any. */
437
438#define WINDOW_LEFT_EDGE_COL(W) \
077288cf 439 (XFASTINT (WGET (W, left_col)))
6000501b
KS
440
441/* Return the canonical frame column before which window W ends.
8516ba9a
RS
442 This includes a right-hand scroll bar, if any. */
443
6000501b
KS
444#define WINDOW_RIGHT_EDGE_COL(W) \
445 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
8516ba9a 446
6000501b
KS
447/* Return the canonical frame line at which window W starts.
448 This includes a header line, if any. */
449
450#define WINDOW_TOP_EDGE_LINE(W) \
077288cf 451 (XFASTINT (WGET (W, top_line)))
6000501b
KS
452
453/* Return the canonical frame line before which window W ends.
454 This includes a mode line, if any. */
455
456#define WINDOW_BOTTOM_EDGE_LINE(W) \
457 (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
458
459
460/* Return the frame x-position at which window W starts.
461 This includes a left-hand scroll bar, if any. */
462
463#define WINDOW_LEFT_EDGE_X(W) \
464 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
465 + WINDOW_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
466
467/* Return the frame x- position before which window W ends.
468 This includes a right-hand scroll bar, if any. */
469
470#define WINDOW_RIGHT_EDGE_X(W) \
471 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
472 + WINDOW_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
473
4b00d3b1
YM
474/* 1 if W is a menu bar window. */
475
476#define WINDOW_MENU_BAR_P(W) \
edd74c35
DA
477 (WINDOWP (FGET (WINDOW_XFRAME (W), menu_bar_window)) \
478 && (W) == XWINDOW (FGET (WINDOW_XFRAME (W), menu_bar_window)))
4b00d3b1
YM
479
480/* 1 if W is a tool bar window. */
481
482#define WINDOW_TOOL_BAR_P(W) \
edd74c35
DA
483 (WINDOWP (FGET (WINDOW_XFRAME (W), tool_bar_window)) \
484 && (W) == XWINDOW (FGET (WINDOW_XFRAME (W), tool_bar_window)))
4b00d3b1 485
6000501b
KS
486/* Return the frame y-position at which window W starts.
487 This includes a header line, if any. */
488
489#define WINDOW_TOP_EDGE_Y(W) \
4b00d3b1
YM
490 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
491 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
6000501b
KS
492 + WINDOW_TOP_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
493
494/* Return the frame y-position before which window W ends.
495 This includes a mode line, if any. */
496
497#define WINDOW_BOTTOM_EDGE_Y(W) \
4b00d3b1
YM
498 (((WINDOW_MENU_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
499 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
6000501b 500 + WINDOW_BOTTOM_EDGE_LINE (W) * WINDOW_FRAME_LINE_HEIGHT (W))
14a65ffe 501
8516ba9a 502
177c0ea7 503/* 1 if window W takes up the full width of its frame. */
8516ba9a
RS
504
505#define WINDOW_FULL_WIDTH_P(W) \
6000501b
KS
506 (WINDOW_TOTAL_COLS (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
507
508/* 1 if window W's has no other windows to its left in its frame. */
509
510#define WINDOW_LEFTMOST_P(W) \
511 (WINDOW_LEFT_EDGE_COL (W) == 0)
8516ba9a 512
177c0ea7 513/* 1 if window W's has no other windows to its right in its frame. */
8516ba9a
RS
514
515#define WINDOW_RIGHTMOST_P(W) \
6000501b
KS
516 (WINDOW_RIGHT_EDGE_COL (W) == FRAME_TOTAL_COLS (WINDOW_XFRAME (W)))
517
518
519/* Return the frame column at which the text (or left fringe) in
520 window W starts. This is different from the `LEFT_EDGE' because it
521 does not include a left-hand scroll bar if any. */
522
523#define WINDOW_BOX_LEFT_EDGE_COL(W) \
524 (WINDOW_LEFT_EDGE_COL (W) \
525 + WINDOW_LEFT_SCROLL_BAR_COLS (W))
526
527/* Return the window column before which the text in window W ends.
528 This is different from WINDOW_RIGHT_EDGE_COL because it does not
529 include a scroll bar or window-separating line on the right edge. */
530
531#define WINDOW_BOX_RIGHT_EDGE_COL(W) \
532 (WINDOW_RIGHT_EDGE_COL (W) \
533 - WINDOW_RIGHT_SCROLL_BAR_COLS (W))
534
535
536/* Return the frame position at which the text (or left fringe) in
537 window W starts. This is different from the `LEFT_EDGE' because it
538 does not include a left-hand scroll bar if any. */
539
540#define WINDOW_BOX_LEFT_EDGE_X(W) \
541 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
542 + WINDOW_BOX_LEFT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
543
544/* Return the window column before which the text in window W ends.
545 This is different from WINDOW_RIGHT_EDGE_COL because it does not
546 include a scroll bar or window-separating line on the right edge. */
547
548#define WINDOW_BOX_RIGHT_EDGE_X(W) \
549 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
550 + WINDOW_BOX_RIGHT_EDGE_COL (W) * WINDOW_FRAME_COLUMN_WIDTH (W))
551
552
553/* Width of left margin area in columns. */
554
555#define WINDOW_LEFT_MARGIN_COLS(W) \
077288cf 556 (NILP (WGET (W, left_margin_cols)) \
6000501b 557 ? 0 \
077288cf 558 : XINT (WGET (W, left_margin_cols)))
6000501b
KS
559
560/* Width of right marginal area in columns. */
561
562#define WINDOW_RIGHT_MARGIN_COLS(W) \
077288cf 563 (NILP (WGET (W, right_margin_cols)) \
6000501b 564 ? 0 \
077288cf 565 : XINT (WGET (W, right_margin_cols)))
6000501b
KS
566
567/* Width of left margin area in pixels. */
568
569#define WINDOW_LEFT_MARGIN_WIDTH(W) \
077288cf 570 (NILP (WGET (W, left_margin_cols)) \
6000501b 571 ? 0 \
077288cf 572 : (XINT (WGET (W, left_margin_cols)) \
6000501b
KS
573 * WINDOW_FRAME_COLUMN_WIDTH (W)))
574
575/* Width of right marginal area in pixels. */
576
577#define WINDOW_RIGHT_MARGIN_WIDTH(W) \
077288cf 578 (NILP (WGET (W, right_margin_cols)) \
6000501b 579 ? 0 \
077288cf 580 : (XINT (WGET (W, right_margin_cols)) \
6000501b
KS
581 * WINDOW_FRAME_COLUMN_WIDTH (W)))
582
583/* Total width of fringes reserved for drawing truncation bitmaps,
584 continuation bitmaps and alike. The width is in canonical char
585 units of the frame. This must currently be the case because window
586 sizes aren't pixel values. If it weren't the case, we wouldn't be
587 able to split windows horizontally nicely. */
588
589#define WINDOW_FRINGE_COLS(W) \
077288cf
DA
590 ((INTEGERP (WGET (W, left_fringe_width)) \
591 || INTEGERP (WGET (W, right_fringe_width))) \
6000501b
KS
592 ? ((WINDOW_LEFT_FRINGE_WIDTH (W) \
593 + WINDOW_RIGHT_FRINGE_WIDTH (W) \
594 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
595 / WINDOW_FRAME_COLUMN_WIDTH (W)) \
596 : FRAME_FRINGE_COLS (WINDOW_XFRAME (W)))
597
01aa0b2e
RS
598/* Column-width of the left and right fringe. */
599
600#define WINDOW_LEFT_FRINGE_COLS(W) \
601 ((WINDOW_LEFT_FRINGE_WIDTH ((W)) \
602 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
603 / WINDOW_FRAME_COLUMN_WIDTH (W))
604
605#define WINDOW_RIGHT_FRINGE_COLS(W) \
606 ((WINDOW_RIGHT_FRINGE_WIDTH ((W)) \
607 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
608 / WINDOW_FRAME_COLUMN_WIDTH (W))
609
6000501b
KS
610/* Pixel-width of the left and right fringe. */
611
612#define WINDOW_LEFT_FRINGE_WIDTH(W) \
077288cf
DA
613 (INTEGERP (WGET (W, left_fringe_width)) \
614 ? XFASTINT (WGET (W, left_fringe_width)) \
6000501b
KS
615 : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
616
617#define WINDOW_RIGHT_FRINGE_WIDTH(W) \
077288cf
DA
618 (INTEGERP (WGET (W, right_fringe_width)) \
619 ? XFASTINT (WGET (W, right_fringe_width)) \
6000501b
KS
620 : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
621
622/* Total width of fringes in pixels. */
623
624#define WINDOW_TOTAL_FRINGE_WIDTH(W) \
625 (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
626
627/* Are fringes outside display margins in window W. */
628
629#define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
2af3565e 630 ((W)->fringes_outside_margins)
6000501b
KS
631
632/* Say whether scroll bars are currently enabled for window W,
633 and which side they are on. */
634
635#define WINDOW_VERTICAL_SCROLL_BAR_TYPE(w) \
077288cf 636 (EQ (WGET (w, vertical_scroll_bar_type), Qt) \
6000501b 637 ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (w)) \
077288cf 638 : EQ (WGET (w, vertical_scroll_bar_type), Qleft) \
6000501b 639 ? vertical_scroll_bar_left \
077288cf 640 : EQ (WGET (w, vertical_scroll_bar_type), Qright) \
6000501b
KS
641 ? vertical_scroll_bar_right \
642 : vertical_scroll_bar_none) \
643
644#define WINDOW_HAS_VERTICAL_SCROLL_BAR(w) \
077288cf 645 (EQ (WGET (w, vertical_scroll_bar_type), Qt) \
6000501b 646 ? FRAME_HAS_VERTICAL_SCROLL_BARS (WINDOW_XFRAME (w)) \
077288cf 647 : !NILP (WGET (w, vertical_scroll_bar_type)))
6000501b
KS
648
649#define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(w) \
077288cf 650 (EQ (WGET (w, vertical_scroll_bar_type), Qt) \
6000501b 651 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (WINDOW_XFRAME (w)) \
077288cf 652 : EQ (WGET (w, vertical_scroll_bar_type), Qleft))
6000501b
KS
653
654#define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT(w) \
077288cf 655 (EQ (WGET (w, vertical_scroll_bar_type), Qt) \
6000501b 656 ? FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (WINDOW_XFRAME (w))\
077288cf 657 : EQ (WGET (w, vertical_scroll_bar_type), Qright))
6000501b
KS
658
659/* Width that a scroll bar in window W should have, if there is one.
660 Measured in pixels. If scroll bars are turned off, this is still
661 nonzero. */
662
663#define WINDOW_CONFIG_SCROLL_BAR_WIDTH(w) \
077288cf
DA
664 (INTEGERP (WGET (w, scroll_bar_width)) \
665 ? XFASTINT (WGET (w, scroll_bar_width)) \
6000501b
KS
666 : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (w)))
667
668/* Width that a scroll bar in window W should have, if there is one.
669 Measured in columns (characters). If scroll bars are turned off,
670 this is still nonzero. */
671
672#define WINDOW_CONFIG_SCROLL_BAR_COLS(w) \
077288cf
DA
673 (INTEGERP (WGET (w, scroll_bar_width)) \
674 ? ((XFASTINT (WGET (w, scroll_bar_width)) \
6000501b
KS
675 + WINDOW_FRAME_COLUMN_WIDTH (w) - 1) \
676 / WINDOW_FRAME_COLUMN_WIDTH (w)) \
677 : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (w)))
678
679/* Width of a scroll bar in window W, measured in columns (characters),
680 but only if scroll bars are on the left. If scroll bars are on
681 the right in this frame, or there are no scroll bars, value is 0. */
682
683#define WINDOW_LEFT_SCROLL_BAR_COLS(w) \
684 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
685 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w)) \
686 : 0)
687
688/* Width of a left scroll bar area in window W , measured in pixels. */
689
690#define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(w) \
691 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) \
692 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
693 : 0)
694
695/* Width of a scroll bar in window W, measured in columns (characters),
696 but only if scroll bars are on the right. If scroll bars are on
697 the left in this frame, or there are no scroll bars, value is 0. */
698
699#define WINDOW_RIGHT_SCROLL_BAR_COLS(w) \
700 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
701 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
702 : 0)
703
704/* Width of a left scroll bar area in window W , measured in pixels. */
705
706#define WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(w) \
707 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (w) \
708 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
709 : 0)
710
711
712/* Actual width of a scroll bar in window W, measured in columns. */
713
714#define WINDOW_SCROLL_BAR_COLS(w) \
715 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
716 ? WINDOW_CONFIG_SCROLL_BAR_COLS (w) \
717 : 0)
718
719/* Width of a left scroll bar area in window W , measured in pixels. */
720
721#define WINDOW_SCROLL_BAR_AREA_WIDTH(w) \
722 (WINDOW_HAS_VERTICAL_SCROLL_BAR (w) \
723 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (w) * WINDOW_FRAME_COLUMN_WIDTH (w)) \
724 : 0)
725
726
727/* Return the frame position where the scroll bar of window W starts. */
728
729#define WINDOW_SCROLL_BAR_AREA_X(W) \
730 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
731 ? WINDOW_BOX_RIGHT_EDGE_X (W) \
732 : WINDOW_LEFT_EDGE_X (W))
733
734
01aa0b2e
RS
735/* Height in pixels, and in lines, of the mode line.
736 May be zero if W doesn't have a mode line. */
6000501b
KS
737
738#define WINDOW_MODE_LINE_HEIGHT(W) \
739 (WINDOW_WANTS_MODELINE_P ((W)) \
740 ? CURRENT_MODE_LINE_HEIGHT (W) \
741 : 0)
742
01aa0b2e
RS
743#define WINDOW_MODE_LINE_LINES(W) \
744 (!! WINDOW_WANTS_MODELINE_P ((W)))
745
746/* Height in pixels, and in lines, of the header line.
747 Zero if W doesn't have a header line. */
6000501b
KS
748
749#define WINDOW_HEADER_LINE_HEIGHT(W) \
750 (WINDOW_WANTS_HEADER_LINE_P ((W)) \
751 ? CURRENT_HEADER_LINE_HEIGHT (W) \
752 : 0)
753
01aa0b2e
RS
754#define WINDOW_HEADER_LINE_LINES(W) \
755 (!! WINDOW_WANTS_HEADER_LINE_P ((W)))
756
6000501b
KS
757/* Pixel height of window W without mode line. */
758
759#define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W) \
760 (WINDOW_TOTAL_HEIGHT ((W)) \
761 - WINDOW_MODE_LINE_HEIGHT ((W)))
762
763/* Pixel height of window W without mode and header line. */
764
765#define WINDOW_BOX_TEXT_HEIGHT(W) \
766 (WINDOW_TOTAL_HEIGHT ((W)) \
767 - WINDOW_MODE_LINE_HEIGHT ((W)) \
768 - WINDOW_HEADER_LINE_HEIGHT ((W)))
769
770
771/* Convert window W relative pixel X to frame pixel coordinates. */
772
773#define WINDOW_TO_FRAME_PIXEL_X(W, X) \
774 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
775
776/* Convert window W relative pixel Y to frame pixel coordinates. */
777
778#define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
779 ((Y) + WINDOW_TOP_EDGE_Y ((W)))
780
781/* Convert frame relative pixel X to window relative pixel X. */
782
783#define FRAME_TO_WINDOW_PIXEL_X(W, X) \
784 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
785
786/* Convert frame relative pixel Y to window relative pixel Y. */
787
788#define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
789 ((Y) - WINDOW_TOP_EDGE_Y ((W)))
790
791/* Convert a text area relative x-position in window W to frame X
792 pixel coordinates. */
177c0ea7 793
6000501b
KS
794#define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
795 (window_box_left ((W), TEXT_AREA) + (X))
f43dd834 796
83b2229f
JB
797/* This is the window in which the terminal's cursor should
798 be left when nothing is being done with it. This must
799 always be a leaf window, and its buffer is selected by
800 the top level editing loop at the end of each command.
801
802 This value is always the same as
44fa5b1e 803 FRAME_SELECTED_WINDOW (selected_frame). */
83b2229f
JB
804
805extern Lisp_Object selected_window;
806
807/* This is a time stamp for window selection, so we can find the least
808 recently used window. Its only users are Fselect_window,
44fa5b1e 809 init_window_once, and make_frame. */
83b2229f
JB
810
811extern int window_select_count;
812
44fa5b1e 813/* The minibuffer window of the selected frame.
83b2229f 814 Note that you cannot test for minibufferness of an arbitrary window
fbfed6f0 815 by comparing against this; use the MINI_WINDOW_P macro instead. */
83b2229f
JB
816
817extern Lisp_Object minibuf_window;
818
76e316e0
KS
819/* Non-nil means it is the window whose mode line should be
820 shown as the selected window when the minibuffer is selected. */
821
5705966b 822extern Lisp_Object minibuf_selected_window;
76e316e0 823
83b2229f 824/* Window that the mouse is over (nil if no mouse support). */
f43dd834 825
83b2229f
JB
826extern Lisp_Object Vmouse_window;
827
828/* Last mouse-click event (nil if no mouse support). */
f43dd834 829
83b2229f
JB
830extern Lisp_Object Vmouse_event;
831
383e0970 832extern Lisp_Object make_window (void);
383e0970 833extern Lisp_Object window_from_coordinates (struct frame *, int, int,
9173a8fb 834 enum window_part *, int);
9397e56f 835extern void resize_frame_windows (struct frame *, int, int);
be7f5545 836extern void delete_all_child_windows (Lisp_Object);
383e0970 837extern void freeze_window_starts (struct frame *, int);
383e0970
J
838extern void grow_mini_window (struct window *, int);
839extern void shrink_mini_window (struct window *);
9173a8fb 840extern int window_relative_x_coord (struct window *, enum window_part, int);
57209cba 841
ef264c42 842void run_window_configuration_change_hook (struct frame *f);
83b2229f 843
f43dd834
GM
844/* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero
845 means it's allowed to run hooks. See make_frame for a case where
846 it's not allowed. */
847
383e0970
J
848void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
849 int run_hooks_p, int keep_margins_p);
f43dd834 850
f43dd834
GM
851/* This is the window where the echo area message was displayed. It
852 is always a minibuffer window, but it may not be the same window
853 currently active as a minibuffer. */
854
c0acc112
RS
855extern Lisp_Object echo_area_window;
856
83b2229f 857/* Depth in recursive edits. */
f43dd834 858
62f19c19 859extern EMACS_INT command_loop_level;
83b2229f
JB
860
861/* Depth in minibuffer invocations. */
f43dd834 862
62f19c19 863extern EMACS_INT minibuf_level;
83b2229f 864
e0f24100 865/* true if we should redraw the mode lines on the next redisplay. */
f43dd834 866
83b2229f
JB
867extern int update_mode_lines;
868
f43dd834
GM
869/* Nonzero if window sizes or contents have changed since last
870 redisplay that finished */
871
83b2229f
JB
872extern int windows_or_buffers_changed;
873
d1a0ea0a
RS
874/* Nonzero means a frame's cursor type has been changed. */
875
876extern int cursor_type_changed;
877
f43dd834
GM
878/* Number of windows displaying the selected buffer. Normally this is
879 1, but it can be more. */
880
83b2229f 881extern int buffer_shared;
fbfed6f0
JB
882
883/* If *ROWS or *COLS are too small a size for FRAME, set them to the
884 minimum allowable size. */
f43dd834 885
383e0970 886extern void check_frame_size (struct frame *frame, int *rows, int *cols);
f43dd834
GM
887
888/* Return a pointer to the glyph W's physical cursor is on. Value is
c80e3b4a 889 null if W's current matrix is invalid, so that no meaningful glyph
f43dd834
GM
890 can be returned. */
891
383e0970 892struct glyph *get_phys_cursor_glyph (struct window *w);
f43dd834 893
91523be9
GM
894/* Value is non-zero if WINDOW is a live window. */
895
077288cf
DA
896#define WINDOW_LIVE_P(WINDOW) \
897 (WINDOWP (WINDOW) && !NILP (WGET (XWINDOW (WINDOW), buffer)))
9a274fbd
SM
898
899/* These used to be in lisp.h. */
900
901extern Lisp_Object Qwindowp, Qwindow_live_p;
902extern Lisp_Object Vwindow_list;
903
383e0970 904extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);
383e0970
J
905extern void mark_window_cursors_off (struct window *);
906extern int window_internal_height (struct window *);
496e208e 907extern int window_body_cols (struct window *w);
383e0970 908extern void temp_output_buffer_show (Lisp_Object);
b6e3633c 909extern void replace_buffer_in_windows (Lisp_Object);
9397e56f 910extern void replace_buffer_in_windows_safely (Lisp_Object);
383e0970
J
911extern void init_window_once (void);
912extern void init_window (void);
913extern void syms_of_window (void);
914extern void keys_of_window (void);
915
f43dd834 916#endif /* not WINDOW_H_INCLUDED */