frame.h 15.7 KB
Newer Older
Jim Blandy's avatar
Jim Blandy committed
1
/* Define frame-object for GNU Emacs.
Jim Blandy's avatar
Jim Blandy committed
2
   Copyright (C) 1988, 1992 Free Software Foundation, Inc.
Jim Blandy's avatar
Jim Blandy committed
3 4 5 6 7

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Jim Blandy's avatar
Jim Blandy committed
8
the Free Software Foundation; either version 2, or (at your option)
Jim Blandy's avatar
Jim Blandy committed
9 10 11 12 13 14 15 16 17 18 19 20
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */


Jim Blandy's avatar
Jim Blandy committed
21
/* The structure representing a frame.
Jim Blandy's avatar
Jim Blandy committed
22

Jim Blandy's avatar
Jim Blandy committed
23 24 25
   We declare this even if MULTI_FRAME is not defined, because when
   we lack multi-frame support, we use one instance of this structure
   to represent the one frame we support.  This is cleaner than
Jim Blandy's avatar
Jim Blandy committed
26
   having miscellaneous random variables scattered about.  */
Jim Blandy's avatar
Jim Blandy committed
27 28 29 30

enum output_method
{ output_termcap, output_x_window };

Jim Blandy's avatar
Jim Blandy committed
31
struct frame
Jim Blandy's avatar
Jim Blandy committed
32 33 34 35
{
  int size;
  struct Lisp_Vector *next;

Jim Blandy's avatar
Jim Blandy committed
36 37
  /* glyphs as they appear on the frame */
  struct frame_glyphs *current_glyphs;
Jim Blandy's avatar
Jim Blandy committed
38

Jim Blandy's avatar
Jim Blandy committed
39 40
  /* glyphs we'd like to appear on the frame */
  struct frame_glyphs *desired_glyphs;
Jim Blandy's avatar
Jim Blandy committed
41

Jim Blandy's avatar
Jim Blandy committed
42
  /* See do_line_insertion_deletion_costs for info on these arrays. */
Jim Blandy's avatar
Jim Blandy committed
43
  /* Cost of inserting 1 line on this frame */
Jim Blandy's avatar
Jim Blandy committed
44
  int *insert_line_cost;
Jim Blandy's avatar
Jim Blandy committed
45
  /* Cost of deleting 1 line on this frame */
Jim Blandy's avatar
Jim Blandy committed
46
  int *delete_line_cost;
Jim Blandy's avatar
Jim Blandy committed
47
  /* Cost of inserting n lines on this frame */
Jim Blandy's avatar
Jim Blandy committed
48
  int *insert_n_lines_cost;
Jim Blandy's avatar
Jim Blandy committed
49
  /* Cost of deleting n lines on this frame */
Jim Blandy's avatar
Jim Blandy committed
50 51 52
  int *delete_n_lines_cost;

  /* glyphs for the mode line */
Jim Blandy's avatar
Jim Blandy committed
53
  struct frame_glyphs *temp_glyphs;
Jim Blandy's avatar
Jim Blandy committed
54

Jim Blandy's avatar
Jim Blandy committed
55
  /* Intended cursor position of this frame.
Jim Blandy's avatar
Jim Blandy committed
56
     Measured in characters, counting from upper left corner
Jim Blandy's avatar
Jim Blandy committed
57
     within the frame.  */
Jim Blandy's avatar
Jim Blandy committed
58 59 60
  int cursor_x;
  int cursor_y;

Jim Blandy's avatar
Jim Blandy committed
61 62
  /* Actual cursor position of this frame, and the character under it.
     (Not used for terminal frames.)  */
Jim Blandy's avatar
Jim Blandy committed
63 64
  int phys_cursor_x;
  int phys_cursor_y;
Jim Blandy's avatar
Jim Blandy committed
65 66 67
  /* This is handy for undrawing the cursor, because current_glyphs is
     not always accurate when in do_scrolling.  */
  GLYPH phys_cursor_glyph;
Jim Blandy's avatar
Jim Blandy committed
68

Jim Blandy's avatar
Jim Blandy committed
69
  /* Size of this frame, in units of characters.  */
Jim Blandy's avatar
Jim Blandy committed
70 71 72 73 74 75
  int height;
  int width;

  /* New height and width for pending size change.  0 if no change pending.  */
  int new_height, new_width;

Jim Blandy's avatar
Jim Blandy committed
76
  /* Name of this frame: a Lisp string.  See also `explicit_name'.  */
Jim Blandy's avatar
Jim Blandy committed
77 78
  Lisp_Object name;

Jim Blandy's avatar
Jim Blandy committed
79
  /* The frame which should recieve keystrokes that occur in this
80 81 82 83 84 85 86 87 88 89
     frame, or nil if they should go to the frame itself.  This is
     usually nil, but if the frame is minibufferless, we can use this
     to redirect keystrokes to a surrogate minibuffer frame when
     needed.

     Note that a value of nil is different than having the field point
     to the frame itself.  Whenever the Fselect_frame function is used
     to shift from one frame to the other, any redirections to the
     original frame are shifted to the newly selected frame; if
     focus_frame is nil, Fselect_frame will leave it alone.  */
Jim Blandy's avatar
Jim Blandy committed
90
  Lisp_Object focus_frame;
Jim Blandy's avatar
Jim Blandy committed
91

Jim Blandy's avatar
Jim Blandy committed
92 93 94
  /* This frame's root window.  Every frame has one.
     If the frame has only a minibuffer window, this is it.
     Otherwise, if the frame has a minibuffer window, this is its sibling.  */
Jim Blandy's avatar
Jim Blandy committed
95 96
  Lisp_Object root_window;

Jim Blandy's avatar
Jim Blandy committed
97 98 99 100
  /* This frame's selected window.
     Each frame has its own window hierarchy
     and one of the windows in it is selected within the frame.
     The selected window of the selected frame is Emacs's selected window.  */
Jim Blandy's avatar
Jim Blandy committed
101 102
  Lisp_Object selected_window;

Jim Blandy's avatar
Jim Blandy committed
103 104 105
  /* This frame's minibuffer window.
     Most frames have their own minibuffer windows,
     but only the selected frame's minibuffer window
Jim Blandy's avatar
Jim Blandy committed
106 107 108
     can actually appear to exist.  */
  Lisp_Object minibuffer_window;

Jim Blandy's avatar
Jim Blandy committed
109 110 111
  /* Parameter alist of this frame.
     These are the parameters specified when creating the frame
     or modified with modify-frame-parameters.  */
Jim Blandy's avatar
Jim Blandy committed
112 113
  Lisp_Object param_alist;

Jim Blandy's avatar
Jim Blandy committed
114
  /* The output method says how the contents of this frame
Jim Blandy's avatar
Jim Blandy committed
115 116 117 118
     are displayed.  It could be using termcap, or using an X window.  */
  enum output_method output_method;

  /* A structure of auxiliary data used for displaying the contents.
Jim Blandy's avatar
Jim Blandy committed
119
     struct x_display is used for X window frames;
Jim Blandy's avatar
Jim Blandy committed
120 121 122
     it is defined in xterm.h.  */
  union display { struct x_display *x; int nothing; } display;

Jim Blandy's avatar
Jim Blandy committed
123
  /* Nonzero if last attempt at redisplay on this frame was preempted.  */
Jim Blandy's avatar
Jim Blandy committed
124 125
  char display_preempted;

126 127
  /* visible is nonzero if the frame is currently displayed; we check
     it to see if we should bother updating the frame's contents.
128
     DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
Jim Blandy's avatar
Jim Blandy committed
129

130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
     iconified is nonzero if the frame is currently iconified.

     Asynchronous input handlers should NOT change these directly;
     instead, they should change async_visible or async_iconified, and
     let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
     at the next redisplay.

     These should probably be considered read-only by everyone except
     FRAME_SAMPLE_VISIBILITY.

     This two are mutually exclusive.  They might both be zero, if the
     frame has been made invisible without an icon.  */
  char visible, iconified;

  /* Asynchronous input handlers change these, and
     FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
     See FRAME_SAMPLE_VISIBILITY, below.  */
#ifdef __STDC__
  volatile
#endif
  char async_visible, async_iconified;
Jim Blandy's avatar
Jim Blandy committed
151

Jim Blandy's avatar
Jim Blandy committed
152
  /* Nonzero if this frame should be redrawn.  */
153 154 155
#ifdef __STDC__
  volatile
#endif
Jim Blandy's avatar
Jim Blandy committed
156 157
  char garbaged;

Jim Blandy's avatar
Jim Blandy committed
158 159
  /* True if frame actually has a minibuffer window on it.
     0 if using a minibuffer window that isn't on this frame.  */
Jim Blandy's avatar
Jim Blandy committed
160 161
  char has_minibuffer;
     
Jim Blandy's avatar
Jim Blandy committed
162
  /* 0 means, if this frame has just one window,
Jim Blandy's avatar
Jim Blandy committed
163 164 165
     show no modeline for that window.  */
  char wants_modeline;

166 167 168 169 170 171 172 173
  /* Non-zero if the hardware device this frame is displaying on can
     support scrollbars.  */
  char can_have_scrollbars;

  /* If can_have_scrollbars is non-zero, this is non-zero if we should
     actually display them on this frame.  */
  char has_vertical_scrollbars;

Jim Blandy's avatar
Jim Blandy committed
174
  /* Non-0 means raise this frame to the top of the heap when selected.  */
Jim Blandy's avatar
Jim Blandy committed
175 176
  char auto_raise;

Jim Blandy's avatar
Jim Blandy committed
177
  /* Non-0 means lower this frame to the bottom of the stack when left.  */
Jim Blandy's avatar
Jim Blandy committed
178 179
  char auto_lower;

Jim Blandy's avatar
Jim Blandy committed
180
  /* True if frame's root window can't be split.  */
Jim Blandy's avatar
Jim Blandy committed
181 182
  char no_split;

Jim Blandy's avatar
Jim Blandy committed
183 184 185 186 187 188
  /* If this is set, then Emacs won't change the frame name to indicate
     the current buffer, etcetera.  If the user explicitly sets the frame
     name, this gets set.  If the user sets the name to Qnil, this is
     cleared.  */
  char explicit_name;

Jim Blandy's avatar
Jim Blandy committed
189
  /* Storage for messages to this frame. */
Jim Blandy's avatar
Jim Blandy committed
190 191 192 193 194 195 196
  char *message_buf;

  /* Nonnegative if current redisplay should not do scroll computation
     for lines beyond a certain vpos.  This is the vpos.  */
  int scroll_bottom_vpos;
};

