home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / e20313sr.zip / emacs / 20.3.1 / src / frame.h < prev    next >
C/C++ Source or Header  |  1999-07-31  |  24KB  |  609 lines

  1. /* Define frame-object for GNU Emacs.
  2.    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. /* Modified for emx by Jeremy Bowen, May 1999 */
  22.  
  23. /* Miscellanea.  */
  24.  
  25. /* Nonzero means don't assume anything about current
  26.    contents of actual terminal frame */
  27. extern int frame_garbaged;
  28.  
  29. /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
  30.    print.  */
  31. extern int message_buf_print;
  32.  
  33.  
  34. /* The structure representing a frame.  */
  35.  
  36. enum output_method
  37. { output_termcap, output_x_window, output_msdos_raw, output_w32 };
  38.  
  39. enum vertical_scroll_bar_type
  40. { vertical_scroll_bar_none, vertical_scroll_bar_left, vertical_scroll_bar_right };
  41.  
  42. struct frame
  43. {
  44.   EMACS_INT size;
  45.   struct Lisp_Vector *next;
  46.  
  47.   /* All Lisp_Object components must come first.
  48.      Only EMACS_INT values can be intermixed with them.
  49.      That ensures they are all aligned normally.  */
  50.  
  51.   /* Name of this frame: a Lisp string.  It is used for looking up resources,
  52.      as well as for the title in some cases.  */
  53.   Lisp_Object name;
  54.  
  55.   /* The name to use for the icon, the last time
  56.      it was refreshed.  nil means not explicitly specified.  */
  57.   Lisp_Object icon_name;
  58.  
  59.   /* This is the frame title specified explicitly, if any.
  60.      Usually it is nil.  */
  61.   Lisp_Object title;
  62.  
  63.   /* The frame which should receive keystrokes that occur in this
  64.      frame, or nil if they should go to the frame itself.  This is
  65.      usually nil, but if the frame is minibufferless, we can use this
  66.      to redirect keystrokes to a surrogate minibuffer frame when
  67.      needed.
  68.  
  69.      Note that a value of nil is different than having the field point
  70.      to the frame itself.  Whenever the Fselect_frame function is used
  71.      to shift from one frame to the other, any redirections to the
  72.      original frame are shifted to the newly selected frame; if
  73.      focus_frame is nil, Fselect_frame will leave it alone.  */
  74.   Lisp_Object focus_frame;
  75.  
  76.   /* This frame's root window.  Every frame has one.
  77.      If the frame has only a minibuffer window, this is it.
  78.      Otherwise, if the frame has a minibuffer window, this is its sibling.  */
  79.   Lisp_Object root_window;
  80.  
  81.   /* This frame's selected window.
  82.      Each frame has its own window hierarchy
  83.      and one of the windows in it is selected within the frame.
  84.      The selected window of the selected frame is Emacs's selected window.  */
  85.   Lisp_Object selected_window;
  86.  
  87.   /* This frame's minibuffer window.
  88.      Most frames have their own minibuffer windows,
  89.      but only the selected frame's minibuffer window
  90.      can actually appear to exist.  */
  91.   Lisp_Object minibuffer_window;
  92.  
  93.   /* Parameter alist of this frame.
  94.      These are the parameters specified when creating the frame
  95.      or modified with modify-frame-parameters.  */
  96.   Lisp_Object param_alist;
  97.  
  98.   /* List of scroll bars on this frame.  
  99.      Actually, we don't specify exactly what is stored here at all; the
  100.      scroll bar implementation code can use it to store anything it likes.
  101.      This field is marked by the garbage collector.  It is here
  102.      instead of in the `display' structure so that the garbage
  103.      collector doesn't need to look inside the window-system-dependent
  104.      structure.  */
  105.   Lisp_Object scroll_bars;
  106.   Lisp_Object condemned_scroll_bars;
  107.  
  108.   /* Vector describing the items to display in the menu bar.
  109.      Each item has four elements in this vector.
  110.      They are KEY, STRING, SUBMAP, and HPOS.
  111.      (HPOS is not used in when the X toolkit is in use.)
  112.      There are four additional elements of nil at the end, to terminate.  */
  113.   Lisp_Object menu_bar_items;
  114.  
  115.   /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA).  */
  116.   Lisp_Object face_alist;
  117.  
  118.   /* A vector that records the entire structure of this frame's menu bar.
  119.      For the format of the data, see extensive comments in xmenu.c.
  120.      Only the X toolkit version uses this.  */
  121.   Lisp_Object menu_bar_vector;
  122.   /* Number of elements in the vector that have meaningful data.  */
  123.   EMACS_INT menu_bar_items_used;
  124.  
  125.   /* Predicate for selecting buffers for other-buffer.  */
  126.   Lisp_Object buffer_predicate;
  127.  
  128.   /* List of buffers viewed in this frame, for other-buffer.  */
  129.   Lisp_Object buffer_list;
  130.  
  131.   /* beyond here, there should be no more Lisp_Object components.  */
  132.  
  133.  
  134.   /* A buffer to hold the frame's name.  We can't use the Lisp string's
  135.      pointer (`name', above) because it might get relocated.  */
  136.   char *namebuf;
  137.  
  138.   /* glyphs as they appear on the frame */
  139.   struct frame_glyphs *current_glyphs;
  140.  
  141.   /* glyphs we'd like to appear on the frame */
  142.   struct frame_glyphs *desired_glyphs;
  143.  
  144.   /* See do_line_insertion_deletion_costs for info on these arrays. */
  145.   /* Cost of inserting 1 line on this frame */
  146.   int *insert_line_cost;
  147.   /* Cost of deleting 1 line on this frame */
  148.   int *delete_line_cost;
  149.   /* Cost of inserting n lines on this frame */
  150.   int *insert_n_lines_cost;
  151.   /* Cost of deleting n lines on this frame */
  152.   int *delete_n_lines_cost;
  153.  
  154.   /* glyphs for the mode line */
  155.   struct frame_glyphs *temp_glyphs;
  156.  
  157.   /* Intended cursor position of this frame.
  158.      Measured in characters, counting from upper left corner
  159.      within the frame.  */
  160.   int cursor_x;
  161.   int cursor_y;
  162.  
  163.   /* Actual cursor position of this frame, and the character under it.
  164.      (Not used for terminal frames.)  */
  165.   int phys_cursor_x;
  166.   int phys_cursor_y;
  167.   /* This is handy for undrawing the cursor, because current_glyphs is
  168.      not always accurate when in do_scrolling.  */
  169.   GLYPH phys_cursor_glyph;
  170.   /* Nonzero means the cursor is displayed.  */
  171.   int phys_cursor_on;
  172.  
  173.   /* Size of this frame, in units of characters.  */
  174.   EMACS_INT height;
  175.   EMACS_INT width;
  176.   EMACS_INT window_width;
  177.  
  178.   /* New height and width for pending size change.  0 if no change pending.  */
  179.   int new_height, new_width;
  180.  
  181.   /* The output method says how the contents of this frame
  182.      are displayed.  It could be using termcap, or using an X window.  */
  183.   enum output_method output_method;
  184.  
  185.   /* A structure of auxiliary data used for displaying the contents.
  186.      struct x_output is used for X window frames;
  187.      it is defined in xterm.h.  
  188.      struct w32_output is used for W32 window frames;
  189.      it is defined in w32term.h.  */
  190.   union output_data { struct x_output *x; struct w32_output *w32; int nothing; } output_data;
  191.  
  192. #ifdef MULTI_KBOARD
  193.   /* A pointer to the kboard structure associated with this frame.
  194.      For termcap frames, this points to initial_kboard.  For X frames,
  195.      it will be the same as display.x->display_info->kboard.  */
  196.   struct kboard *kboard;
  197. #endif
  198.  
  199.   /* Number of lines of menu bar.  */
  200.   int menu_bar_lines;
  201.  
  202. #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
  203.   /* Nonzero means using a menu bar that comes from the X toolkit.  */
  204.   int external_menu_bar;
  205. #endif
  206.  
  207.   /* Nonzero if last attempt at redisplay on this frame was preempted.  */
  208.   char display_preempted;
  209.  
  210.   /* visible is nonzero if the frame is currently displayed; we check
  211.      it to see if we should bother updating the frame's contents.
  212.      DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
  213.  
  214.      Note that, since invisible frames aren't updated, whenever a
  215.      frame becomes visible again, it must be marked as garbaged.  The
  216.      FRAME_SAMPLE_VISIBILITY macro takes care of this.
  217.  
  218.      On Windows NT/9X, to avoid wasting effort updating visible frames
  219.      that are actually completely obscured by other windows on the
  220.      display, we bend the meaning of visible slightly: if greater than
  221.      1, then the frame is obscured - we still consider it to be
  222.      "visible" as seen from lisp, but we don't bother updating it.  We
  223.      must take care to garbage the frame when it ceaces to be obscured
  224.      though.  Note that these semantics are only used on NT/9X.
  225.  
  226.      iconified is nonzero if the frame is currently iconified.
  227.  
  228.      Asynchronous input handlers should NOT change these directly;
  229.      instead, they should change async_visible or async_iconified, and
  230.      let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
  231.      at the next redisplay.
  232.  
  233.      These should probably be considered read-only by everyone except
  234.      FRAME_SAMPLE_VISIBILITY.
  235.  
  236.      These two are mutually exclusive.  They might both be zero, if the
  237.      frame has been made invisible without an icon.  */
  238.   char visible, iconified;
  239.  
  240.   /* Asynchronous input handlers change these, and
  241.      FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
  242.      See FRAME_SAMPLE_VISIBILITY, below.  */
  243. #ifdef __STDC__
  244.   volatile
  245. #endif
  246.   char async_visible, async_iconified;
  247.  
  248.   /* Nonzero if this frame should be redrawn.  */
  249. #ifdef __STDC__
  250.   volatile
  251. #endif
  252.   char garbaged;
  253.  
  254.   /* True if frame actually has a minibuffer window on it.
  255.      0 if using a minibuffer window that isn't on this frame.  */
  256.   char has_minibuffer;
  257.      
  258.   /* 0 means, if this frame has just one window,
  259.      show no modeline for that window.  */
  260.   char wants_modeline;
  261.  
  262.   /* Non-zero if the hardware device this frame is displaying on can
  263.      support scroll bars.  */
  264.   char can_have_scroll_bars;
  265.  
  266.   /* If can_have_scroll_bars is non-zero, this is non-zero if we should
  267.      actually display them on this frame.  */
  268.   enum vertical_scroll_bar_type vertical_scroll_bar_type;
  269.  
  270.   /* Non-0 means raise this frame to the top of the heap when selected.  */
  271.   char auto_raise;
  272.  
  273.   /* Non-0 means lower this frame to the bottom of the stack when left.  */
  274.   char auto_lower;
  275.  
  276.   /* True if frame's root window can't be split.  */
  277.   char no_split;
  278.  
  279.   /* If this is set, then Emacs won't change the frame name to indicate
  280.      the current buffer, etcetera.  If the user explicitly sets the frame
  281.      name, this gets set.  If the user sets the name to Qnil, this is
  282.      cleared.  */
  283.   char explicit_name;
  284.  
  285.   /* Nonzero if size of some window on this frame has changed.  */
  286.   char window_sizes_changed;
  287.  
  288.   /* Storage for messages to this frame. */
  289.   char *message_buf;
  290.  
  291.   /* Nonnegative if current redisplay should not do scroll computation
  292.      for lines beyond a certain vpos.  This is the vpos.  */
  293.   int scroll_bottom_vpos;
  294.  
  295.   /* Width of the scroll bar, in pixels and in characters.
  296.      scroll_bar_cols tracks scroll_bar_pixel_width if the latter is positive;
  297.      a zero value in scroll_bar_pixel_width means to compute the actual width
  298.      on the fly, using scroll_bar_cols and the current font width.  */
  299.   int scroll_bar_pixel_width;
  300.   int scroll_bar_cols;
  301.  
  302.   /* The baud rate that was used to calculate costs for this frame.  */
  303.   int cost_calculation_baud_rate;
  304.  
  305.   /* A pointer to the data structure containing all information of
  306.      fontsets associated with this frame.  See the comments in
  307.      fontset.h for more detail.  */
  308.   struct fontset_data *fontset_data;
  309.  
  310.   /* Nonzero if the mouse has moved on this display
  311.      since the last time we checked.  */
  312.   char mouse_moved;
  313. };
  314.  
  315. #ifdef MULTI_KBOARD
  316. #define FRAME_KBOARD(f) ((f)->kboard)
  317. #else
  318. #define FRAME_KBOARD(f) (&the_only_kboard)
  319. #endif
  320.  
  321. typedef struct frame *FRAME_PTR;
  322.  
  323. #define XFRAME(p) ((struct frame *) XPNTR (p))
  324. #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
  325.  
  326. /* Given a window, return its frame as a Lisp_Object.  */
  327. #define WINDOW_FRAME(w) (w)->frame
  328.  
  329. /* Test a frame for particular kinds of display methods.  */
  330. #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
  331. #define FRAME_X_P(f) ((f)->output_method == output_x_window)
  332. #define FRAME_W32_P(f) ((f)->output_method == output_w32)
  333. #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
  334.  
  335. /* FRAME_WINDOW_P tests whether the frame is a window, and is
  336.    defined to be the predicate for the window system being used.  */
  337. #ifdef HAVE_X_WINDOWS
  338. #define FRAME_WINDOW_P(f) FRAME_X_P (f)
  339. #endif
  340. #ifdef HAVE_NTGUI
  341. #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
  342. #endif
  343. #ifndef FRAME_WINDOW_P
  344. #define FRAME_WINDOW_P(f) (0)
  345. #endif
  346.  
  347. /* Nonzero if frame F is still alive (not deleted).  */
  348. #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0)
  349.  
  350. /* Nonzero if frame F is a minibuffer-only frame.  */
  351. #define FRAME_MINIBUF_ONLY_P(f) \
  352.   EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
  353.  
  354. /* Nonzero if frame F contains a minibuffer window.
  355.    (If this is 0, F must use some other minibuffer window.)  */
  356. #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
  357.  
  358. /* This points to the structure which describes the contents
  359.    currently displayed on frame F.  See dispextern.h.  */
  360. #define FRAME_CURRENT_GLYPHS(f) (f)->current_glyphs
  361.  
  362. /* This points to the structure which describes the contents
  363.    intended to be displayed on frame F.  See dispextern.h.  */
  364. #define FRAME_DESIRED_GLYPHS(f) (f)->desired_glyphs
  365.  
  366. #define FRAME_TEMP_GLYPHS(f) (f)->temp_glyphs
  367. #define SET_GLYPHS_FRAME(glyphs,frame) ((glyphs)->frame = (frame))
  368.  
  369. /* Height of frame F, measured in character lines.  */
  370. #define FRAME_HEIGHT(f) (f)->height
  371.  
  372. /* Width of frame F, measured in character columns,
  373.    not including scroll bars if any.  */
  374. #define FRAME_WIDTH(f) (f)->width
  375.  
  376. /* Number of lines of frame F used for menu bar.
  377.    This is relevant on terminal frames and on
  378.    X Windows when not using the X toolkit.
  379.    These lines are counted in FRAME_HEIGHT.  */
  380. #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
  381.  
  382. /* Nonzero if this frame should display a menu bar
  383.    in a way that does not use any text lines.  */
  384. #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
  385. #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
  386. #else
  387. #define FRAME_EXTERNAL_MENU_BAR(f) 0
  388. #endif
  389.  
  390. /* Current cursor position for frame F.  */
  391. #define FRAME_CURSOR_X(f) (f)->cursor_x
  392. #define FRAME_CURSOR_Y(f) (f)->cursor_y
  393.  
  394. /* Nonzero if frame F is currently visible.  */
  395. #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
  396.  
  397. /* Nonzero if frame F is currently visible but hidden.  */
  398. #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
  399.  
  400. /* Nonzero if frame F is currently iconified.  */
  401. #define FRAME_ICONIFIED_P(f) (f)->iconified
  402.  
  403. #define FRAME_SET_VISIBLE(f,p) \
  404.   ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
  405. #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
  406. #define FRAME_GARBAGED_P(f) (f)->garbaged
  407.  
  408. /* Nonzero means do not allow splitting this frame's window.  */
  409. #define FRAME_NO_SPLIT_P(f) (f)->no_split
  410.  
  411. /* Not really implemented.  */
  412. #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
  413.  
  414. /* Nonzero if a size change has been requested for frame F
  415.    but not yet really put into effect.  This can be true temporarily
  416.    when an X event comes in at a bad time.  */
  417. #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
  418. /* When a size change is pending, these are the requested new sizes.  */
  419. #define FRAME_NEW_HEIGHT(f) (f)->new_height
  420. #define FRAME_NEW_WIDTH(f) (f)->new_width
  421.  
  422. /* The minibuffer window of frame F, if it has one; otherwise nil.  */
  423. #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
  424.  
  425. /* The root window of the window tree of frame F.  */
  426. #define FRAME_ROOT_WINDOW(f) (f)->root_window
  427.  
  428. /* The currently selected window of the window tree of frame F.  */
  429. #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
  430.  
  431. #define FRAME_INSERT_COST(f) (f)->insert_line_cost    
  432. #define FRAME_DELETE_COST(f) (f)->delete_line_cost    
  433. #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
  434. #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
  435. #define FRAME_MESSAGE_BUF(f) (f)->message_buf
  436. #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
  437. #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
  438.  
  439. /* Nonzero if frame F supports scroll bars.
  440.    If this is zero, then it is impossible to enable scroll bars
  441.    on frame F.  */
  442. #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
  443.  
  444. /* This frame slot says whether scroll bars are currently enabled for frame F,
  445.    and which side they are on.  */
  446. #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
  447. #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
  448.      ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
  449. #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
  450.      ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
  451. #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
  452.      ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
  453.  
  454. /* Width that a scroll bar in frame F should have, if there is one.
  455.    Measured in pixels.
  456.    If scroll bars are turned off, this is still nonzero.  */
  457. #define FRAME_SCROLL_BAR_PIXEL_WIDTH(f) ((f)->scroll_bar_pixel_width)
  458.  
  459. /* Width that a scroll bar in frame F should have, if there is one.
  460.    Measured in columns (characters).
  461.    If scroll bars are turned off, this is still nonzero.  */
  462. #define FRAME_SCROLL_BAR_COLS(f) ((f)->scroll_bar_cols)
  463.  
  464. /* Width of a scroll bar in frame F, measured in columns (characters),
  465.    but only if scroll bars are on the left.
  466.    If scroll bars are on the right in this frame, it is 0.  */
  467. #define FRAME_LEFT_SCROLL_BAR_WIDTH(f) \
  468.      (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
  469.       ? FRAME_SCROLL_BAR_COLS (f) \
  470.       : 0)
  471.  
  472. /* Width of a scroll bar in frame F, measured in columns (characters).  */
  473. #define FRAME_SCROLL_BAR_WIDTH(f) \
  474.      (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
  475.       ? FRAME_SCROLL_BAR_COLS (f) \
  476.       : 0)
  477.  
  478. /* Total width of frame F, in columns (characters),
  479.    including the width used by scroll bars if any.  */
  480. #define FRAME_WINDOW_WIDTH(f) ((f)->window_width)
  481.  
  482. /* Set the width of frame F to VAL.
  483.    VAL is the width of a full-frame window,
  484.    not including scroll bars.  */
  485. #define SET_FRAME_WIDTH(f, val)                        \
  486.      ((f)->width = (val),                        \
  487.       (f)->window_width = FRAME_WINDOW_WIDTH_ARG (f, (f)->width))
  488.  
  489. /* Given a value WIDTH for frame F's nominal width,
  490.    return the value that FRAME_WINDOW_WIDTH should have.  */
  491. #define FRAME_WINDOW_WIDTH_ARG(f, width) \
  492.      ((width) + FRAME_SCROLL_BAR_WIDTH (f))
  493.  
  494. /* Maximum + 1 legitimate value for FRAME_CURSOR_X.  */
  495. #define FRAME_CURSOR_X_LIMIT(f) \
  496.      (FRAME_WIDTH (f) + FRAME_LEFT_SCROLL_BAR_WIDTH (f))
  497.  
  498. /* Nonzero if frame F has scroll bars.  */
  499. #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
  500.  
  501. #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
  502. #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
  503. #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
  504. #define FRAME_FONTSET_DATA(f) ((f)->fontset_data)
  505.  
  506. /* Return the size of message_buf of the frame F.  We multiply the
  507.    width of the frame by 4 because multi-byte form may require at most
  508.    4-byte for a character.  */
  509. #define FRAME_MESSAGE_BUF_SIZE(f) (((int) (f)->width) * 4)
  510.  
  511. /* Emacs's redisplay code could become confused if a frame's
  512.    visibility changes at arbitrary times.  For example, if a frame is
  513.    visible while the desired glyphs are being built, but becomes
  514.    invisible before they are updated, then some rows of the
  515.    desired_glyphs will be left marked as enabled after redisplay is
  516.    complete, which should never happen.  The next time the frame
  517.    becomes visible, redisplay will probably barf.
  518.  
  519.    Currently, there are no similar situations involving iconified, but
  520.    the principle is the same.
  521.  
  522.    So instead of having asynchronous input handlers directly set and
  523.    clear the frame's visibility and iconification flags, they just set
  524.    the async_visible and async_iconified flags; the redisplay code
  525.    calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
  526.    which sets visible and iconified from their asynchronous
  527.    counterparts.
  528.  
  529.    Synchronous code must use the FRAME_SET_VISIBLE macro.
  530.  
  531.    Also, if a frame used to be invisible, but has just become visible,
  532.    it must be marked as garbaged, since redisplay hasn't been keeping
  533.    up its contents.  */
  534. #define FRAME_SAMPLE_VISIBILITY(f) \
  535.   (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
  536.    SET_FRAME_GARBAGED (f) : 0, \
  537.    (f)->visible = (f)->async_visible, \
  538.    (f)->iconified = (f)->async_iconified)
  539.  
  540. #define CHECK_FRAME(x, i)                \
  541.   {                            \
  542.     if (! FRAMEP (x))                    \
  543.       x = wrong_type_argument (Qframep, (x));        \
  544.   }
  545.  
  546. #define CHECK_LIVE_FRAME(x, i)                \
  547.   {                            \
  548.     if (! FRAMEP (x)                    \
  549.     || ! FRAME_LIVE_P (XFRAME (x)))        \
  550.       x = wrong_type_argument (Qframe_live_p, (x));    \
  551.   }
  552.  
  553. /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
  554.    `for' loop which iterates over the elements of Vframe_list.  The
  555.    loop will set FRAME_VAR, a Lisp_Object, to each frame in
  556.    Vframe_list in succession and execute the statement.  LIST_VAR
  557.    should be a Lisp_Object too; it is used to iterate through the
  558.    Vframe_list.  
  559.  
  560.    This macro is a holdover from a time when multiple frames weren't always
  561.    supported.  An alternate definition of the macro would expand to
  562.    something which executes the statement once.  */
  563. #define FOR_EACH_FRAME(list_var, frame_var)            \
  564.   for ((list_var) = Vframe_list;                \
  565.        (CONSP (list_var)                    \
  566.     && (frame_var = XCONS (list_var)->car, 1));        \
  567.        list_var = XCONS (list_var)->cdr)
  568.  
  569.  
  570. extern Lisp_Object Qframep, Qframe_live_p, Qicon;
  571.  
  572. extern struct frame *selected_frame;
  573. extern struct frame *last_nonminibuf_frame;
  574.  
  575. extern struct frame *make_terminal_frame P_ ((void));
  576. extern struct frame *make_frame P_ ((int));
  577. #ifdef HAVE_WINDOW_SYSTEM
  578. extern struct frame *make_minibuffer_frame P_ ((void));
  579. extern struct frame *make_frame_without_minibuffer P_ ((/* Lisp_Object,
  580.                                                         struct kboard *,
  581.                                                         Lisp_Object JMB */));
  582. #endif /* HAVE_WINDOW_SYSTEM */
  583. extern int other_visible_frames P_ ((struct frame *));
  584.  
  585. extern Lisp_Object Vframe_list;
  586. extern Lisp_Object Vdefault_frame_alist;
  587.  
  588. extern Lisp_Object Vterminal_frame;
  589.  
  590. /* Device-independent scroll bar stuff.  */
  591.  
  592. /* Return the starting column (zero-based) of the vertical scroll bar
  593.    for window W.  The column before this one is the last column we can
  594.    use for text.  If the window touches the right edge of the frame,
  595.    we have extra space allocated for it.  Otherwise, the scroll bar
  596.    takes over the window's rightmost columns.  */
  597. #define WINDOW_VERTICAL_SCROLL_BAR_COLUMN(w) \
  598.   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (XFRAME (WINDOW_FRAME (w))) ? \
  599.     (((XINT ((w)->left) + XINT ((w)->width)) \
  600.       < FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) \
  601.      ? (XINT ((w)->left) + XINT ((w)->width) \
  602.        - FRAME_SCROLL_BAR_COLS (XFRAME (WINDOW_FRAME (w)))) \
  603.      : FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) \
  604.   : XINT ((w)->left))
  605.  
  606. /* Return the height in lines of the vertical scroll bar in w.  If the
  607.    window has a mode line, don't make the scroll bar extend that far.  */
  608. #define WINDOW_VERTICAL_SCROLL_BAR_HEIGHT(w) (window_internal_height (w))
  609.