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