Jim Blandy's avatar
Jim Blandy committed
197 198 199 200 201 202 203 204 205 206 207
#ifdef MULTI_FRAME

typedef struct frame *FRAME_PTR;

#define XFRAME(p) ((struct frame *) XPNTR (p))
#define XSETFRAME(p, v) ((struct frame *) XSETPNTR (p, v))

#define WINDOW_FRAME(w) (w)->frame

#define FRAMEP(f) (XTYPE(f) == Lisp_Frame)
#define FRAME_LIVE_P(f) ((f)->display.nothing != 0)
Jim Blandy's avatar
Jim Blandy committed
208 209
#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
#define FRAME_X_P(f) ((f)->output_method == output_x_window)
Jim Blandy's avatar
Jim Blandy committed
210 211
#define FRAME_MINIBUF_ONLY_P(f) \
  EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
Jim Blandy's avatar
Jim Blandy committed
212
#define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
Jim Blandy's avatar
Jim Blandy committed
213 214 215 216 217 218 219 220 221
#define FRAME_CURRENT_GLYPHS(f) (f)->current_glyphs
#define FRAME_DESIRED_GLYPHS(f) (f)->desired_glyphs
#define FRAME_TEMP_GLYPHS(f) (f)->temp_glyphs
#define FRAME_HEIGHT(f) (f)->height
#define FRAME_WIDTH(f) (f)->width
#define FRAME_NEW_HEIGHT(f) (f)->new_height
#define FRAME_NEW_WIDTH(f) (f)->new_width
#define FRAME_CURSOR_X(f) (f)->cursor_x
#define FRAME_CURSOR_Y(f) (f)->cursor_y
222 223 224
#define FRAME_VISIBLE_P(f) ((f)->visible != 0)
#define FRAME_SET_VISIBLE(f,p) \
  ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
