(struct frame): Move all bit fields after the first bit
[emacs.git] / src / frame.h
bloba9bddbe34b889a3639f604de9c6e387edbc2cf4c
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993, 1994, 1999, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007 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 frame
82 EMACS_UINT size;
83 struct Lisp_Vector *next;
85 /* All Lisp_Object components must come first.
86 That ensures they are all aligned normally. */
88 /* Name of this frame: a Lisp string. It is used for looking up resources,
89 as well as for the title in some cases. */
90 Lisp_Object name;
92 /* The name to use for the icon, the last time
93 it was refreshed. nil means not explicitly specified. */
94 Lisp_Object icon_name;
96 /* This is the frame title specified explicitly, if any.
97 Usually it is nil. */
98 Lisp_Object title;
100 /* The frame which should receive keystrokes that occur in this
101 frame, or nil if they should go to the frame itself. This is
102 usually nil, but if the frame is minibufferless, we can use this
103 to redirect keystrokes to a surrogate minibuffer frame when
104 needed.
106 Note that a value of nil is different than having the field point
107 to the frame itself. Whenever the Fselect_frame function is used
108 to shift from one frame to the other, any redirections to the
109 original frame are shifted to the newly selected frame; if
110 focus_frame is nil, Fselect_frame will leave it alone. */
111 Lisp_Object focus_frame;
113 /* This frame's root window. Every frame has one.
114 If the frame has only a minibuffer window, this is it.
115 Otherwise, if the frame has a minibuffer window, this is its sibling. */
116 Lisp_Object root_window;
118 /* This frame's selected window.
119 Each frame has its own window hierarchy
120 and one of the windows in it is selected within the frame.
121 The selected window of the selected frame is Emacs's selected window. */
122 Lisp_Object selected_window;
124 /* This frame's minibuffer window.
125 Most frames have their own minibuffer windows,
126 but only the selected frame's minibuffer window
127 can actually appear to exist. */
128 Lisp_Object minibuffer_window;
130 /* Parameter alist of this frame.
131 These are the parameters specified when creating the frame
132 or modified with modify-frame-parameters. */
133 Lisp_Object param_alist;
135 /* List of scroll bars on this frame.
136 Actually, we don't specify exactly what is stored here at all; the
137 scroll bar implementation code can use it to store anything it likes.
138 This field is marked by the garbage collector. It is here
139 instead of in the `device' structure so that the garbage
140 collector doesn't need to look inside the window-system-dependent
141 structure. */
142 Lisp_Object scroll_bars;
143 Lisp_Object condemned_scroll_bars;
145 /* Vector describing the items to display in the menu bar.
146 Each item has four elements in this vector.
147 They are KEY, STRING, SUBMAP, and HPOS.
148 (HPOS is not used in when the X toolkit is in use.)
149 There are four additional elements of nil at the end, to terminate. */
150 Lisp_Object menu_bar_items;
152 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
153 Lisp_Object face_alist;
155 /* A vector that records the entire structure of this frame's menu bar.
156 For the format of the data, see extensive comments in xmenu.c.
157 Only the X toolkit version uses this. */
158 Lisp_Object menu_bar_vector;
160 /* Predicate for selecting buffers for other-buffer. */
161 Lisp_Object buffer_predicate;
163 /* List of buffers viewed in this frame, for other-buffer. */
164 Lisp_Object buffer_list;
166 /* List of buffers that were viewed, then buried in this frame. The
167 most recently buried buffer is first. For last-buffer. */
168 Lisp_Object buried_buffer_list;
170 /* A dummy window used to display menu bars under X when no X
171 toolkit support is available. */
172 Lisp_Object menu_bar_window;
174 /* A window used to display the tool-bar of a frame. */
175 Lisp_Object tool_bar_window;
177 /* Desired and current tool-bar items. */
178 Lisp_Object tool_bar_items;
180 /* Desired and current contents displayed in tool_bar_window. */
181 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
183 /* Beyond here, there should be no more Lisp_Object components. */
185 /* Cache of realized faces. */
186 struct face_cache *face_cache;
188 /* Number of elements in `menu_bar_vector' that have meaningful data. */
189 EMACS_INT menu_bar_items_used;
191 /* A buffer to hold the frame's name. We can't use the Lisp
192 string's pointer (`name', above) because it might get relocated. */
193 char *namebuf;
195 /* Glyph pool and matrix. */
196 struct glyph_pool *current_pool;
197 struct glyph_pool *desired_pool;
198 struct glyph_matrix *desired_matrix;
199 struct glyph_matrix *current_matrix;
201 /* 1 means that glyphs on this frame have been initialized so it can
202 be used for output. */
203 unsigned glyphs_initialized_p : 1;
205 /* Set to non-zero in change_frame_size when size of frame changed
206 Clear the frame in clear_garbaged_frames if set. */
207 unsigned resized_p : 1;
209 /* Set to non-zero in when we want for force a flush_display in
210 update_frame, usually after resizing the frame. */
211 unsigned force_flush_display_p : 1;
213 /* Set to non-zero if the default face for the frame has been
214 realized. Reset to zero whenever the default face changes.
215 Used to see the difference between a font change and face change. */
216 unsigned default_face_done_p : 1;
218 /* Set to non-zero if this frame has already been hscrolled during
219 current redisplay. */
220 unsigned already_hscrolled_p : 1;
222 /* Set to non-zero when current redisplay has updated frame. */
223 unsigned updated_p : 1;
225 /* Set to non-zero to minimize tool-bar height even when
226 auto-resize-tool-bar is set to grow-only. */
227 unsigned minimize_tool_bar_window_p : 1;
229 #if defined (USE_GTK) || defined (MAC_OS)
230 /* Nonzero means using a tool bar that comes from the toolkit. */
231 int external_tool_bar;
232 #endif
234 /* Margin at the top of the frame. Used to display the tool-bar. */
235 int tool_bar_lines;
237 int n_tool_bar_rows;
238 int n_tool_bar_items;
240 /* A buffer for decode_mode_line. */
241 char *decode_mode_spec_buffer;
243 /* See do_line_insertion_deletion_costs for info on these arrays. */
244 /* Cost of inserting 1 line on this frame */
245 int *insert_line_cost;
246 /* Cost of deleting 1 line on this frame */
247 int *delete_line_cost;
248 /* Cost of inserting n lines on this frame */
249 int *insert_n_lines_cost;
250 /* Cost of deleting n lines on this frame */
251 int *delete_n_lines_cost;
253 /* Size of this frame, excluding fringes, scroll bars etc.,
254 in units of canonical characters. */
255 EMACS_INT text_lines, text_cols;
257 /* Total size of this frame (i.e. its native window), in units of
258 canonical characters. */
259 EMACS_INT total_lines, total_cols;
261 /* New text height and width for pending size change.
262 0 if no change pending. */
263 int new_text_lines, new_text_cols;
265 /* Pixel position of the frame window (x and y offsets in root window). */
266 int left_pos, top_pos;
268 /* Size of the frame window in pixels. */
269 int pixel_height, pixel_width;
271 /* These many pixels are the difference between the outer window (i.e. the
272 left and top of the window manager decoration) and FRAME_X_WINDOW. */
273 int x_pixels_diff, y_pixels_diff;
275 /* This is the gravity value for the specified window position. */
276 int win_gravity;
278 /* The geometry flags for this window. */
279 int size_hint_flags;
281 /* Border width of the frame window as known by the (X) window system. */
282 int border_width;
284 /* Width of the internal border. This is a line of background color
285 just inside the window's border. When the frame is selected,
286 a highlighting is displayed inside the internal border. */
287 int internal_border_width;
289 /* Canonical X unit. Width of default font, in pixels. */
290 int column_width;
292 /* Widht of space glyph of default font, in pixels. */
293 int space_width;
295 /* Canonical Y unit. Height of a line, in pixels. */
296 int line_height;
298 /* The output method says how the contents of this frame are
299 displayed. It could be using termcap, or using an X window.
300 This must be the same as the terminal->type. */
301 enum output_method output_method;
303 /* The terminal device that this frame uses. If this is NULL, then
304 the frame has been deleted. */
305 struct terminal *terminal;
307 /* Device-dependent, frame-local auxiliary data used for displaying
308 the contents. When the frame is deleted, this data is deleted as
309 well. */
310 union output_data
312 struct tty_output *tty; /* termchar.h */
313 struct x_output *x; /* xterm.h */
314 struct w32_output *w32; /* w32term.h */
315 struct mac_output *mac; /* macterm.h */
316 EMACS_INT nothing;
318 output_data;
320 /* Total width of fringes reserved for drawing truncation bitmaps,
321 continuation bitmaps and alike. The width is in canonical char
322 units of the frame. This must currently be the case because window
323 sizes aren't pixel values. If it weren't the case, we wouldn't be
324 able to split windows horizontally nicely. */
325 int fringe_cols;
327 /* The extra width (in pixels) currently allotted for fringes. */
328 int left_fringe_width, right_fringe_width;
330 /* See FULLSCREEN_ enum below */
331 int want_fullscreen;
333 /* Number of lines of menu bar. */
334 int menu_bar_lines;
336 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
337 || defined (USE_GTK)
338 /* Nonzero means using a menu bar that comes from the X toolkit. */
339 int external_menu_bar;
340 #endif
342 /* Nonzero if last attempt at redisplay on this frame was preempted. */
343 char display_preempted;
345 /* visible is nonzero if the frame is currently displayed; we check
346 it to see if we should bother updating the frame's contents.
347 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
349 Note that, since invisible frames aren't updated, whenever a
350 frame becomes visible again, it must be marked as garbaged. The
351 FRAME_SAMPLE_VISIBILITY macro takes care of this.
353 On ttys and on Windows NT/9X, to avoid wasting effort updating
354 visible frames that are actually completely obscured by other
355 windows on the display, we bend the meaning of visible slightly:
356 if greater than 1, then the frame is obscured - we still consider
357 it to be "visible" as seen from lisp, but we don't bother
358 updating it. We must take care to garbage the frame when it
359 ceaces to be obscured though.
361 iconified is nonzero if the frame is currently iconified.
363 Asynchronous input handlers should NOT change these directly;
364 instead, they should change async_visible or async_iconified, and
365 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
366 at the next redisplay.
368 These should probably be considered read-only by everyone except
369 FRAME_SAMPLE_VISIBILITY.
371 These two are mutually exclusive. They might both be zero, if the
372 frame has been made invisible without an icon. */
373 char visible, iconified;
375 /* Asynchronous input handlers change these, and
376 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
377 See FRAME_SAMPLE_VISIBILITY, below. */
378 volatile char async_visible, async_iconified;
380 /* Nonzero if this frame should be redrawn. */
381 volatile char garbaged;
383 /* True if frame actually has a minibuffer window on it.
384 0 if using a minibuffer window that isn't on this frame. */
385 char has_minibuffer;
387 /* 0 means, if this frame has just one window,
388 show no modeline for that window. */
389 char wants_modeline;
391 /* Non-zero if the hardware device this frame is displaying on can
392 support scroll bars. */
393 char can_have_scroll_bars;
395 /* Non-0 means raise this frame to the top of the heap when selected. */
396 char auto_raise;
398 /* Non-0 means lower this frame to the bottom of the stack when left. */
399 char auto_lower;
401 /* True if frame's root window can't be split. */
402 char no_split;
404 /* If this is set, then Emacs won't change the frame name to indicate
405 the current buffer, etcetera. If the user explicitly sets the frame
406 name, this gets set. If the user sets the name to Qnil, this is
407 cleared. */
408 char explicit_name;
410 /* Nonzero if size of some window on this frame has changed. */
411 char window_sizes_changed;
413 /* Nonzero if the mouse has moved on this display device
414 since the last time we checked. */
415 char mouse_moved;
417 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
418 actually display them on this frame. */
419 enum vertical_scroll_bar_type vertical_scroll_bar_type;
421 /* What kind of text cursor should we draw in the future?
422 This should always be filled_box_cursor or bar_cursor. */
423 enum text_cursor_kinds desired_cursor;
425 /* Width of bar cursor (if we are using that). */
426 int cursor_width;
428 /* What kind of text cursor should we draw when the cursor blinks off?
429 This can be filled_box_cursor or bar_cursor or no_cursor. */
430 enum text_cursor_kinds blink_off_cursor;
432 /* Width of bar cursor (if we are using that) for blink-off state. */
433 int blink_off_cursor_width;
435 /* Storage for messages to this frame. */
436 char *message_buf;
438 /* Nonnegative if current redisplay should not do scroll computation
439 for lines beyond a certain vpos. This is the vpos. */
440 int scroll_bottom_vpos;
442 /* Configured width of the scroll bar, in pixels and in characters.
443 config_scroll_bar_cols tracks config_scroll_bar_width if the
444 latter is positive; a zero value in config_scroll_bar_width means
445 to compute the actual width on the fly, using config_scroll_bar_cols
446 and the current font width. */
447 int config_scroll_bar_width;
448 int config_scroll_bar_cols;
450 /* The size of the extra width currently allotted for vertical
451 scroll bars in this frame, in pixels. */
452 int scroll_bar_actual_width;
454 /* The baud rate that was used to calculate costs for this frame. */
455 int cost_calculation_baud_rate;
457 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
458 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
459 frame parameter. 0 means don't do gamma correction. */
460 double gamma;
462 /* Additional space to put between text lines on this frame. */
463 int extra_line_spacing;
465 /* All display backends seem to need these two pixel values. */
466 unsigned long background_pixel;
467 unsigned long foreground_pixel;
470 #ifdef MULTI_KBOARD
471 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
472 #else
473 #define FRAME_KBOARD(f) (&the_only_kboard)
474 #endif
476 typedef struct frame *FRAME_PTR;
478 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
479 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
481 /* Given a window, return its frame as a Lisp_Object. */
482 #define WINDOW_FRAME(w) (w)->frame
484 /* Test a frame for particular kinds of display methods. */
485 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
486 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
487 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
488 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
489 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
490 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
492 /* FRAME_WINDOW_P tests whether the frame is a window, and is
493 defined to be the predicate for the window system being used. */
495 #ifdef HAVE_X_WINDOWS
496 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
497 #endif
498 #ifdef HAVE_NTGUI
499 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
500 #endif
501 #ifdef MAC_OS
502 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
503 #endif
504 #ifndef FRAME_WINDOW_P
505 #define FRAME_WINDOW_P(f) (0)
506 #endif
508 /* Nonzero if frame F is still alive (not deleted). */
509 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
511 /* Nonzero if frame F is a minibuffer-only frame. */
512 #define FRAME_MINIBUF_ONLY_P(f) \
513 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
515 /* Nonzero if frame F contains a minibuffer window.
516 (If this is 0, F must use some other minibuffer window.) */
517 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
519 /* Pixel height of frame F, including non-toolkit menu bar and
520 non-toolkit tool bar lines. */
521 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
523 /* Pixel width of frame F. */
524 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
526 /* Height of frame F, measured in canonical lines, including
527 non-toolkit menu bar and non-toolkit tool bar lines. */
528 #define FRAME_LINES(f) (f)->text_lines
530 /* Width of frame F, measured in canonical character columns,
531 not including scroll bars if any. */
532 #define FRAME_COLS(f) (f)->text_cols
534 /* Number of lines of frame F used for menu bar.
535 This is relevant on terminal frames and on
536 X Windows when not using the X toolkit.
537 These lines are counted in FRAME_LINES. */
538 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
540 /* Nonzero if this frame should display a tool bar
541 in a way that does not use any text lines. */
542 #if defined (USE_GTK) || defined (MAC_OS)
543 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
544 #else
545 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
546 #endif
548 /* Number of lines of frame F used for the tool-bar. */
550 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
553 /* Lines above the top-most window in frame F. */
555 #define FRAME_TOP_MARGIN(F) \
556 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
558 /* Nonzero if this frame should display a menu bar
559 in a way that does not use any text lines. */
560 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
561 || defined (USE_GTK)
562 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
563 #else
564 #define FRAME_EXTERNAL_MENU_BAR(f) 0
565 #endif
566 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
568 /* Nonzero if frame F is currently visible but hidden. */
569 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
571 /* Nonzero if frame F is currently iconified. */
572 #define FRAME_ICONIFIED_P(f) (f)->iconified
574 #define FRAME_SET_VISIBLE(f,p) \
575 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
576 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
577 #define FRAME_GARBAGED_P(f) (f)->garbaged
579 /* Nonzero means do not allow splitting this frame's window. */
580 #define FRAME_NO_SPLIT_P(f) (f)->no_split
582 /* Not really implemented. */
583 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
585 /* Nonzero if a size change has been requested for frame F
586 but not yet really put into effect. This can be true temporarily
587 when an X event comes in at a bad time. */
588 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
590 /* The minibuffer window of frame F, if it has one; otherwise nil. */
591 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
593 /* The root window of the window tree of frame F. */
594 #define FRAME_ROOT_WINDOW(f) (f)->root_window
596 /* The currently selected window of the window tree of frame F. */
597 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
599 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
600 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
601 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
602 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
603 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
604 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
605 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
607 /* Nonzero if frame F supports scroll bars.
608 If this is zero, then it is impossible to enable scroll bars
609 on frame F. */
610 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
612 /* This frame slot says whether scroll bars are currently enabled for frame F,
613 and which side they are on. */
614 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
615 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
616 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
617 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
618 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
619 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
620 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
622 /* Width that a scroll bar in frame F should have, if there is one.
623 Measured in pixels.
624 If scroll bars are turned off, this is still nonzero. */
625 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
627 /* Width that a scroll bar in frame F should have, if there is one.
628 Measured in columns (characters).
629 If scroll bars are turned off, this is still nonzero. */
630 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
632 /* Width of a scroll bar in frame F, measured in columns (characters),
633 but only if scroll bars are on the left. If scroll bars are on
634 the right in this frame, or there are no scroll bars, value is 0. */
636 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
637 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
638 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
639 : 0)
641 /* Width of a left scroll bar in frame F, measured in pixels */
643 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
644 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
645 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
646 : 0)
648 /* Width of a scroll bar in frame F, measured in columns (characters),
649 but only if scroll bars are on the right. If scroll bars are on
650 the left in this frame, or there are no scroll bars, value is 0. */
652 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
653 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
654 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
655 : 0)
657 /* Width of a right scroll bar area in frame F, measured in pixels */
659 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
660 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
661 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
662 : 0)
664 /* Actual width of a scroll bar in frame F, measured in columns. */
666 #define FRAME_SCROLL_BAR_COLS(f) \
667 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
668 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
669 : 0)
671 /* Actual width of a scroll bar area in frame F, measured in pixels. */
673 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
674 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
675 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
676 : 0)
678 /* Total width of frame F, in columns (characters),
679 including the width used by scroll bars if any. */
681 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
683 /* Set the width of frame F to VAL.
684 VAL is the width of a full-frame window,
685 not including scroll bars and fringes. */
687 #define SET_FRAME_COLS(f, val) \
688 (FRAME_COLS (f) = (val), \
689 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
691 /* Given a value WIDTH for frame F's nominal width,
692 return the value that FRAME_TOTAL_COLS should have. */
694 #define FRAME_TOTAL_COLS_ARG(f, width) \
695 ((width) \
696 + FRAME_SCROLL_BAR_COLS (f) \
697 + FRAME_FRINGE_COLS (f))
699 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
701 #define FRAME_CURSOR_X_LIMIT(f) \
702 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
704 /* Nonzero if frame F has scroll bars. */
706 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
708 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
709 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
710 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
712 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
713 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
714 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
715 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
717 /* Return a pointer to the face cache of frame F. */
719 #define FRAME_FACE_CACHE(F) (F)->face_cache
721 /* Return the size of message_buf of the frame F. We multiply the
722 width of the frame by 4 because multi-byte form may require at most
723 4-byte for a character. */
725 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
727 /* Emacs's redisplay code could become confused if a frame's
728 visibility changes at arbitrary times. For example, if a frame is
729 visible while the desired glyphs are being built, but becomes
730 invisible before they are updated, then some rows of the
731 desired_glyphs will be left marked as enabled after redisplay is
732 complete, which should never happen. The next time the frame
733 becomes visible, redisplay will probably barf.
735 Currently, there are no similar situations involving iconified, but
736 the principle is the same.
738 So instead of having asynchronous input handlers directly set and
739 clear the frame's visibility and iconification flags, they just set
740 the async_visible and async_iconified flags; the redisplay code
741 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
742 which sets visible and iconified from their asynchronous
743 counterparts.
745 Synchronous code must use the FRAME_SET_VISIBLE macro.
747 Also, if a frame used to be invisible, but has just become visible,
748 it must be marked as garbaged, since redisplay hasn't been keeping
749 up its contents.
751 Note that a tty frame is visible if and only if it is the topmost
752 frame. */
754 #define FRAME_SAMPLE_VISIBILITY(f) \
755 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
756 SET_FRAME_GARBAGED (f) : 0, \
757 (f)->visible = (f)->async_visible, \
758 (f)->iconified = (f)->async_iconified)
760 #define CHECK_FRAME(x) \
761 CHECK_TYPE (FRAMEP (x), Qframep, x)
763 #define CHECK_LIVE_FRAME(x) \
764 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
766 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
767 `for' loop which iterates over the elements of Vframe_list. The
768 loop will set FRAME_VAR, a Lisp_Object, to each frame in
769 Vframe_list in succession and execute the statement. LIST_VAR
770 should be a Lisp_Object too; it is used to iterate through the
771 Vframe_list.
773 This macro is a holdover from a time when multiple frames weren't always
774 supported. An alternate definition of the macro would expand to
775 something which executes the statement once. */
777 #define FOR_EACH_FRAME(list_var, frame_var) \
778 for ((list_var) = Vframe_list; \
779 (CONSP (list_var) \
780 && (frame_var = XCAR (list_var), 1)); \
781 list_var = XCDR (list_var))
784 extern Lisp_Object Qframep, Qframe_live_p;
785 extern Lisp_Object Qtty, Qtty_type;
786 extern Lisp_Object Qterminal, Qterminal_live_p;
788 extern struct frame *last_nonminibuf_frame;
790 extern struct frame *make_initial_frame P_ ((void));
791 extern struct frame *make_terminal_frame P_ ((struct terminal *));
792 extern struct frame *make_frame P_ ((int));
793 #ifdef HAVE_WINDOW_SYSTEM
794 extern struct frame *make_minibuffer_frame P_ ((void));
795 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
796 struct kboard *,
797 Lisp_Object));
798 #endif /* HAVE_WINDOW_SYSTEM */
799 extern int other_visible_frames P_ ((struct frame *));
801 extern Lisp_Object Vframe_list;
802 extern Lisp_Object Vdefault_frame_alist;
804 extern Lisp_Object Vterminal_frame;
806 extern Lisp_Object Vmouse_highlight;
808 /* The currently selected frame. */
810 extern Lisp_Object selected_frame;
812 /* Value is a pointer to the selected frame. If the selected frame
813 isn't live, abort. */
815 #define SELECTED_FRAME() \
816 ((FRAMEP (selected_frame) \
817 && FRAME_LIVE_P (XFRAME (selected_frame))) \
818 ? XFRAME (selected_frame) \
819 : (abort (), (struct frame *) 0))
822 /***********************************************************************
823 Display-related Macros
824 ***********************************************************************/
826 /* Canonical y-unit on frame F.
827 This value currently equals the line height of the frame (which is
828 the height of the default font of F). */
830 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
832 /* Canonical x-unit on frame F.
833 This value currently equals the average width of the default font of F. */
835 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
837 /* Space glyph width of the default font of frame F. */
839 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
842 /* Pixel width of areas used to display truncation marks, continuation
843 marks, overlay arrows. This is 0 for terminal frames. */
845 #ifdef HAVE_WINDOW_SYSTEM
847 /* Total width of fringes reserved for drawing truncation bitmaps,
848 continuation bitmaps and alike. The width is in canonical char
849 units of the frame. This must currently be the case because window
850 sizes aren't pixel values. If it weren't the case, we wouldn't be
851 able to split windows horizontally nicely. */
853 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
855 /* Pixel-width of the left and right fringe. */
857 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
858 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
860 /* Total width of fringes in pixels. */
862 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
863 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
866 /* Pixel-width of internal border lines */
868 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
870 #else /* not HAVE_WINDOW_SYSTEM */
872 #define FRAME_FRINGE_COLS(F) 0
873 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
874 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
875 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
876 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
878 #endif /* not HAVE_WINDOW_SYSTEM */
883 /***********************************************************************
884 Conversion between canonical units and pixels
885 ***********************************************************************/
887 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
888 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
889 represented as Lisp numbers, i.e. integers or floats. */
891 /* Convert canonical value X to pixels. F is the frame whose
892 canonical char width is to be used. X must be a Lisp integer or
893 float. Value is a C integer. */
895 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
896 (INTEGERP (X) \
897 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
898 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
900 /* Convert canonical value Y to pixels. F is the frame whose
901 canonical character height is to be used. X must be a Lisp integer
902 or float. Value is a C integer. */
904 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
905 (INTEGERP (Y) \
906 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
907 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
909 /* Convert pixel-value X to canonical units. F is the frame whose
910 canonical character width is to be used. X is a C integer. Result
911 is a Lisp float if X is not a multiple of the canon width,
912 otherwise it's a Lisp integer. */
914 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
915 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
916 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
917 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
919 /* Convert pixel-value Y to canonical units. F is the frame whose
920 canonical character height is to be used. Y is a C integer.
921 Result is a Lisp float if Y is not a multiple of the canon width,
922 otherwise it's a Lisp integer. */
924 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
925 ((Y) % FRAME_LINE_HEIGHT (F) \
926 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
927 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
931 /* Manipulating pixel sizes and character sizes.
932 Knowledge of which factors affect the overall size of the window should
933 be hidden in these macros, if that's possible.
935 Return the upper/left pixel position of the character cell on frame F
936 at ROW/COL. */
938 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
939 (FRAME_INTERNAL_BORDER_WIDTH (f) \
940 + (row) * FRAME_LINE_HEIGHT (f))
942 #define FRAME_COL_TO_PIXEL_X(f, col) \
943 (FRAME_INTERNAL_BORDER_WIDTH (f) \
944 + (col) * FRAME_COLUMN_WIDTH (f))
946 /* Return the pixel width/height of frame F if it has
947 COLS columns/LINES rows. */
949 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
950 (FRAME_COL_TO_PIXEL_X (f, cols) \
951 + (f)->scroll_bar_actual_width \
952 + FRAME_TOTAL_FRINGE_WIDTH (f) \
953 + FRAME_INTERNAL_BORDER_WIDTH (f))
955 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
956 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
957 + FRAME_INTERNAL_BORDER_WIDTH (f))
960 /* Return the row/column (zero-based) of the character cell containing
961 the pixel on FRAME at Y/X. */
963 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
964 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
965 / FRAME_LINE_HEIGHT (f))
967 #define FRAME_PIXEL_X_TO_COL(f, x) \
968 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
969 / FRAME_COLUMN_WIDTH (f))
971 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
972 frame F? */
974 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
975 (FRAME_PIXEL_X_TO_COL (f, ((width) \
976 - FRAME_INTERNAL_BORDER_WIDTH (f) \
977 - FRAME_TOTAL_FRINGE_WIDTH (f) \
978 - (f)->scroll_bar_actual_width)))
980 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
981 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
982 - FRAME_INTERNAL_BORDER_WIDTH (f))))
985 /***********************************************************************
986 Frame Parameters
987 ***********************************************************************/
989 extern Lisp_Object Qauto_raise, Qauto_lower;
990 extern Lisp_Object Qborder_color, Qborder_width;
991 extern Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
992 extern Lisp_Object Qcursor_color, Qcursor_type;
993 extern Lisp_Object Qfont;
994 extern Lisp_Object Qbackground_color, Qforeground_color;
995 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
996 extern Lisp_Object Qinternal_border_width;
997 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
998 extern Lisp_Object Qmouse_color;
999 extern Lisp_Object Qname, Qtitle;
1000 extern Lisp_Object Qparent_id;
1001 extern Lisp_Object Qunsplittable, Qvisibility;
1002 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1003 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1004 extern Lisp_Object Qscreen_gamma;
1005 extern Lisp_Object Qline_spacing;
1006 extern Lisp_Object Qwait_for_wm;
1007 extern Lisp_Object Qfullscreen;
1009 extern Lisp_Object Qleft_fringe, Qright_fringe;
1010 extern Lisp_Object Qheight, Qwidth;
1011 extern Lisp_Object Qminibuffer, Qmodeline;
1012 extern Lisp_Object Qonly;
1013 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
1014 extern Lisp_Object Qvisible;
1015 extern Lisp_Object Qdisplay_type;
1016 extern Lisp_Object Qbackground_mode;
1018 extern Lisp_Object Qx_resource_name;
1020 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1021 extern Lisp_Object Qdisplay;
1023 #ifdef HAVE_WINDOW_SYSTEM
1025 /* The class of this X application. */
1026 #define EMACS_CLASS "Emacs"
1028 enum
1030 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1031 FULLSCREEN_NONE = 0,
1032 FULLSCREEN_WIDTH = 1,
1033 FULLSCREEN_HEIGHT = 2,
1034 FULLSCREEN_BOTH = 3,
1035 FULLSCREEN_WAIT = 4
1039 /* These are in xterm.c, w32term.c, etc. */
1041 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1042 extern void x_set_offset P_ ((struct frame *, int, int, int));
1043 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1045 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1046 extern Lisp_Object x_new_fontset P_ ((struct frame *, char *));
1049 /* These are in frame.c */
1051 extern Lisp_Object Vx_resource_name;
1052 extern Lisp_Object Vx_resource_class;
1055 extern Lisp_Object Qface_set_after_frame_default;
1057 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1058 int *, int *));
1060 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1061 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1063 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1064 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1065 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1066 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1067 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1068 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1069 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1070 Lisp_Object));
1071 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1072 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1073 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1074 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1075 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1076 Lisp_Object));
1077 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1078 Lisp_Object));
1080 extern Lisp_Object x_icon_type P_ ((struct frame *));
1082 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1085 extern void validate_x_resource_name P_ ((void));
1087 #endif /* HAVE_WINDOW_SYSTEM */
1089 #endif /* not EMACS_FRAME_H */
1091 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1092 (do not change this comment) */