(hol-loaddefs): Load this rather than explicit autoloads.
[emacs.git] / src / frame.h
blob3b5a27f78a8ce02e9db78f0c278d876313391cef
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993, 1994, 1999, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2008 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 3, 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;
40 /* Nonzero means window system changes focus when moving the
41 mouse. */
43 extern int focus_follows_mouse;
46 /* The structure representing a frame. */
48 enum output_method
50 output_initial,
51 output_termcap,
52 output_x_window,
53 output_msdos_raw,
54 output_w32,
55 output_mac
58 enum vertical_scroll_bar_type
60 vertical_scroll_bar_none,
61 vertical_scroll_bar_left,
62 vertical_scroll_bar_right
65 enum text_cursor_kinds
67 DEFAULT_CURSOR = -2,
68 NO_CURSOR = -1,
69 FILLED_BOX_CURSOR,
70 HOLLOW_BOX_CURSOR,
71 BAR_CURSOR,
72 HBAR_CURSOR
75 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
76 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
78 struct terminal;
80 struct font_driver_list;
82 struct frame
84 EMACS_UINT size;
85 struct Lisp_Vector *next;
87 /* All Lisp_Object components must come first.
88 That ensures they are all aligned normally. */
90 /* Name of this frame: a Lisp string. It is used for looking up resources,
91 as well as for the title in some cases. */
92 Lisp_Object name;
94 /* The name to use for the icon, the last time
95 it was refreshed. nil means not explicitly specified. */
96 Lisp_Object icon_name;
98 /* This is the frame title specified explicitly, if any.
99 Usually it is nil. */
100 Lisp_Object title;
102 /* The frame which should receive keystrokes that occur in this
103 frame, or nil if they should go to the frame itself. This is
104 usually nil, but if the frame is minibufferless, we can use this
105 to redirect keystrokes to a surrogate minibuffer frame when
106 needed.
108 Note that a value of nil is different than having the field point
109 to the frame itself. Whenever the Fselect_frame function is used
110 to shift from one frame to the other, any redirections to the
111 original frame are shifted to the newly selected frame; if
112 focus_frame is nil, Fselect_frame will leave it alone. */
113 Lisp_Object focus_frame;
115 /* This frame's root window. Every frame has one.
116 If the frame has only a minibuffer window, this is it.
117 Otherwise, if the frame has a minibuffer window, this is its sibling. */
118 Lisp_Object root_window;
120 /* This frame's selected window.
121 Each frame has its own window hierarchy
122 and one of the windows in it is selected within the frame.
123 The selected window of the selected frame is Emacs's selected window. */
124 Lisp_Object selected_window;
126 /* This frame's minibuffer window.
127 Most frames have their own minibuffer windows,
128 but only the selected frame's minibuffer window
129 can actually appear to exist. */
130 Lisp_Object minibuffer_window;
132 /* Parameter alist of this frame.
133 These are the parameters specified when creating the frame
134 or modified with modify-frame-parameters. */
135 Lisp_Object param_alist;
137 /* List of scroll bars on this frame.
138 Actually, we don't specify exactly what is stored here at all; the
139 scroll bar implementation code can use it to store anything it likes.
140 This field is marked by the garbage collector. It is here
141 instead of in the `device' structure so that the garbage
142 collector doesn't need to look inside the window-system-dependent
143 structure. */
144 Lisp_Object scroll_bars;
145 Lisp_Object condemned_scroll_bars;
147 /* Vector describing the items to display in the menu bar.
148 Each item has four elements in this vector.
149 They are KEY, STRING, SUBMAP, and HPOS.
150 (HPOS is not used in when the X toolkit is in use.)
151 There are four additional elements of nil at the end, to terminate. */
152 Lisp_Object menu_bar_items;
154 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
155 Lisp_Object face_alist;
157 /* A vector that records the entire structure of this frame's menu bar.
158 For the format of the data, see extensive comments in xmenu.c.
159 Only the X toolkit version uses this. */
160 Lisp_Object menu_bar_vector;
162 /* Predicate for selecting buffers for other-buffer. */
163 Lisp_Object buffer_predicate;
165 /* List of buffers viewed in this frame, for other-buffer. */
166 Lisp_Object buffer_list;
168 /* List of buffers that were viewed, then buried in this frame. The
169 most recently buried buffer is first. For last-buffer. */
170 Lisp_Object buried_buffer_list;
172 /* A dummy window used to display menu bars under X when no X
173 toolkit support is available. */
174 Lisp_Object menu_bar_window;
176 /* A window used to display the tool-bar of a frame. */
177 Lisp_Object tool_bar_window;
179 /* Desired and current tool-bar items. */
180 Lisp_Object tool_bar_items;
182 /* Desired and current contents displayed in tool_bar_window. */
183 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
185 /* Beyond here, there should be no more Lisp_Object components. */
187 /* Cache of realized faces. */
188 struct face_cache *face_cache;
190 /* Number of elements in `menu_bar_vector' that have meaningful data. */
191 EMACS_INT menu_bar_items_used;
193 /* A buffer to hold the frame's name. We can't use the Lisp
194 string's pointer (`name', above) because it might get relocated. */
195 char *namebuf;
197 /* Glyph pool and matrix. */
198 struct glyph_pool *current_pool;
199 struct glyph_pool *desired_pool;
200 struct glyph_matrix *desired_matrix;
201 struct glyph_matrix *current_matrix;
203 /* 1 means that glyphs on this frame have been initialized so it can
204 be used for output. */
205 unsigned glyphs_initialized_p : 1;
207 /* Set to non-zero in change_frame_size when size of frame changed
208 Clear the frame in clear_garbaged_frames if set. */
209 unsigned resized_p : 1;
211 /* Set to non-zero in when we want for force a flush_display in
212 update_frame, usually after resizing the frame. */
213 unsigned force_flush_display_p : 1;
215 /* Set to non-zero if the default face for the frame has been
216 realized. Reset to zero whenever the default face changes.
217 Used to see the difference between a font change and face change. */
218 unsigned default_face_done_p : 1;
220 /* Set to non-zero if this frame has already been hscrolled during
221 current redisplay. */
222 unsigned already_hscrolled_p : 1;
224 /* Set to non-zero when current redisplay has updated frame. */
225 unsigned updated_p : 1;
227 /* Set to non-zero to minimize tool-bar height even when
228 auto-resize-tool-bar is set to grow-only. */
229 unsigned minimize_tool_bar_window_p : 1;
231 #if defined (USE_GTK) || defined (MAC_OS)
232 /* Nonzero means using a tool bar that comes from the toolkit. */
233 int external_tool_bar;
234 #endif
236 /* Margin at the top of the frame. Used to display the tool-bar. */
237 int tool_bar_lines;
239 int n_tool_bar_rows;
240 int n_tool_bar_items;
242 /* A buffer for decode_mode_line. */
243 char *decode_mode_spec_buffer;
245 /* See do_line_insertion_deletion_costs for info on these arrays. */
246 /* Cost of inserting 1 line on this frame */
247 int *insert_line_cost;
248 /* Cost of deleting 1 line on this frame */
249 int *delete_line_cost;
250 /* Cost of inserting n lines on this frame */
251 int *insert_n_lines_cost;
252 /* Cost of deleting n lines on this frame */
253 int *delete_n_lines_cost;
255 /* Size of this frame, excluding fringes, scroll bars etc.,
256 in units of canonical characters. */
257 EMACS_INT text_lines, text_cols;
259 /* Total size of this frame (i.e. its native window), in units of
260 canonical characters. */
261 EMACS_INT total_lines, total_cols;
263 /* New text height and width for pending size change.
264 0 if no change pending. */
265 int new_text_lines, new_text_cols;
267 /* Pixel position of the frame window (x and y offsets in root window). */
268 int left_pos, top_pos;
270 /* Size of the frame window in pixels. */
271 int pixel_height, pixel_width;
273 /* Dots per inch of the screen the frame is on. */
274 double resx, resy;
276 /* These many pixels are the difference between the outer window (i.e. the
277 left and top of the window manager decoration) and FRAME_X_WINDOW. */
278 int x_pixels_diff, y_pixels_diff;
280 /* This is the gravity value for the specified window position. */
281 int win_gravity;
283 /* The geometry flags for this window. */
284 int size_hint_flags;
286 /* Border width of the frame window as known by the (X) window system. */
287 int border_width;
289 /* Width of the internal border. This is a line of background color
290 just inside the window's border. When the frame is selected,
291 a highlighting is displayed inside the internal border. */
292 int internal_border_width;
294 /* Canonical X unit. Width of default font, in pixels. */
295 int column_width;
297 /* Widht of space glyph of default font, in pixels. */
298 int space_width;
300 /* Canonical Y unit. Height of a line, in pixels. */
301 int line_height;
303 /* The output method says how the contents of this frame are
304 displayed. It could be using termcap, or using an X window.
305 This must be the same as the terminal->type. */
306 enum output_method output_method;
308 /* The terminal device that this frame uses. If this is NULL, then
309 the frame has been deleted. */
310 struct terminal *terminal;
312 /* Device-dependent, frame-local auxiliary data used for displaying
313 the contents. When the frame is deleted, this data is deleted as
314 well. */
315 union output_data
317 struct tty_output *tty; /* termchar.h */
318 struct x_output *x; /* xterm.h */
319 struct w32_output *w32; /* w32term.h */
320 struct mac_output *mac; /* macterm.h */
321 EMACS_INT nothing;
323 output_data;
325 /* List of font-drivers available on the frame. */
326 struct font_driver_list *font_driver_list;
327 /* List of data specific to font-driver and frame, but common to
328 faces. */
329 struct font_data_list *font_data_list;
331 /* Total width of fringes reserved for drawing truncation bitmaps,
332 continuation bitmaps and alike. The width is in canonical char
333 units of the frame. This must currently be the case because window
334 sizes aren't pixel values. If it weren't the case, we wouldn't be
335 able to split windows horizontally nicely. */
336 int fringe_cols;
338 /* The extra width (in pixels) currently allotted for fringes. */
339 int left_fringe_width, right_fringe_width;
341 /* See FULLSCREEN_ enum below */
342 int want_fullscreen;
344 /* Number of lines of menu bar. */
345 int menu_bar_lines;
347 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
348 || defined (USE_GTK)
349 /* Nonzero means using a menu bar that comes from the X toolkit. */
350 int external_menu_bar;
351 #endif
353 /* Nonzero if last attempt at redisplay on this frame was preempted. */
354 char display_preempted;
356 /* visible is nonzero if the frame is currently displayed; we check
357 it to see if we should bother updating the frame's contents.
358 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
360 Note that, since invisible frames aren't updated, whenever a
361 frame becomes visible again, it must be marked as garbaged. The
362 FRAME_SAMPLE_VISIBILITY macro takes care of this.
364 On ttys and on Windows NT/9X, to avoid wasting effort updating
365 visible frames that are actually completely obscured by other
366 windows on the display, we bend the meaning of visible slightly:
367 if greater than 1, then the frame is obscured - we still consider
368 it to be "visible" as seen from lisp, but we don't bother
369 updating it. We must take care to garbage the frame when it
370 ceaces to be obscured though.
372 iconified is nonzero if the frame is currently iconified.
374 Asynchronous input handlers should NOT change these directly;
375 instead, they should change async_visible or async_iconified, and
376 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
377 at the next redisplay.
379 These should probably be considered read-only by everyone except
380 FRAME_SAMPLE_VISIBILITY.
382 These two are mutually exclusive. They might both be zero, if the
383 frame has been made invisible without an icon. */
384 char visible, iconified;
386 /* Asynchronous input handlers change these, and
387 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
388 See FRAME_SAMPLE_VISIBILITY, below. */
389 volatile char async_visible, async_iconified;
391 /* Nonzero if this frame should be redrawn. */
392 volatile char garbaged;
394 /* True if frame actually has a minibuffer window on it.
395 0 if using a minibuffer window that isn't on this frame. */
396 char has_minibuffer;
398 /* 0 means, if this frame has just one window,
399 show no modeline for that window. */
400 char wants_modeline;
402 /* Non-zero if the hardware device this frame is displaying on can
403 support scroll bars. */
404 char can_have_scroll_bars;
406 /* Non-0 means raise this frame to the top of the heap when selected. */
407 char auto_raise;
409 /* Non-0 means lower this frame to the bottom of the stack when left. */
410 char auto_lower;
412 /* True if frame's root window can't be split. */
413 char no_split;
415 /* If this is set, then Emacs won't change the frame name to indicate
416 the current buffer, etcetera. If the user explicitly sets the frame
417 name, this gets set. If the user sets the name to Qnil, this is
418 cleared. */
419 char explicit_name;
421 /* Nonzero if size of some window on this frame has changed. */
422 char window_sizes_changed;
424 /* Nonzero if the mouse has moved on this display device
425 since the last time we checked. */
426 char mouse_moved;
428 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
429 actually display them on this frame. */
430 enum vertical_scroll_bar_type vertical_scroll_bar_type;
432 /* What kind of text cursor should we draw in the future?
433 This should always be filled_box_cursor or bar_cursor. */
434 enum text_cursor_kinds desired_cursor;
436 /* Width of bar cursor (if we are using that). */
437 int cursor_width;
439 /* What kind of text cursor should we draw when the cursor blinks off?
440 This can be filled_box_cursor or bar_cursor or no_cursor. */
441 enum text_cursor_kinds blink_off_cursor;
443 /* Width of bar cursor (if we are using that) for blink-off state. */
444 int blink_off_cursor_width;
446 /* Storage for messages to this frame. */
447 char *message_buf;
449 /* Nonnegative if current redisplay should not do scroll computation
450 for lines beyond a certain vpos. This is the vpos. */
451 int scroll_bottom_vpos;
453 /* Configured width of the scroll bar, in pixels and in characters.
454 config_scroll_bar_cols tracks config_scroll_bar_width if the
455 latter is positive; a zero value in config_scroll_bar_width means
456 to compute the actual width on the fly, using config_scroll_bar_cols
457 and the current font width. */
458 int config_scroll_bar_width;
459 int config_scroll_bar_cols;
461 /* The size of the extra width currently allotted for vertical
462 scroll bars in this frame, in pixels. */
463 int scroll_bar_actual_width;
465 /* The baud rate that was used to calculate costs for this frame. */
466 int cost_calculation_baud_rate;
468 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
469 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
470 frame parameter. 0 means don't do gamma correction. */
471 double gamma;
473 /* Additional space to put between text lines on this frame. */
474 int extra_line_spacing;
476 /* All display backends seem to need these two pixel values. */
477 unsigned long background_pixel;
478 unsigned long foreground_pixel;
481 #ifdef MULTI_KBOARD
482 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
483 #else
484 #define FRAME_KBOARD(f) (&the_only_kboard)
485 #endif
487 /* Return a pointer to the image cache of frame F. */
488 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
490 typedef struct frame *FRAME_PTR;
492 #define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p))
493 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
495 /* Given a window, return its frame as a Lisp_Object. */
496 #define WINDOW_FRAME(w) (w)->frame
498 /* Test a frame for particular kinds of display methods. */
499 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
500 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
501 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
502 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
503 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
504 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
506 /* FRAME_WINDOW_P tests whether the frame is a window, and is
507 defined to be the predicate for the window system being used. */
509 #ifdef HAVE_X_WINDOWS
510 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
511 #endif
512 #ifdef HAVE_NTGUI
513 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
514 #endif
515 #ifdef MAC_OS
516 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
517 #endif
518 #ifndef FRAME_WINDOW_P
519 #define FRAME_WINDOW_P(f) (0)
520 #endif
522 /* Nonzero if frame F is still alive (not deleted). */
523 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
525 /* Nonzero if frame F is a minibuffer-only frame. */
526 #define FRAME_MINIBUF_ONLY_P(f) \
527 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
529 /* Nonzero if frame F contains a minibuffer window.
530 (If this is 0, F must use some other minibuffer window.) */
531 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
533 /* Pixel height of frame F, including non-toolkit menu bar and
534 non-toolkit tool bar lines. */
535 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
537 /* Pixel width of frame F. */
538 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
540 /* Height of frame F, measured in canonical lines, including
541 non-toolkit menu bar and non-toolkit tool bar lines. */
542 #define FRAME_LINES(f) (f)->text_lines
544 /* Width of frame F, measured in canonical character columns,
545 not including scroll bars if any. */
546 #define FRAME_COLS(f) (f)->text_cols
548 /* Number of lines of frame F used for menu bar.
549 This is relevant on terminal frames and on
550 X Windows when not using the X toolkit.
551 These lines are counted in FRAME_LINES. */
552 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
554 /* Nonzero if this frame should display a tool bar
555 in a way that does not use any text lines. */
556 #if defined (USE_GTK) || defined (MAC_OS)
557 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
558 #else
559 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
560 #endif
562 /* Number of lines of frame F used for the tool-bar. */
564 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
567 /* Lines above the top-most window in frame F. */
569 #define FRAME_TOP_MARGIN(F) \
570 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
572 /* Nonzero if this frame should display a menu bar
573 in a way that does not use any text lines. */
574 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
575 || defined (USE_GTK)
576 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
577 #else
578 #define FRAME_EXTERNAL_MENU_BAR(f) 0
579 #endif
580 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
582 /* Nonzero if frame F is currently visible but hidden. */
583 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
585 /* Nonzero if frame F is currently iconified. */
586 #define FRAME_ICONIFIED_P(f) (f)->iconified
588 #define FRAME_SET_VISIBLE(f,p) \
589 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
590 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
591 #define FRAME_GARBAGED_P(f) (f)->garbaged
593 /* Nonzero means do not allow splitting this frame's window. */
594 #define FRAME_NO_SPLIT_P(f) (f)->no_split
596 /* Not really implemented. */
597 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
599 /* Nonzero if a size change has been requested for frame F
600 but not yet really put into effect. This can be true temporarily
601 when an X event comes in at a bad time. */
602 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
604 /* The minibuffer window of frame F, if it has one; otherwise nil. */
605 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
607 /* The root window of the window tree of frame F. */
608 #define FRAME_ROOT_WINDOW(f) (f)->root_window
610 /* The currently selected window of the window tree of frame F. */
611 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
613 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
614 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
615 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
616 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
617 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
618 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
619 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
621 /* Nonzero if frame F supports scroll bars.
622 If this is zero, then it is impossible to enable scroll bars
623 on frame F. */
624 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
626 /* This frame slot says whether scroll bars are currently enabled for frame F,
627 and which side they are on. */
628 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
629 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
630 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
631 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
632 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
633 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
634 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
636 /* Width that a scroll bar in frame F should have, if there is one.
637 Measured in pixels.
638 If scroll bars are turned off, this is still nonzero. */
639 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
641 /* Width that a scroll bar in frame F should have, if there is one.
642 Measured in columns (characters).
643 If scroll bars are turned off, this is still nonzero. */
644 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
646 /* Width of a scroll bar in frame F, measured in columns (characters),
647 but only if scroll bars are on the left. If scroll bars are on
648 the right in this frame, or there are no scroll bars, value is 0. */
650 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
651 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
652 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
653 : 0)
655 /* Width of a left scroll bar in frame F, measured in pixels */
657 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
658 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
659 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
660 : 0)
662 /* Width of a scroll bar in frame F, measured in columns (characters),
663 but only if scroll bars are on the right. If scroll bars are on
664 the left in this frame, or there are no scroll bars, value is 0. */
666 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
667 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
668 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
669 : 0)
671 /* Width of a right scroll bar area in frame F, measured in pixels */
673 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
674 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
675 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
676 : 0)
678 /* Actual width of a scroll bar in frame F, measured in columns. */
680 #define FRAME_SCROLL_BAR_COLS(f) \
681 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
682 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
683 : 0)
685 /* Actual width of a scroll bar area in frame F, measured in pixels. */
687 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
688 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
689 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
690 : 0)
692 /* Total width of frame F, in columns (characters),
693 including the width used by scroll bars if any. */
695 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
697 /* Set the width of frame F to VAL.
698 VAL is the width of a full-frame window,
699 not including scroll bars and fringes. */
701 #define SET_FRAME_COLS(f, val) \
702 (FRAME_COLS (f) = (val), \
703 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
705 /* Given a value WIDTH for frame F's nominal width,
706 return the value that FRAME_TOTAL_COLS should have. */
708 #define FRAME_TOTAL_COLS_ARG(f, width) \
709 ((width) \
710 + FRAME_SCROLL_BAR_COLS (f) \
711 + FRAME_FRINGE_COLS (f))
713 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
715 #define FRAME_CURSOR_X_LIMIT(f) \
716 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
718 /* Nonzero if frame F has scroll bars. */
720 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
722 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
723 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
724 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
726 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
727 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
728 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
729 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
731 /* Return a pointer to the face cache of frame F. */
733 #define FRAME_FACE_CACHE(F) (F)->face_cache
735 /* Return the size of message_buf of the frame F. We multiply the
736 width of the frame by 4 because multi-byte form may require at most
737 4-byte for a character. */
739 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
741 /* Emacs's redisplay code could become confused if a frame's
742 visibility changes at arbitrary times. For example, if a frame is
743 visible while the desired glyphs are being built, but becomes
744 invisible before they are updated, then some rows of the
745 desired_glyphs will be left marked as enabled after redisplay is
746 complete, which should never happen. The next time the frame
747 becomes visible, redisplay will probably barf.
749 Currently, there are no similar situations involving iconified, but
750 the principle is the same.
752 So instead of having asynchronous input handlers directly set and
753 clear the frame's visibility and iconification flags, they just set
754 the async_visible and async_iconified flags; the redisplay code
755 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
756 which sets visible and iconified from their asynchronous
757 counterparts.
759 Synchronous code must use the FRAME_SET_VISIBLE macro.
761 Also, if a frame used to be invisible, but has just become visible,
762 it must be marked as garbaged, since redisplay hasn't been keeping
763 up its contents.
765 Note that a tty frame is visible if and only if it is the topmost
766 frame. */
768 #define FRAME_SAMPLE_VISIBILITY(f) \
769 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
770 SET_FRAME_GARBAGED (f) : 0, \
771 (f)->visible = (f)->async_visible, \
772 (f)->iconified = (f)->async_iconified)
774 #define CHECK_FRAME(x) \
775 CHECK_TYPE (FRAMEP (x), Qframep, x)
777 #define CHECK_LIVE_FRAME(x) \
778 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
780 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
781 `for' loop which iterates over the elements of Vframe_list. The
782 loop will set FRAME_VAR, a Lisp_Object, to each frame in
783 Vframe_list in succession and execute the statement. LIST_VAR
784 should be a Lisp_Object too; it is used to iterate through the
785 Vframe_list.
787 This macro is a holdover from a time when multiple frames weren't always
788 supported. An alternate definition of the macro would expand to
789 something which executes the statement once. */
791 #define FOR_EACH_FRAME(list_var, frame_var) \
792 for ((list_var) = Vframe_list; \
793 (CONSP (list_var) \
794 && (frame_var = XCAR (list_var), 1)); \
795 list_var = XCDR (list_var))
798 extern Lisp_Object Qframep, Qframe_live_p;
799 extern Lisp_Object Qtty, Qtty_type;
800 extern Lisp_Object Qterminal, Qterminal_live_p;
801 extern Lisp_Object Qnoelisp;
803 extern struct frame *last_nonminibuf_frame;
805 extern struct frame *make_initial_frame P_ ((void));
806 extern struct frame *make_terminal_frame P_ ((struct terminal *));
807 extern struct frame *make_frame P_ ((int));
808 #ifdef HAVE_WINDOW_SYSTEM
809 extern struct frame *make_minibuffer_frame P_ ((void));
810 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
811 struct kboard *,
812 Lisp_Object));
813 #endif /* HAVE_WINDOW_SYSTEM */
814 extern int other_visible_frames P_ ((struct frame *));
816 extern Lisp_Object Vframe_list;
817 extern Lisp_Object Vdefault_frame_alist;
819 extern Lisp_Object Vterminal_frame;
821 extern Lisp_Object Vmouse_highlight;
823 /* The currently selected frame. */
825 extern Lisp_Object selected_frame;
827 /* Value is a pointer to the selected frame. If the selected frame
828 isn't live, abort. */
830 #define SELECTED_FRAME() \
831 ((FRAMEP (selected_frame) \
832 && FRAME_LIVE_P (XFRAME (selected_frame))) \
833 ? XFRAME (selected_frame) \
834 : (abort (), (struct frame *) 0))
837 /***********************************************************************
838 Display-related Macros
839 ***********************************************************************/
841 /* Canonical y-unit on frame F.
842 This value currently equals the line height of the frame (which is
843 the height of the default font of F). */
845 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
847 /* Canonical x-unit on frame F.
848 This value currently equals the average width of the default font of F. */
850 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
852 /* Space glyph width of the default font of frame F. */
854 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
857 /* Pixel width of areas used to display truncation marks, continuation
858 marks, overlay arrows. This is 0 for terminal frames. */
860 #ifdef HAVE_WINDOW_SYSTEM
862 /* Total width of fringes reserved for drawing truncation bitmaps,
863 continuation bitmaps and alike. The width is in canonical char
864 units of the frame. This must currently be the case because window
865 sizes aren't pixel values. If it weren't the case, we wouldn't be
866 able to split windows horizontally nicely. */
868 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
870 /* Pixel-width of the left and right fringe. */
872 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
873 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
875 /* Total width of fringes in pixels. */
877 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
878 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
881 /* Pixel-width of internal border lines */
883 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
885 #else /* not HAVE_WINDOW_SYSTEM */
887 #define FRAME_FRINGE_COLS(F) 0
888 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
889 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
890 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
891 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
893 #endif /* not HAVE_WINDOW_SYSTEM */
898 /***********************************************************************
899 Conversion between canonical units and pixels
900 ***********************************************************************/
902 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
903 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
904 represented as Lisp numbers, i.e. integers or floats. */
906 /* Convert canonical value X to pixels. F is the frame whose
907 canonical char width is to be used. X must be a Lisp integer or
908 float. Value is a C integer. */
910 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
911 (INTEGERP (X) \
912 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
913 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
915 /* Convert canonical value Y to pixels. F is the frame whose
916 canonical character height is to be used. X must be a Lisp integer
917 or float. Value is a C integer. */
919 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
920 (INTEGERP (Y) \
921 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
922 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
924 /* Convert pixel-value X to canonical units. F is the frame whose
925 canonical character width is to be used. X is a C integer. Result
926 is a Lisp float if X is not a multiple of the canon width,
927 otherwise it's a Lisp integer. */
929 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
930 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
931 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
932 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
934 /* Convert pixel-value Y to canonical units. F is the frame whose
935 canonical character height is to be used. Y is a C integer.
936 Result is a Lisp float if Y is not a multiple of the canon width,
937 otherwise it's a Lisp integer. */
939 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
940 ((Y) % FRAME_LINE_HEIGHT (F) \
941 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
942 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
946 /* Manipulating pixel sizes and character sizes.
947 Knowledge of which factors affect the overall size of the window should
948 be hidden in these macros, if that's possible.
950 Return the upper/left pixel position of the character cell on frame F
951 at ROW/COL. */
953 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
954 (FRAME_INTERNAL_BORDER_WIDTH (f) \
955 + (row) * FRAME_LINE_HEIGHT (f))
957 #define FRAME_COL_TO_PIXEL_X(f, col) \
958 (FRAME_INTERNAL_BORDER_WIDTH (f) \
959 + (col) * FRAME_COLUMN_WIDTH (f))
961 /* Return the pixel width/height of frame F if it has
962 COLS columns/LINES rows. */
964 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
965 (FRAME_COL_TO_PIXEL_X (f, cols) \
966 + (f)->scroll_bar_actual_width \
967 + FRAME_TOTAL_FRINGE_WIDTH (f) \
968 + FRAME_INTERNAL_BORDER_WIDTH (f))
970 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
971 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
972 + FRAME_INTERNAL_BORDER_WIDTH (f))
975 /* Return the row/column (zero-based) of the character cell containing
976 the pixel on FRAME at Y/X. */
978 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
979 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
980 / FRAME_LINE_HEIGHT (f))
982 #define FRAME_PIXEL_X_TO_COL(f, x) \
983 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
984 / FRAME_COLUMN_WIDTH (f))
986 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
987 frame F? */
989 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
990 (FRAME_PIXEL_X_TO_COL (f, ((width) \
991 - FRAME_INTERNAL_BORDER_WIDTH (f) \
992 - FRAME_TOTAL_FRINGE_WIDTH (f) \
993 - (f)->scroll_bar_actual_width)))
995 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
996 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
997 - FRAME_INTERNAL_BORDER_WIDTH (f))))
1000 /***********************************************************************
1001 Frame Parameters
1002 ***********************************************************************/
1004 extern Lisp_Object Qauto_raise, Qauto_lower;
1005 extern Lisp_Object Qborder_color, Qborder_width;
1006 extern Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
1007 extern Lisp_Object Qcursor_color, Qcursor_type;
1008 extern Lisp_Object Qfont;
1009 extern Lisp_Object Qbackground_color, Qforeground_color;
1010 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1011 extern Lisp_Object Qinternal_border_width;
1012 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
1013 extern Lisp_Object Qmouse_color;
1014 extern Lisp_Object Qname, Qtitle;
1015 extern Lisp_Object Qparent_id;
1016 extern Lisp_Object Qunsplittable, Qvisibility;
1017 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1018 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1019 extern Lisp_Object Qscreen_gamma;
1020 extern Lisp_Object Qline_spacing;
1021 extern Lisp_Object Qwait_for_wm;
1022 extern Lisp_Object Qfullscreen;
1023 extern Lisp_Object Qfont_backend;
1025 extern Lisp_Object Qleft_fringe, Qright_fringe;
1026 extern Lisp_Object Qheight, Qwidth;
1027 extern Lisp_Object Qminibuffer, Qmodeline;
1028 extern Lisp_Object Qonly;
1029 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
1030 extern Lisp_Object Qvisible;
1031 extern Lisp_Object Qdisplay_type;
1032 extern Lisp_Object Qbackground_mode;
1034 extern Lisp_Object Qx_resource_name;
1036 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1037 extern Lisp_Object Qdisplay;
1039 #ifdef HAVE_WINDOW_SYSTEM
1041 /* The class of this X application. */
1042 #define EMACS_CLASS "Emacs"
1044 enum
1046 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1047 FULLSCREEN_NONE = 0,
1048 FULLSCREEN_WIDTH = 1,
1049 FULLSCREEN_HEIGHT = 2,
1050 FULLSCREEN_BOTH = 3,
1051 FULLSCREEN_WAIT = 4
1055 /* These are in xterm.c, w32term.c, etc. */
1057 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1058 extern void x_set_offset P_ ((struct frame *, int, int, int));
1059 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1061 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1062 extern Lisp_Object x_new_fontset P_ ((struct frame *, Lisp_Object));
1063 #ifdef USE_FONT_BACKEND
1064 extern Lisp_Object x_new_fontset2 P_ ((struct frame *, int, Lisp_Object));
1065 #endif /* USE_FONT_BACKEND */
1067 /* These are in frame.c */
1069 extern Lisp_Object Vx_resource_name;
1070 extern Lisp_Object Vx_resource_class;
1073 extern Lisp_Object Qface_set_after_frame_default;
1075 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1076 int *, int *));
1078 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1079 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1081 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1082 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1083 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1084 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1085 extern void x_set_font_backend P_ ((struct frame *, Lisp_Object, Lisp_Object));
1086 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1087 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1088 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1089 Lisp_Object));
1090 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1091 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1092 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1093 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1094 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1095 Lisp_Object));
1096 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1097 Lisp_Object));
1099 extern Lisp_Object x_icon_type P_ ((struct frame *));
1101 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1104 extern void validate_x_resource_name P_ ((void));
1106 #endif /* HAVE_WINDOW_SYSTEM */
1108 #endif /* not EMACS_FRAME_H */
1110 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1111 (do not change this comment) */