Jim Blandy's avatar
Jim Blandy committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
#define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
#define FRAME_GARBAGED_P(f) (f)->garbaged
#define FRAME_NO_SPLIT_P(f) (f)->no_split
#define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
#define FRAME_ICONIFIED_P(f) (f)->iconified
#define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
#define FRAME_ROOT_WINDOW(f) (f)->root_window
#define FRAME_SELECTED_WINDOW(f) (f)->selected_window
#define SET_GLYPHS_FRAME(glyphs,frame) ((glyphs)->frame = (frame))
#define FRAME_INSERT_COST(f) (f)->insert_line_cost    
#define FRAME_DELETE_COST(f) (f)->delete_line_cost    
#define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
#define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
#define FRAME_MESSAGE_BUF(f) (f)->message_buf
#define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
#define FRAME_FOCUS_FRAME(f) (f)->focus_frame
241 242
#define FRAME_CAN_HAVE_SCROLLBARS(f) ((f)->can_have_scrollbars)
#define FRAME_HAS_VERTICAL_SCROLLBARS(f) ((f)->has_vertical_scrollbars)
Jim Blandy's avatar
Jim Blandy committed
243

244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
/* Emacs's redisplay code could become confused if a frame's
   visibility changes at arbitrary times.  For example, if a frame is
   visible while the desired glyphs are being built, but becomes
   invisible before they are updated, then some rows of the
   desired_glyphs will be left marked as enabled after redisplay is
   complete, which should never happen.  The next time the frame
   becomes visible, redisplay will probably barf.

   Currently, there are no similar situations involving iconified, but
   the principle is the same.

   So instead of having asynchronous input handlers directly set and
   clear the frame's visibility and iconification flags, they just set
   the async_visible and async_iconified flags; the redisplay code
   calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
   which sets visible and iconified from their asynchronous
260 261 262
   counterparts.

   Synchronous code must use the FRAME_SET_VISIBLE macro.  */
