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