1 /* Window definitions for GNU Emacs.
2 Copyright (C) 1985-1986, 1993, 1995, 1997-2021 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 /* If redisplay in this window goes beyond this buffer position,
203 must run the redisplay-end-trigger-hook. */
204 Lisp_Object redisplay_end_trigger;
205
206 /* t means this window's child windows are not (re-)combined. */
207 Lisp_Object combination_limit;
208
209 /* An alist with parameters. */
210 Lisp_Object window_parameters;
211
212 /* The help echo text for this window. Qnil if there's none. */
213 Lisp_Object mode_line_help_echo;
214
215 /* No Lisp data may follow this point; mode_line_help_echo must be
216 the last Lisp member. */
217
218 /* Glyph matrices. */
219 struct glyph_matrix *current_matrix;
220 struct glyph_matrix *desired_matrix;
221
222 /* The two Lisp_Object fields below are marked in a special way,
223 which is why they're placed after `current_matrix'. */
224 /* A list of <buffer, window-start, window-point> triples listing
225 buffers previously shown in this window. */
226 Lisp_Object prev_buffers;
227 /* List of buffers re-shown in this window. */
228 Lisp_Object next_buffers;
229
230 /* Number saying how recently window was selected. */
231 EMACS_INT use_time;
232
233 /* Unique number of window assigned when it was created. */
234 EMACS_INT sequence_number;
235
236 /* The change stamp of this window. Set to 0 when the window is
237 created, it is set to its frame's change stamp every time
238 run_window_change_functions is run on that frame with this
239 window live. It is left alone when the window exists only
240 within a window configuration. Not useful for internal
241 windows. */
242 int change_stamp;
243
244 /* The upper left corner pixel coordinates of this window, as
245 integers relative to upper left corner of frame = 0, 0. */
246 int pixel_left;
247 int pixel_top;
248
249 /* The upper left corner coordinates of this window,
250 relative to upper left corner of frame = 0, 0. */
251 int left_col;
252 int top_line;
253
254 /* The pixel size of the window. */
255 int pixel_width;
256 int pixel_height;
257
258 /* The pixel and pixel body sizes of the window at the last time
259 run_window_change_functions was run with this window live. Not
260 useful for internal windows. */
261 int old_pixel_width;
262 int old_pixel_height;
263 int old_body_pixel_width;
264 int old_body_pixel_height;
265
266 /* The size of the window. */
267 int total_cols;
268 int total_lines;
269
270 /* Number of columns display within the window is scrolled to the left. */
271 ptrdiff_t hscroll;
272
273 /* Minimum hscroll for automatic hscrolling. This is the value
274 the user has set, by set-window-hscroll for example. */
275 ptrdiff_t min_hscroll;
276
277 /* Maximum line length in pixels within window bound by size of
278 window (set up by set_horizontal_scroll_bar). */
279 ptrdiff_t hscroll_whole;
280
281 /* Displayed buffer's text modification events counter as of last time
282 display completed. */
283 modiff_count last_modified;
284
285 /* Displayed buffer's overlays modification events counter as of last
286 complete update. */
287 modiff_count last_overlay_modified;
288
289 /* Value of point at that time. Since this is a position in a buffer,
290 it should be positive. */
291 ptrdiff_t last_point;
292
293 /* Line number and position of a line somewhere above the top of the
294 screen. If this field is zero, it means we don't have a base line. */
295 ptrdiff_t base_line_number;
296
297 /* If this field is zero, it means we don't have a base line.
298 If it is -1, it means don't display the line number as long
299 as the window shows its buffer. */
300 ptrdiff_t base_line_pos;
301
302 /* The column number currently displayed in this window's mode
303 line, or -1 if column numbers are not being displayed. */
304 ptrdiff_t column_number_displayed;
305
306 /* Scaling factor for the glyph_matrix size calculation in this window.
307 Used if window contains many small images or uses proportional fonts,
308 as the normal may yield a matrix which is too small. */
309 int nrows_scale_factor, ncols_scale_factor;
310
311 /* Intended cursor position. This is a position within the
312 glyph matrix. */
313 struct cursor_pos cursor;
314
315 /* Where the cursor actually is. */
316 struct cursor_pos phys_cursor;
317
318 /* Internally used for redisplay purposes. */
319 struct cursor_pos output_cursor;
320
321 /* Vertical cursor position as of last update that completed
322 without pause. This is the position of last_point. */
323 int last_cursor_vpos;
324
325 #ifdef HAVE_WINDOW_SYSTEM
326
327 /* Cursor type of last cursor drawn on the window. */
328 enum text_cursor_kinds phys_cursor_type;
329
330 /* Width of the cursor above. */
331 int phys_cursor_width;
332
333 /* This is handy for undrawing the cursor. */
334 int phys_cursor_ascent, phys_cursor_height;
335
336 #endif /* HAVE_WINDOW_SYSTEM */
337
338 /* Width of left and right fringes, in pixels.
339 A value of -1 means use frame values. */
340 int left_fringe_width;
341 int right_fringe_width;
342
343 /* Requested width of left and right marginal areas in columns. A
344 value of 0 means no margin. The actual values are recorded in
345 the window's glyph matrix, in the left_margin_glyphs and
346 right_margin_glyphs members. */
347 int left_margin_cols;
348 int right_margin_cols;
349
350 /* Pixel width of scroll bars.
351 A value of -1 means use frame values. */
352 int scroll_bar_width;
353
354 /* Pixel height of scroll bars.
355 A value of -1 means use frame values. */
356 int scroll_bar_height;
357
358 /* Effective height of the mode line, or -1 if not known. */
359 int mode_line_height;
360
361 /* Effective height of the header line, or -1 if not known. */
362 int header_line_height;
363
364 /* Effective height of the tab line, or -1 if not known. */
365 int tab_line_height;
366
367 /* Z - the buffer position of the last glyph in the current
368 matrix of W. Only valid if window_end_valid is true. */
369 ptrdiff_t window_end_pos;
370
371 /* Glyph matrix row of the last glyph in the current matrix
372 of W. Only valid if window_end_valid is true. */
373 int window_end_vpos;
374
375 /* True if this window is a minibuffer window. */
376 bool_bf mini : 1;
377
378 /* Meaningful for internal windows only: true if this window is a
379 horizontal combination, false if it is a vertical
380 combination. */
381 bool_bf horizontal : 1;
382
383 /* True means must regenerate mode line of this window. */
384 bool_bf update_mode_line : 1;
385
386 /* True if the buffer was "modified" when the window
387 was last updated. */
388 bool_bf last_had_star : 1;
389
390 /* True means current value of `start'
391 was the beginning of a line when it was chosen. */
392 bool_bf start_at_line_beg : 1;
393
394 /* True means next redisplay must use the value of start
395 set up for it in advance. Set by scrolling commands. */
396 bool_bf force_start : 1;
397
398 /* True means we have explicitly changed the value of start,
399 but that the next redisplay is not obliged to use the new value.
400 This is used in Fdelete_other_windows to force a call to
401 Vwindow_scroll_functions; also by Frecenter with argument. */
402 bool_bf optional_new_start : 1;
403
404 /* True means the cursor is currently displayed. This can be
405 set to zero by functions overpainting the cursor image. */
406 bool_bf phys_cursor_on_p : 1;
407
408 /* False means cursor is logically on, true means it's off. Used for
409 blinking cursor. */
410 bool_bf cursor_off_p : 1;
411
412 /* Value of cursor_off_p as of the last redisplay. */
413 bool_bf last_cursor_off_p : 1;
414
415 /* True means desired matrix has been build and window must be
416 updated in update_frame. */
417 bool_bf must_be_updated_p : 1;
418
419 /* Flag indicating that this window is not a real one.
420 Currently only used for menu bar windows, for tool bar windows,
421 and for tooltips. */
422 bool_bf pseudo_window_p : 1;
423
424 /* True means fringes are drawn outside display margins.
425 Otherwise draw them between margin areas and text. */
426 bool_bf fringes_outside_margins : 1;
427
428 /* True if this window's fringe specifications are persistent,
429 i.e., always survive Fset_window_buffer. */
430 bool_bf fringes_persistent : 1;
431
432 /* True if this window's scroll bar specifications are persistent,
433 i.e., always survive Fset_window_buffer. */
434 bool_bf scroll_bars_persistent : 1;
435
436 /* True if window_end_pos and window_end_vpos are truly valid.
437 This is false if nontrivial redisplay is preempted since in that case
438 the frame image that window_end_pos did not get onto the frame. */
439 bool_bf window_end_valid : 1;
440
441 /* True if it needs to be redisplayed. */
442 bool_bf redisplay : 1;
443
444 /* True if auto hscrolling is currently suspended in this
445 window. */
446 bool_bf suspend_auto_hscroll : 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
WINDOWP(Lisp_Object a)458 WINDOWP (Lisp_Object a)
459 {
460 return PSEUDOVECTORP (a, PVEC_WINDOW);
461 }
462
463 INLINE void
CHECK_WINDOW(Lisp_Object x)464 CHECK_WINDOW (Lisp_Object x)
465 {
466 CHECK_TYPE (WINDOWP (x), Qwindowp, x);
467 }
468
469 INLINE struct window *
XWINDOW(Lisp_Object a)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
wset_frame(struct window * w,Lisp_Object val)479 wset_frame (struct window *w, Lisp_Object val)
480 {
481 w->frame = val;
482 }
483
484 INLINE void
wset_next(struct window * w,Lisp_Object val)485 wset_next (struct window *w, Lisp_Object val)
486 {
487 w->next = val;
488 }
489
490 INLINE void
wset_prev(struct window * w,Lisp_Object val)491 wset_prev (struct window *w, Lisp_Object val)
492 {
493 w->prev = val;
494 }
495
496 INLINE void
wset_redisplay_end_trigger(struct window * w,Lisp_Object val)497 wset_redisplay_end_trigger (struct window *w, Lisp_Object val)
498 {
499 w->redisplay_end_trigger = val;
500 }
501
502 INLINE void
wset_mode_line_help_echo(struct window * w,Lisp_Object val)503 wset_mode_line_help_echo (struct window *w, Lisp_Object val)
504 {
505 w->mode_line_help_echo = val;
506 }
507
508 INLINE void
wset_new_pixel(struct window * w,Lisp_Object val)509 wset_new_pixel (struct window *w, Lisp_Object val)
510 {
511 w->new_pixel = val;
512 }
513
514 INLINE void
wset_vertical_scroll_bar(struct window * w,Lisp_Object val)515 wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
516 {
517 w->vertical_scroll_bar = val;
518 }
519
520 INLINE void
wset_horizontal_scroll_bar(struct window * w,Lisp_Object val)521 wset_horizontal_scroll_bar (struct window *w, Lisp_Object val)
522 {
523 w->horizontal_scroll_bar = val;
524 }
525
526 INLINE void
wset_horizontal_scroll_bar_type(struct window * w,Lisp_Object val)527 wset_horizontal_scroll_bar_type (struct window *w, Lisp_Object val)
528 {
529 w->horizontal_scroll_bar_type = val;
530 }
531
532 INLINE void
wset_prev_buffers(struct window * w,Lisp_Object val)533 wset_prev_buffers (struct window *w, Lisp_Object val)
534 {
535 w->prev_buffers = val;
536 }
537
538 INLINE void
wset_next_buffers(struct window * w,Lisp_Object val)539 wset_next_buffers (struct window *w, Lisp_Object val)
540 {
541 w->next_buffers = val;
542 }
543
544 /* True if W is a minibuffer window. */
545 #define MINI_WINDOW_P(W) ((W)->mini)
546
547 /* True if W is a minibuffer window on a frame that contains at least
548 one other window. */
549 #define MINI_NON_ONLY_WINDOW_P(W) \
550 (MINI_WINDOW_P (W) && !NILP ((W)->prev))
551
552 /* True if W is a minibuffer window that is alone on its frame. */
553 #define MINI_ONLY_WINDOW_P(W) \
554 (MINI_WINDOW_P (W) && NILP ((W)->prev))
555
556 /* General window layout:
557
558 LEFT_EDGE_COL RIGHT_EDGE_COL
559 | |
560 | |
561 | BOX_LEFT_EDGE_COL |
562 | | BOX_RIGHT_EDGE_COL |
563 | | | |
564 v v v v
565 <-><-><---><-----------><---><-><->
566 ^ ^ ^ ^ ^ ^ ^
567 | | | | | | |
568 | | | | | | +-- RIGHT_SCROLL_BAR_COLS
569 | | | | | +----- RIGHT_FRINGE_WIDTH
570 | | | | +--------- RIGHT_MARGIN_COLS
571 | | | |
572 | | | +------------------ TEXT_AREA_COLS
573 | | |
574 | | +--------------------------- LEFT_MARGIN_COLS
575 | +------------------------------- LEFT_FRINGE_WIDTH
576 +---------------------------------- LEFT_SCROLL_BAR_COLS
577
578 */
579
580
581 /* A handy macro. */
582
583 /* Non-nil if window W is leaf window (has a buffer). */
584 #define WINDOW_LEAF_P(W) \
585 (BUFFERP ((W)->contents))
586
587 /* Non-nil if window W is internal (is a parent window). */
588 #define WINDOW_INTERNAL_P(W) \
589 (WINDOWP ((W)->contents))
590
591 /* True if window W is a horizontal combination of windows. */
592 #define WINDOW_HORIZONTAL_COMBINATION_P(W) \
593 (WINDOW_INTERNAL_P (W) && (W)->horizontal)
594
595 /* True if window W is a vertical combination of windows. */
596 #define WINDOW_VERTICAL_COMBINATION_P(W) \
597 (WINDOW_INTERNAL_P (W) && !(W)->horizontal)
598
599 /* Window W's XFRAME. */
600 #define WINDOW_XFRAME(W) (XFRAME (WINDOW_FRAME ((W))))
601
602 /* Whether window W is a pseudo window. */
603 #define WINDOW_PSEUDO_P(W) ((W)->pseudo_window_p)
604
605 /* Window W's buffer. */
606 #define WINDOW_BUFFER(W) \
607 (WINDOW_LEAF_P(W) \
608 ? (W)->contents \
609 : Qnil)
610
611 /* Local value of variable V in window W's buffer. Nil if W has no
612 buffer. */
613 #define WINDOW_BUFFER_LOCAL_VALUE(V, W) \
614 (BUFFERP ((W)->contents) \
615 ? buffer_local_value(V, (W)->contents) \
616 : Qnil)
617
618 /* Return the canonical column width of the frame of window W. */
619 #define WINDOW_FRAME_COLUMN_WIDTH(W) \
620 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
621
622 /* Return the canonical line height of the frame of window W. */
623 #define WINDOW_FRAME_LINE_HEIGHT(W) \
624 (FRAME_LINE_HEIGHT (WINDOW_XFRAME ((W))))
625
626 /* Return the pixel width of window W. This includes dividers, scroll
627 bars, fringes and margins, if any. */
628 #define WINDOW_PIXEL_WIDTH(W) (W)->pixel_width
629
630 /* Return the pixel height of window W. This includes dividers, scroll
631 bars, header and mode lines, if any. */
632 #define WINDOW_PIXEL_HEIGHT(W) (W)->pixel_height
633
634 /* Return the width of window W in canonical column units. This
635 includes dividers, scroll bars, fringes and margins, if any. The
636 value is adjusted such that the sum of the widths of all child
637 windows equals the width of their parent window. */
638 #define WINDOW_TOTAL_COLS(W) (W)->total_cols
639
640 /* Return the height of window W in canonical line units. This includes
641 dividers, scroll bars, header and mode lines, if any. The value is
642 adjusted such that the sum of the heights of all child windows equals
643 the height of their parent window. */
644 #define WINDOW_TOTAL_LINES(W) (W)->total_lines
645
646 /* The smallest acceptable dimensions for a window. Anything smaller
647 might crash Emacs. */
648 #define MIN_SAFE_WINDOW_WIDTH (2)
649
650 #define MIN_SAFE_WINDOW_PIXEL_WIDTH(W) \
651 (2 * WINDOW_FRAME_COLUMN_WIDTH (W))
652
653 #define MIN_SAFE_WINDOW_HEIGHT (1)
654
655 #define MIN_SAFE_WINDOW_PIXEL_HEIGHT(W) \
656 (WINDOW_FRAME_LINE_HEIGHT (W))
657
658 /* True if window W has no other windows to its left on its frame. */
659 #define WINDOW_LEFTMOST_P(W) \
660 (WINDOW_LEFT_PIXEL_EDGE (W) == 0)
661
662 /* True if window W has no other windows above it on its frame. */
663 #define WINDOW_TOPMOST_P(W) \
664 (WINDOW_TOP_PIXEL_EDGE (W) == 0)
665
666 /* True if window W has no other windows to its right on its frame. */
667 #define WINDOW_RIGHTMOST_P(W) \
668 (WINDOW_RIGHT_PIXEL_EDGE (W) \
669 == (WINDOW_RIGHT_PIXEL_EDGE \
670 (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
671
672 /* True if window W has no other windows below it on its frame (the
673 minibuffer window is not counted in this respect unless W itself is a
674 minibuffer window). */
675 #define WINDOW_BOTTOMMOST_P(W) \
676 (WINDOW_BOTTOM_PIXEL_EDGE (W) \
677 == (WINDOW_BOTTOM_PIXEL_EDGE \
678 (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
679
680 /* True if window W takes up the full width of its frame. */
681 #define WINDOW_FULL_WIDTH_P(W) \
682 (WINDOW_PIXEL_WIDTH (W) \
683 == (WINDOW_PIXEL_WIDTH \
684 (XWINDOW (FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))))))
685
686 /* Width of right divider of window W. */
687 #define WINDOW_RIGHT_DIVIDER_WIDTH(W) \
688 (WINDOW_RIGHTMOST_P (W) \
689 ? 0 : FRAME_RIGHT_DIVIDER_WIDTH (WINDOW_XFRAME (W)))
690
691 /* Width of bottom divider of window W. */
692 #define WINDOW_BOTTOM_DIVIDER_WIDTH(W) \
693 (((WINDOW_BOTTOMMOST_P (W) \
694 && NILP ((XWINDOW (FRAME_ROOT_WINDOW \
695 (WINDOW_XFRAME (W))))->next)) \
696 || EQ ((W)->prev, FRAME_ROOT_WINDOW (WINDOW_XFRAME (W))) \
697 || (W)->pseudo_window_p) \
698 ? 0 : FRAME_BOTTOM_DIVIDER_WIDTH (WINDOW_XFRAME (W)))
699
700 /* Return the canonical frame column at which window W starts.
701 This includes a left-hand scroll bar, if any. */
702 #define WINDOW_LEFT_EDGE_COL(W) (W)->left_col
703
704 /* Return the canonical frame column before which window W ends.
705 This includes a right-hand scroll bar, if any. */
706 #define WINDOW_RIGHT_EDGE_COL(W) \
707 (WINDOW_LEFT_EDGE_COL (W) + WINDOW_TOTAL_COLS (W))
708
709 /* Return the canonical frame line at which window W starts.
710 This includes a header/tab line, if any. */
711 #define WINDOW_TOP_EDGE_LINE(W) (W)->top_line
712
713 /* Return the canonical frame line before which window W ends.
714 This includes a mode line, if any. */
715 #define WINDOW_BOTTOM_EDGE_LINE(W) \
716 (WINDOW_TOP_EDGE_LINE (W) + WINDOW_TOTAL_LINES (W))
717
718 /* Return the left pixel edge at which window W starts.
719 This includes a left-hand scroll bar, if any. */
720 #define WINDOW_LEFT_PIXEL_EDGE(W) (W)->pixel_left
721
722 /* Return the right pixel edge before which window W ends.
723 This includes a right-hand scroll bar, if any. */
724 #define WINDOW_RIGHT_PIXEL_EDGE(W) \
725 (WINDOW_LEFT_PIXEL_EDGE (W) + WINDOW_PIXEL_WIDTH (W))
726
727 /* Return the top pixel edge at which window W starts.
728 This includes a header/tab line, if any. */
729 #define WINDOW_TOP_PIXEL_EDGE(W) (W)->pixel_top
730
731 /* Return the bottom pixel edge before which window W ends.
732 This includes a mode line, if any. */
733 #define WINDOW_BOTTOM_PIXEL_EDGE(W) \
734 (WINDOW_TOP_PIXEL_EDGE (W) + WINDOW_PIXEL_HEIGHT (W))
735
736 /* Return the frame x-position at which window W starts.
737 This includes a left-hand scroll bar, if any. */
738 #define WINDOW_LEFT_EDGE_X(W) \
739 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
740 + WINDOW_LEFT_PIXEL_EDGE (W))
741
742 /* Return the frame x- position before which window W ends.
743 This includes a right-hand scroll bar, if any. */
744 #define WINDOW_RIGHT_EDGE_X(W) \
745 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
746 + WINDOW_RIGHT_PIXEL_EDGE (W))
747
748 /* True if W is a menu bar window. */
749 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
750 #define WINDOW_MENU_BAR_P(W) \
751 (WINDOWP (WINDOW_XFRAME (W)->menu_bar_window) \
752 && (W) == XWINDOW (WINDOW_XFRAME (W)->menu_bar_window))
753 #else
754 /* No menu bar windows if X toolkit is in use. */
755 #define WINDOW_MENU_BAR_P(W) false
756 #endif
757
758 /* True if W is a tab bar window. */
759 #if defined (HAVE_WINDOW_SYSTEM)
760 # define WINDOW_TAB_BAR_P(W) \
761 (WINDOWP (WINDOW_XFRAME (W)->tab_bar_window) \
762 && (W) == XWINDOW (WINDOW_XFRAME (W)->tab_bar_window))
763 #else
764 # define WINDOW_TAB_BAR_P(W) false
765 #endif
766
767 /* True if W is a tool bar window. */
768 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
769 #define WINDOW_TOOL_BAR_P(W) \
770 (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
771 && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
772 #else
773 #define WINDOW_TOOL_BAR_P(W) false
774 #endif
775
776 /* Return the frame y-position at which window W starts. */
777 #define WINDOW_TOP_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_TOP_PIXEL_EDGE (W))
781
782 /* Return the frame y-position before which window W ends. */
783 #define WINDOW_BOTTOM_EDGE_Y(W) \
784 (((WINDOW_MENU_BAR_P (W) || WINDOW_TAB_BAR_P (W) || WINDOW_TOOL_BAR_P (W)) \
785 ? 0 : FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W))) \
786 + WINDOW_BOTTOM_PIXEL_EDGE (W))
787
788 /* Return the pixel value where the text (or left fringe) in window W
789 starts. */
790 #define WINDOW_BOX_LEFT_PIXEL_EDGE(W) \
791 (WINDOW_LEFT_PIXEL_EDGE (W) \
792 + WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (W))
793
794 /* Return the pixel value before which the text in window W ends. This
795 is different from the `RIGHT_EDGE' because it does not include a
796 right-hand scroll bar or window-separating line on the right
797 edge. */
798 #define WINDOW_BOX_RIGHT_PIXEL_EDGE(W) \
799 (WINDOW_RIGHT_PIXEL_EDGE (W) \
800 - WINDOW_RIGHT_DIVIDER_WIDTH (W) \
801 - WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH (W))
802
803 /* Return the frame x-position at which the text (or left fringe) in
804 window W starts. This does not include a left-hand scroll bar if
805 any. */
806 #define WINDOW_BOX_LEFT_EDGE_X(W) \
807 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
808 + WINDOW_BOX_LEFT_PIXEL_EDGE (W))
809
810 /* Return the frame x-position before which the text in window W ends.
811 This does not include a scroll bar, divider or window-separating line
812 on the right edge. */
813 #define WINDOW_BOX_RIGHT_EDGE_X(W) \
814 (FRAME_INTERNAL_BORDER_WIDTH (WINDOW_XFRAME (W)) \
815 + WINDOW_BOX_RIGHT_PIXEL_EDGE (W))
816
817 /* Widths of marginal areas in columns. */
818 #define WINDOW_LEFT_MARGIN_COLS(W) (W->left_margin_cols)
819
820 #define WINDOW_RIGHT_MARGIN_COLS(W) (W->right_margin_cols)
821
822 #define WINDOW_MARGINS_COLS(W) \
823 (WINDOW_LEFT_MARGIN_COLS (W) \
824 + WINDOW_RIGHT_MARGIN_COLS (W))
825
826 /* Widths of marginal areas in pixels. */
827 #define WINDOW_LEFT_MARGIN_WIDTH(W) \
828 (W->left_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
829
830 #define WINDOW_RIGHT_MARGIN_WIDTH(W) \
831 (W->right_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
832
833 #define WINDOW_MARGINS_WIDTH(W) \
834 (WINDOW_LEFT_MARGIN_WIDTH (W) \
835 + WINDOW_RIGHT_MARGIN_WIDTH (W))
836
837 /* Pixel-widths of fringes. */
838 #define WINDOW_LEFT_FRINGE_WIDTH(W) \
839 (W->left_fringe_width >= 0 \
840 ? W->left_fringe_width \
841 : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
842
843 #define WINDOW_RIGHT_FRINGE_WIDTH(W) \
844 (W->right_fringe_width >= 0 \
845 ? W->right_fringe_width \
846 : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
847
848 #define WINDOW_FRINGES_WIDTH(W) \
849 (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
850
851 /* Are fringes outside display margins in window W. */
852 #define WINDOW_HAS_FRINGES_OUTSIDE_MARGINS(W) \
853 ((W)->fringes_outside_margins)
854
855 /* Say whether vertical scroll bars are currently enabled for window W,
856 and which side they are on. */
857 #define WINDOW_VERTICAL_SCROLL_BAR_TYPE(W) \
858 (WINDOW_PSEUDO_P (W) \
859 ? vertical_scroll_bar_none \
860 : EQ (W->vertical_scroll_bar_type, Qt) \
861 ? FRAME_VERTICAL_SCROLL_BAR_TYPE (WINDOW_XFRAME (W)) \
862 : EQ (W->vertical_scroll_bar_type, Qleft) \
863 ? vertical_scroll_bar_left \
864 : EQ (W->vertical_scroll_bar_type, Qright) \
865 ? vertical_scroll_bar_right \
866 : vertical_scroll_bar_none)
867
868 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT(W) \
869 (WINDOW_VERTICAL_SCROLL_BAR_TYPE (W) == vertical_scroll_bar_left)
870
871 #define WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT(W) \
872 (WINDOW_VERTICAL_SCROLL_BAR_TYPE (W) == vertical_scroll_bar_right)
873
874 #define WINDOW_HAS_VERTICAL_SCROLL_BAR(W) \
875 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (W) \
876 || WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W))
877
878 #if (defined (HAVE_WINDOW_SYSTEM) \
879 && ((defined (USE_TOOLKIT_SCROLL_BARS)) \
880 || defined (HAVE_NTGUI)))
881 # define USE_HORIZONTAL_SCROLL_BARS true
882 #else
883 # define USE_HORIZONTAL_SCROLL_BARS false
884 #endif
885
886 /* Say whether horizontal scroll bars are currently enabled for window
887 W. Horizontal scrollbars exist for toolkit versions only. */
888 #if USE_HORIZONTAL_SCROLL_BARS
889 #define WINDOW_HAS_HORIZONTAL_SCROLL_BAR(W) \
890 ((WINDOW_PSEUDO_P (W) \
891 || (MINI_WINDOW_P (W) \
892 && !EQ (W->horizontal_scroll_bar_type, Qbottom))) \
893 ? false \
894 : EQ (W->horizontal_scroll_bar_type, Qt) \
895 ? FRAME_HAS_HORIZONTAL_SCROLL_BARS (WINDOW_XFRAME (W)) \
896 : EQ (W->horizontal_scroll_bar_type, Qbottom) \
897 ? true \
898 : false)
899 #else
900 #define WINDOW_HAS_HORIZONTAL_SCROLL_BAR(W) false
901 #endif
902
903 /* Width that a scroll bar in window W should have, if there is one.
904 Measured in pixels. If scroll bars are turned off, this is still
905 nonzero. */
906 #define WINDOW_CONFIG_SCROLL_BAR_WIDTH(W) \
907 (W->scroll_bar_width >= 0 \
908 ? W->scroll_bar_width \
909 : FRAME_CONFIG_SCROLL_BAR_WIDTH (WINDOW_XFRAME (W)))
910
911 /* Width that a scroll bar in window W should have, if there is one.
912 Measured in columns (characters). If scroll bars are turned off,
913 this is still nonzero. */
914 #define WINDOW_CONFIG_SCROLL_BAR_COLS(W) \
915 (W->scroll_bar_width >= 0 \
916 ? ((W->scroll_bar_width \
917 + WINDOW_FRAME_COLUMN_WIDTH (W) - 1) \
918 / WINDOW_FRAME_COLUMN_WIDTH (W)) \
919 : FRAME_CONFIG_SCROLL_BAR_COLS (WINDOW_XFRAME (W)))
920
921 /* Width of left scroll bar in window W, measured in columns
922 (characters). If scroll bars are on the right in this frame, or
923 there are no scroll bars, value is 0. */
924 #define WINDOW_LEFT_SCROLL_BAR_COLS(W) \
925 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (W) \
926 ? (WINDOW_CONFIG_SCROLL_BAR_COLS (W)) \
927 : 0)
928
929 /* Width of right scroll bar in window W, measured in columns
930 (characters). If scroll bars are on the left in this frame, or there
931 are no scroll bars, value is 0. */
932 #define WINDOW_RIGHT_SCROLL_BAR_COLS(W) \
933 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
934 ? WINDOW_CONFIG_SCROLL_BAR_COLS (W) \
935 : 0)
936
937 /* Width of a scroll bar in window W, measured in columns. */
938 #define WINDOW_SCROLL_BAR_COLS(W) \
939 (WINDOW_HAS_VERTICAL_SCROLL_BAR (W) \
940 ? WINDOW_CONFIG_SCROLL_BAR_COLS (W) \
941 : 0)
942
943 /* Width of a left scroll bar area in window W, measured in pixels. */
944 #define WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH(W) \
945 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (W) \
946 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \
947 : 0)
948
949 /* Width of a right scroll bar area in window W, measured in pixels. */
950 #define WINDOW_RIGHT_SCROLL_BAR_AREA_WIDTH(W) \
951 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
952 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \
953 : 0)
954
955 /* Width of scroll bar area in window W, measured in pixels. */
956 #define WINDOW_SCROLL_BAR_AREA_WIDTH(W) \
957 (WINDOW_HAS_VERTICAL_SCROLL_BAR (W) \
958 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (W) \
959 : 0)
960
961 /* Return the frame position where the vertical scroll bar of window W
962 starts. */
963 #define WINDOW_SCROLL_BAR_AREA_X(W) \
964 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_RIGHT (W) \
965 ? WINDOW_BOX_RIGHT_EDGE_X (W) \
966 : WINDOW_LEFT_EDGE_X (W))
967
968 /* Height that a scroll bar in window W should have, if there is one.
969 Measured in pixels. If scroll bars are turned off, this is still
970 nonzero. */
971 #define WINDOW_CONFIG_SCROLL_BAR_HEIGHT(W) \
972 (W->scroll_bar_height >= 0 \
973 ? W->scroll_bar_height \
974 : FRAME_CONFIG_SCROLL_BAR_HEIGHT (WINDOW_XFRAME (W)))
975
976 /* Height that a scroll bar in window W should have, if there is one.
977 Measured in lines (characters). If scroll bars are turned off, this
978 is still nonzero. */
979 #define WINDOW_CONFIG_SCROLL_BAR_LINES(W) \
980 (W->scroll_bar_height >= 0 \
981 ? ((W->scroll_bar_height \
982 + WINDOW_FRAME_LINE_HEIGHT (W) - 1) \
983 / WINDOW_FRAME_LINE_HEIGHT (W)) \
984 : FRAME_CONFIG_SCROLL_BAR_LINES (WINDOW_XFRAME (W)))
985
986 /* Height of a scroll bar in window W, measured in columns. */
987 #define WINDOW_SCROLL_BAR_LINES(W) \
988 (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (W) \
989 ? WINDOW_CONFIG_SCROLL_BAR_LINES (W) \
990 : 0)
991
992 /* Height of scroll bar area in window W, measured in pixels. */
993 #define WINDOW_SCROLL_BAR_AREA_HEIGHT(W) \
994 (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (W) \
995 ? WINDOW_CONFIG_SCROLL_BAR_HEIGHT (W) \
996 : 0)
997
998 /* Height in pixels of the mode line.
999 May be zero if W doesn't have a mode line. */
1000 #define WINDOW_MODE_LINE_HEIGHT(W) \
1001 (window_wants_mode_line ((W)) \
1002 ? CURRENT_MODE_LINE_HEIGHT (W) \
1003 : 0)
1004
1005 #define WINDOW_MODE_LINE_LINES(W) \
1006 window_wants_mode_line (W)
1007
1008 /* Height in pixels of the header line.
1009 Zero if W doesn't have a header line. */
1010 #define WINDOW_HEADER_LINE_HEIGHT(W) \
1011 (window_wants_header_line (W) \
1012 ? CURRENT_HEADER_LINE_HEIGHT (W) \
1013 : 0)
1014
1015 #define WINDOW_HEADER_LINE_LINES(W) \
1016 window_wants_header_line (W)
1017
1018 /* Height in pixels of the tab line.
1019 Zero if W doesn't have a tab line. */
1020 #define WINDOW_TAB_LINE_HEIGHT(W) \
1021 (window_wants_tab_line (W) \
1022 ? CURRENT_TAB_LINE_HEIGHT (W) \
1023 : 0)
1024
1025 #define WINDOW_TAB_LINE_LINES(W) \
1026 window_wants_tab_line (W)
1027
1028 /* Pixel height of window W without mode line, bottom scroll bar and
1029 bottom divider. */
1030 #define WINDOW_BOX_HEIGHT_NO_MODE_LINE(W) \
1031 (WINDOW_PIXEL_HEIGHT (W) \
1032 - WINDOW_BOTTOM_DIVIDER_WIDTH (W) \
1033 - WINDOW_SCROLL_BAR_AREA_HEIGHT (W) \
1034 - WINDOW_MODE_LINE_HEIGHT (W))
1035
1036 /* Pixel height of window W without mode and header/tab line and bottom
1037 divider. */
1038 #define WINDOW_BOX_TEXT_HEIGHT(W) \
1039 (WINDOW_PIXEL_HEIGHT ((W)) \
1040 - WINDOW_BOTTOM_DIVIDER_WIDTH (W) \
1041 - WINDOW_SCROLL_BAR_AREA_HEIGHT (W) \
1042 - WINDOW_MODE_LINE_HEIGHT (W) \
1043 - WINDOW_HEADER_LINE_HEIGHT (W) \
1044 - WINDOW_TAB_LINE_HEIGHT (W))
1045
1046 /* Return the frame position where the horizontal scroll bar of window W
1047 starts. */
1048 #define WINDOW_SCROLL_BAR_AREA_Y(W) \
1049 (WINDOW_TOP_EDGE_Y (W) \
1050 + (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (W) \
1051 ? WINDOW_BOX_HEIGHT_NO_MODE_LINE (W) : 0))
1052
1053 /* Convert window W relative pixel X to frame pixel coordinates. */
1054 #define WINDOW_TO_FRAME_PIXEL_X(W, X) \
1055 ((X) + WINDOW_BOX_LEFT_EDGE_X ((W)))
1056
1057 /* Convert window W relative pixel Y to frame pixel coordinates. */
1058 #define WINDOW_TO_FRAME_PIXEL_Y(W, Y) \
1059 ((Y) + WINDOW_TOP_EDGE_Y (W))
1060
1061 /* Convert frame relative pixel X to window relative pixel X. */
1062 #define FRAME_TO_WINDOW_PIXEL_X(W, X) \
1063 ((X) - WINDOW_BOX_LEFT_EDGE_X ((W)))
1064
1065 /* Convert frame relative pixel Y to window relative pixel Y. */
1066 #define FRAME_TO_WINDOW_PIXEL_Y(W, Y) \
1067 ((Y) - WINDOW_TOP_EDGE_Y (W))
1068
1069 /* Convert a text area relative x-position in window W to frame X
1070 pixel coordinates. */
1071 #define WINDOW_TEXT_TO_FRAME_PIXEL_X(W, X) \
1072 (window_box_left ((W), TEXT_AREA) + (X))
1073
1074 /* This is the window in which the terminal's cursor should be left when
1075 nothing is being done with it. This must always be a leaf window, and its
1076 buffer is selected by the top level editing loop at the end of each command.
1077
1078 This value is always the same as FRAME_SELECTED_WINDOW (selected_frame). */
1079
1080 extern Lisp_Object selected_window;
1081
1082 /* This is a time stamp for window selection, so we can find the least
1083 recently used window. Its only users are Fselect_window,
1084 init_window_once, and make_frame. */
1085
1086 extern EMACS_INT window_select_count;
1087
1088 /* The minibuffer window of the selected frame.
1089 Note that you cannot test for minibufferness of an arbitrary window
1090 by comparing against this; use the MINI_WINDOW_P macro instead. */
1091
1092 extern Lisp_Object minibuf_window;
1093
1094 /* Non-nil means it is the window whose mode line should be
1095 shown as the selected window when the minibuffer is selected. */
1096
1097 extern Lisp_Object minibuf_selected_window;
1098
1099 extern Lisp_Object make_window (void);
1100 extern Lisp_Object window_from_coordinates (struct frame *, int, int,
1101 enum window_part *, bool, bool);
1102 extern void resize_frame_windows (struct frame *, int, bool);
1103 extern void restore_window_configuration (Lisp_Object);
1104 extern void delete_all_child_windows (Lisp_Object);
1105 extern void grow_mini_window (struct window *, int);
1106 extern void shrink_mini_window (struct window *);
1107 extern int window_relative_x_coord (struct window *, enum window_part, int);
1108
1109 void run_window_change_functions (void);
1110
1111 /* Make WINDOW display BUFFER. RUN_HOOKS_P means it's allowed
1112 to run hooks. See make_frame for a case where it's not allowed. */
1113
1114 void set_window_buffer (Lisp_Object window, Lisp_Object buffer,
1115 bool run_hooks_p, bool keep_margins_p);
1116
1117 /* This is the window where the echo area message was displayed. It
1118 is always a minibuffer window, but it may not be the same window
1119 currently active as a minibuffer. */
1120
1121 extern Lisp_Object echo_area_window;
1122
1123 /* Depth in recursive edits. */
1124
1125 extern EMACS_INT command_loop_level;
1126
1127 /* Depth in minibuffer invocations. */
1128
1129 extern EMACS_INT minibuf_level;
1130
1131 /* Non-zero if we should redraw the mode lines on the next redisplay.
1132 Usually set to a unique small integer so we can track the main causes of
1133 full redisplays in `redisplay--mode-lines-cause'. */
1134
1135 extern int update_mode_lines;
1136
1137 /* Nonzero if window sizes or contents have changed since last
1138 redisplay that finished. Usually set to a unique small integer so
1139 we can track the main causes of full redisplays in
1140 `redisplay--all-windows-cause'. */
1141
1142 extern int windows_or_buffers_changed;
1143
1144 /* The main redisplay routine usually only redisplays the selected-window,
1145 so when something's changed elsewhere, we call one of the functions below
1146 to indicate which other windows might also need to be redisplayed. */
1147
1148 extern void wset_redisplay (struct window *w);
1149 extern void fset_redisplay (struct frame *f);
1150 extern void bset_redisplay (struct buffer *b);
1151 extern void bset_update_mode_line (struct buffer *b);
1152 /* Call this to tell redisplay to look for other windows than selected-window
1153 that need to be redisplayed. Calling one of the *set_redisplay functions
1154 above already does it, so it's only needed in unusual cases. */
1155 extern void redisplay_other_windows (void);
1156
1157 /* Return a pointer to the glyph W's physical cursor is on. Value is
1158 null if W's current matrix is invalid, so that no meaningful glyph
1159 can be returned. */
1160
1161 struct glyph *get_phys_cursor_glyph (struct window *w);
1162
1163 /* True if WINDOW is a valid window. */
1164 #define WINDOW_VALID_P(WINDOW) \
1165 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents))
1166
1167 /* A window of any sort, leaf or interior, is "valid" if its
1168 contents slot is non-nil. */
1169 #define CHECK_VALID_WINDOW(WINDOW) \
1170 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
1171
1172 /* True if WINDOW is a live window. */
1173 #define WINDOW_LIVE_P(WINDOW) \
1174 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
1175
1176 /* A window is "live" if and only if it shows a buffer. */
1177 #define CHECK_LIVE_WINDOW(WINDOW) \
1178 CHECK_TYPE (WINDOW_LIVE_P (WINDOW), Qwindow_live_p, WINDOW)
1179
1180 /* These used to be in lisp.h. */
1181 extern Lisp_Object Vwindow_list;
1182
1183 extern Lisp_Object window_list (void);
1184 extern Lisp_Object window_parameter (struct window *, Lisp_Object parameter);
1185 extern struct window *decode_live_window (Lisp_Object);
1186 extern struct window *decode_any_window (Lisp_Object);
1187 extern bool compare_window_configurations (Lisp_Object, Lisp_Object, bool);
1188 extern void mark_window_cursors_off (struct window *);
1189 extern bool window_wants_mode_line (struct window *);
1190 extern bool window_wants_header_line (struct window *);
1191 extern bool window_wants_tab_line (struct window *);
1192 extern int window_internal_height (struct window *);
1193 extern int window_body_width (struct window *w, bool);
1194 enum margin_unit { MARGIN_IN_LINES, MARGIN_IN_PIXELS };
1195 extern int window_scroll_margin (struct window *, enum margin_unit);
1196 extern void temp_output_buffer_show (Lisp_Object);
1197 extern void replace_buffer_in_windows (Lisp_Object);
1198 extern void replace_buffer_in_windows_safely (Lisp_Object);
1199 extern void sanitize_window_sizes (Lisp_Object horizontal);
1200 /* This looks like a setter, but it is a bit special. */
1201 extern void wset_buffer (struct window *, Lisp_Object);
1202 extern bool window_outdated (struct window *);
1203 extern void init_window_once (void);
1204 extern void init_window (void);
1205 extern void syms_of_window (void);
1206 extern void keys_of_window (void);
1207 /* Move cursor to row/column position VPOS/HPOS, pixel coordinates
1208 Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y
1209 are window-relative pixel positions. This is always done during
1210 window update, so the position is the future output cursor position
1211 for currently updated window W. */
1212
1213 INLINE void
output_cursor_to(struct window * w,int vpos,int hpos,int y,int x)1214 output_cursor_to (struct window *w, int vpos, int hpos, int y, int x)
1215 {
1216 eassert (w);
1217 w->output_cursor.hpos = hpos;
1218 w->output_cursor.vpos = vpos;
1219 w->output_cursor.x = x;
1220 w->output_cursor.y = y;
1221 }
1222
1223 INLINE_HEADER_END
1224
1225 #endif /* not WINDOW_H_INCLUDED */
1226