263 264 265 266
#define FRAME_SAMPLE_VISIBILITY(f) \
  ((f)->visible = (f)->async_visible, \
   (f)->iconified = (f)->async_iconified)

Jim Blandy's avatar
Jim Blandy committed
267
#define CHECK_FRAME(x, i)				\
Jim Blandy's avatar
Jim Blandy committed
268
  {							\
Jim Blandy's avatar
Jim Blandy committed
269 270
    if (! FRAMEP (x))					\
      x = wrong_type_argument (Qframep, (x));		\
Jim Blandy's avatar
Jim Blandy committed
271 272
  }

Jim Blandy's avatar
Jim Blandy committed
273
#define CHECK_LIVE_FRAME(x, i)				\
Jim Blandy's avatar
Jim Blandy committed
274
  {							\
Jim Blandy's avatar
Jim Blandy committed
275 276 277
    if (! FRAMEP (x)					\
	|| ! FRAME_LIVE_P (XFRAME (x)))		\
      x = wrong_type_argument (Qlive_frame_p, (x));	\
Jim Blandy's avatar
Jim Blandy committed
278 279
  }

Jim Blandy's avatar
Jim Blandy committed
280 281 282 283
/* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
   `for' loop which iterates over the elements of Vframe_list.  The
   loop will set FRAME_VAR, a FRAME_PTR, to each frame in
   Vframe_list in succession and execute the statement.  LIST_VAR
Jim Blandy's avatar
Jim Blandy committed
284
   should be a Lisp_Object; it is used to iterate through the
Jim Blandy's avatar
Jim Blandy committed
285
   Vframe_list.  
Jim Blandy's avatar
Jim Blandy committed
286

Jim Blandy's avatar
Jim Blandy committed
287
   If MULTI_FRAME isn't defined, then this loop expands to something which 
Jim Blandy's avatar
Jim Blandy committed
288
   executes the statement once.  */
Jim Blandy's avatar
Jim Blandy committed
289 290
#define FOR_EACH_FRAME(list_var, frame_var)			\
  for ((list_var) = Vframe_list;				\
Jim Blandy's avatar
Jim Blandy committed
291
       (CONSP (list_var)					\
Jim Blandy's avatar
Jim Blandy committed
292
	&& (frame_var = XFRAME (XCONS (list_var)->car), 1));	\
Jim Blandy's avatar
Jim Blandy committed
293 294 295
       list_var = XCONS (list_var)->cdr)


Jim Blandy's avatar
Jim Blandy committed
296
extern Lisp_Object Qframep, Qlive_frame_p;
Jim Blandy's avatar
Jim Blandy committed
297

Jim Blandy's avatar
Jim Blandy committed
298 299
extern struct frame *selected_frame;
extern struct frame *last_nonminibuf_frame;
Jim Blandy's avatar
Jim Blandy committed
300

