(thumbs-find-image): Don't make variables automatically buffer local.
[emacs.git] / src / frame.h
bloba2f5fc2fde5c5150f144ab23e50ed44026001119
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993, 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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.
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.
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., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* Don't multiply include: dispextern.h includes macterm.h which
22 includes frame.h some emacs source includes both dispextern.h and
23 frame.h */
25 #ifndef EMACS_FRAME_H
26 #define EMACS_FRAME_H
29 /* Miscellanea. */
31 /* Nonzero means don't assume anything about current contents of
32 actual terminal frame */
34 extern int frame_garbaged;
36 /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
37 print. */
39 extern int message_buf_print;
42 /* The structure representing a frame. */
44 enum output_method
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 #if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS)
72 #if !defined(HAVE_X_WINDOWS)
74 #define PIX_TYPE int
76 /* A (mostly empty) x_output structure definition for building Emacs
77 on Unix and GNU/Linux without X support. */
78 struct x_output
80 PIX_TYPE background_pixel;
81 PIX_TYPE foreground_pixel;
84 #endif /* ! HAVE_X_WINDOWS */
87 #define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
88 #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
90 /* A structure describing a termcap frame display. */
91 extern struct x_output tty_display;
93 #endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */
95 struct frame
97 EMACS_INT size;
98 struct Lisp_Vector *next;
100 /* All Lisp_Object components must come first.
101 Only EMACS_INT values can be intermixed with them.
102 That ensures they are all aligned normally. */
104 /* Name of this frame: a Lisp string. It is used for looking up resources,
105 as well as for the title in some cases. */
106 Lisp_Object name;
108 /* The name to use for the icon, the last time
109 it was refreshed. nil means not explicitly specified. */
110 Lisp_Object icon_name;
112 /* This is the frame title specified explicitly, if any.
113 Usually it is nil. */
114 Lisp_Object title;
116 /* The frame which should receive keystrokes that occur in this
117 frame, or nil if they should go to the frame itself. This is
118 usually nil, but if the frame is minibufferless, we can use this
119 to redirect keystrokes to a surrogate minibuffer frame when
120 needed.
122 Note that a value of nil is different than having the field point
123 to the frame itself. Whenever the Fselect_frame function is used
124 to shift from one frame to the other, any redirections to the
125 original frame are shifted to the newly selected frame; if
126 focus_frame is nil, Fselect_frame will leave it alone. */
127 Lisp_Object focus_frame;
129 /* This frame's root window. Every frame has one.
130 If the frame has only a minibuffer window, this is it.
131 Otherwise, if the frame has a minibuffer window, this is its sibling. */
132 Lisp_Object root_window;
134 /* This frame's selected window.
135 Each frame has its own window hierarchy
136 and one of the windows in it is selected within the frame.
137 The selected window of the selected frame is Emacs's selected window. */
138 Lisp_Object selected_window;
140 /* This frame's minibuffer window.
141 Most frames have their own minibuffer windows,
142 but only the selected frame's minibuffer window
143 can actually appear to exist. */
144 Lisp_Object minibuffer_window;
146 /* Parameter alist of this frame.
147 These are the parameters specified when creating the frame
148 or modified with modify-frame-parameters. */
149 Lisp_Object param_alist;
151 /* List of scroll bars on this frame.
152 Actually, we don't specify exactly what is stored here at all; the
153 scroll bar implementation code can use it to store anything it likes.
154 This field is marked by the garbage collector. It is here
155 instead of in the `display' structure so that the garbage
156 collector doesn't need to look inside the window-system-dependent
157 structure. */
158 Lisp_Object scroll_bars;
159 Lisp_Object condemned_scroll_bars;
161 /* Vector describing the items to display in the menu bar.
162 Each item has four elements in this vector.
163 They are KEY, STRING, SUBMAP, and HPOS.
164 (HPOS is not used in when the X toolkit is in use.)
165 There are four additional elements of nil at the end, to terminate. */
166 Lisp_Object menu_bar_items;
168 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
169 Lisp_Object face_alist;
171 /* A vector that records the entire structure of this frame's menu bar.
172 For the format of the data, see extensive comments in xmenu.c.
173 Only the X toolkit version uses this. */
174 Lisp_Object menu_bar_vector;
175 /* Number of elements in the vector that have meaningful data. */
176 EMACS_INT menu_bar_items_used;
178 /* Predicate for selecting buffers for other-buffer. */
179 Lisp_Object buffer_predicate;
181 /* List of buffers viewed in this frame, for other-buffer. */
182 Lisp_Object buffer_list;
184 /* A dummy window used to display menu bars under X when no X
185 toolkit support is available. */
186 Lisp_Object menu_bar_window;
188 /* A window used to display the tool-bar of a frame. */
189 Lisp_Object tool_bar_window;
191 /* Desired and current tool-bar items. */
192 Lisp_Object tool_bar_items;
194 /* Desired and current contents displayed in tool_bar_window. */
195 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
197 /* beyond here, there should be no more Lisp_Object components. */
199 /* Cache of realized faces. */
200 struct face_cache *face_cache;
202 /* A buffer to hold the frame's name. We can't use the Lisp
203 string's pointer (`name', above) because it might get relocated. */
204 char *namebuf;
206 /* Glyph pool and matrix. */
207 struct glyph_pool *current_pool;
208 struct glyph_pool *desired_pool;
209 struct glyph_matrix *desired_matrix;
210 struct glyph_matrix *current_matrix;
212 /* 1 means that glyphs on this frame have been initialized so it can
213 be used for output. */
214 unsigned glyphs_initialized_p : 1;
216 #if defined (USE_GTK)
217 /* Nonzero means using a tool bar that comes from the toolkit. */
218 int external_tool_bar;
219 #endif
221 /* Margin at the top of the frame. Used to display the tool-bar. */
222 int tool_bar_lines;
224 int n_tool_bar_items;
226 /* A buffer for decode_mode_line. */
227 char *decode_mode_spec_buffer;
229 /* See do_line_insertion_deletion_costs for info on these arrays. */
230 /* Cost of inserting 1 line on this frame */
231 int *insert_line_cost;
232 /* Cost of deleting 1 line on this frame */
233 int *delete_line_cost;
234 /* Cost of inserting n lines on this frame */
235 int *insert_n_lines_cost;
236 /* Cost of deleting n lines on this frame */
237 int *delete_n_lines_cost;
239 /* Size of this frame, excluding fringes, scroll bars etc.,
240 in units of canonical characters. */
241 EMACS_INT text_lines, text_cols;
243 /* Total size of this frame (i.e. its native window), in units of
244 canonical characters. */
245 EMACS_INT total_lines, total_cols;
247 /* New text height and width for pending size change.
248 0 if no change pending. */
249 int new_text_lines, new_text_cols;
251 /* Pixel position of the frame window (x and y offsets in root window). */
252 int left_pos, top_pos;
254 /* Size of the frame window in pixels. */
255 int pixel_height, pixel_width;
257 /* These many pixels are the difference between the outer window (i.e. the
258 left and top of the window manager decoration) and FRAME_X_WINDOW. */
259 int x_pixels_diff, y_pixels_diff;
261 /* This is the gravity value for the specified window position. */
262 int win_gravity;
264 /* The geometry flags for this window. */
265 int size_hint_flags;
267 /* Border width of the frame window as known by the (X) window system. */
268 int border_width;
270 /* Width of the internal border. This is a line of background color
271 just inside the window's border. When the frame is selected,
272 a highlighting is displayed inside the internal border. */
273 int internal_border_width;
275 /* Canonical X unit. Width of default font, in pixels. */
276 int column_width;
278 /* Widht of space glyph of default font, in pixels. */
279 int space_width;
281 /* Canonical Y unit. Height of a line, in pixels. */
282 int line_height;
284 /* The output method says how the contents of this frame
285 are displayed. It could be using termcap, or using an X window. */
286 enum output_method output_method;
288 /* A structure of auxiliary data used for displaying the contents.
289 struct x_output is used for X window frames;
290 it is defined in xterm.h.
291 struct w32_output is used for W32 window frames;
292 it is defined in w32term.h. */
293 union output_data
295 struct x_output *x;
296 struct w32_output *w32;
297 struct mac_output *mac;
298 EMACS_INT nothing;
300 output_data;
302 /* Total width of fringes reserved for drawing truncation bitmaps,
303 continuation bitmaps and alike. The width is in canonical char
304 units of the frame. This must currently be the case because window
305 sizes aren't pixel values. If it weren't the case, we wouldn't be
306 able to split windows horizontally nicely. */
307 int fringe_cols;
309 /* The extra width (in pixels) currently allotted for fringes. */
310 int left_fringe_width, right_fringe_width;
312 #ifdef MULTI_KBOARD
313 /* A pointer to the kboard structure associated with this frame.
314 For termcap frames, this points to initial_kboard. For X frames,
315 it will be the same as display.x->display_info->kboard. */
316 struct kboard *kboard;
317 #endif
319 /* See FULLSCREEN_ enum below */
320 int want_fullscreen;
322 /* Number of lines of menu bar. */
323 int menu_bar_lines;
325 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
326 || defined (USE_GTK)
327 /* Nonzero means using a menu bar that comes from the X toolkit. */
328 int external_menu_bar;
329 #endif
331 /* Nonzero if last attempt at redisplay on this frame was preempted. */
332 char display_preempted;
334 /* visible is nonzero if the frame is currently displayed; we check
335 it to see if we should bother updating the frame's contents.
336 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
338 Note that, since invisible frames aren't updated, whenever a
339 frame becomes visible again, it must be marked as garbaged. The
340 FRAME_SAMPLE_VISIBILITY macro takes care of this.
342 On Windows NT/9X, to avoid wasting effort updating visible frames
343 that are actually completely obscured by other windows on the
344 display, we bend the meaning of visible slightly: if greater than
345 1, then the frame is obscured - we still consider it to be
346 "visible" as seen from lisp, but we don't bother updating it. We
347 must take care to garbage the frame when it ceaces to be obscured
348 though. Note that these semantics are only used on NT/9X.
350 iconified is nonzero if the frame is currently iconified.
352 Asynchronous input handlers should NOT change these directly;
353 instead, they should change async_visible or async_iconified, and
354 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
355 at the next redisplay.
357 These should probably be considered read-only by everyone except
358 FRAME_SAMPLE_VISIBILITY.
360 These two are mutually exclusive. They might both be zero, if the
361 frame has been made invisible without an icon. */
362 char visible, iconified;
364 /* Asynchronous input handlers change these, and
365 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
366 See FRAME_SAMPLE_VISIBILITY, below. */
367 volatile char async_visible, async_iconified;
369 /* Nonzero if this frame should be redrawn. */
370 volatile char garbaged;
372 /* True if frame actually has a minibuffer window on it.
373 0 if using a minibuffer window that isn't on this frame. */
374 char has_minibuffer;
376 /* 0 means, if this frame has just one window,
377 show no modeline for that window. */
378 char wants_modeline;
380 /* Non-zero if the hardware device this frame is displaying on can
381 support scroll bars. */
382 char can_have_scroll_bars;
384 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
385 actually display them on this frame. */
386 enum vertical_scroll_bar_type vertical_scroll_bar_type;
388 /* What kind of text cursor should we draw in the future?
389 This should always be filled_box_cursor or bar_cursor. */
390 enum text_cursor_kinds desired_cursor;
392 /* Width of bar cursor (if we are using that). */
393 int cursor_width;
395 /* What kind of text cursor should we draw when the cursor blinks off?
396 This can be filled_box_cursor or bar_cursor or no_cursor. */
397 enum text_cursor_kinds blink_off_cursor;
399 /* Width of bar cursor (if we are using that) for blink-off state. */
400 int blink_off_cursor_width;
402 /* Non-0 means raise this frame to the top of the heap when selected. */
403 char auto_raise;
405 /* Non-0 means lower this frame to the bottom of the stack when left. */
406 char auto_lower;
408 /* True if frame's root window can't be split. */
409 char no_split;
411 /* If this is set, then Emacs won't change the frame name to indicate
412 the current buffer, etcetera. If the user explicitly sets the frame
413 name, this gets set. If the user sets the name to Qnil, this is
414 cleared. */
415 char explicit_name;
417 /* Nonzero if size of some window on this frame has changed. */
418 char window_sizes_changed;
420 /* Storage for messages to this frame. */
421 char *message_buf;
423 /* Nonnegative if current redisplay should not do scroll computation
424 for lines beyond a certain vpos. This is the vpos. */
425 int scroll_bottom_vpos;
427 /* Configured width of the scroll bar, in pixels and in characters.
428 config_scroll_bar_cols tracks config_scroll_bar_width if the
429 latter is positive; a zero value in config_scroll_bar_width means
430 to compute the actual width on the fly, using config_scroll_bar_cols
431 and the current font width. */
432 int config_scroll_bar_width;
433 int config_scroll_bar_cols;
435 /* The size of the extra width currently allotted for vertical
436 scroll bars in this frame, in pixels. */
437 int scroll_bar_actual_width;
439 /* The baud rate that was used to calculate costs for this frame. */
440 int cost_calculation_baud_rate;
442 /* Nonzero if the mouse has moved on this display
443 since the last time we checked. */
444 char mouse_moved;
446 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
447 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
448 frame parameter. 0 means don't do gamma correction. */
449 double gamma;
451 /* Additional space to put between text lines on this frame. */
452 int extra_line_spacing;
454 /* Set to non-zero in change_frame_size when size of frame changed
455 Clear the frame in clear_garbaged_frames if set. */
456 unsigned resized_p : 1;
458 /* Set to non-zero in when we want for force a flush_display in
459 update_frame, usually after resizing the frame. */
460 unsigned force_flush_display_p : 1;
462 /* Set to non-zero if the default face for the frame has been
463 realized. Reset to zero whenever the default face changes.
464 Used to see the difference between a font change and face change. */
465 unsigned default_face_done_p : 1;
467 /* Set to non-zero if this frame has already been hscrolled during
468 current redisplay. */
469 unsigned already_hscrolled_p : 1;
472 #ifdef MULTI_KBOARD
473 #define FRAME_KBOARD(f) ((f)->kboard)
474 #else
475 #define FRAME_KBOARD(f) (&the_only_kboard)
476 #endif
478 typedef struct frame *FRAME_PTR;
480 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
481 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
483 /* Given a window, return its frame as a Lisp_Object. */
484 #define WINDOW_FRAME(w) (w)->frame
486 /* Test a frame for particular kinds of display methods. */
487 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
488 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
489 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
490 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
491 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
493 /* FRAME_WINDOW_P tests whether the frame is a window, and is
494 defined to be the predicate for the window system being used. */
496 #ifdef HAVE_X_WINDOWS
497 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
498 #endif
499 #ifdef HAVE_NTGUI
500 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
501 #endif
502 #ifdef MAC_OS
503 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
504 #endif
505 #ifndef FRAME_WINDOW_P
506 #define FRAME_WINDOW_P(f) (0)
507 #endif
509 /* Nonzero if frame F is still alive (not deleted). */
510 #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0)
512 /* Nonzero if frame F is a minibuffer-only frame. */
513 #define FRAME_MINIBUF_ONLY_P(f) \
514 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
516 /* Nonzero if frame F contains a minibuffer window.
517 (If this is 0, F must use some other minibuffer window.) */
518 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
520 /* Pixel height of frame F, including non-toolkit menu bar and
521 non-toolkit tool bar lines. */
522 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
524 /* Pixel width of frame F. */
525 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
527 /* Height of frame F, measured in canonical lines, including
528 non-toolkit menu bar and non-toolkit tool bar lines. */
529 #define FRAME_LINES(f) (f)->text_lines
531 /* Width of frame F, measured in canonical character columns,
532 not including scroll bars if any. */
533 #define FRAME_COLS(f) (f)->text_cols
535 /* Number of lines of frame F used for menu bar.
536 This is relevant on terminal frames and on
537 X Windows when not using the X toolkit.
538 These lines are counted in FRAME_LINES. */
539 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
541 /* Nonzero if this frame should display a tool bar
542 in a way that does not use any text lines. */
543 #if defined (USE_GTK)
544 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
545 #else
546 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
547 #endif
549 /* Number of lines of frame F used for the tool-bar. */
551 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
554 /* Lines above the top-most window in frame F. */
556 #define FRAME_TOP_MARGIN(F) \
557 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
559 /* Nonzero if this frame should display a menu bar
560 in a way that does not use any text lines. */
561 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
562 || defined (USE_GTK)
563 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
564 #else
565 #define FRAME_EXTERNAL_MENU_BAR(f) 0
566 #endif
567 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
569 /* Nonzero if frame F is currently visible but hidden. */
570 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
572 /* Nonzero if frame F is currently iconified. */
573 #define FRAME_ICONIFIED_P(f) (f)->iconified
575 #define FRAME_SET_VISIBLE(f,p) \
576 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
577 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
578 #define FRAME_GARBAGED_P(f) (f)->garbaged
580 /* Nonzero means do not allow splitting this frame's window. */
581 #define FRAME_NO_SPLIT_P(f) (f)->no_split
583 /* Not really implemented. */
584 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
586 /* Nonzero if a size change has been requested for frame F
587 but not yet really put into effect. This can be true temporarily
588 when an X event comes in at a bad time. */
589 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
591 /* The minibuffer window of frame F, if it has one; otherwise nil. */
592 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
594 /* The root window of the window tree of frame F. */
595 #define FRAME_ROOT_WINDOW(f) (f)->root_window
597 /* The currently selected window of the window tree of frame F. */
598 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
600 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
601 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
602 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
603 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
604 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
605 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
606 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
608 /* Nonzero if frame F supports scroll bars.
609 If this is zero, then it is impossible to enable scroll bars
610 on frame F. */
611 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
613 /* This frame slot says whether scroll bars are currently enabled for frame F,
614 and which side they are on. */
615 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
616 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
617 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
618 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
619 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
620 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
621 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
623 /* Width that a scroll bar in frame F should have, if there is one.
624 Measured in pixels.
625 If scroll bars are turned off, this is still nonzero. */
626 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
628 /* Width that a scroll bar in frame F should have, if there is one.
629 Measured in columns (characters).
630 If scroll bars are turned off, this is still nonzero. */
631 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
633 /* Width of a scroll bar in frame F, measured in columns (characters),
634 but only if scroll bars are on the left. If scroll bars are on
635 the right in this frame, or there are no scroll bars, value is 0. */
637 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
638 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
639 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
640 : 0)
642 /* Width of a left scroll bar in frame F, measured in pixels */
644 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
645 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
646 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
647 : 0)
649 /* Width of a scroll bar in frame F, measured in columns (characters),
650 but only if scroll bars are on the right. If scroll bars are on
651 the left in this frame, or there are no scroll bars, value is 0. */
653 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
654 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
655 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
656 : 0)
658 /* Width of a right scroll bar area in frame F, measured in pixels */
660 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
661 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
662 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
663 : 0)
665 /* Actual width of a scroll bar in frame F, measured in columns. */
667 #define FRAME_SCROLL_BAR_COLS(f) \
668 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
669 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
670 : 0)
672 /* Actual width of a scroll bar area in frame F, measured in pixels. */
674 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
675 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
676 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
677 : 0)
679 /* Total width of frame F, in columns (characters),
680 including the width used by scroll bars if any. */
682 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
684 /* Set the width of frame F to VAL.
685 VAL is the width of a full-frame window,
686 not including scroll bars and fringes. */
688 #define SET_FRAME_COLS(f, val) \
689 (FRAME_COLS (f) = (val), \
690 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
692 /* Given a value WIDTH for frame F's nominal width,
693 return the value that FRAME_TOTAL_COLS should have. */
695 #define FRAME_TOTAL_COLS_ARG(f, width) \
696 ((width) \
697 + FRAME_SCROLL_BAR_COLS (f) \
698 + FRAME_FRINGE_COLS (f))
700 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
702 #define FRAME_CURSOR_X_LIMIT(f) \
703 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
705 /* Nonzero if frame F has scroll bars. */
707 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
709 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
710 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
711 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
713 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
714 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
715 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
716 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
718 /* Return a pointer to the face cache of frame F. */
720 #define FRAME_FACE_CACHE(F) (F)->face_cache
722 /* Return the size of message_buf of the frame F. We multiply the
723 width of the frame by 4 because multi-byte form may require at most
724 4-byte for a character. */
726 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
728 /* Emacs's redisplay code could become confused if a frame's
729 visibility changes at arbitrary times. For example, if a frame is
730 visible while the desired glyphs are being built, but becomes
731 invisible before they are updated, then some rows of the
732 desired_glyphs will be left marked as enabled after redisplay is
733 complete, which should never happen. The next time the frame
734 becomes visible, redisplay will probably barf.
736 Currently, there are no similar situations involving iconified, but
737 the principle is the same.
739 So instead of having asynchronous input handlers directly set and
740 clear the frame's visibility and iconification flags, they just set
741 the async_visible and async_iconified flags; the redisplay code
742 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
743 which sets visible and iconified from their asynchronous
744 counterparts.
746 Synchronous code must use the FRAME_SET_VISIBLE macro.
748 Also, if a frame used to be invisible, but has just become visible,
749 it must be marked as garbaged, since redisplay hasn't been keeping
750 up its contents. */
752 #define FRAME_SAMPLE_VISIBILITY(f) \
753 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
754 SET_FRAME_GARBAGED (f) : 0, \
755 (f)->visible = (f)->async_visible, \
756 (f)->iconified = (f)->async_iconified)
758 #define CHECK_FRAME(x) \
759 do { \
760 if (! FRAMEP (x)) \
761 x = wrong_type_argument (Qframep, (x)); \
762 } while (0)
764 #define CHECK_LIVE_FRAME(x) \
765 do { \
766 if (! FRAMEP (x) \
767 || ! FRAME_LIVE_P (XFRAME (x))) \
768 x = wrong_type_argument (Qframe_live_p, (x)); \
769 } while (0)
771 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
772 `for' loop which iterates over the elements of Vframe_list. The
773 loop will set FRAME_VAR, a Lisp_Object, to each frame in
774 Vframe_list in succession and execute the statement. LIST_VAR
775 should be a Lisp_Object too; it is used to iterate through the
776 Vframe_list.
778 This macro is a holdover from a time when multiple frames weren't always
779 supported. An alternate definition of the macro would expand to
780 something which executes the statement once. */
782 #define FOR_EACH_FRAME(list_var, frame_var) \
783 for ((list_var) = Vframe_list; \
784 (CONSP (list_var) \
785 && (frame_var = XCAR (list_var), 1)); \
786 list_var = XCDR (list_var))
789 extern Lisp_Object Qframep, Qframe_live_p;
791 extern struct frame *last_nonminibuf_frame;
793 extern struct frame *make_terminal_frame P_ ((void));
794 extern struct frame *make_frame P_ ((int));
795 #ifdef HAVE_WINDOW_SYSTEM
796 extern struct frame *make_minibuffer_frame P_ ((void));
797 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
798 struct kboard *,
799 Lisp_Object));
800 #endif /* HAVE_WINDOW_SYSTEM */
801 extern int other_visible_frames P_ ((struct frame *));
803 extern Lisp_Object Vframe_list;
804 extern Lisp_Object Vdefault_frame_alist;
806 extern Lisp_Object Vterminal_frame;
808 extern Lisp_Object Vmouse_highlight;
810 /* The currently selected frame. */
812 extern Lisp_Object selected_frame;
814 /* Value is a pointer to the selected frame. If the selected frame
815 isn't live, abort. */
817 #define SELECTED_FRAME() \
818 ((FRAMEP (selected_frame) \
819 && FRAME_LIVE_P (XFRAME (selected_frame))) \
820 ? XFRAME (selected_frame) \
821 : (abort (), (struct frame *) 0))
824 /***********************************************************************
825 Display-related Macros
826 ***********************************************************************/
828 /* Canonical y-unit on frame F.
829 This value currently equals the line height of the frame (which is
830 the height of the default font of F). */
832 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
834 /* Canonical x-unit on frame F.
835 This value currently equals the average width of the default font of F. */
837 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
839 /* Space glyph width of the default font of frame F. */
841 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
844 /* Pixel width of areas used to display truncation marks, continuation
845 marks, overlay arrows. This is 0 for terminal frames. */
847 #ifdef HAVE_WINDOW_SYSTEM
849 /* Total width of fringes reserved for drawing truncation bitmaps,
850 continuation bitmaps and alike. The width is in canonical char
851 units of the frame. This must currently be the case because window
852 sizes aren't pixel values. If it weren't the case, we wouldn't be
853 able to split windows horizontally nicely. */
855 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
857 /* Pixel-width of the left and right fringe. */
859 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
860 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
862 /* Total width of fringes in pixels. */
864 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
865 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
868 /* Pixel-width of internal border lines */
870 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
872 #else /* not HAVE_WINDOW_SYSTEM */
874 #define FRAME_FRINGE_COLS(F) 0
875 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
876 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
877 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
878 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
880 #endif /* not HAVE_WINDOW_SYSTEM */
885 /***********************************************************************
886 Conversion between canonical units and pixels
887 ***********************************************************************/
889 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
890 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
891 represented as Lisp numbers, i.e. integers or floats. */
893 /* Convert canonical value X to pixels. F is the frame whose
894 canonical char width is to be used. X must be a Lisp integer or
895 float. Value is a C integer. */
897 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
898 (INTEGERP (X) \
899 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
900 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
902 /* Convert canonical value Y to pixels. F is the frame whose
903 canonical character height is to be used. X must be a Lisp integer
904 or float. Value is a C integer. */
906 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
907 (INTEGERP (Y) \
908 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
909 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
911 /* Convert pixel-value X to canonical units. F is the frame whose
912 canonical character width is to be used. X is a C integer. Result
913 is a Lisp float if X is not a multiple of the canon width,
914 otherwise it's a Lisp integer. */
916 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
917 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
918 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
919 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
921 /* Convert pixel-value Y to canonical units. F is the frame whose
922 canonical character height is to be used. Y is a C integer.
923 Result is a Lisp float if Y is not a multiple of the canon width,
924 otherwise it's a Lisp integer. */
926 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
927 ((Y) % FRAME_LINE_HEIGHT (F) \
928 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
929 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
933 /* Manipulating pixel sizes and character sizes.
934 Knowledge of which factors affect the overall size of the window should
935 be hidden in these macros, if that's possible.
937 Return the upper/left pixel position of the character cell on frame F
938 at ROW/COL. */
940 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
941 (FRAME_INTERNAL_BORDER_WIDTH (f) \
942 + (row) * FRAME_LINE_HEIGHT (f))
944 #define FRAME_COL_TO_PIXEL_X(f, col) \
945 (FRAME_INTERNAL_BORDER_WIDTH (f) \
946 + (col) * FRAME_COLUMN_WIDTH (f))
948 /* Return the pixel width/height of frame F if it has
949 COLS columns/LINES rows. */
951 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
952 (FRAME_COL_TO_PIXEL_X (f, cols) \
953 + (f)->scroll_bar_actual_width \
954 + FRAME_TOTAL_FRINGE_WIDTH (f) \
955 + FRAME_INTERNAL_BORDER_WIDTH (f))
957 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
958 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
959 + FRAME_INTERNAL_BORDER_WIDTH (f))
962 /* Return the row/column (zero-based) of the character cell containing
963 the pixel on FRAME at Y/X. */
965 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
966 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
967 / FRAME_LINE_HEIGHT (f))
969 #define FRAME_PIXEL_X_TO_COL(f, x) \
970 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
971 / FRAME_COLUMN_WIDTH (f))
973 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
974 frame F? */
976 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
977 (FRAME_PIXEL_X_TO_COL (f, ((width) \
978 - FRAME_INTERNAL_BORDER_WIDTH (f) \
979 - FRAME_TOTAL_FRINGE_WIDTH (f) \
980 - (f)->scroll_bar_actual_width)))
982 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
983 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
984 - FRAME_INTERNAL_BORDER_WIDTH (f))))
987 /***********************************************************************
988 Frame Parameters
989 ***********************************************************************/
991 extern Lisp_Object Qauto_raise, Qauto_lower;
992 extern Lisp_Object Qborder_color, Qborder_width;
993 extern Lisp_Object Qbuffer_predicate, Qbuffer_list;
994 extern Lisp_Object Qcursor_color, Qcursor_type;
995 extern Lisp_Object Qfont;
996 extern Lisp_Object Qbackground_color, Qforeground_color;
997 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
998 extern Lisp_Object Qinternal_border_width;
999 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
1000 extern Lisp_Object Qmouse_color;
1001 extern Lisp_Object Qname, Qtitle;
1002 extern Lisp_Object Qparent_id;
1003 extern Lisp_Object Qunsplittable, Qvisibility;
1004 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1005 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1006 extern Lisp_Object Qscreen_gamma;
1007 extern Lisp_Object Qline_spacing;
1008 extern Lisp_Object Qwait_for_wm;
1009 extern Lisp_Object Qfullscreen;
1011 extern Lisp_Object Qleft_fringe, Qright_fringe;
1012 extern Lisp_Object Qheight, Qwidth;
1013 extern Lisp_Object Qminibuffer, Qmodeline;
1014 extern Lisp_Object Qonly;
1015 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
1016 extern Lisp_Object Qvisible;
1017 extern Lisp_Object Qdisplay_type;
1018 extern Lisp_Object Qbackground_mode;
1020 extern Lisp_Object Qx_resource_name;
1022 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1023 extern Lisp_Object Qdisplay;
1025 #ifdef HAVE_WINDOW_SYSTEM
1027 /* The class of this X application. */
1028 #define EMACS_CLASS "Emacs"
1030 enum
1032 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1033 FULLSCREEN_NONE = 0,
1034 FULLSCREEN_WIDTH = 1,
1035 FULLSCREEN_HEIGHT = 2,
1036 FULLSCREEN_BOTH = 3,
1037 FULLSCREEN_WAIT = 4,
1041 /* These are in xterm.c, w32term.c, etc. */
1043 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1044 extern void x_set_offset P_ ((struct frame *, int, int, int));
1045 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1047 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1048 extern Lisp_Object x_new_fontset P_ ((struct frame *, char *));
1051 /* These are in frame.c */
1053 extern Lisp_Object Vx_resource_name;
1054 extern Lisp_Object Vx_resource_class;
1057 extern Lisp_Object Qface_set_after_frame_default;
1059 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1060 int *, int *));
1062 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1063 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1065 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1066 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1067 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1068 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1069 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1070 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1071 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1072 Lisp_Object));
1073 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1074 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1075 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1076 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1077 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1078 Lisp_Object));
1079 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1080 Lisp_Object));
1082 extern Lisp_Object x_icon_type P_ ((struct frame *));
1084 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1087 extern void validate_x_resource_name P_ ((void));
1089 #endif /* HAVE_WINDOW_SYSTEM */
1091 #endif /* not EMACS_FRAME_H */
1093 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1094 (do not change this comment) */