1 /* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2023 Free Software
3 Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or (at
10 your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19
20 #ifndef WINDOW_H_INCLUDED
21 #define WINDOW_H_INCLUDED
22
23 #include "dispextern.h"
24
25 INLINE_HEADER_BEGIN
26
27 /* Windows are allocated as if they were vectors, but then the Lisp
28 data type is changed to Lisp_Window. They are garbage collected along
29 with the vectors.
30
31 All windows in use are arranged into a tree, with pointers up and down.
32
33 Windows that are leaves of the tree are actually displayed and show
34 the contents of buffers. Windows that are not leaves are used for
35 representing the way groups of leaf windows are arranged on the frame.
36 Leaf windows never become non-leaves. They are deleted only by
37 calling `delete-window' on them (but this can be done implicitly).
38 Non-leaf windows never become leaf windows and can be created and
39 deleted at any time by the window management code. Non-leaf windows
40 can be seen but not directly manipulated by Lisp functions.
41
42 A leaf window has a buffer stored in its contents field and markers in
43 its 'start' and 'pointm' fields. Non-leaf windows have nil in the
44 latter two fields. Non-leaf windows are either vertical or horizontal
45 combinations.
46
47 A vertical combination window has children that are arranged on the
48 frame one above the next. Its 'contents' field points to the
49 uppermost child. The 'parent' field of each of the children points to
50 the vertical combination window. The 'next' field of each child
51 points to the child below it, or is nil for the lowest child. The
52 'prev' field of each child points to the child above it, or is nil for
53 the highest child.
54
55 A horizontal combination window has children that are arranged side by
56 side. Its 'contents' field points to the leftmost child. In each
57 child the 'next' field points to the child to the right and the 'prev'
58 field points to the child to the left.
59
60 On each frame there are at least one and at most two windows which
61 have nil as parent. The second of these, if present, is the frame's
62 minibuffer window and shows the minibuffer or the echo area. The
63 first one manages the remaining frame area and is called the frame's
64 root window. Different windows can be the root at different times;
65 initially the root window is a leaf window, but if more windows are
66 created, then that leaf window ceases to be root and a newly made
67 combination window becomes the root instead.
68
69 On frames which have an ordinary window and a minibuffer window,
70 'prev' of the minibuffer window is the root window and 'next' of the
71 root window is the minibuffer window. On minibuffer-less frames there
72 is only a root window and 'next' of the root window is nil. On
73 minibuffer-only frames, the root window and the minibuffer window are
74 one and the same, so its 'prev' and 'next' members are nil. In any
75 case, 'prev' of a root window and 'next' of a minibuffer window are
76 always nil.
77
78 In Lisp parlance, leaf windows are called "live windows" and non-leaf
79 windows are called "internal windows". Together, live and internal
80 windows form the set of "valid windows". A window that has been
81 deleted is considered "dead" regardless of whether it formerly was a
82 leaf or a non-leaf window. A dead window has its 'contents' field set
83 to nil.
84
85 Frames may also contain pseudo windows, windows that are not exposed
86 directly to Lisp code. Pseudo windows are currently either used to
87 display the menu bar or the tool bar (when Emacs uses toolkits that
88 don't display their own menu bar and tool bar) or a tooltip in a
89 tooltip frame (when tooltips are not display by the toolkit). */
90
91 struct cursor_pos
92 {
93 /* Pixel position. These are always window relative. */
94 int x, y;
95
96 /* Glyph matrix position. */
97 int hpos, vpos;
98 };
99
100 struct window
101 {
102 /* This is for Lisp; the terminal code does not refer to it. */
103 union vectorlike_header header;
104
105 /* The frame this window is on. */
106 Lisp_Object frame;
107
108 /* Following (to right or down) and preceding (to left or up)
109 child at same level of tree. Whether this is left/right or
110 up/down is determined by the parent window's 'horizontal' flag,
111 see below. On a frame that is neither a minibuffer-only nor a
112 minibuffer-less frame, 'next' of the root window points to the
113 frame's minibuffer window and 'prev' of the minibuffer window
114 points to the frame's root window. In all other cases, 'next'
115 of the root window and 'prev' of the minibuffer window, if
116 present, are nil. 'prev' of the root window and 'next' of the
117 minibuffer window are always nil. */
118 Lisp_Object next;
119 Lisp_Object prev;
120
121 /* The window this one is a child of. For the root and a
122 minibuffer window this is always nil. */
123 Lisp_Object parent;
124
125 /* The "normal" size of the window. These are fractions, but we
126 do not use C doubles to avoid creating new Lisp_Float objects
127 while interfacing Lisp in Fwindow_normal_size. */
128 Lisp_Object normal_lines;
129 Lisp_Object normal_cols;
130
131 /* The new sizes of the window as proposed by the window resizing
132 functions. Note that Lisp code may set new_normal to something
133 beyond an integer, so C int can't be used here. */
134 Lisp_Object new_total;
135 Lisp_Object new_normal;
136 Lisp_Object new_pixel;
137
138 /* For a leaf window or a tooltip window this is the buffer shown
139 in the window; for a combination window this is the first of
140 its child windows; for a pseudo window showing the menu bar or
141 tool bar this is nil. It is a buffer for a minibuffer window
142 as well. */
143 Lisp_Object contents;
144
145 /* The old buffer of this window, set to this window's buffer by
146 run_window_change_functions every time it sees this window.
147 Unused for internal windows. */
148 Lisp_Object old_buffer;
149
150 /* A marker pointing to where in the text to start displaying.
151 BIDI Note: This is the _logical-order_ start, i.e. the smallest
152 buffer position visible in the window, not necessarily the
153 character displayed in the top left corner of the window. */
154 Lisp_Object start;
155
156 /* A marker pointing to where in the text point is in this window,
157 used only when the window is not selected.
158 This exists so that when multiple windows show one buffer
159 each one can have its own value of point. */
160 Lisp_Object pointm;
161
162 /* A marker pointing to where in the text point was in this window
163 at the time of last redisplay. The value is saved for the
164 selected window too. */
165 Lisp_Object old_pointm;
166
167 /* No permanent meaning; used by save-window-excursion's
168 bookkeeping. */
169 Lisp_Object temslot;
170
171 /* This window's vertical scroll bar. This field is only for use by
172 the window-system-dependent code which implements the scroll
173 bars; it can store anything it likes here. If this window is
174 newly created and we haven't displayed a scroll bar in it yet, or
175 if the frame doesn't have any scroll bars, this is nil. */
176 Lisp_Object vertical_scroll_bar;
177
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;
181
182 /* This window's horizontal scroll bar. This field is only for use
183 by the window-system-dependent code which implements the scroll
184 bars; it can store anything it likes here. If this window is
185 newly created and we haven't displayed a scroll bar in it yet, or
186 if the frame doesn't have any scroll bars, this is nil. */
187 Lisp_Object horizontal_scroll_bar;
188
189 /* Type of horizontal scroll bar. A value of nil means
190 no scroll bar. A value of t means use frame value. */
191 Lisp_Object horizontal_scroll_bar_type;
192
193 /* Display-table to use for displaying chars in this window.
194 Nil means use the buffer's own display-table. */
195 Lisp_Object display_table;
196
197 /* Non-nil usually means window is marked as dedicated.
198 Note Lisp code may set this to something beyond Qnil
199 and Qt, so bitfield can't be used here. */
200 Lisp_Object dedicated;
201
202 /* t means this window's child windows are not (re-)combined. */
203 Lisp_Object combination_limit;
204
205 /* An alist with parameters. */
206 Lisp_Object window_parameters;
207
208 /* The help echo text for this window. Qnil if there's none. */
209 Lisp_Object mode_line_help_echo;
210
211 /* No Lisp data may follow this point; mode_line_help_echo must be
212 the last Lisp member. */
213
214 /* Glyph matrices. */
215 struct glyph_matrix *current_matrix;
216 struct glyph_matrix *desired_matrix;
217
218 /* The two Lisp_Object fields below are marked in a special way,
219 which is why they're placed after `current_matrix'. */
220 /* A list of <buffer, window-start, window-point> triples listing
221 buffers previously shown in this window. */
222 Lisp_Object prev_buffers;
223 /* List of buffers re-shown in this window. */
224 Lisp_Object next_buffers;
225
226 /* Number saying how recently window was selected. */
227 EMACS_INT use_time;
228
229 /* Unique number of window assigned when it was created. */
230 EMACS_INT sequence_number;
231
232 /* The change stamp of this window. Set to 0 when the window is
233 created, it is set to its frame's change stamp every time
234 run_window_change_functions is run on that frame with this
235 window live. It is left alone when the window exists only
236 within a window configuration. Not useful for internal
237 windows. */
238 int change_stamp;
239
240 /* The upper left corner pixel coordinates of this window, as
241 integers relative to upper left corner of frame = 0, 0. */
242 int pixel_left;
243 int pixel_top;
244
245 /* The upper left corner coordinates of this window,
246 relative to upper left corner of frame = 0, 0. */
247 int left_col;
248 int top_line;
249
250 /* The pixel size of the window. */
251 int pixel_width;
252 int pixel_height;
253
254 /* The pixel and pixel body sizes of the window at the last time
255 run_window_change_functions was run with this window live. Not
256 useful for internal windows. */
257 int old_pixel_width;
258 int old_pixel_height;
259 int old_body_pixel_width;
260 int old_body_pixel_height;
261
262 /* The size of the window. */
263 int total_cols;
264 int total_lines;
265
266 /* Number of columns display within the window is scrolled to the left. */
267 ptrdiff_t hscroll;
268
269 /* Minimum hscroll for automatic hscrolling. This is the value
270 the user has set, by set-window-hscroll for example. */
271 ptrdiff_t min_hscroll;
272
273 /* Maximum line length in pixels within window bound by size of
274 window (set up by set_horizontal_scroll_bar). */
275 ptrdiff_t hscroll_whole;
276
277 /* Displayed buffer's text modification events counter as of last time
278 display completed. */
279 modiff_count last_modified;
280
281 /* Displayed buffer's overlays modification events counter as of last
282 complete update. */
283 modiff_count last_overlay_modified;
284
285 /* Value of point at that time. Since this is a position in a buffer,
286 it should be positive. */
287 ptrdiff_t last_point;
288
289 /* Line number and position of a line somewhere above the top of the
290 screen. If this field is zero, it means we don't have a base line. */
291 ptrdiff_t base_line_number;
292
293 /* If this field is zero, it means we don't have a base line.
294 If it is -1, it means don't display the line number as long
295 as the window shows its buffer. */
296 ptrdiff_t base_line_pos;
297
298 /* The column number currently displayed in this window's mode
299 line, or -1 if column numbers are not being displayed. */
300 ptrdiff_t column_number_displayed;
301
302 /* Scaling factor for the glyph_matrix size calculation in this window.
303 Used if window contains many small images or uses proportional fonts,
304 as the normal may yield a matrix which is too small. */
305 int nrows_scale_factor, ncols_scale_factor;
306
307 /* Intended cursor position. This is a position within the
308 glyph matrix. */
309 struct cursor_pos cursor;
310
311 /* Where the cursor actually is. */
312 struct cursor_pos phys_cursor;
313
314 /* Internally used for redisplay purposes. */
315 struct cursor_pos output_cursor;
316
317 /* Vertical cursor position as of last update that completed
318 without pause. This is the position of last_point. */
319 int last_cursor_vpos;
320
321 #ifdef HAVE_WINDOW_SYSTEM
322
323 /* Cursor type of last cursor drawn on the window. */
324 enum text_cursor_kinds phys_cursor_type;
325
326 /* Width of the cursor above. */
327 int phys_cursor_width;
328
329 /* This is handy for undrawing the cursor. */
330 int phys_cursor_ascent, phys_cursor_height;
331
332 #endif /* HAVE_WINDOW_SYSTEM */
333
334 /* Width of left and right fringes, in pixels.
335 A value of -1 means use frame values. */
336 int left_fringe_width;
337 int right_fringe_width;
338
339 /* Requested width of left and right marginal areas in columns. A
340 value of 0 means no margin. The actual values are recorded in
341 the window's glyph matrix, in the left_margin_glyphs and
342 right_margin_glyphs members. */
343 int left_margin_cols;
344 int right_margin_cols;
345
346 /* Pixel width of scroll bars.
347 A value of -1 means use frame values. */
348 int scroll_bar_width;
349
350 /* Pixel height of scroll bars.
351 A value of -1 means use frame values. */
352 int scroll_bar_height;
353
354 /* Effective height of the mode line, or -1 if not known. */
355 int mode_line_height;
356
357 /* Effective height of the header line, or -1 if not known. */
358 int header_line_height;
359
360 /* Effective height of the tab line, or -1 if not known. */
361 int tab_line_height;
362
363 /* Z - the buffer position of the last glyph in the current
364 matrix of W. Only valid if window_end_valid is true. */
365 ptrdiff_t window_end_pos;
366
367 /* Glyph matrix row of the last glyph in the current matrix
368 of W. Only valid if window_end_valid is true. */
369 int window_end_vpos;
370
371 /* True if this window is a minibuffer window. */
372 bool_bf mini : 1;
373
374 /* Meaningful for internal windows only: true if this window is a
375 horizontal combination, false if it is a vertical
376 combination. */
377 bool_bf horizontal : 1;
378
379 /* True means must regenerate mode line of this window. */
380 bool_bf update_mode_line : 1;
381
382 /* True if the buffer was "modified" when the window
383 was last updated. */
384 bool_bf last_had_star : 1;
385
386 /* True means current value of `start'
387 was the beginning of a line when it was chosen. */
388 bool_bf start_at_line_beg : 1;
389
390 /* True means next redisplay must use the value of start
391 set up for it in advance. Set by scrolling commands. */
392 bool_bf force_start : 1;
393
394 /* True means we have explicitly changed the value of start,
395 but that the next redisplay is not obliged to use the new value.
396 This is used in Fdelete_other_windows to force a call to
397 Vwindow_scroll_functions; also by Frecenter with argument. */
398 bool_bf optional_new_start : 1;
399
400 /* True means the cursor is currently displayed. This can be
401 set to zero by functions overpainting the cursor image. */
402 bool_bf phys_cursor_on_p : 1;
403
404 /* False means cursor is logically on, true means it's off. Used for
405 blinking cursor. */
406 bool_bf cursor_off_p : 1;
407
408 /* Value of cursor_off_p as of the last redisplay. */
409 bool_bf last_cursor_off_p : 1;
410
411 /* True means desired matrix has been build and window must be
412 updated in update_frame. */
413 bool_bf must_be_updated_p : 1;
414
415 /* Flag indicating that this window is not a real one.
416 Currently only used for menu bar windows, for tool bar windows,
417 and for tooltips. */
418 bool_bf pseudo_window_p : 1;
419
420 /* True means fringes are drawn outside display margins.
421 Otherwise draw them between margin areas and text. */
422 bool_bf fringes_outside_margins : 1;
423
424 /* True if this window's fringe specifications are persistent,
425 i.e., always survive Fset_window_buffer. */
426 bool_bf fringes_persistent : 1;
427
428 /* True if this window's scroll bar specifications are persistent,
429 i.e., always survive Fset_window_buffer. */
430 bool_bf scroll_bars_persistent : 1;
431
432 /* True if window_end_pos and window_end_vpos are truly valid.
433 This is false if nontrivial redisplay is preempted since in that case
434 the frame image that window_end_pos did not get onto the frame. */
435 bool_bf window_end_valid : 1;
436
437 /* True if it needs to be redisplayed. */
438 bool_bf redisplay : 1;
439
440 /* True if auto hscrolling is currently suspended in this
441 window. */
442 bool_bf suspend_auto_hscroll : 1;
443
444 /* True if vscroll should be preserved while forcing the start due
445 to a frozen window. */
446 bool_bf preserve_vscroll_p : 1;
447
448 /* Amount by which lines of this window are scrolled in
449 y-direction (smooth scrolling). */
450 int vscroll;
451
452 /* Z_BYTE - buffer position of the last glyph in the current matrix of W.
453 Should be nonnegative, and only valid if window_end_valid is true. */
454 ptrdiff_t window_end_bytepos;
455 } GCALIGNED_STRUCT;
456
457 INLINE bool
458 WINDOWP (Lisp_Object a)
459 {
460 return PSEUDOVECTORP (a, PVEC_WINDOW);
461 }
462
463 INLINE void
464 CHECK_WINDOW (Lisp_Object x)
465 {
466 CHECK_TYPE (WINDOWP (x), Qwindowp, x);
467 }
468
469 INLINE struct window *
470 XWINDOW (Lisp_Object a)
471 {
472 eassert (WINDOWP (a));
473 return XUNTAG (a, Lisp_Vectorlike, struct window);
474 }
475
476 /* Most code should use these functions to set Lisp fields in struct
477 window. */
478 INLINE void
479 wset_frame (struct window *w, Lisp_Object val)
480 {
481 w->frame = val;
482 }
483
484 INLINE void
485 wset_next (struct window *w, Lisp_Object val)
486 {
487 w->next = val;
488 }
489
490 INLINE void
491 wset_prev (struct window *w, Lisp_Object val)
492 {
493 w->prev = val;
494 }
495
496 INLINE void
497 wset_mode_line_help_echo (struct window *w, Lisp_Object val)
498 {
499 w->mode_line_help_echo = val;
500 }
501
502 INLINE void
503 wset_new_pixel (struct window *w, Lisp_Object val)
504 {
505 w->new_pixel = val;
506 }
507
508 INLINE void
509 wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
510 {
511 w->vertical_scroll_bar = val;
512 }
513
514 INLINE void
515 wset_horizontal_scroll_bar (struct window *w, Lisp_Object val)
516 {
517 w->horizontal_scroll_bar = val;
518 }
519
520 INLINE void
521 wset_horizontal_scroll_bar_type (struct window *w, Lisp_Object val)
522 {
523 w->horizontal_scroll_bar_type = val;
524 }
525
526 INLINE void
527 wset_prev_buffers (struct window *w, Lisp_Object val)
528 {
529 w->prev_buffers = val;
530 }
531
532 INLINE void
533 wset_next_buffers (struct window *w, Lisp_Object val)
534 {
535 w->next_buffers = val;
536 }
537
538 /* True if W is a minibuffer window. */
539 #define MINI_WINDOW_P(W) ((W)->mini)
540
541 /* True if W is a minibuffer window on a frame that contains at least
542 one other window. */
543 #define MINI_NON_ONLY_WINDOW_P(W) \
544 (MINI_WINDOW_P (W) && !NILP ((W)->prev))
545
546 /* True if W is a minibuffer window that is alone on its frame. */
547 #define MINI_ONLY_WINDOW_P(W) \
548 (MINI_WINDOW_P (W) && NILP ((W)->prev))
549
550 /* General window layout:
551
552 LEFT_EDGE_COL RIGHT_EDGE_COL
553 | |
554 | |
555 | BOX_LEFT_EDGE_COL |
556 | | BOX_RIGHT_EDGE_COL |
557 | | | |
558 v v v v
559 <-><-><---><-----------><---><-><->
560 ^ ^ ^ ^ ^ ^ ^
561 | | | | | | |
562 | | | | | | +-- RIGHT_SCROLL_BAR_COLS
563 | | | | | +----- RIGHT_FRINGE_WIDTH
564 | | | | +--------- RIGHT_MARGIN_COLS
565 | | | |
566 | | | +------------------ TEXT_AREA_COLS
567 | | |
568 | | +--------------------------- LEFT_MARGIN_COLS
569 | +------------------------------- LEFT_FRINGE_WIDTH
570 +---------------------------------- LEFT_SCROLL_BAR_COLS
571
572 */
573
574
575 /* A handy macro. */
576
577 /* Non-nil if window W is leaf window (has a buffer). */
578 #define WINDOW_LEAF_P(W) \
579 (BUFFERP ((W)->contents))
580
581 /* Non-nil if window W is internal (is a parent window). */
582 #define WINDOW_INTERNAL_P(W) \
583 (WINDOWP ((W)->contents))
584
585 /* True if window W is a horizontal combination of windows. */
586 #define WINDOW_HORIZONTAL_COMBINATION_P(W) \
587 (WINDOW_INTERNAL_P (W) && (W)->horizontal)
588
589 /* True if window W is a vertical combination of windows. */
590 #define WINDOW_VERTICAL_COMBINATION_P(W) \
591 (WINDOW_INTERNAL_P (W) && !(W)->horizontal)
592
593 /* Window W's XFRAME. */
594 #define WINDOW_XFRAME(W) (XFRAME (WINDOW_FRAME ((W))))
595
596 /* Whether window W is a pseudo window. */
597 #define WINDOW_PSEUDO_P(W) ((W)->pseudo_window_p)
598
599 /* Window W's buffer. */
600 #define WINDOW_BUFFER(W) \
601 (WINDOW_LEAF_P(W) \
602 ? (W)->contents \
603 : Qnil)
604
605 /* Local value of variable V in window W's buffer. Nil if W has no
606 buffer. */
607 #define WINDOW_BUFFER_LOCAL_VALUE(V, W) \
608 (BUFFERP ((W)->contents) \
609 ? buffer_local_value(V, (W)->contents) \
610 : Qnil)
611
612 /* Return the canonical column width of the frame of window W. */
613 #define WINDOW_FRAME_COLUMN_WIDTH(W) \
614 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
615
616 /* Return the canonical line height of the frame of window W. */
617 #define WINDOW_FRAME_LINE_HEIGHT(W) \
618 (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
619
620 /* Return the pixel width of window W. This includes dividers, scroll
621 bars, fringes and margins, if any. */
622 #define WINDOW_PIXEL_WIDTH(W) (W)->pixel_width
623
624 /* Return the pixel height of window W. This includes dividers, scroll
625 bars, header and mode lines, if any. */
626 #define WINDOW_PIXEL_HEIGHT(W) (W)->pixel_height
627
628 /* Return the width of window W in canonical column units. This
629 includes dividers, scroll bars, fringes and margins, if any. The
630 value is adjusted such that the sum of the widths of all child
631 windows equals the width of their parent window. */
632 #define WINDOW_TOTAL_COLS(W) (W)->total_cols
633
634 /* Return the height of window W in canonical line units. This includes
635 dividers, scroll bars, header and mode lines, if any. The value is
636 adjusted such that the sum of the heights of all child windows equals
637 the height of their parent window. */
638 #define WINDOW_TOTAL_LINES(W) (W)->total_lines
639
640 /* The smallest acceptable dimensions for a window. Anything smaller
641 might crash Emacs. */
642 #define MIN_SAFE_WINDOW_WIDTH (2)
643
644 #define MIN_SAFE_WINDOW_PIXEL_WIDTH(W) \
645 (2 * WINDOW_FRAME_COLUMN_WIDTH (W))
646
647 #define MIN_SAFE_WINDOW_HEIGHT (1)
648
649 #define MIN_SAFE_WINDOW_PIXEL_HEIGHT(W) \
650 (WINDOW_FRAME_LINE_HEIGHT (W))
651
652 /* True if window W has no other windows to its left on its frame. */
653 #define WINDOW_LEFTMOST_P(W) \
654 (WINDOW_LEFT_PIXEL_EDGE (W) == 0)
655
656 /* True if window W has no other windows above it on its frame. */
657 #define WINDOW_TOPMOST_P(W) \
658 (WINDOW_TOP_PIXEL_EDGE (W) == 0)
659
660 /* True if window W has no other windows to its right on its frame. */
661 #define WINDOW_RIGHTMOST_P(W) \
662 (WINDOW_RIGHT_PIXEL_EDGE (W) \
663 == (WINDOW_RIGHT_PIXEL_EDGE \
664 (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
665
666 /* True if window W has no other windows below it on its frame (the
667 minibuffer window is not counted in this respect unless W itself is a
668 minibuffer window). */
669 #define WINDOW_BOTTOMMOST_P(W) \
670 (WINDOW_BOTTOM_PIXEL_EDGE (W) \
671 == (WINDOW_BOTTOM_PIXEL_EDGE \
672 (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
673
674 /* True if window W takes up the full width of its frame. */
675 #define WINDOW_FULL_WIDTH_P(W) \
676 (WINDOW_PIXEL_WIDTH (W) \
677 == (WINDOW_PIXEL_WIDTH \
678 (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
679
680 /* Width of right divider of window W. */
681 #define WINDOW_RIGHT_DIVIDER_WIDTH(W) \
682 (WINDOW_RIGHTMOST_P (W) \
683 ? 0 : FRAME_RIGHT_DIVIDER_WIDTH (WINDOW_XFRAME (W)))
684
685 /* Width of bottom divider of window W. */
686 #define WINDOW_BOTTOM_DIVIDER_WIDTH(W) \
687 (((WINDOW_BOTTOMMOST_P (W) \
688 && NILP ((XWINDOW (FRAME_ROOT_WINDOW \
689 (WINDOW_XFRAME (W))))->next)) \
690 || EQ ((W)->prev, FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))) \
691 || (W)->pseudo_window_p) \
692 ? 0 : FRAME_BOTTOM_DIVIDER_WIDTH (WINDOW_XFRAME (W)))
693
694 /* Return the canonical frame column at which window W starts.
695 This includes a left-hand scroll bar, if any. */
696 #define WINDOW_LEFT_EDGE_COL(W) (W)->left_col
697
698 /* Return the canonical frame column before which window W ends.
699 This includes a right-hand scroll bar, if any. */
700 #define WINDOW_RIGHT_EDGE_COL(W) \
701 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
702
703 /* Return the canonical frame line at which window W starts.
704 This includes a header/tab line, if any. */
705 #define WINDOW_TOP_EDGE_LINE(W) (W)->top_line
706
707 /* Return the canonical frame line before which window W ends.
708 This includes a mode line, if any. */
709 #define WINDOW_BOTTOM_EDGE_LINE(W) \
710 (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
711
712 /* Return the left pixel edge at which window W starts.
713 This includes a left-hand scroll bar, if any. */
714 #define WINDOW_LEFT_PIXEL_EDGE(W) (W)->pixel_left
715
716 /* Return the right pixel edge before which window W ends.
717 This includes a right-hand scroll bar, if any. */
718 #define WINDOW_RIGHT_PIXEL_EDGE(W) \
719 (WINDOW_LEFT_PIXEL_EDGE (W) + WINDOW_PIXEL_WIDTH (W))
720
721 /* Return the top pixel edge at which window W starts.
722 This includes a header/tab line, if any. */
723 #define WINDOW_TOP_PIXEL_EDGE(W) (W)->pixel_top
724
725 /* Return the bottom pixel edge before which window W ends.
726 This includes a mode line, if any. */
727 #define WINDOW_BOTTOM_PIXEL_EDGE(W) \
728 (WINDOW_TOP_PIXEL_EDGE (W) + WINDOW_PIXEL_HEIGHT (W))
729
730 /* Return the frame x-position at which window W starts.
731 This includes a left-hand scroll bar, if any. */
732 #define WINDOW_LEFT_EDGE_X(W) \
733 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
734 + WINDOW_LEFT_PIXEL_EDGE (W))
735
736 /* Return the frame x- position before which window W ends.
737 This includes a right-hand scroll bar, if any. */
738 #define WINDOW_RIGHT_EDGE_X(W) \
739 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
740 + WINDOW_RIGHT_PIXEL_EDGE (W))
741
742 /* True if W is a menu bar window. */
743 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
744 #define WINDOW_MENU_BAR_P(W) \
745 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
746 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
747 #else
748 /* No menu bar windows if X toolkit is in use. */
749 #define WINDOW_MENU_BAR_P(W) false
750 #endif
751
752 /* True if W is a tab bar window. */
753 #if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_PGTK)
754 # define WINDOW_TAB_BAR_P(W) \
755 (WINDOWP (WINDOW_XFRAME (W)->tab_bar_window) \
756 && (W) == XWINDOW (WINDOW_XFRAME (W)->tab_bar_window))
757 #else
758 # define WINDOW_TAB_BAR_P(W) false
759 #endif
760
761 /* True if W is a tool bar window. */
762 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
763 #define WINDOW_TOOL_BAR_P(W) \
764 (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
765 && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
766 #else
767 #define WINDOW_TOOL_BAR_P(W) false
768 #endif
769
770 /* Return the frame y-position at which window W starts. */
771 #define WINDOW_TOP_EDGE_Y(W) \
772 (((WINDOW_MENU_BAR_P (W) || WINDOW_TAB_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
773 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
774 + WINDOW_TOP_PIXEL_EDGE (W))
775
776 /* Return the frame y-position before which window W ends. */
777 #define WINDOW_BOTTOM_EDGE_Y(W) \
778 (((WINDOW_MENU_BAR_P (W) || WINDOW_TAB_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
779 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
780 + WINDOW_BOTTOM_PIXEL_EDGE (W))
781
782 /* Return the pixel value where the text (or left fringe) in window W
783 starts. */
784 #define WINDOW_BOX_LEFT_PIXEL_EDGE(W) \
785 (WINDOW_LEFT_PIXEL_EDGE (W) \
786 + WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (W))
787
788 /* Return the pixel value before which the text in window W ends. This
789 is different from the `RIGHT_EDGE' because it does not include a
790 right-hand scroll bar or window-separating line on the right
791 edge. */
792 #define WINDOW_BOX_RIGHT_PIXEL_EDGE(W) \
793 (WINDOW_RIGHT_PIXEL_EDGE (W) \
794 - WINDOW_RIGHT_DIVIDER_WIDTH (W) \
795 - WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (W))
796
797 /* Return the frame x-position at which the text (or left fringe) in
798 window W starts. This does not include a left-hand scroll bar if
799 any. */
800 #define WINDOW_BOX_LEFT_EDGE_X(W) \
801 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
802 + WINDOW_BOX_LEFT_PIXEL_EDGE (W))
803
804 /* Return the frame x-position before which the text in window W ends.
805 This does not include a scroll bar, divider or window-separating line
806 on the right edge. */
807 #define WINDOW_BOX_RIGHT_EDGE_X(W) \
808 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
809 + WINDOW_BOX_RIGHT_PIXEL_EDGE (W))
810
811 /* Widths of marginal areas in columns. */
812 #define WINDOW_LEFT_MARGIN_COLS(W) (W->left_margin_cols)
813
814 #define WINDOW_RIGHT_MARGIN_COLS(W) (W->right_margin_cols)
815
816 #define WINDOW_MARGINS_COLS(W) \
817 (WINDOW_LEFT_MARGIN_COLS (W) \
818 + WINDOW_RIGHT_MARGIN_COLS (W))
819
820 /* Widths of marginal areas in pixels. */
821 #define WINDOW_LEFT_MARGIN_WIDTH(W) \
822 (W->left_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
823
824 #define WINDOW_RIGHT_MARGIN_WIDTH(W) \
825 (W->right_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
826
827 #define WINDOW_MARGINS_WIDTH(W) \
828 (WINDOW_LEFT_MARGIN_WIDTH (W) \
829 + WINDOW_RIGHT_MARGIN_WIDTH (W))
830
831 /* Pixel-widths of fringes. */
832 #define WINDOW_LEFT_FRINGE_WIDTH(W) \
833 (W->left_fringe_width >= 0 \
834 ? W->left_fringe_width \
835 : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
836
837 #define WINDOW_RIGHT_FRINGE_WIDTH(W) \
838 (W->right_fringe_width >= 0 \
839 ? W->right_fringe_width \
840 : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
841
842 #define WINDOW_FRINGES_WIDTH(W) \
843 (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
844
845 /* Are fringes outside display margins in window W. */
846 #define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
847 ((W)->fringes_outside_margins)
848
849 /* Say whether vertical scroll bars are currently enabled for window W,
850 and which side they are on. */
851 #define WINDOW_VERTICAL_SCROLL_BAR_TYPE(W) \
852 (WINDOW_PSEUDO_P (W) \
853 ? vertical_scroll_bar_none \
854 : EQ (W->vertical_scroll_bar_type, Qt) \
855 ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (W)) \
856 : EQ (W->vertical_scroll_bar_type, Qleft) \
857 ? vertical_scroll_bar_left \
858 : EQ (W->vertical_scroll_bar_type, Qright) \
859 ? vertical_scroll_bar_right \
860 : vertical_scroll_bar_none)
861
862 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(W) \
863 (WINDOW_VERTICAL_SCROLL_BAR_TYPE (W) == vertical_scroll_bar_left)
864
865 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT(W) \
866 (WINDOW_VERTICAL_SCROLL_BAR_TYPE (W) == vertical_scroll_bar_right)
867
868 #define WINDOW_HAS_VERTICAL_SCROLL_BAR(W) \
869 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (W) \
870 || WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W))
871
872 #if (defined (HAVE_WINDOW_SYSTEM) \
873 && ((defined (USE_TOOLKIT_SCROLL_BARS)) \
874 || defined (HAVE_NTGUI)))
875 # define USE_HORIZONTAL_SCROLL_BARS true
876 #else
877 # define USE_HORIZONTAL_SCROLL_BARS false
878 #endif
879
880 /* Say whether horizontal scroll bars are currently enabled for window
881 W. Horizontal scrollbars exist for toolkit versions only. */
882 #if USE_HORIZONTAL_SCROLL_BARS
883 #define WINDOW_HAS_HORIZONTAL_SCROLL_BAR(W) \
884 ((WINDOW_PSEUDO_P (W) \
885 || (MINI_WINDOW_P (W) \
886 && !EQ (W->horizontal_scroll_bar_type, Qbottom))) \
887 ? false \
888 : EQ (W->horizontal_scroll_bar_type, Qt) \
889 ? FRAME_HAS_HORIZONTAL_SCROLL_BARS (WINDOW_XFRAME (W)) \
890 : EQ (W->horizontal_scroll_bar_type, Qbottom) \
891 ? true \
892 : false)
893 #else
894 #define WINDOW_HAS_HORIZONTAL_SCROLL_BAR(W) false
895 #endif
896
897 /* Width that a scroll bar in window W should have, if there is one.
898 Measured in pixels. If scroll bars are turned off, this is still
899 nonzero. */
900 #define WINDOW_CONFIG_SCROLL_BAR_WIDTH(W) \
901 (W->scroll_bar_width >= 0 \
902 ? W->scroll_bar_width \
903 : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (W)))
904
905 /* Width that a scroll bar in window W should have, if there is one.
906 Measured in columns (characters). If scroll bars are turned off,
907 this is still nonzero. */
908 #define WINDOW_CONFIG_SCROLL_BAR_COLS(W) \
909 (W->scroll_bar_width >= 0 \
910 ? ((W->scroll_bar_width \
911 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
912 / WINDOW_FRAME_COLUMN_WIDTH (W)) \
913 : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (W)))
914
915 /* Width of left scroll bar in window W, measured in columns
916 (characters). If scroll bars are on the right in this frame, or
917 there are no scroll bars, value is 0. */
918 #define WINDOW_LEFT_SCROLL_BAR_COLS(W) \
919 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (W) \
920 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (W)) \
921 : 0)
922
923 /* Width of right scroll bar in window W, measured in columns
924 (characters). If scroll bars are on the left in this frame, or there
925 are no scroll bars, value is 0. */
926 #define WINDOW_RIGHT_SCROLL_BAR_COLS(W) \
927 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
928 ? WINDOW_CONFIG_SCROLL_BAR_COLS (W) \
929 : 0)
930
931 /* Width of a scroll bar in window W, measured in columns. */
932 #define WINDOW_SCROLL_BAR_COLS(W) \
933 (WINDOW_HAS_VERTICAL_SCROLL_BAR (W) \
934 ? WINDOW_CONFIG_SCROLL_BAR_COLS (W) \
935 : 0)
936
937 /* Width of a left scroll bar area in window W, measured in pixels. */
938 #define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(W) \
939 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (W) \
940 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \
941 : 0)
942
943 /* Width of a right scroll bar area in window W, measured in pixels. */
944 #define WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(W) \
945 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
946 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \
947 : 0)
948
949 /* Width of scroll bar area in window W, measured in pixels. */
950 #define WINDOW_SCROLL_BAR_AREA_WIDTH(W) \
951 (WINDOW_HAS_VERTICAL_SCROLL_BAR (W) \
952 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \
953 : 0)
954
955 /* Return the frame position where the vertical scroll bar of window W
956 starts. */
957 #define WINDOW_SCROLL_BAR_AREA_X(W) \
958 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
959 ? WINDOW_BOX_RIGHT_EDGE_X (W) \
960 : WINDOW_LEFT_EDGE_X (W))
961
962 /* Height that a scroll bar in window W should have, if there is one.
963 Measured in pixels. If scroll bars are turned off, this is still
964 nonzero. */
965 #define WINDOW_CONFIG_SCROLL_BAR_HEIGHT(W) \
966 (W->scroll_bar_height >= 0 \
967 ? W->scroll_bar_height \
968 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (WINDOW_XFRAME (W)))
969
970 /* Height that a scroll bar in window W should have, if there is one.
971 Measured in lines (characters). If scroll bars are turned off, this
972 is still nonzero. */
973 #define WINDOW_CONFIG_SCROLL_BAR_LINES(W) \
974 (W->scroll_bar_height >= 0 \
975 ? ((W->scroll_bar_height \
976 + WINDOW_FRAME_LINE_HEIGHT (W) - 1) \
977 / WINDOW_FRAME_LINE_HEIGHT (W)) \
978 : FRAME_CONFIG_SCROLL_BAR_LINES (WINDOW_XFRAME (W)))
979
980 /* Height of a scroll bar in window W, measured in columns. */
981 #define WINDOW_SCROLL_BAR_LINES(W) \
982 (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (W) \
983 ? WINDOW_CONFIG_SCROLL_BAR_LINES (W) \
984 : 0)
985
986 /* Height of scroll bar area in window W, measured in pixels. */
987 #define WINDOW_SCROLL_BAR_AREA_HEIGHT(W) \
988 (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (W) \
989 ? WINDOW_CONFIG_SCROLL_BAR_HEIGHT (W) \
990 : 0)
991
992 /* Height in pixels of the mode line.
993 May be zero if W doesn't have a mode line. */
994 #define WINDOW_MODE_LINE_HEIGHT(W) \
995 (window_wants_mode_line ((W)) \
996 ? CURRENT_MODE_LINE_HEIGHT (W) \
997 : 0)
998
999 #define WINDOW_MODE_LINE_LINES(W) \
1000 window_wants_mode_line (W)
1001
1002 /* Height in pixels of the header line.
1003 Zero if W doesn't have a header line. */
1004 #define WINDOW_HEADER_LINE_HEIGHT(W) \
1005 (window_wants_header_line (W) \
1006 ? CURRENT_HEADER_LINE_HEIGHT (W) \
1007 : 0)
1008
1009 #define WINDOW_HEADER_LINE_LINES(W) \
1010 window_wants_header_line (W)
1011
1012 /* Height in pixels of the tab line.
1013 Zero if W doesn't have a tab line. */
1014 #define WINDOW_TAB_LINE_HEIGHT(W) \
1015 (window_wants_tab_line (W) \
1016 ? CURRENT_TAB_LINE_HEIGHT (W) \
1017 : 0)
1018
1019 #define WINDOW_TAB_LINE_LINES(W) \
1020 window_wants_tab_line (W)
1021
1022 /* Pixel height of window W without mode line, bottom scroll bar and
1023 bottom divider. */
1024 #define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W) \
1025 (WINDOW_PIXEL_HEIGHT (W) \
1026 - WINDOW_BOTTOM_DIVIDER_WIDTH (W) \
1027 - WINDOW_SCROLL_BAR_AREA_HEIGHT (W) \
1028 - WINDOW_MODE_LINE_HEIGHT (W))
1029
1030 /* Pixel height of window W without mode and header/tab line and bottom
1031 divider. */
1032 #define WINDOW_BOX_TEXT_HEIGHT(W) \
1033 (WINDOW_PIXEL_HEIGHT ((W)) \
1034 - WINDOW_BOTTOM_DIVIDER_WIDTH (W) \
1035 - WINDOW_SCROLL_BAR_AREA_HEIGHT (W) \
1036 - WINDOW_MODE_LINE_HEIGHT (W) \
1037 - WINDOW_HEADER_LINE_HEIGHT (W) \
1038 - WINDOW_TAB_LINE_HEIGHT (W))
1039
1040 /* Return the frame position where the horizontal scroll bar of window W
1041 starts. */
1042 #define WINDOW_SCROLL_BAR_AREA_Y(W) \
1043 (WINDOW_TOP_EDGE_Y (W) \
1044 + (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (W) \
1045 ? WINDOW_BOX_HEIGHT_NO_MODE_LINE (W) : 0))
1046
1047 /* Convert window W relative pixel X to frame pixel coordinates. */
1048 #define WINDOW_TO_FRAME_PIXEL_X(W, X) \
1049 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
1050
1051 /* Convert window W relative pixel Y to frame pixel coordinates. */
1052 #define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
1053 ((Y) + WINDOW_TOP_EDGE_Y (W))
1054
1055 /* Convert frame relative pixel X to window relative pixel X. */
1056 #define FRAME_TO_WINDOW_PIXEL_X(W, X) \
1057 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
1058
1059 /* Convert frame relative pixel Y to window relative pixel Y. */
1060 #define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
1061 ((Y) - WINDOW_TOP_EDGE_Y (W))
1062
1063 /* Convert a text area relative x-position in window W to frame X
1064 pixel coordinates. */
1065 #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
1066 (window_box_left ((W), TEXT_AREA) + (X))
1067
1068 /* This is the window in which the terminal's cursor should be left when
1069 nothing is being done with it. This must always be a leaf window, and its
1070 buffer is selected by the top level editing loop at the end of each command.
1071
1072 This value is always the same as FRAME_SELECTED_WINDOW (selected_frame). */
1073
1074 extern Lisp_Object selected_window;
1075
1076 /* This is a time stamp for window selection, so we can find the least
1077 recently used window. Its only users are Fselect_window,
1078 init_window_once, and make_frame. */
1079
1080 extern EMACS_INT window_select_count;
1081
1082 /* The minibuffer window of the selected frame.
1083 Note that you cannot test for minibufferness of an arbitrary window
1084 by comparing against this; use the MINI_WINDOW_P macro instead. */
1085
1086 extern Lisp_Object minibuf_window;
1087
1088 /* Non-nil means it is the window whose mode line should be
1089 shown as the selected window when the minibuffer is selected. */
1090
1091 extern Lisp_Object minibuf_selected_window;
1092
1093 extern Lisp_Object make_window (void);
1094 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
1095 enum window_part *, bool, bool);
1096 extern void resize_frame_windows (struct frame *, int, bool);
1097 extern void restore_window_configuration (Lisp_Object);
1098 extern void delete_all_child_windows (Lisp_Object);
1099 extern void grow_mini_window (struct window *, int);
1100 extern void shrink_mini_window (struct window *);
1101 extern int window_relative_x_coord (struct window *, enum window_part, int);
1102
1103 void run_window_change_functions (void);
1104
1105 /* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed
1106 to run hooks. See make_frame for a case where it's not allowed. */
1107
1108 void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
1109 bool run_hooks_p, bool keep_margins_p);
1110
1111 /* This is the window where the echo area message was displayed. It
1112 is always a minibuffer window, but it may not be the same window
1113 currently active as a minibuffer. */
1114
1115 extern Lisp_Object echo_area_window;
1116
1117 /* Non-zero if we should redraw the mode lines on the next redisplay.
1118 Usually set to a unique small integer so we can track the main causes of
1119 full redisplays in `redisplay--mode-lines-cause'. */
1120
1121 extern int update_mode_lines;
1122
1123 /* Nonzero if window sizes or contents have changed since last
1124 redisplay that finished. Usually set to a unique small integer so
1125 we can track the main causes of full redisplays in
1126 `redisplay--all-windows-cause'. */
1127
1128 extern int windows_or_buffers_changed;
1129
1130 /* The main redisplay routine usually only redisplays the selected-window,
1131 so when something's changed elsewhere, we call one of the functions below
1132 to indicate which other windows might also need to be redisplayed. */
1133
1134 extern void wset_redisplay (struct window *w);
1135 extern void fset_redisplay (struct frame *f);
1136 extern void bset_redisplay (struct buffer *b);
1137 extern void bset_update_mode_line (struct buffer *b);
1138 extern void wset_update_mode_line (struct window *w);
1139 /* Call this to tell redisplay to look for other windows than selected-window
1140 that need to be redisplayed. Calling one of the *set_redisplay functions
1141 above already does it, so it's only needed in unusual cases. */
1142 extern void redisplay_other_windows (void);
1143
1144 /* Return a pointer to the glyph W's physical cursor is on. Value is
1145 null if W's current matrix is invalid, so that no meaningful glyph
1146 can be returned. */
1147
1148 struct glyph *get_phys_cursor_glyph (struct window *w);
1149
1150 /* True if WINDOW is a valid window. */
1151 #define WINDOW_VALID_P(WINDOW) \
1152 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents))
1153
1154 /* A window of any sort, leaf or interior, is "valid" if its
1155 contents slot is non-nil. */
1156 #define CHECK_VALID_WINDOW(WINDOW) \
1157 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
1158
1159 /* True if WINDOW is a live window. */
1160 #define WINDOW_LIVE_P(WINDOW) \
1161 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
1162
1163 /* A window is "live" if and only if it shows a buffer. */
1164 #define CHECK_LIVE_WINDOW(WINDOW) \
1165 CHECK_TYPE (WINDOW_LIVE_P (WINDOW), Qwindow_live_p, WINDOW)
1166
1167 /* These used to be in lisp.h. */
1168 extern Lisp_Object Vwindow_list;
1169
1170 extern Lisp_Object window_list (void);
1171 extern Lisp_Object window_parameter (struct window *, Lisp_Object parameter);
1172 extern struct window *decode_live_window (Lisp_Object);
1173 extern struct window *decode_any_window (Lisp_Object);
1174 extern void mark_window_cursors_off (struct window *);
1175 extern bool window_wants_mode_line (struct window *);
1176 extern bool window_wants_header_line (struct window *);
1177 extern bool window_wants_tab_line (struct window *);
1178 extern int window_internal_height (struct window *);
1179 enum window_body_unit
1180 {
1181 WINDOW_BODY_IN_CANONICAL_CHARS,
1182 WINDOW_BODY_IN_PIXELS,
1183 WINDOW_BODY_IN_REMAPPED_CHARS
1184 };
1185 extern int window_body_width (struct window *w, enum window_body_unit);
1186 extern int window_body_height (struct window *w, enum window_body_unit);
1187 enum margin_unit { MARGIN_IN_LINES, MARGIN_IN_PIXELS };
1188 extern int window_scroll_margin (struct window *, enum margin_unit);
1189 extern void temp_output_buffer_show (Lisp_Object);
1190 extern void replace_buffer_in_windows (Lisp_Object);
1191 extern void replace_buffer_in_windows_safely (Lisp_Object);
1192 /* This looks like a setter, but it is a bit special. */
1193 extern void wset_buffer (struct window *, Lisp_Object);
1194 extern bool window_outdated (struct window *);
1195 extern ptrdiff_t window_point (struct window *w);
1196 extern void init_window_once (void);
1197 extern void init_window (void);
1198 extern void syms_of_window (void);
1199 /* Move cursor to row/column position VPOS/HPOS, pixel coordinates
1200 Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y
1201 are window-relative pixel positions. This is always done during
1202 window update, so the position is the future output cursor position
1203 for currently updated window W. */
1204
1205 INLINE void
1206 output_cursor_to (struct window *w, int vpos, int hpos, int y, int x)
1207 {
1208 eassert (w);
1209 w->output_cursor.hpos = hpos;
1210 w->output_cursor.vpos = vpos;
1211 w->output_cursor.x = x;
1212 w->output_cursor.y = y;
1213 }
1214
1215 /* Return true, if overlay OV's properties should have an effect in
1216 window W. */
1217 INLINE bool
1218 overlay_matches_window (const struct window *w, Lisp_Object ov)
1219 {
1220 eassert (OVERLAYP (ov));
1221 Lisp_Object window = Foverlay_get (ov, Qwindow);
1222 return (! WINDOWP (window) || XWINDOW (window) == w);
1223 }
1224
1225 INLINE_HEADER_END
1226
1227 #endif /* not WINDOW_H_INCLUDED */