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