Fix crashes in `delete-terminal' caused by recursive calls or X displays with live...
[emacs.git] / src / frame.h
blobaa4a00d6dfa4d926df3aa909b182bdbefd03e6df
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993, 1994, 1999, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 /* Don't multiply include: dispextern.h includes macterm.h which
23 includes frame.h some emacs source includes both dispextern.h and
24 frame.h */
26 #ifndef EMACS_FRAME_H
27 #define EMACS_FRAME_H
30 /* Miscellanea. */
32 /* Nonzero means there is at least one garbaged frame. */
33 extern int frame_garbaged;
35 /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
36 print. */
38 extern int message_buf_print;
41 /* The structure representing a frame. */
43 enum output_method
45 output_initial,
46 output_termcap,
47 output_x_window,
48 output_msdos_raw,
49 output_w32,
50 output_mac
53 enum vertical_scroll_bar_type
55 vertical_scroll_bar_none,
56 vertical_scroll_bar_left,
57 vertical_scroll_bar_right
60 enum text_cursor_kinds
62 DEFAULT_CURSOR = -2,
63 NO_CURSOR = -1,
64 FILLED_BOX_CURSOR,
65 HOLLOW_BOX_CURSOR,
66 BAR_CURSOR,
67 HBAR_CURSOR
70 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
71 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
73 struct terminal;
75 struct frame
77 EMACS_INT size;
78 struct Lisp_Vector *next;
80 /* All Lisp_Object components must come first.
81 Only EMACS_INT values can be intermixed with them.
82 That ensures they are all aligned normally. */
84 /* Name of this frame: a Lisp string. It is used for looking up resources,
85 as well as for the title in some cases. */
86 Lisp_Object name;
88 /* The name to use for the icon, the last time
89 it was refreshed. nil means not explicitly specified. */
90 Lisp_Object icon_name;
92 /* This is the frame title specified explicitly, if any.
93 Usually it is nil. */
94 Lisp_Object title;
96 /* The frame which should receive keystrokes that occur in this
97 frame, or nil if they should go to the frame itself. This is
98 usually nil, but if the frame is minibufferless, we can use this
99 to redirect keystrokes to a surrogate minibuffer frame when
100 needed.
102 Note that a value of nil is different than having the field point
103 to the frame itself. Whenever the Fselect_frame function is used
104 to shift from one frame to the other, any redirections to the
105 original frame are shifted to the newly selected frame; if
106 focus_frame is nil, Fselect_frame will leave it alone. */
107 Lisp_Object focus_frame;
109 /* This frame's root window. Every frame has one.
110 If the frame has only a minibuffer window, this is it.
111 Otherwise, if the frame has a minibuffer window, this is its sibling. */
112 Lisp_Object root_window;
114 /* This frame's selected window.
115 Each frame has its own window hierarchy
116 and one of the windows in it is selected within the frame.
117 The selected window of the selected frame is Emacs's selected window. */
118 Lisp_Object selected_window;
120 /* This frame's minibuffer window.
121 Most frames have their own minibuffer windows,
122 but only the selected frame's minibuffer window
123 can actually appear to exist. */
124 Lisp_Object minibuffer_window;
126 /* Parameter alist of this frame.
127 These are the parameters specified when creating the frame
128 or modified with modify-frame-parameters. */
129 Lisp_Object param_alist;
131 /* List of scroll bars on this frame.
132 Actually, we don't specify exactly what is stored here at all; the
133 scroll bar implementation code can use it to store anything it likes.
134 This field is marked by the garbage collector. It is here
135 instead of in the `device' structure so that the garbage
136 collector doesn't need to look inside the window-system-dependent
137 structure. */
138 Lisp_Object scroll_bars;
139 Lisp_Object condemned_scroll_bars;
141 /* Vector describing the items to display in the menu bar.
142 Each item has four elements in this vector.
143 They are KEY, STRING, SUBMAP, and HPOS.
144 (HPOS is not used in when the X toolkit is in use.)
145 There are four additional elements of nil at the end, to terminate. */
146 Lisp_Object menu_bar_items;
148 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
149 Lisp_Object face_alist;
151 /* A vector that records the entire structure of this frame's menu bar.
152 For the format of the data, see extensive comments in xmenu.c.
153 Only the X toolkit version uses this. */
154 Lisp_Object menu_bar_vector;
155 /* Number of elements in the vector that have meaningful data. */
156 EMACS_INT menu_bar_items_used;
158 /* Predicate for selecting buffers for other-buffer. */
159 Lisp_Object buffer_predicate;
161 /* List of buffers viewed in this frame, for other-buffer. */
162 Lisp_Object buffer_list;
164 /* List of buffers that were viewed, then buried in this frame. The
165 most recently buried buffer is first. For last-buffer. */
166 Lisp_Object buried_buffer_list;
168 /* A dummy window used to display menu bars under X when no X
169 toolkit support is available. */
170 Lisp_Object menu_bar_window;
172 /* A window used to display the tool-bar of a frame. */
173 Lisp_Object tool_bar_window;
175 /* Desired and current tool-bar items. */
176 Lisp_Object tool_bar_items;
178 /* Desired and current contents displayed in tool_bar_window. */
179 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
181 /* beyond here, there should be no more Lisp_Object components. */
183 /* Cache of realized faces. */
184 struct face_cache *face_cache;
186 /* A buffer to hold the frame's name. We can't use the Lisp
187 string's pointer (`name', above) because it might get relocated. */
188 char *namebuf;
190 /* Glyph pool and matrix. */
191 struct glyph_pool *current_pool;
192 struct glyph_pool *desired_pool;
193 struct glyph_matrix *desired_matrix;
194 struct glyph_matrix *current_matrix;
196 /* 1 means that glyphs on this frame have been initialized so it can
197 be used for output. */
198 unsigned glyphs_initialized_p : 1;
200 #if defined (USE_GTK)
201 /* Nonzero means using a tool bar that comes from the toolkit. */
202 int external_tool_bar;
203 #endif
205 /* Margin at the top of the frame. Used to display the tool-bar. */
206 int tool_bar_lines;
208 int n_tool_bar_rows;
209 int n_tool_bar_items;
211 /* A buffer for decode_mode_line. */
212 char *decode_mode_spec_buffer;
214 /* See do_line_insertion_deletion_costs for info on these arrays. */
215 /* Cost of inserting 1 line on this frame */
216 int *insert_line_cost;
217 /* Cost of deleting 1 line on this frame */
218 int *delete_line_cost;
219 /* Cost of inserting n lines on this frame */
220 int *insert_n_lines_cost;
221 /* Cost of deleting n lines on this frame */
222 int *delete_n_lines_cost;
224 /* Size of this frame, excluding fringes, scroll bars etc.,
225 in units of canonical characters. */
226 EMACS_INT text_lines, text_cols;
228 /* Total size of this frame (i.e. its native window), in units of
229 canonical characters. */
230 EMACS_INT total_lines, total_cols;
232 /* New text height and width for pending size change.
233 0 if no change pending. */
234 int new_text_lines, new_text_cols;
236 /* Pixel position of the frame window (x and y offsets in root window). */
237 int left_pos, top_pos;
239 /* Size of the frame window in pixels. */
240 int pixel_height, pixel_width;
242 /* These many pixels are the difference between the outer window (i.e. the
243 left and top of the window manager decoration) and FRAME_X_WINDOW. */
244 int x_pixels_diff, y_pixels_diff;
246 /* This is the gravity value for the specified window position. */
247 int win_gravity;
249 /* The geometry flags for this window. */
250 int size_hint_flags;
252 /* Border width of the frame window as known by the (X) window system. */
253 int border_width;
255 /* Width of the internal border. This is a line of background color
256 just inside the window's border. When the frame is selected,
257 a highlighting is displayed inside the internal border. */
258 int internal_border_width;
260 /* Canonical X unit. Width of default font, in pixels. */
261 int column_width;
263 /* Widht of space glyph of default font, in pixels. */
264 int space_width;
266 /* Canonical Y unit. Height of a line, in pixels. */
267 int line_height;
269 /* The output method says how the contents of this frame are
270 displayed. It could be using termcap, or using an X window.
271 This must be the same as the terminal->type. */
272 enum output_method output_method;
274 /* The terminal device that this frame uses. If this is NULL, then
275 the frame has been deleted. */
276 struct terminal *terminal;
278 /* Device-dependent, frame-local auxiliary data used for displaying
279 the contents. When the frame is deleted, this data is deleted as
280 well. */
281 union output_data
283 struct tty_output *tty; /* termchar.h */
284 struct x_output *x; /* xterm.h */
285 struct w32_output *w32; /* w32term.h */
286 struct mac_output *mac; /* macterm.h */
287 EMACS_INT nothing;
289 output_data;
291 /* Total width of fringes reserved for drawing truncation bitmaps,
292 continuation bitmaps and alike. The width is in canonical char
293 units of the frame. This must currently be the case because window
294 sizes aren't pixel values. If it weren't the case, we wouldn't be
295 able to split windows horizontally nicely. */
296 int fringe_cols;
298 /* The extra width (in pixels) currently allotted for fringes. */
299 int left_fringe_width, right_fringe_width;
301 /* See FULLSCREEN_ enum below */
302 int want_fullscreen;
304 /* Number of lines of menu bar. */
305 int menu_bar_lines;
307 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
308 || defined (USE_GTK)
309 /* Nonzero means using a menu bar that comes from the X toolkit. */
310 int external_menu_bar;
311 #endif
313 /* Nonzero if last attempt at redisplay on this frame was preempted. */
314 char display_preempted;
316 /* visible is nonzero if the frame is currently displayed; we check
317 it to see if we should bother updating the frame's contents.
318 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
320 Note that, since invisible frames aren't updated, whenever a
321 frame becomes visible again, it must be marked as garbaged. The
322 FRAME_SAMPLE_VISIBILITY macro takes care of this.
324 On ttys and on Windows NT/9X, to avoid wasting effort updating
325 visible frames that are actually completely obscured by other
326 windows on the display, we bend the meaning of visible slightly:
327 if greater than 1, then the frame is obscured - we still consider
328 it to be "visible" as seen from lisp, but we don't bother
329 updating it. We must take care to garbage the frame when it
330 ceaces to be obscured though.
332 iconified is nonzero if the frame is currently iconified.
334 Asynchronous input handlers should NOT change these directly;
335 instead, they should change async_visible or async_iconified, and
336 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
337 at the next redisplay.
339 These should probably be considered read-only by everyone except
340 FRAME_SAMPLE_VISIBILITY.
342 These two are mutually exclusive. They might both be zero, if the
343 frame has been made invisible without an icon. */
344 char visible, iconified;
346 /* Asynchronous input handlers change these, and
347 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
348 See FRAME_SAMPLE_VISIBILITY, below. */
349 volatile char async_visible, async_iconified;
351 /* Nonzero if this frame should be redrawn. */
352 volatile char garbaged;
354 /* True if frame actually has a minibuffer window on it.
355 0 if using a minibuffer window that isn't on this frame. */
356 char has_minibuffer;
358 /* 0 means, if this frame has just one window,
359 show no modeline for that window. */
360 char wants_modeline;
362 /* Non-zero if the hardware device this frame is displaying on can
363 support scroll bars. */
364 char can_have_scroll_bars;
366 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
367 actually display them on this frame. */
368 enum vertical_scroll_bar_type vertical_scroll_bar_type;
370 /* What kind of text cursor should we draw in the future?
371 This should always be filled_box_cursor or bar_cursor. */
372 enum text_cursor_kinds desired_cursor;
374 /* Width of bar cursor (if we are using that). */
375 int cursor_width;
377 /* What kind of text cursor should we draw when the cursor blinks off?
378 This can be filled_box_cursor or bar_cursor or no_cursor. */
379 enum text_cursor_kinds blink_off_cursor;
381 /* Width of bar cursor (if we are using that) for blink-off state. */
382 int blink_off_cursor_width;
384 /* Non-0 means raise this frame to the top of the heap when selected. */
385 char auto_raise;
387 /* Non-0 means lower this frame to the bottom of the stack when left. */
388 char auto_lower;
390 /* True if frame's root window can't be split. */
391 char no_split;
393 /* If this is set, then Emacs won't change the frame name to indicate
394 the current buffer, etcetera. If the user explicitly sets the frame
395 name, this gets set. If the user sets the name to Qnil, this is
396 cleared. */
397 char explicit_name;
399 /* Nonzero if size of some window on this frame has changed. */
400 char window_sizes_changed;
402 /* Storage for messages to this frame. */
403 char *message_buf;
405 /* Nonnegative if current redisplay should not do scroll computation
406 for lines beyond a certain vpos. This is the vpos. */
407 int scroll_bottom_vpos;
409 /* Configured width of the scroll bar, in pixels and in characters.
410 config_scroll_bar_cols tracks config_scroll_bar_width if the
411 latter is positive; a zero value in config_scroll_bar_width means
412 to compute the actual width on the fly, using config_scroll_bar_cols
413 and the current font width. */
414 int config_scroll_bar_width;
415 int config_scroll_bar_cols;
417 /* The size of the extra width currently allotted for vertical
418 scroll bars in this frame, in pixels. */
419 int scroll_bar_actual_width;
421 /* The baud rate that was used to calculate costs for this frame. */
422 int cost_calculation_baud_rate;
424 /* Nonzero if the mouse has moved on this display device
425 since the last time we checked. */
426 char mouse_moved;
428 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
429 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
430 frame parameter. 0 means don't do gamma correction. */
431 double gamma;
433 /* Additional space to put between text lines on this frame. */
434 int extra_line_spacing;
436 /* Set to non-zero in change_frame_size when size of frame changed
437 Clear the frame in clear_garbaged_frames if set. */
438 unsigned resized_p : 1;
440 /* Set to non-zero in when we want for force a flush_display in
441 update_frame, usually after resizing the frame. */
442 unsigned force_flush_display_p : 1;
444 /* All display backends seem to need these two pixel values. */
445 unsigned long background_pixel;
446 unsigned long foreground_pixel;
448 /* Set to non-zero if the default face for the frame has been
449 realized. Reset to zero whenever the default face changes.
450 Used to see the difference between a font change and face change. */
451 unsigned default_face_done_p : 1;
453 /* Set to non-zero if this frame has already been hscrolled during
454 current redisplay. */
455 unsigned already_hscrolled_p : 1;
457 /* Set to non-zero when current redisplay has updated frame. */
458 unsigned updated_p : 1;
461 #ifdef MULTI_KBOARD
462 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
463 #else
464 #define FRAME_KBOARD(f) (&the_only_kboard)
465 #endif
467 typedef struct frame *FRAME_PTR;
469 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
470 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
472 /* Given a window, return its frame as a Lisp_Object. */
473 #define WINDOW_FRAME(w) (w)->frame
475 /* Test a frame for particular kinds of display methods. */
476 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
477 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
478 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
479 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
480 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
481 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
483 /* FRAME_WINDOW_P tests whether the frame is a window, and is
484 defined to be the predicate for the window system being used. */
486 #ifdef HAVE_X_WINDOWS
487 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
488 #endif
489 #ifdef HAVE_NTGUI
490 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
491 #endif
492 #ifdef MAC_OS
493 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
494 #endif
495 #ifndef FRAME_WINDOW_P
496 #define FRAME_WINDOW_P(f) (0)
497 #endif
499 /* Nonzero if frame F is still alive (not deleted). */
500 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
502 /* Nonzero if frame F is a minibuffer-only frame. */
503 #define FRAME_MINIBUF_ONLY_P(f) \
504 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
506 /* Nonzero if frame F contains a minibuffer window.
507 (If this is 0, F must use some other minibuffer window.) */
508 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
510 /* Pixel height of frame F, including non-toolkit menu bar and
511 non-toolkit tool bar lines. */
512 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
514 /* Pixel width of frame F. */
515 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
517 /* Height of frame F, measured in canonical lines, including
518 non-toolkit menu bar and non-toolkit tool bar lines. */
519 #define FRAME_LINES(f) (f)->text_lines
521 /* Width of frame F, measured in canonical character columns,
522 not including scroll bars if any. */
523 #define FRAME_COLS(f) (f)->text_cols
525 /* Number of lines of frame F used for menu bar.
526 This is relevant on terminal frames and on
527 X Windows when not using the X toolkit.
528 These lines are counted in FRAME_LINES. */
529 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
531 /* Nonzero if this frame should display a tool bar
532 in a way that does not use any text lines. */
533 #if defined (USE_GTK)
534 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
535 #else
536 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
537 #endif
539 /* Number of lines of frame F used for the tool-bar. */
541 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
544 /* Lines above the top-most window in frame F. */
546 #define FRAME_TOP_MARGIN(F) \
547 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
549 /* Nonzero if this frame should display a menu bar
550 in a way that does not use any text lines. */
551 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
552 || defined (USE_GTK)
553 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
554 #else
555 #define FRAME_EXTERNAL_MENU_BAR(f) 0
556 #endif
557 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
559 /* Nonzero if frame F is currently visible but hidden. */
560 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
562 /* Nonzero if frame F is currently iconified. */
563 #define FRAME_ICONIFIED_P(f) (f)->iconified
565 #define FRAME_SET_VISIBLE(f,p) \
566 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
567 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
568 #define FRAME_GARBAGED_P(f) (f)->garbaged
570 /* Nonzero means do not allow splitting this frame's window. */
571 #define FRAME_NO_SPLIT_P(f) (f)->no_split
573 /* Not really implemented. */
574 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
576 /* Nonzero if a size change has been requested for frame F
577 but not yet really put into effect. This can be true temporarily
578 when an X event comes in at a bad time. */
579 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
581 /* The minibuffer window of frame F, if it has one; otherwise nil. */
582 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
584 /* The root window of the window tree of frame F. */
585 #define FRAME_ROOT_WINDOW(f) (f)->root_window
587 /* The currently selected window of the window tree of frame F. */
588 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
590 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
591 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
592 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
593 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
594 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
595 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
596 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
598 /* Nonzero if frame F supports scroll bars.
599 If this is zero, then it is impossible to enable scroll bars
600 on frame F. */
601 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
603 /* This frame slot says whether scroll bars are currently enabled for frame F,
604 and which side they are on. */
605 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
606 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
607 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
608 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
609 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
610 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
611 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
613 /* Width that a scroll bar in frame F should have, if there is one.
614 Measured in pixels.
615 If scroll bars are turned off, this is still nonzero. */
616 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
618 /* Width that a scroll bar in frame F should have, if there is one.
619 Measured in columns (characters).
620 If scroll bars are turned off, this is still nonzero. */
621 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
623 /* Width of a scroll bar in frame F, measured in columns (characters),
624 but only if scroll bars are on the left. If scroll bars are on
625 the right in this frame, or there are no scroll bars, value is 0. */
627 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
628 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
629 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
630 : 0)
632 /* Width of a left scroll bar in frame F, measured in pixels */
634 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
635 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
636 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
637 : 0)
639 /* Width of a scroll bar in frame F, measured in columns (characters),
640 but only if scroll bars are on the right. If scroll bars are on
641 the left in this frame, or there are no scroll bars, value is 0. */
643 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
644 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
645 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
646 : 0)
648 /* Width of a right scroll bar area in frame F, measured in pixels */
650 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
651 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
652 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
653 : 0)
655 /* Actual width of a scroll bar in frame F, measured in columns. */
657 #define FRAME_SCROLL_BAR_COLS(f) \
658 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
659 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
660 : 0)
662 /* Actual width of a scroll bar area in frame F, measured in pixels. */
664 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
665 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
666 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
667 : 0)
669 /* Total width of frame F, in columns (characters),
670 including the width used by scroll bars if any. */
672 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
674 /* Set the width of frame F to VAL.
675 VAL is the width of a full-frame window,
676 not including scroll bars and fringes. */
678 #define SET_FRAME_COLS(f, val) \
679 (FRAME_COLS (f) = (val), \
680 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
682 /* Given a value WIDTH for frame F's nominal width,
683 return the value that FRAME_TOTAL_COLS should have. */
685 #define FRAME_TOTAL_COLS_ARG(f, width) \
686 ((width) \
687 + FRAME_SCROLL_BAR_COLS (f) \
688 + FRAME_FRINGE_COLS (f))
690 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
692 #define FRAME_CURSOR_X_LIMIT(f) \
693 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
695 /* Nonzero if frame F has scroll bars. */
697 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
699 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
700 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
701 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
703 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
704 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
705 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
706 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
708 /* Return a pointer to the face cache of frame F. */
710 #define FRAME_FACE_CACHE(F) (F)->face_cache
712 /* Return the size of message_buf of the frame F. We multiply the
713 width of the frame by 4 because multi-byte form may require at most
714 4-byte for a character. */
716 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
718 /* Emacs's redisplay code could become confused if a frame's
719 visibility changes at arbitrary times. For example, if a frame is
720 visible while the desired glyphs are being built, but becomes
721 invisible before they are updated, then some rows of the
722 desired_glyphs will be left marked as enabled after redisplay is
723 complete, which should never happen. The next time the frame
724 becomes visible, redisplay will probably barf.
726 Currently, there are no similar situations involving iconified, but
727 the principle is the same.
729 So instead of having asynchronous input handlers directly set and
730 clear the frame's visibility and iconification flags, they just set
731 the async_visible and async_iconified flags; the redisplay code
732 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
733 which sets visible and iconified from their asynchronous
734 counterparts.
736 Synchronous code must use the FRAME_SET_VISIBLE macro.
738 Also, if a frame used to be invisible, but has just become visible,
739 it must be marked as garbaged, since redisplay hasn't been keeping
740 up its contents.
742 Note that a tty frame is visible if and only if it is the topmost
743 frame. */
745 #define FRAME_SAMPLE_VISIBILITY(f) \
746 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
747 SET_FRAME_GARBAGED (f) : 0, \
748 (f)->visible = (f)->async_visible, \
749 (f)->iconified = (f)->async_iconified)
751 #define CHECK_FRAME(x) \
752 do { \
753 if (! FRAMEP (x)) \
754 x = wrong_type_argument (Qframep, (x)); \
755 } while (0)
757 #define CHECK_LIVE_FRAME(x) \
758 do { \
759 if (! FRAMEP (x) \
760 || ! FRAME_LIVE_P (XFRAME (x))) \
761 x = wrong_type_argument (Qframe_live_p, (x)); \
762 } while (0)
764 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
765 `for' loop which iterates over the elements of Vframe_list. The
766 loop will set FRAME_VAR, a Lisp_Object, to each frame in
767 Vframe_list in succession and execute the statement. LIST_VAR
768 should be a Lisp_Object too; it is used to iterate through the
769 Vframe_list.
771 This macro is a holdover from a time when multiple frames weren't always
772 supported. An alternate definition of the macro would expand to
773 something which executes the statement once. */
775 #define FOR_EACH_FRAME(list_var, frame_var) \
776 for ((list_var) = Vframe_list; \
777 (CONSP (list_var) \
778 && (frame_var = XCAR (list_var), 1)); \
779 list_var = XCDR (list_var))
782 extern Lisp_Object Qframep, Qframe_live_p;
783 extern Lisp_Object Qtty, Qtty_type;
784 extern Lisp_Object Qterminal, Qterminal_live_p;
785 extern Lisp_Object Qenvironment;
787 extern struct frame *last_nonminibuf_frame;
789 extern struct frame *make_initial_frame P_ ((void));
790 extern struct frame *make_terminal_frame P_ ((struct terminal *));
791 extern struct frame *make_frame P_ ((int));
792 #ifdef HAVE_WINDOW_SYSTEM
793 extern struct frame *make_minibuffer_frame P_ ((void));
794 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
795 struct kboard *,
796 Lisp_Object));
797 #endif /* HAVE_WINDOW_SYSTEM */
798 extern int other_visible_frames P_ ((struct frame *));
800 extern Lisp_Object Vframe_list;
801 extern Lisp_Object Vdefault_frame_alist;
803 extern Lisp_Object Vterminal_frame;
805 extern Lisp_Object Vmouse_highlight;
807 /* The currently selected frame. */
809 extern Lisp_Object selected_frame;
811 /* Value is a pointer to the selected frame. If the selected frame
812 isn't live, abort. */
814 #define SELECTED_FRAME() \
815 ((FRAMEP (selected_frame) \
816 && FRAME_LIVE_P (XFRAME (selected_frame))) \
817 ? XFRAME (selected_frame) \
818 : (abort (), (struct frame *) 0))
821 /***********************************************************************
822 Display-related Macros
823 ***********************************************************************/
825 /* Canonical y-unit on frame F.
826 This value currently equals the line height of the frame (which is
827 the height of the default font of F). */
829 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
831 /* Canonical x-unit on frame F.
832 This value currently equals the average width of the default font of F. */
834 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
836 /* Space glyph width of the default font of frame F. */
838 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
841 /* Pixel width of areas used to display truncation marks, continuation
842 marks, overlay arrows. This is 0 for terminal frames. */
844 #ifdef HAVE_WINDOW_SYSTEM
846 /* Total width of fringes reserved for drawing truncation bitmaps,
847 continuation bitmaps and alike. The width is in canonical char
848 units of the frame. This must currently be the case because window
849 sizes aren't pixel values. If it weren't the case, we wouldn't be
850 able to split windows horizontally nicely. */
852 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
854 /* Pixel-width of the left and right fringe. */
856 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
857 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
859 /* Total width of fringes in pixels. */
861 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
862 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
865 /* Pixel-width of internal border lines */
867 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
869 #else /* not HAVE_WINDOW_SYSTEM */
871 #define FRAME_FRINGE_COLS(F) 0
872 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
873 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
874 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
875 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
877 #endif /* not HAVE_WINDOW_SYSTEM */
882 /***********************************************************************
883 Conversion between canonical units and pixels
884 ***********************************************************************/
886 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
887 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
888 represented as Lisp numbers, i.e. integers or floats. */
890 /* Convert canonical value X to pixels. F is the frame whose
891 canonical char width is to be used. X must be a Lisp integer or
892 float. Value is a C integer. */
894 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
895 (INTEGERP (X) \
896 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
897 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
899 /* Convert canonical value Y to pixels. F is the frame whose
900 canonical character height is to be used. X must be a Lisp integer
901 or float. Value is a C integer. */
903 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
904 (INTEGERP (Y) \
905 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
906 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
908 /* Convert pixel-value X to canonical units. F is the frame whose
909 canonical character width is to be used. X is a C integer. Result
910 is a Lisp float if X is not a multiple of the canon width,
911 otherwise it's a Lisp integer. */
913 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
914 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
915 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
916 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
918 /* Convert pixel-value Y to canonical units. F is the frame whose
919 canonical character height is to be used. Y is a C integer.
920 Result is a Lisp float if Y is not a multiple of the canon width,
921 otherwise it's a Lisp integer. */
923 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
924 ((Y) % FRAME_LINE_HEIGHT (F) \
925 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
926 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
930 /* Manipulating pixel sizes and character sizes.
931 Knowledge of which factors affect the overall size of the window should
932 be hidden in these macros, if that's possible.
934 Return the upper/left pixel position of the character cell on frame F
935 at ROW/COL. */
937 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
938 (FRAME_INTERNAL_BORDER_WIDTH (f) \
939 + (row) * FRAME_LINE_HEIGHT (f))
941 #define FRAME_COL_TO_PIXEL_X(f, col) \
942 (FRAME_INTERNAL_BORDER_WIDTH (f) \
943 + (col) * FRAME_COLUMN_WIDTH (f))
945 /* Return the pixel width/height of frame F if it has
946 COLS columns/LINES rows. */
948 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
949 (FRAME_COL_TO_PIXEL_X (f, cols) \
950 + (f)->scroll_bar_actual_width \
951 + FRAME_TOTAL_FRINGE_WIDTH (f) \
952 + FRAME_INTERNAL_BORDER_WIDTH (f))
954 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
955 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
956 + FRAME_INTERNAL_BORDER_WIDTH (f))
959 /* Return the row/column (zero-based) of the character cell containing
960 the pixel on FRAME at Y/X. */
962 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
963 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
964 / FRAME_LINE_HEIGHT (f))
966 #define FRAME_PIXEL_X_TO_COL(f, x) \
967 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
968 / FRAME_COLUMN_WIDTH (f))
970 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
971 frame F? */
973 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
974 (FRAME_PIXEL_X_TO_COL (f, ((width) \
975 - FRAME_INTERNAL_BORDER_WIDTH (f) \
976 - FRAME_TOTAL_FRINGE_WIDTH (f) \
977 - (f)->scroll_bar_actual_width)))
979 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
980 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
981 - FRAME_INTERNAL_BORDER_WIDTH (f))))
984 /***********************************************************************
985 Frame Parameters
986 ***********************************************************************/
988 extern Lisp_Object Qauto_raise, Qauto_lower;
989 extern Lisp_Object Qborder_color, Qborder_width;
990 extern Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
991 extern Lisp_Object Qcursor_color, Qcursor_type;
992 extern Lisp_Object Qfont;
993 extern Lisp_Object Qbackground_color, Qforeground_color;
994 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
995 extern Lisp_Object Qinternal_border_width;
996 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
997 extern Lisp_Object Qmouse_color;
998 extern Lisp_Object Qname, Qtitle;
999 extern Lisp_Object Qparent_id;
1000 extern Lisp_Object Qunsplittable, Qvisibility;
1001 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1002 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1003 extern Lisp_Object Qscreen_gamma;
1004 extern Lisp_Object Qline_spacing;
1005 extern Lisp_Object Qwait_for_wm;
1006 extern Lisp_Object Qfullscreen;
1008 extern Lisp_Object Qleft_fringe, Qright_fringe;
1009 extern Lisp_Object Qheight, Qwidth;
1010 extern Lisp_Object Qminibuffer, Qmodeline;
1011 extern Lisp_Object Qonly;
1012 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
1013 extern Lisp_Object Qvisible;
1014 extern Lisp_Object Qdisplay_type;
1015 extern Lisp_Object Qbackground_mode;
1017 extern Lisp_Object Qx_resource_name;
1019 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1020 extern Lisp_Object Qdisplay;
1022 extern Lisp_Object Qwindow_system;
1024 #ifdef HAVE_WINDOW_SYSTEM
1026 /* The class of this X application. */
1027 #define EMACS_CLASS "Emacs"
1029 enum
1031 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1032 FULLSCREEN_NONE = 0,
1033 FULLSCREEN_WIDTH = 1,
1034 FULLSCREEN_HEIGHT = 2,
1035 FULLSCREEN_BOTH = 3,
1036 FULLSCREEN_WAIT = 4,
1040 /* These are in xterm.c, w32term.c, etc. */
1042 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1043 extern void x_set_offset P_ ((struct frame *, int, int, int));
1044 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1046 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1047 extern Lisp_Object x_new_fontset P_ ((struct frame *, char *));
1050 /* These are in frame.c */
1052 extern Lisp_Object Vx_resource_name;
1053 extern Lisp_Object Vx_resource_class;
1056 extern Lisp_Object Qface_set_after_frame_default;
1058 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1059 int *, int *));
1061 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1062 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1064 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1065 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1066 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1067 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1068 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1069 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1070 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1071 Lisp_Object));
1072 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1073 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1074 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1075 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1076 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1077 Lisp_Object));
1078 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1079 Lisp_Object));
1081 extern Lisp_Object x_icon_type P_ ((struct frame *));
1083 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1086 extern void validate_x_resource_name P_ ((void));
1088 #endif /* HAVE_WINDOW_SYSTEM */
1090 #endif /* not EMACS_FRAME_H */
1092 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1093 (do not change this comment) */