Jim Blandy's avatar
Jim Blandy committed
301 302 303 304
extern struct frame *make_terminal_frame ();
extern struct frame *make_frame ();
extern struct frame *make_minibuffer_frame ();
extern struct frame *make_frame_without_minibuffer ();
Jim Blandy's avatar
Jim Blandy committed
305

Jim Blandy's avatar
Jim Blandy committed
306
/* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
Jim Blandy's avatar
Jim Blandy committed
307 308 309
   print.  */
extern int message_buf_print;

Jim Blandy's avatar
Jim Blandy committed
310 311
extern Lisp_Object Vframe_list;
extern Lisp_Object Vdefault_frame_alist;
Jim Blandy's avatar
Jim Blandy committed
312

Jim Blandy's avatar
Jim Blandy committed
313
extern Lisp_Object Vterminal_frame;
Jim Blandy's avatar
Jim Blandy committed
314

Jim Blandy's avatar
Jim Blandy committed
315
#else /* not MULTI_FRAME */
Jim Blandy's avatar
Jim Blandy committed
316

Jim Blandy's avatar
Jim Blandy committed
317
/* These definitions are used in a single-frame version of Emacs.  */
Jim Blandy's avatar
Jim Blandy committed
318

Jim Blandy's avatar
Jim Blandy committed
319
#define FRAME_PTR int
Jim Blandy's avatar
Jim Blandy committed
320

Jim Blandy's avatar
Jim Blandy committed
321 322 323 324
/* A frame we use to store all the data concerning the screen when we
   don't have multiple frames.  Remember, if you store any data in it
   which needs to be protected from GC, you should staticpro that
   element explicitly.  */
Jim Blandy's avatar
Jim Blandy committed
325
extern struct frame the_only_frame;
Jim Blandy's avatar
Jim Blandy committed
326

Jim Blandy's avatar
Jim Blandy committed
327 328
extern int selected_frame;
extern int last_nonminibuf_frame;
Jim Blandy's avatar
Jim Blandy committed
329

Jim Blandy's avatar
Jim Blandy committed
330
/* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
Jim Blandy's avatar
Jim Blandy committed
331 332
   print.  */
extern int message_buf_print;
Jim Blandy's avatar
Jim Blandy committed
333

Jim Blandy's avatar
Jim Blandy committed
334 335 336 337 338
#define XFRAME(f) selected_frame
#define WINDOW_FRAME(w) selected_frame

#define FRAMEP(f) (XTYPE(f) == Lisp_Frame)
#define FRAME_LIVE_P(f) 1
Jim Blandy's avatar
Jim Blandy committed
339 340
#define FRAME_TERMCAP_P(f) 1
#define FRAME_X_P(f) 0
Jim Blandy's avatar
Jim Blandy committed
341
#define FRAME_MINIBUF_ONLY_P(f) 0
Jim Blandy's avatar
Jim Blandy committed
342
#define FRAME_HAS_MINIBUF_P(f) 1
Jim Blandy's avatar
Jim Blandy committed
343 344 345 346 347 348 349 350 351
#define FRAME_CURRENT_GLYPHS(f) (the_only_frame.current_glyphs)
#define FRAME_DESIRED_GLYPHS(f) (the_only_frame.desired_glyphs)
#define FRAME_TEMP_GLYPHS(f) (the_only_frame.temp_glyphs)
#define FRAME_HEIGHT(f) (the_only_frame.height)
#define FRAME_WIDTH(f) (the_only_frame.width)
#define FRAME_NEW_HEIGHT(f) (the_only_frame.new_height)
#define FRAME_NEW_WIDTH(f) (the_only_frame.new_width)
#define FRAME_CURSOR_X(f) (the_only_frame.cursor_x)
#define FRAME_CURSOR_Y(f) (the_only_frame.cursor_y)
352
#define FRAME_SET_VISIBLE(f,p) (p)
Jim Blandy's avatar
Jim Blandy committed
353 354
#define FRAME_VISIBLE_P(f) 1
#define SET_FRAME_GARBAGED(f) (frame_garbaged = 1)
Jim Blandy's avatar
Jim Blandy committed
355
#define FRAME_GARBAGED_P(f) (frame_garbaged)
Jim Blandy's avatar
Jim Blandy committed
356 357 358
#define FRAME_NO_SPLIT_P(f) 0
#define FRAME_WANTS_MODELINE_P(f) 1
#define FRAME_ICONIFIED_P(f) 0
Jim Blandy's avatar
Jim Blandy committed
359 360
#define FRAME_MINIBUF_WINDOW(f) (the_only_frame.root_window)
#define FRAME_ROOT_WINDOW(f) (the_only_frame.root_window)
Jim Blandy's avatar
Jim Blandy committed
361 362 363 364 365 366 367 368
#define FRAME_SELECTED_WINDOW(f) (selected_window)
#define SET_GLYPHS_FRAME(glyphs,frame) do ; while (0)
#define FRAME_INSERT_COST(frame)  (the_only_frame.insert_line_cost)
#define FRAME_DELETE_COST(frame)  (the_only_frame.delete_line_cost)
#define FRAME_INSERTN_COST(frame) (the_only_frame.insert_n_lines_cost)
#define FRAME_DELETEN_COST(frame) (the_only_frame.delete_n_lines_cost)
#define FRAME_MESSAGE_BUF(f) (the_only_frame.message_buf)
#define FRAME_SCROLL_BOTTOM_VPOS(f) (the_only_frame.scroll_bottom_vpos)
369 370 371 372
#define FRAME_FOCUS_FRAME(f) (Qnil)
#define FRAME_CAN_HAVE_SCROLLBARS(f) (the_only_frame.can_have_scrollbars)
#define FRAME_HAS_VERTICAL_SCROLLBARS(f) \
  (the_only_frame.has_vertical_scrollbars)
