]> code.delx.au - gnu-emacs/blob - src/frame.h
(load_face_colors): Load background color if setting
[gnu-emacs] / src / frame.h
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 \f
22 /* Miscellanea. */
23
24 /* Nonzero means don't assume anything about current contents of
25 actual terminal frame */
26
27 extern int frame_garbaged;
28
29 /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
30 print. */
31
32 extern int message_buf_print;
33
34 \f
35 /* The structure representing a frame. */
36
37 enum output_method
38 {
39 output_termcap,
40 output_x_window,
41 output_msdos_raw,
42 output_w32
43 };
44
45 enum vertical_scroll_bar_type
46 {
47 vertical_scroll_bar_none,
48 vertical_scroll_bar_left,
49 vertical_scroll_bar_right
50 };
51
52 struct frame
53 {
54 EMACS_INT size;
55 struct Lisp_Vector *next;
56
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. */
60
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. */
63 Lisp_Object name;
64
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
69 /* This is the frame title specified explicitly, if any.
70 Usually it is nil. */
71 Lisp_Object title;
72
73 /* The frame which should receive keystrokes that occur in this
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. */
84 Lisp_Object focus_frame;
85
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. */
89 Lisp_Object root_window;
90
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. */
95 Lisp_Object selected_window;
96
97 /* This frame's minibuffer window.
98 Most frames have their own minibuffer windows,
99 but only the selected frame's minibuffer window
100 can actually appear to exist. */
101 Lisp_Object minibuffer_window;
102
103 /* Parameter alist of this frame.
104 These are the parameters specified when creating the frame
105 or modified with modify-frame-parameters. */
106 Lisp_Object param_alist;
107
108 /* List of scroll bars on this frame.
109 Actually, we don't specify exactly what is stored here at all; the
110 scroll bar implementation code can use it to store anything it likes.
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. */
115 Lisp_Object scroll_bars;
116 Lisp_Object condemned_scroll_bars;
117
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. */
123 Lisp_Object menu_bar_items;
124
125 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
126 Lisp_Object face_alist;
127
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
138 /* List of buffers viewed in this frame, for other-buffer. */
139 Lisp_Object buffer_list;
140
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
154 /* beyond here, there should be no more Lisp_Object components. */
155
156 /* Cache of realized faces. */
157 struct face_cache *face_cache;
158
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. */
161 char *namebuf;
162
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;
172
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;
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
192 /* Size of this frame, in units of characters. */
193 EMACS_INT height;
194 EMACS_INT width;
195 EMACS_INT window_width;
196 EMACS_INT window_height;
197
198 /* New height and width for pending size change. 0 if no change pending. */
199 int new_height, new_width;
200
201 /* The output method says how the contents of this frame
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.
206 struct x_output is used for X window frames;
207 it is defined in xterm.h.
208 struct w32_output is used for W32 window frames;
209 it is defined in w32term.h. */
210 union output_data
211 {
212 struct x_output *x;
213 struct w32_output *w32;
214 int nothing;
215 }
216 output_data;
217
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. */
222 struct kboard *kboard;
223 #endif
224
225 /* Number of lines of menu bar. */
226 int menu_bar_lines;
227
228 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
229 /* Nonzero means using a menu bar that comes from the X toolkit. */
230 int external_menu_bar;
231 #endif
232
233 /* Nonzero if last attempt at redisplay on this frame was preempted. */
234 char display_preempted;
235
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.
238 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
239
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
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
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
262 These two are mutually exclusive. They might both be zero, if the
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;
273
274 /* Nonzero if this frame should be redrawn. */
275 #ifdef __STDC__
276 volatile
277 #endif
278 char garbaged;
279
280 /* True if frame actually has a minibuffer window on it.
281 0 if using a minibuffer window that isn't on this frame. */
282 char has_minibuffer;
283
284 /* 0 means, if this frame has just one window,
285 show no modeline for that window. */
286 char wants_modeline;
287
288 /* Non-zero if the hardware device this frame is displaying on can
289 support scroll bars. */
290 char can_have_scroll_bars;
291
292 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
293 actually display them on this frame. */
294 enum vertical_scroll_bar_type vertical_scroll_bar_type;
295
296 /* Non-0 means raise this frame to the top of the heap when selected. */
297 char auto_raise;
298
299 /* Non-0 means lower this frame to the bottom of the stack when left. */
300 char auto_lower;
301
302 /* True if frame's root window can't be split. */
303 char no_split;
304
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
311 /* Nonzero if size of some window on this frame has changed. */
312 char window_sizes_changed;
313
314 /* Storage for messages to this frame. */
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;
320
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. */
325 int scroll_bar_pixel_width;
326 int scroll_bar_cols;
327
328 /* Width of area for drawing truncation marks and overlay arrow. */
329 int trunc_area_pixel_width, trunc_area_cols;
330
331 /* The baud rate that was used to calculate costs for this frame. */
332 int cost_calculation_baud_rate;
333
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
339 /* Nonzero if the mouse has moved on this display
340 since the last time we checked. */
341 char mouse_moved;
342 };
343
344 #ifdef MULTI_KBOARD
345 #define FRAME_KBOARD(f) ((f)->kboard)
346 #else
347 #define FRAME_KBOARD(f) (&the_only_kboard)
348 #endif
349
350 typedef struct frame *FRAME_PTR;
351
352 #define XFRAME(p) ((struct frame *) XPNTR (p))
353 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
354
355 /* Given a window, return its frame as a Lisp_Object. */
356 #define WINDOW_FRAME(w) (w)->frame
357
358 /* Test a frame for particular kinds of display methods. */
359 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
360 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
361 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
362 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
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. */
366
367 #ifdef HAVE_X_WINDOWS
368 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
369 #endif
370 #ifdef HAVE_NTGUI
371 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
372 #endif
373 #ifndef FRAME_WINDOW_P
374 #define FRAME_WINDOW_P(f) (0)
375 #endif
376
377 /* Nonzero if frame F is still alive (not deleted). */
378 #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0)
379
380 /* Nonzero if frame F is a minibuffer-only frame. */
381 #define FRAME_MINIBUF_ONLY_P(f) \
382 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
383
384 /* Nonzero if frame F contains a minibuffer window.
385 (If this is 0, F must use some other minibuffer window.) */
386 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
387 #define FRAME_HEIGHT(f) (f)->height
388
389 /* Width of frame F, measured in character columns,
390 not including scroll bars if any. */
391 #define FRAME_WIDTH(f) (f)->width
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. */
397 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
398
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
408 /* Nonzero if this frame should display a menu bar
409 in a way that does not use any text lines. */
410 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
411 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
412 #else
413 #define FRAME_EXTERNAL_MENU_BAR(f) 0
414 #endif
415 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
416
417 /* Nonzero if frame F is currently visible but hidden. */
418 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
419
420 /* Nonzero if frame F is currently iconified. */
421 #define FRAME_ICONIFIED_P(f) (f)->iconified
422
423 #define FRAME_SET_VISIBLE(f,p) \
424 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
425 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
426 #define FRAME_GARBAGED_P(f) (f)->garbaged
427
428 /* Nonzero means do not allow splitting this frame's window. */
429 #define FRAME_NO_SPLIT_P(f) (f)->no_split
430
431 /* Not really implemented. */
432 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
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. */
437 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
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. */
443 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
444
445 /* The root window of the window tree of frame F. */
446 #define FRAME_ROOT_WINDOW(f) (f)->root_window
447
448 /* The currently selected window of the window tree of frame F. */
449 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
450
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
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. */
462 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
463
464 /* This frame slot says whether scroll bars are currently enabled for frame F,
465 and which side they are on. */
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)
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. */
477 #define FRAME_SCROLL_BAR_PIXEL_WIDTH(f) ((f)->scroll_bar_pixel_width)
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. */
482 #define FRAME_SCROLL_BAR_COLS(f) ((f)->scroll_bar_cols)
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. */
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)
491
492 /* Width of a scroll bar in frame F, measured in columns (characters). */
493 #define FRAME_SCROLL_BAR_WIDTH(f) \
494 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
495 ? FRAME_SCROLL_BAR_COLS (f) \
496 : 0)
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. */
511 #define FRAME_WINDOW_WIDTH_ARG(f, width) \
512 ((width) \
513 + FRAME_SCROLL_BAR_WIDTH (f) \
514 + 2 * FRAME_FLAGS_AREA_COLS (f))
515
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))
519
520 /* Nonzero if frame F has scroll bars. */
521 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
522
523 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
524 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
525 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
526 #define FRAME_FONTSET_DATA(f) ((f)->fontset_data)
527
528 /* Return a pointer to the face cache of frame F. */
529
530 #define FRAME_FACE_CACHE(F) (F)->face_cache
531
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. */
535
536 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) (f)->width) * 4)
537
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
554 counterparts.
555
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. */
561
562 #define FRAME_SAMPLE_VISIBILITY(f) \
563 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
564 SET_FRAME_GARBAGED (f) : 0, \
565 (f)->visible = (f)->async_visible, \
566 (f)->iconified = (f)->async_iconified)
567
568 #define CHECK_FRAME(x, i) \
569 if (! FRAMEP (x)) \
570 x = wrong_type_argument (Qframep, (x)); \
571 else \
572 (void) 0
573
574 #define CHECK_LIVE_FRAME(x, i) \
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
581
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
584 loop will set FRAME_VAR, a Lisp_Object, to each frame in
585 Vframe_list in succession and execute the statement. LIST_VAR
586 should be a Lisp_Object too; it is used to iterate through the
587 Vframe_list.
588
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. */
592
593 #define FOR_EACH_FRAME(list_var, frame_var) \
594 for ((list_var) = Vframe_list; \
595 (CONSP (list_var) \
596 && (frame_var = XCONS (list_var)->car, 1)); \
597 list_var = XCONS (list_var)->cdr)
598
599
600 extern Lisp_Object Qframep, Qframe_live_p, Qicon;
601
602 extern struct frame *selected_frame;
603 extern struct frame *last_nonminibuf_frame;
604
605 extern struct frame *make_terminal_frame P_ ((void));
606 extern struct frame *make_frame P_ ((int));
607 #ifdef HAVE_WINDOW_SYSTEM
608 extern struct frame *make_minibuffer_frame P_ ((void));
609 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
610 struct kboard *,
611 Lisp_Object));
612 #endif /* HAVE_WINDOW_SYSTEM */
613 extern int other_visible_frames P_ ((struct frame *));
614
615 extern Lisp_Object Vframe_list;
616 extern Lisp_Object Vdefault_frame_alist;
617
618 extern Lisp_Object Vterminal_frame;
619 \f
620 /* Device-independent scroll bar stuff. */
621
622 /* Return the starting column (zero-based) of the vertical scroll bar
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,
625 we have extra space allocated for it. Otherwise, the scroll bar
626 takes over the window's rightmost columns. */
627
628 #define WINDOW_VERTICAL_SCROLL_BAR_COLUMN(w) \
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))
636
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. */
639
640 #define WINDOW_VERTICAL_SCROLL_BAR_HEIGHT(w) (window_internal_height (w))
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