Merge from gnus--rel--5.10
[emacs.git] / src / frame.h
blob47fdb1b685f039a79801827a1a45d001a89f367e
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 don't assume anything about current contents of
33 actual terminal frame */
35 extern int frame_garbaged;
37 /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
38 print. */
40 extern int message_buf_print;
42 /* Nonzero means window system changes focus when moving the
43 mouse. */
45 extern int focus_follows_mouse;
48 /* The structure representing a frame. */
50 enum output_method
52 output_termcap,
53 output_x_window,
54 output_msdos_raw,
55 output_w32,
56 output_mac
59 enum vertical_scroll_bar_type
61 vertical_scroll_bar_none,
62 vertical_scroll_bar_left,
63 vertical_scroll_bar_right
66 enum text_cursor_kinds
68 DEFAULT_CURSOR = -2,
69 NO_CURSOR = -1,
70 FILLED_BOX_CURSOR,
71 HOLLOW_BOX_CURSOR,
72 BAR_CURSOR,
73 HBAR_CURSOR
76 #if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS)
78 #if !defined(HAVE_X_WINDOWS)
80 #define PIX_TYPE unsigned long
82 /* A (mostly empty) x_output structure definition for building Emacs
83 on Unix and GNU/Linux without X support. */
84 struct x_output
86 PIX_TYPE background_pixel;
87 PIX_TYPE foreground_pixel;
90 #endif /* ! HAVE_X_WINDOWS */
93 #define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
94 #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
96 /* A structure describing a termcap frame display. */
97 extern struct x_output tty_display;
99 #endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */
101 struct frame
103 EMACS_INT size;
104 struct Lisp_Vector *next;
106 /* All Lisp_Object components must come first.
107 Only EMACS_INT values can be intermixed with them.
108 That ensures they are all aligned normally. */
110 /* Name of this frame: a Lisp string. It is used for looking up resources,
111 as well as for the title in some cases. */
112 Lisp_Object name;
114 /* The name to use for the icon, the last time
115 it was refreshed. nil means not explicitly specified. */
116 Lisp_Object icon_name;
118 /* This is the frame title specified explicitly, if any.
119 Usually it is nil. */
120 Lisp_Object title;
122 /* The frame which should receive keystrokes that occur in this
123 frame, or nil if they should go to the frame itself. This is
124 usually nil, but if the frame is minibufferless, we can use this
125 to redirect keystrokes to a surrogate minibuffer frame when
126 needed.
128 Note that a value of nil is different than having the field point
129 to the frame itself. Whenever the Fselect_frame function is used
130 to shift from one frame to the other, any redirections to the
131 original frame are shifted to the newly selected frame; if
132 focus_frame is nil, Fselect_frame will leave it alone. */
133 Lisp_Object focus_frame;
135 /* This frame's root window. Every frame has one.
136 If the frame has only a minibuffer window, this is it.
137 Otherwise, if the frame has a minibuffer window, this is its sibling. */
138 Lisp_Object root_window;
140 /* This frame's selected window.
141 Each frame has its own window hierarchy
142 and one of the windows in it is selected within the frame.
143 The selected window of the selected frame is Emacs's selected window. */
144 Lisp_Object selected_window;
146 /* This frame's minibuffer window.
147 Most frames have their own minibuffer windows,
148 but only the selected frame's minibuffer window
149 can actually appear to exist. */
150 Lisp_Object minibuffer_window;
152 /* Parameter alist of this frame.
153 These are the parameters specified when creating the frame
154 or modified with modify-frame-parameters. */
155 Lisp_Object param_alist;
157 /* List of scroll bars on this frame.
158 Actually, we don't specify exactly what is stored here at all; the
159 scroll bar implementation code can use it to store anything it likes.
160 This field is marked by the garbage collector. It is here
161 instead of in the `display' structure so that the garbage
162 collector doesn't need to look inside the window-system-dependent
163 structure. */
164 Lisp_Object scroll_bars;
165 Lisp_Object condemned_scroll_bars;
167 /* Vector describing the items to display in the menu bar.
168 Each item has four elements in this vector.
169 They are KEY, STRING, SUBMAP, and HPOS.
170 (HPOS is not used in when the X toolkit is in use.)
171 There are four additional elements of nil at the end, to terminate. */
172 Lisp_Object menu_bar_items;
174 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
175 Lisp_Object face_alist;
177 /* A vector that records the entire structure of this frame's menu bar.
178 For the format of the data, see extensive comments in xmenu.c.
179 Only the X toolkit version uses this. */
180 Lisp_Object menu_bar_vector;
181 /* Number of elements in the vector that have meaningful data. */
182 EMACS_INT menu_bar_items_used;
184 /* Predicate for selecting buffers for other-buffer. */
185 Lisp_Object buffer_predicate;
187 /* List of buffers viewed in this frame, for other-buffer. */
188 Lisp_Object buffer_list;
190 /* A dummy window used to display menu bars under X when no X
191 toolkit support is available. */
192 Lisp_Object menu_bar_window;
194 /* A window used to display the tool-bar of a frame. */
195 Lisp_Object tool_bar_window;
197 /* Desired and current tool-bar items. */
198 Lisp_Object tool_bar_items;
200 /* Desired and current contents displayed in tool_bar_window. */
201 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
203 /* beyond here, there should be no more Lisp_Object components. */
205 /* Cache of realized faces. */
206 struct face_cache *face_cache;
208 /* A buffer to hold the frame's name. We can't use the Lisp
209 string's pointer (`name', above) because it might get relocated. */
210 char *namebuf;
212 /* Glyph pool and matrix. */
213 struct glyph_pool *current_pool;
214 struct glyph_pool *desired_pool;
215 struct glyph_matrix *desired_matrix;
216 struct glyph_matrix *current_matrix;
218 /* 1 means that glyphs on this frame have been initialized so it can
219 be used for output. */
220 unsigned glyphs_initialized_p : 1;
222 #if defined (USE_GTK) || defined (MAC_OS)
223 /* Nonzero means using a tool bar that comes from the toolkit. */
224 int external_tool_bar;
225 #endif
227 /* Margin at the top of the frame. Used to display the tool-bar. */
228 int tool_bar_lines;
230 int n_tool_bar_rows;
231 int n_tool_bar_items;
233 /* A buffer for decode_mode_line. */
234 char *decode_mode_spec_buffer;
236 /* See do_line_insertion_deletion_costs for info on these arrays. */
237 /* Cost of inserting 1 line on this frame */
238 int *insert_line_cost;
239 /* Cost of deleting 1 line on this frame */
240 int *delete_line_cost;
241 /* Cost of inserting n lines on this frame */
242 int *insert_n_lines_cost;
243 /* Cost of deleting n lines on this frame */
244 int *delete_n_lines_cost;
246 /* Size of this frame, excluding fringes, scroll bars etc.,
247 in units of canonical characters. */
248 EMACS_INT text_lines, text_cols;
250 /* Total size of this frame (i.e. its native window), in units of
251 canonical characters. */
252 EMACS_INT total_lines, total_cols;
254 /* New text height and width for pending size change.
255 0 if no change pending. */
256 int new_text_lines, new_text_cols;
258 /* Pixel position of the frame window (x and y offsets in root window). */
259 int left_pos, top_pos;
261 /* Size of the frame window in pixels. */
262 int pixel_height, pixel_width;
264 /* These many pixels are the difference between the outer window (i.e. the
265 left and top of the window manager decoration) and FRAME_X_WINDOW. */
266 int x_pixels_diff, y_pixels_diff;
268 /* This is the gravity value for the specified window position. */
269 int win_gravity;
271 /* The geometry flags for this window. */
272 int size_hint_flags;
274 /* Border width of the frame window as known by the (X) window system. */
275 int border_width;
277 /* Width of the internal border. This is a line of background color
278 just inside the window's border. When the frame is selected,
279 a highlighting is displayed inside the internal border. */
280 int internal_border_width;
282 /* Canonical X unit. Width of default font, in pixels. */
283 int column_width;
285 /* Widht of space glyph of default font, in pixels. */
286 int space_width;
288 /* Canonical Y unit. Height of a line, in pixels. */
289 int line_height;
291 /* The output method says how the contents of this frame
292 are displayed. It could be using termcap, or using an X window. */
293 enum output_method output_method;
295 /* A structure of auxiliary data used for displaying the contents.
296 struct x_output is used for X window frames;
297 it is defined in xterm.h.
298 struct w32_output is used for W32 window frames;
299 it is defined in w32term.h. */
300 union output_data
302 struct x_output *x;
303 struct w32_output *w32;
304 struct mac_output *mac;
305 EMACS_INT nothing;
307 output_data;
309 /* Total width of fringes reserved for drawing truncation bitmaps,
310 continuation bitmaps and alike. The width is in canonical char
311 units of the frame. This must currently be the case because window
312 sizes aren't pixel values. If it weren't the case, we wouldn't be
313 able to split windows horizontally nicely. */
314 int fringe_cols;
316 /* The extra width (in pixels) currently allotted for fringes. */
317 int left_fringe_width, right_fringe_width;
319 #ifdef MULTI_KBOARD
320 /* A pointer to the kboard structure associated with this frame.
321 For termcap frames, this points to initial_kboard. For X frames,
322 it will be the same as display.x->display_info->kboard. */
323 struct kboard *kboard;
324 #endif
326 /* See FULLSCREEN_ enum below */
327 int want_fullscreen;
329 /* Number of lines of menu bar. */
330 int menu_bar_lines;
332 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
333 || defined (USE_GTK)
334 /* Nonzero means using a menu bar that comes from the X toolkit. */
335 int external_menu_bar;
336 #endif
338 /* Nonzero if last attempt at redisplay on this frame was preempted. */
339 char display_preempted;
341 /* visible is nonzero if the frame is currently displayed; we check
342 it to see if we should bother updating the frame's contents.
343 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
345 Note that, since invisible frames aren't updated, whenever a
346 frame becomes visible again, it must be marked as garbaged. The
347 FRAME_SAMPLE_VISIBILITY macro takes care of this.
349 On Windows NT/9X, to avoid wasting effort updating visible frames
350 that are actually completely obscured by other windows on the
351 display, we bend the meaning of visible slightly: if greater than
352 1, then the frame is obscured - we still consider it to be
353 "visible" as seen from lisp, but we don't bother updating it. We
354 must take care to garbage the frame when it ceaces to be obscured
355 though. Note that these semantics are only used on NT/9X.
357 iconified is nonzero if the frame is currently iconified.
359 Asynchronous input handlers should NOT change these directly;
360 instead, they should change async_visible or async_iconified, and
361 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
362 at the next redisplay.
364 These should probably be considered read-only by everyone except
365 FRAME_SAMPLE_VISIBILITY.
367 These two are mutually exclusive. They might both be zero, if the
368 frame has been made invisible without an icon. */
369 char visible, iconified;
371 /* Asynchronous input handlers change these, and
372 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
373 See FRAME_SAMPLE_VISIBILITY, below. */
374 volatile char async_visible, async_iconified;
376 /* Nonzero if this frame should be redrawn. */
377 volatile char garbaged;
379 /* True if frame actually has a minibuffer window on it.
380 0 if using a minibuffer window that isn't on this frame. */
381 char has_minibuffer;
383 /* 0 means, if this frame has just one window,
384 show no modeline for that window. */
385 char wants_modeline;
387 /* Non-zero if the hardware device this frame is displaying on can
388 support scroll bars. */
389 char can_have_scroll_bars;
391 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
392 actually display them on this frame. */
393 enum vertical_scroll_bar_type vertical_scroll_bar_type;
395 /* What kind of text cursor should we draw in the future?
396 This should always be filled_box_cursor or bar_cursor. */
397 enum text_cursor_kinds desired_cursor;
399 /* Width of bar cursor (if we are using that). */
400 int cursor_width;
402 /* What kind of text cursor should we draw when the cursor blinks off?
403 This can be filled_box_cursor or bar_cursor or no_cursor. */
404 enum text_cursor_kinds blink_off_cursor;
406 /* Width of bar cursor (if we are using that) for blink-off state. */
407 int blink_off_cursor_width;
409 /* Non-0 means raise this frame to the top of the heap when selected. */
410 char auto_raise;
412 /* Non-0 means lower this frame to the bottom of the stack when left. */
413 char auto_lower;
415 /* True if frame's root window can't be split. */
416 char no_split;
418 /* If this is set, then Emacs won't change the frame name to indicate
419 the current buffer, etcetera. If the user explicitly sets the frame
420 name, this gets set. If the user sets the name to Qnil, this is
421 cleared. */
422 char explicit_name;
424 /* Nonzero if size of some window on this frame has changed. */
425 char window_sizes_changed;
427 /* Storage for messages to this frame. */
428 char *message_buf;
430 /* Nonnegative if current redisplay should not do scroll computation
431 for lines beyond a certain vpos. This is the vpos. */
432 int scroll_bottom_vpos;
434 /* Configured width of the scroll bar, in pixels and in characters.
435 config_scroll_bar_cols tracks config_scroll_bar_width if the
436 latter is positive; a zero value in config_scroll_bar_width means
437 to compute the actual width on the fly, using config_scroll_bar_cols
438 and the current font width. */
439 int config_scroll_bar_width;
440 int config_scroll_bar_cols;
442 /* The size of the extra width currently allotted for vertical
443 scroll bars in this frame, in pixels. */
444 int scroll_bar_actual_width;
446 /* The baud rate that was used to calculate costs for this frame. */
447 int cost_calculation_baud_rate;
449 /* Nonzero if the mouse has moved on this display
450 since the last time we checked. */
451 char mouse_moved;
453 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
454 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
455 frame parameter. 0 means don't do gamma correction. */
456 double gamma;
458 /* Additional space to put between text lines on this frame. */
459 int extra_line_spacing;
461 /* Set to non-zero in change_frame_size when size of frame changed
462 Clear the frame in clear_garbaged_frames if set. */
463 unsigned resized_p : 1;
465 /* Set to non-zero in when we want for force a flush_display in
466 update_frame, usually after resizing the frame. */
467 unsigned force_flush_display_p : 1;
469 /* Set to non-zero if the default face for the frame has been
470 realized. Reset to zero whenever the default face changes.
471 Used to see the difference between a font change and face change. */
472 unsigned default_face_done_p : 1;
474 /* Set to non-zero if this frame has already been hscrolled during
475 current redisplay. */
476 unsigned already_hscrolled_p : 1;
478 /* Set to non-zero when current redisplay has updated frame. */
479 unsigned updated_p : 1;
481 /* Set to non-zero to minimize tool-bar height even when
482 auto-resize-tool-bar is set to grow-only. */
483 unsigned minimize_tool_bar_window_p : 1;
486 #ifdef MULTI_KBOARD
487 #define FRAME_KBOARD(f) ((f)->kboard)
488 #else
489 #define FRAME_KBOARD(f) (&the_only_kboard)
490 #endif
492 typedef struct frame *FRAME_PTR;
494 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
495 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
497 /* Given a window, return its frame as a Lisp_Object. */
498 #define WINDOW_FRAME(w) (w)->frame
500 /* Test a frame for particular kinds of display methods. */
501 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
502 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
503 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
504 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
505 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
507 /* FRAME_WINDOW_P tests whether the frame is a window, and is
508 defined to be the predicate for the window system being used. */
510 #ifdef HAVE_X_WINDOWS
511 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
512 #endif
513 #ifdef HAVE_NTGUI
514 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
515 #endif
516 #ifdef MAC_OS
517 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
518 #endif
519 #ifndef FRAME_WINDOW_P
520 #define FRAME_WINDOW_P(f) (0)
521 #endif
523 /* Nonzero if frame F is still alive (not deleted). */
524 #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0)
526 /* Nonzero if frame F is a minibuffer-only frame. */
527 #define FRAME_MINIBUF_ONLY_P(f) \
528 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
530 /* Nonzero if frame F contains a minibuffer window.
531 (If this is 0, F must use some other minibuffer window.) */
532 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
534 /* Pixel height of frame F, including non-toolkit menu bar and
535 non-toolkit tool bar lines. */
536 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
538 /* Pixel width of frame F. */
539 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
541 /* Height of frame F, measured in canonical lines, including
542 non-toolkit menu bar and non-toolkit tool bar lines. */
543 #define FRAME_LINES(f) (f)->text_lines
545 /* Width of frame F, measured in canonical character columns,
546 not including scroll bars if any. */
547 #define FRAME_COLS(f) (f)->text_cols
549 /* Number of lines of frame F used for menu bar.
550 This is relevant on terminal frames and on
551 X Windows when not using the X toolkit.
552 These lines are counted in FRAME_LINES. */
553 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
555 /* Nonzero if this frame should display a tool bar
556 in a way that does not use any text lines. */
557 #if defined (USE_GTK) || defined (MAC_OS)
558 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
559 #else
560 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
561 #endif
563 /* Number of lines of frame F used for the tool-bar. */
565 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
568 /* Lines above the top-most window in frame F. */
570 #define FRAME_TOP_MARGIN(F) \
571 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
573 /* Nonzero if this frame should display a menu bar
574 in a way that does not use any text lines. */
575 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
576 || defined (USE_GTK)
577 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
578 #else
579 #define FRAME_EXTERNAL_MENU_BAR(f) 0
580 #endif
581 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
583 /* Nonzero if frame F is currently visible but hidden. */
584 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
586 /* Nonzero if frame F is currently iconified. */
587 #define FRAME_ICONIFIED_P(f) (f)->iconified
589 #define FRAME_SET_VISIBLE(f,p) \
590 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
591 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
592 #define FRAME_GARBAGED_P(f) (f)->garbaged
594 /* Nonzero means do not allow splitting this frame's window. */
595 #define FRAME_NO_SPLIT_P(f) (f)->no_split
597 /* Not really implemented. */
598 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
600 /* Nonzero if a size change has been requested for frame F
601 but not yet really put into effect. This can be true temporarily
602 when an X event comes in at a bad time. */
603 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
605 /* The minibuffer window of frame F, if it has one; otherwise nil. */
606 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
608 /* The root window of the window tree of frame F. */
609 #define FRAME_ROOT_WINDOW(f) (f)->root_window
611 /* The currently selected window of the window tree of frame F. */
612 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
614 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
615 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
616 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
617 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
618 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
619 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
620 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
622 /* Nonzero if frame F supports scroll bars.
623 If this is zero, then it is impossible to enable scroll bars
624 on frame F. */
625 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
627 /* This frame slot says whether scroll bars are currently enabled for frame F,
628 and which side they are on. */
629 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
630 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
631 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
632 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
633 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
634 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
635 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
637 /* Width that a scroll bar in frame F should have, if there is one.
638 Measured in pixels.
639 If scroll bars are turned off, this is still nonzero. */
640 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
642 /* Width that a scroll bar in frame F should have, if there is one.
643 Measured in columns (characters).
644 If scroll bars are turned off, this is still nonzero. */
645 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
647 /* Width of a scroll bar in frame F, measured in columns (characters),
648 but only if scroll bars are on the left. If scroll bars are on
649 the right in this frame, or there are no scroll bars, value is 0. */
651 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
652 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
653 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
654 : 0)
656 /* Width of a left scroll bar in frame F, measured in pixels */
658 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
659 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
660 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
661 : 0)
663 /* Width of a scroll bar in frame F, measured in columns (characters),
664 but only if scroll bars are on the right. If scroll bars are on
665 the left in this frame, or there are no scroll bars, value is 0. */
667 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
668 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
669 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
670 : 0)
672 /* Width of a right scroll bar area in frame F, measured in pixels */
674 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
675 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
676 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
677 : 0)
679 /* Actual width of a scroll bar in frame F, measured in columns. */
681 #define FRAME_SCROLL_BAR_COLS(f) \
682 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
683 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
684 : 0)
686 /* Actual width of a scroll bar area in frame F, measured in pixels. */
688 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
689 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
690 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
691 : 0)
693 /* Total width of frame F, in columns (characters),
694 including the width used by scroll bars if any. */
696 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
698 /* Set the width of frame F to VAL.
699 VAL is the width of a full-frame window,
700 not including scroll bars and fringes. */
702 #define SET_FRAME_COLS(f, val) \
703 (FRAME_COLS (f) = (val), \
704 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
706 /* Given a value WIDTH for frame F's nominal width,
707 return the value that FRAME_TOTAL_COLS should have. */
709 #define FRAME_TOTAL_COLS_ARG(f, width) \
710 ((width) \
711 + FRAME_SCROLL_BAR_COLS (f) \
712 + FRAME_FRINGE_COLS (f))
714 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
716 #define FRAME_CURSOR_X_LIMIT(f) \
717 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
719 /* Nonzero if frame F has scroll bars. */
721 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
723 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
724 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
725 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
727 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
728 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
729 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
730 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
732 /* Return a pointer to the face cache of frame F. */
734 #define FRAME_FACE_CACHE(F) (F)->face_cache
736 /* Return the size of message_buf of the frame F. We multiply the
737 width of the frame by 4 because multi-byte form may require at most
738 4-byte for a character. */
740 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
742 /* Emacs's redisplay code could become confused if a frame's
743 visibility changes at arbitrary times. For example, if a frame is
744 visible while the desired glyphs are being built, but becomes
745 invisible before they are updated, then some rows of the
746 desired_glyphs will be left marked as enabled after redisplay is
747 complete, which should never happen. The next time the frame
748 becomes visible, redisplay will probably barf.
750 Currently, there are no similar situations involving iconified, but
751 the principle is the same.
753 So instead of having asynchronous input handlers directly set and
754 clear the frame's visibility and iconification flags, they just set
755 the async_visible and async_iconified flags; the redisplay code
756 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
757 which sets visible and iconified from their asynchronous
758 counterparts.
760 Synchronous code must use the FRAME_SET_VISIBLE macro.
762 Also, if a frame used to be invisible, but has just become visible,
763 it must be marked as garbaged, since redisplay hasn't been keeping
764 up its contents. */
766 #define FRAME_SAMPLE_VISIBILITY(f) \
767 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
768 SET_FRAME_GARBAGED (f) : 0, \
769 (f)->visible = (f)->async_visible, \
770 (f)->iconified = (f)->async_iconified)
772 #define CHECK_FRAME(x) \
773 CHECK_TYPE (FRAMEP (x), Qframep, x)
775 #define CHECK_LIVE_FRAME(x) \
776 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
778 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
779 `for' loop which iterates over the elements of Vframe_list. The
780 loop will set FRAME_VAR, a Lisp_Object, to each frame in
781 Vframe_list in succession and execute the statement. LIST_VAR
782 should be a Lisp_Object too; it is used to iterate through the
783 Vframe_list.
785 This macro is a holdover from a time when multiple frames weren't always
786 supported. An alternate definition of the macro would expand to
787 something which executes the statement once. */
789 #define FOR_EACH_FRAME(list_var, frame_var) \
790 for ((list_var) = Vframe_list; \
791 (CONSP (list_var) \
792 && (frame_var = XCAR (list_var), 1)); \
793 list_var = XCDR (list_var))
796 extern Lisp_Object Qframep, Qframe_live_p;
798 extern struct frame *last_nonminibuf_frame;
800 extern struct frame *make_terminal_frame P_ ((void));
801 extern struct frame *make_frame P_ ((int));
802 #ifdef HAVE_WINDOW_SYSTEM
803 extern struct frame *make_minibuffer_frame P_ ((void));
804 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
805 struct kboard *,
806 Lisp_Object));
807 #endif /* HAVE_WINDOW_SYSTEM */
808 extern int other_visible_frames P_ ((struct frame *));
810 extern Lisp_Object Vframe_list;
811 extern Lisp_Object Vdefault_frame_alist;
813 extern Lisp_Object Vterminal_frame;
815 extern Lisp_Object Vmouse_highlight;
817 /* The currently selected frame. */
819 extern Lisp_Object selected_frame;
821 /* Value is a pointer to the selected frame. If the selected frame
822 isn't live, abort. */
824 #define SELECTED_FRAME() \
825 ((FRAMEP (selected_frame) \
826 && FRAME_LIVE_P (XFRAME (selected_frame))) \
827 ? XFRAME (selected_frame) \
828 : (abort (), (struct frame *) 0))
831 /***********************************************************************
832 Display-related Macros
833 ***********************************************************************/
835 /* Canonical y-unit on frame F.
836 This value currently equals the line height of the frame (which is
837 the height of the default font of F). */
839 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
841 /* Canonical x-unit on frame F.
842 This value currently equals the average width of the default font of F. */
844 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
846 /* Space glyph width of the default font of frame F. */
848 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
851 /* Pixel width of areas used to display truncation marks, continuation
852 marks, overlay arrows. This is 0 for terminal frames. */
854 #ifdef HAVE_WINDOW_SYSTEM
856 /* Total width of fringes reserved for drawing truncation bitmaps,
857 continuation bitmaps and alike. The width is in canonical char
858 units of the frame. This must currently be the case because window
859 sizes aren't pixel values. If it weren't the case, we wouldn't be
860 able to split windows horizontally nicely. */
862 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
864 /* Pixel-width of the left and right fringe. */
866 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
867 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
869 /* Total width of fringes in pixels. */
871 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
872 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
875 /* Pixel-width of internal border lines */
877 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
879 #else /* not HAVE_WINDOW_SYSTEM */
881 #define FRAME_FRINGE_COLS(F) 0
882 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
883 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
884 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
885 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
887 #endif /* not HAVE_WINDOW_SYSTEM */
892 /***********************************************************************
893 Conversion between canonical units and pixels
894 ***********************************************************************/
896 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
897 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
898 represented as Lisp numbers, i.e. integers or floats. */
900 /* Convert canonical value X to pixels. F is the frame whose
901 canonical char width is to be used. X must be a Lisp integer or
902 float. Value is a C integer. */
904 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
905 (INTEGERP (X) \
906 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
907 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
909 /* Convert canonical value Y to pixels. F is the frame whose
910 canonical character height is to be used. X must be a Lisp integer
911 or float. Value is a C integer. */
913 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
914 (INTEGERP (Y) \
915 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
916 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
918 /* Convert pixel-value X to canonical units. F is the frame whose
919 canonical character width is to be used. X is a C integer. Result
920 is a Lisp float if X is not a multiple of the canon width,
921 otherwise it's a Lisp integer. */
923 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
924 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
925 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
926 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
928 /* Convert pixel-value Y to canonical units. F is the frame whose
929 canonical character height is to be used. Y is a C integer.
930 Result is a Lisp float if Y is not a multiple of the canon width,
931 otherwise it's a Lisp integer. */
933 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
934 ((Y) % FRAME_LINE_HEIGHT (F) \
935 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
936 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
940 /* Manipulating pixel sizes and character sizes.
941 Knowledge of which factors affect the overall size of the window should
942 be hidden in these macros, if that's possible.
944 Return the upper/left pixel position of the character cell on frame F
945 at ROW/COL. */
947 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
948 (FRAME_INTERNAL_BORDER_WIDTH (f) \
949 + (row) * FRAME_LINE_HEIGHT (f))
951 #define FRAME_COL_TO_PIXEL_X(f, col) \
952 (FRAME_INTERNAL_BORDER_WIDTH (f) \
953 + (col) * FRAME_COLUMN_WIDTH (f))
955 /* Return the pixel width/height of frame F if it has
956 COLS columns/LINES rows. */
958 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
959 (FRAME_COL_TO_PIXEL_X (f, cols) \
960 + (f)->scroll_bar_actual_width \
961 + FRAME_TOTAL_FRINGE_WIDTH (f) \
962 + FRAME_INTERNAL_BORDER_WIDTH (f))
964 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
965 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
966 + FRAME_INTERNAL_BORDER_WIDTH (f))
969 /* Return the row/column (zero-based) of the character cell containing
970 the pixel on FRAME at Y/X. */
972 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
973 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
974 / FRAME_LINE_HEIGHT (f))
976 #define FRAME_PIXEL_X_TO_COL(f, x) \
977 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
978 / FRAME_COLUMN_WIDTH (f))
980 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
981 frame F? */
983 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
984 (FRAME_PIXEL_X_TO_COL (f, ((width) \
985 - FRAME_INTERNAL_BORDER_WIDTH (f) \
986 - FRAME_TOTAL_FRINGE_WIDTH (f) \
987 - (f)->scroll_bar_actual_width)))
989 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
990 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
991 - FRAME_INTERNAL_BORDER_WIDTH (f))))
994 /***********************************************************************
995 Frame Parameters
996 ***********************************************************************/
998 extern Lisp_Object Qauto_raise, Qauto_lower;
999 extern Lisp_Object Qborder_color, Qborder_width;
1000 extern Lisp_Object Qbuffer_predicate, Qbuffer_list;
1001 extern Lisp_Object Qcursor_color, Qcursor_type;
1002 extern Lisp_Object Qfont;
1003 extern Lisp_Object Qbackground_color, Qforeground_color;
1004 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1005 extern Lisp_Object Qinternal_border_width;
1006 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
1007 extern Lisp_Object Qmouse_color;
1008 extern Lisp_Object Qname, Qtitle;
1009 extern Lisp_Object Qparent_id;
1010 extern Lisp_Object Qunsplittable, Qvisibility;
1011 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1012 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1013 extern Lisp_Object Qscreen_gamma;
1014 extern Lisp_Object Qline_spacing;
1015 extern Lisp_Object Qwait_for_wm;
1016 extern Lisp_Object Qfullscreen;
1018 extern Lisp_Object Qleft_fringe, Qright_fringe;
1019 extern Lisp_Object Qheight, Qwidth;
1020 extern Lisp_Object Qminibuffer, Qmodeline;
1021 extern Lisp_Object Qonly;
1022 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
1023 extern Lisp_Object Qvisible;
1024 extern Lisp_Object Qdisplay_type;
1025 extern Lisp_Object Qbackground_mode;
1027 extern Lisp_Object Qx_resource_name;
1029 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1030 extern Lisp_Object Qdisplay;
1032 #ifdef HAVE_WINDOW_SYSTEM
1034 /* The class of this X application. */
1035 #define EMACS_CLASS "Emacs"
1037 enum
1039 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1040 FULLSCREEN_NONE = 0,
1041 FULLSCREEN_WIDTH = 1,
1042 FULLSCREEN_HEIGHT = 2,
1043 FULLSCREEN_BOTH = 3,
1044 FULLSCREEN_WAIT = 4
1048 /* These are in xterm.c, w32term.c, etc. */
1050 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1051 extern void x_set_offset P_ ((struct frame *, int, int, int));
1052 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1054 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1055 extern Lisp_Object x_new_fontset P_ ((struct frame *, char *));
1058 /* These are in frame.c */
1060 extern Lisp_Object Vx_resource_name;
1061 extern Lisp_Object Vx_resource_class;
1064 extern Lisp_Object Qface_set_after_frame_default;
1066 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1067 int *, int *));
1069 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1070 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1072 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1073 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1074 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1075 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1076 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1077 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1078 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1079 Lisp_Object));
1080 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1081 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1082 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1083 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1084 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1085 Lisp_Object));
1086 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1087 Lisp_Object));
1089 extern Lisp_Object x_icon_type P_ ((struct frame *));
1091 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1094 extern void validate_x_resource_name P_ ((void));
1096 #endif /* HAVE_WINDOW_SYSTEM */
1098 #endif /* not EMACS_FRAME_H */
1100 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1101 (do not change this comment) */