Jim Blandy's avatar
Jim Blandy committed
373

374 375 376
/* See comments in definition above.  */
#define FRAME_SAMPLE_VISIBILITY(f) (0)

Jim Blandy's avatar
Jim Blandy committed
377 378
#define CHECK_FRAME(x, i) do; while (0)
#define CHECK_LIVE_FRAME(x, y) do; while (0)
Jim Blandy's avatar
Jim Blandy committed
379 380 381 382 383

/* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
   `for' loop which iterates over the elements of Vframe_list.  The
   loop will set FRAME_VAR, a FRAME_PTR, to each frame in
   Vframe_list in succession and execute the statement.  LIST_VAR
Jim Blandy's avatar
Jim Blandy committed
384
   should be a Lisp_Object; it is used to iterate through the
Jim Blandy's avatar
Jim Blandy committed
385
   Vframe_list.  
Jim Blandy's avatar
Jim Blandy committed
386

Jim Blandy's avatar
Jim Blandy committed
387 388 389 390 391
   If MULTI_FRAME _is_ defined, then this loop expands to a real
   `for' loop which traverses Vframe_list using LIST_VAR and
   FRAME_VAR.  */
#define FOR_EACH_FRAME(list_var, frame_var)			\
  for (frame_var = (FRAME_PTR) 1; frame_var; frame_var = (FRAME_PTR) 0)
Jim Blandy's avatar
Jim Blandy committed
392

Jim Blandy's avatar
Jim Blandy committed
393
#endif /* not MULTI_FRAME */
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422


/* Device- and MULTI_FRAME-independent scrollbar stuff.  */

/* The number of columns a vertical scrollbar occupies.  */
#define VERTICAL_SCROLLBAR_WIDTH (2)

/* Turn a window's scrollbar member into a `struct scrollbar *';
   return NULL if the window doesn't have a scrollbar.  */
#define WINDOW_VERTICAL_SCROLLBAR(w) \
  (XTYPE ((w)->vertical_scrollbar) == Lisp_Int \
   ? (struct scrollbar *) XPNTR ((w)->vertical_scrollbar) \
   : (struct scrollbar *) 0)


/* Return the starting column (zero-based) of the vertical scrollbar
   for window W.  The column before this one is the last column we can
   use for text.  If the window touches the right edge of the frame,
   we have extra space allocated for it.  Otherwise, the scrollbar
   takes over the window's rightmost columns.  */
#define WINDOW_VERTICAL_SCROLLBAR_COLUMN(w) \
  (((XINT ((w)->left) + XINT ((w)->width)) \
    < FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) \
   ? XINT ((w)->left) + XINT ((w)->width) - VERTICAL_SCROLLBAR_WIDTH \
   : FRAME_WIDTH (XFRAME (WINDOW_FRAME (w))))

/* Return the height in lines of the vertical scrollbar in w.  If the
   window has a mode line, don't make the scrollbar extend that far.  */
#define WINDOW_VERTICAL_SCROLLBAR_HEIGHT(w) (window_internal_height (w))