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