Merge from emacs--devo--0
[emacs.git] / src / frame.h
blobe9be84d8558d0ab7f6831e6571d1c100b0dca46a
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 #ifdef USE_FONT_BACKEND
81 struct font_driver_list;
82 #endif /* USE_FONT_BACKEND */
84 struct frame
86 EMACS_UINT size;
87 struct Lisp_Vector *next;
89 /* All Lisp_Object components must come first.
90 That ensures they are all aligned normally. */
92 /* Name of this frame: a Lisp string. It is used for looking up resources,
93 as well as for the title in some cases. */
94 Lisp_Object name;
96 /* The name to use for the icon, the last time
97 it was refreshed. nil means not explicitly specified. */
98 Lisp_Object icon_name;
100 /* This is the frame title specified explicitly, if any.
101 Usually it is nil. */
102 Lisp_Object title;
104 /* The frame which should receive keystrokes that occur in this
105 frame, or nil if they should go to the frame itself. This is
106 usually nil, but if the frame is minibufferless, we can use this
107 to redirect keystrokes to a surrogate minibuffer frame when
108 needed.
110 Note that a value of nil is different than having the field point
111 to the frame itself. Whenever the Fselect_frame function is used
112 to shift from one frame to the other, any redirections to the
113 original frame are shifted to the newly selected frame; if
114 focus_frame is nil, Fselect_frame will leave it alone. */
115 Lisp_Object focus_frame;
117 /* This frame's root window. Every frame has one.
118 If the frame has only a minibuffer window, this is it.
119 Otherwise, if the frame has a minibuffer window, this is its sibling. */
120 Lisp_Object root_window;
122 /* This frame's selected window.
123 Each frame has its own window hierarchy
124 and one of the windows in it is selected within the frame.
125 The selected window of the selected frame is Emacs's selected window. */
126 Lisp_Object selected_window;
128 /* This frame's minibuffer window.
129 Most frames have their own minibuffer windows,
130 but only the selected frame's minibuffer window
131 can actually appear to exist. */
132 Lisp_Object minibuffer_window;
134 /* Parameter alist of this frame.
135 These are the parameters specified when creating the frame
136 or modified with modify-frame-parameters. */
137 Lisp_Object param_alist;
139 /* List of scroll bars on this frame.
140 Actually, we don't specify exactly what is stored here at all; the
141 scroll bar implementation code can use it to store anything it likes.
142 This field is marked by the garbage collector. It is here
143 instead of in the `device' structure so that the garbage
144 collector doesn't need to look inside the window-system-dependent
145 structure. */
146 Lisp_Object scroll_bars;
147 Lisp_Object condemned_scroll_bars;
149 /* Vector describing the items to display in the menu bar.
150 Each item has four elements in this vector.
151 They are KEY, STRING, SUBMAP, and HPOS.
152 (HPOS is not used in when the X toolkit is in use.)
153 There are four additional elements of nil at the end, to terminate. */
154 Lisp_Object menu_bar_items;
156 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
157 Lisp_Object face_alist;
159 /* A vector that records the entire structure of this frame's menu bar.
160 For the format of the data, see extensive comments in xmenu.c.
161 Only the X toolkit version uses this. */
162 Lisp_Object menu_bar_vector;
164 /* Predicate for selecting buffers for other-buffer. */
165 Lisp_Object buffer_predicate;
167 /* List of buffers viewed in this frame, for other-buffer. */
168 Lisp_Object buffer_list;
170 /* List of buffers that were viewed, then buried in this frame. The
171 most recently buried buffer is first. For last-buffer. */
172 Lisp_Object buried_buffer_list;
174 /* A dummy window used to display menu bars under X when no X
175 toolkit support is available. */
176 Lisp_Object menu_bar_window;
178 /* A window used to display the tool-bar of a frame. */
179 Lisp_Object tool_bar_window;
181 /* Desired and current tool-bar items. */
182 Lisp_Object tool_bar_items;
184 /* Desired and current contents displayed in tool_bar_window. */
185 Lisp_Object desired_tool_bar_string, current_tool_bar_string;
187 /* Beyond here, there should be no more Lisp_Object components. */
189 /* Cache of realized faces. */
190 struct face_cache *face_cache;
192 /* Number of elements in `menu_bar_vector' that have meaningful data. */
193 EMACS_INT menu_bar_items_used;
195 /* A buffer to hold the frame's name. We can't use the Lisp
196 string's pointer (`name', above) because it might get relocated. */
197 char *namebuf;
199 /* Glyph pool and matrix. */
200 struct glyph_pool *current_pool;
201 struct glyph_pool *desired_pool;
202 struct glyph_matrix *desired_matrix;
203 struct glyph_matrix *current_matrix;
205 /* 1 means that glyphs on this frame have been initialized so it can
206 be used for output. */
207 unsigned glyphs_initialized_p : 1;
209 #if defined (USE_GTK) || defined (MAC_OS)
210 /* Nonzero means using a tool bar that comes from the toolkit. */
211 int external_tool_bar;
212 #endif
214 /* Margin at the top of the frame. Used to display the tool-bar. */
215 int tool_bar_lines;
217 int n_tool_bar_rows;
218 int n_tool_bar_items;
220 /* A buffer for decode_mode_line. */
221 char *decode_mode_spec_buffer;
223 /* See do_line_insertion_deletion_costs for info on these arrays. */
224 /* Cost of inserting 1 line on this frame */
225 int *insert_line_cost;
226 /* Cost of deleting 1 line on this frame */
227 int *delete_line_cost;
228 /* Cost of inserting n lines on this frame */
229 int *insert_n_lines_cost;
230 /* Cost of deleting n lines on this frame */
231 int *delete_n_lines_cost;
233 /* Size of this frame, excluding fringes, scroll bars etc.,
234 in units of canonical characters. */
235 EMACS_INT text_lines, text_cols;
237 /* Total size of this frame (i.e. its native window), in units of
238 canonical characters. */
239 EMACS_INT total_lines, total_cols;
241 /* New text height and width for pending size change.
242 0 if no change pending. */
243 int new_text_lines, new_text_cols;
245 /* Pixel position of the frame window (x and y offsets in root window). */
246 int left_pos, top_pos;
248 /* Size of the frame window in pixels. */
249 int pixel_height, pixel_width;
251 /* Dots per inch of the screen the frame is on. */
252 double resx, resy;
254 /* These many pixels are the difference between the outer window (i.e. the
255 left and top of the window manager decoration) and FRAME_X_WINDOW. */
256 int x_pixels_diff, y_pixels_diff;
258 /* This is the gravity value for the specified window position. */
259 int win_gravity;
261 /* The geometry flags for this window. */
262 int size_hint_flags;
264 /* Border width of the frame window as known by the (X) window system. */
265 int border_width;
267 /* Width of the internal border. This is a line of background color
268 just inside the window's border. When the frame is selected,
269 a highlighting is displayed inside the internal border. */
270 int internal_border_width;
272 /* Canonical X unit. Width of default font, in pixels. */
273 int column_width;
275 /* Widht of space glyph of default font, in pixels. */
276 int space_width;
278 /* Canonical Y unit. Height of a line, in pixels. */
279 int line_height;
281 /* The output method says how the contents of this frame are
282 displayed. It could be using termcap, or using an X window.
283 This must be the same as the terminal->type. */
284 enum output_method output_method;
286 /* The terminal device that this frame uses. If this is NULL, then
287 the frame has been deleted. */
288 struct terminal *terminal;
290 /* Device-dependent, frame-local auxiliary data used for displaying
291 the contents. When the frame is deleted, this data is deleted as
292 well. */
293 union output_data
295 struct tty_output *tty; /* termchar.h */
296 struct x_output *x; /* xterm.h */
297 struct w32_output *w32; /* w32term.h */
298 struct mac_output *mac; /* macterm.h */
299 EMACS_INT nothing;
301 output_data;
303 #ifdef USE_FONT_BACKEND
304 /* List of font-drivers available on the frame. */
305 struct font_driver_list *font_driver_list;
306 #endif /* USE_FONT_BACKEND */
308 /* Total width of fringes reserved for drawing truncation bitmaps,
309 continuation bitmaps and alike. The width is in canonical char
310 units of the frame. This must currently be the case because window
311 sizes aren't pixel values. If it weren't the case, we wouldn't be
312 able to split windows horizontally nicely. */
313 int fringe_cols;
315 /* The extra width (in pixels) currently allotted for fringes. */
316 int left_fringe_width, right_fringe_width;
318 /* See FULLSCREEN_ enum below */
319 int want_fullscreen;
321 /* Number of lines of menu bar. */
322 int menu_bar_lines;
324 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
325 || defined (USE_GTK)
326 /* Nonzero means using a menu bar that comes from the X toolkit. */
327 int external_menu_bar;
328 #endif
330 /* Nonzero if last attempt at redisplay on this frame was preempted. */
331 char display_preempted;
333 /* visible is nonzero if the frame is currently displayed; we check
334 it to see if we should bother updating the frame's contents.
335 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
337 Note that, since invisible frames aren't updated, whenever a
338 frame becomes visible again, it must be marked as garbaged. The
339 FRAME_SAMPLE_VISIBILITY macro takes care of this.
341 On ttys and on Windows NT/9X, to avoid wasting effort updating
342 visible frames that are actually completely obscured by other
343 windows on the display, we bend the meaning of visible slightly:
344 if greater than 1, then the frame is obscured - we still consider
345 it to be "visible" as seen from lisp, but we don't bother
346 updating it. We must take care to garbage the frame when it
347 ceaces to be obscured though.
349 iconified is nonzero if the frame is currently iconified.
351 Asynchronous input handlers should NOT change these directly;
352 instead, they should change async_visible or async_iconified, and
353 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
354 at the next redisplay.
356 These should probably be considered read-only by everyone except
357 FRAME_SAMPLE_VISIBILITY.
359 These two are mutually exclusive. They might both be zero, if the
360 frame has been made invisible without an icon. */
361 char visible, iconified;
363 /* Asynchronous input handlers change these, and
364 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
365 See FRAME_SAMPLE_VISIBILITY, below. */
366 volatile char async_visible, async_iconified;
368 /* Nonzero if this frame should be redrawn. */
369 volatile char garbaged;
371 /* True if frame actually has a minibuffer window on it.
372 0 if using a minibuffer window that isn't on this frame. */
373 char has_minibuffer;
375 /* 0 means, if this frame has just one window,
376 show no modeline for that window. */
377 char wants_modeline;
379 /* Non-zero if the hardware device this frame is displaying on can
380 support scroll bars. */
381 char can_have_scroll_bars;
383 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
384 actually display them on this frame. */
385 enum vertical_scroll_bar_type vertical_scroll_bar_type;
387 /* What kind of text cursor should we draw in the future?
388 This should always be filled_box_cursor or bar_cursor. */
389 enum text_cursor_kinds desired_cursor;
391 /* Width of bar cursor (if we are using that). */
392 int cursor_width;
394 /* What kind of text cursor should we draw when the cursor blinks off?
395 This can be filled_box_cursor or bar_cursor or no_cursor. */
396 enum text_cursor_kinds blink_off_cursor;
398 /* Width of bar cursor (if we are using that) for blink-off state. */
399 int blink_off_cursor_width;
401 /* Non-0 means raise this frame to the top of the heap when selected. */
402 char auto_raise;
404 /* Non-0 means lower this frame to the bottom of the stack when left. */
405 char auto_lower;
407 /* True if frame's root window can't be split. */
408 char no_split;
410 /* If this is set, then Emacs won't change the frame name to indicate
411 the current buffer, etcetera. If the user explicitly sets the frame
412 name, this gets set. If the user sets the name to Qnil, this is
413 cleared. */
414 char explicit_name;
416 /* Nonzero if size of some window on this frame has changed. */
417 char window_sizes_changed;
419 /* Storage for messages to this frame. */
420 char *message_buf;
422 /* Nonnegative if current redisplay should not do scroll computation
423 for lines beyond a certain vpos. This is the vpos. */
424 int scroll_bottom_vpos;
426 /* Configured width of the scroll bar, in pixels and in characters.
427 config_scroll_bar_cols tracks config_scroll_bar_width if the
428 latter is positive; a zero value in config_scroll_bar_width means
429 to compute the actual width on the fly, using config_scroll_bar_cols
430 and the current font width. */
431 int config_scroll_bar_width;
432 int config_scroll_bar_cols;
434 /* The size of the extra width currently allotted for vertical
435 scroll bars in this frame, in pixels. */
436 int scroll_bar_actual_width;
438 /* The baud rate that was used to calculate costs for this frame. */
439 int cost_calculation_baud_rate;
441 /* Nonzero if the mouse has moved on this display device
442 since the last time we checked. */
443 char mouse_moved;
445 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
446 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
447 frame parameter. 0 means don't do gamma correction. */
448 double gamma;
450 /* Additional space to put between text lines on this frame. */
451 int extra_line_spacing;
453 /* Set to non-zero in change_frame_size when size of frame changed
454 Clear the frame in clear_garbaged_frames if set. */
455 unsigned resized_p : 1;
457 /* Set to non-zero in when we want for force a flush_display in
458 update_frame, usually after resizing the frame. */
459 unsigned force_flush_display_p : 1;
461 /* All display backends seem to need these two pixel values. */
462 unsigned long background_pixel;
463 unsigned long foreground_pixel;
465 /* Set to non-zero if the default face for the frame has been
466 realized. Reset to zero whenever the default face changes.
467 Used to see the difference between a font change and face change. */
468 unsigned default_face_done_p : 1;
470 /* Set to non-zero if this frame has already been hscrolled during
471 current redisplay. */
472 unsigned already_hscrolled_p : 1;
474 /* Set to non-zero when current redisplay has updated frame. */
475 unsigned updated_p : 1;
477 /* Set to non-zero to minimize tool-bar height even when
478 auto-resize-tool-bar is set to grow-only. */
479 unsigned minimize_tool_bar_window_p : 1;
482 #ifdef MULTI_KBOARD
483 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
484 #else
485 #define FRAME_KBOARD(f) (&the_only_kboard)
486 #endif
488 typedef struct frame *FRAME_PTR;
490 #define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p))
491 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
493 /* Given a window, return its frame as a Lisp_Object. */
494 #define WINDOW_FRAME(w) (w)->frame
496 /* Test a frame for particular kinds of display methods. */
497 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
498 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
499 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
500 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
501 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
502 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
504 /* FRAME_WINDOW_P tests whether the frame is a window, and is
505 defined to be the predicate for the window system being used. */
507 #ifdef HAVE_X_WINDOWS
508 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
509 #endif
510 #ifdef HAVE_NTGUI
511 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
512 #endif
513 #ifdef MAC_OS
514 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
515 #endif
516 #ifndef FRAME_WINDOW_P
517 #define FRAME_WINDOW_P(f) (0)
518 #endif
520 /* Nonzero if frame F is still alive (not deleted). */
521 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
523 /* Nonzero if frame F is a minibuffer-only frame. */
524 #define FRAME_MINIBUF_ONLY_P(f) \
525 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
527 /* Nonzero if frame F contains a minibuffer window.
528 (If this is 0, F must use some other minibuffer window.) */
529 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
531 /* Pixel height of frame F, including non-toolkit menu bar and
532 non-toolkit tool bar lines. */
533 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
535 /* Pixel width of frame F. */
536 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
538 /* Height of frame F, measured in canonical lines, including
539 non-toolkit menu bar and non-toolkit tool bar lines. */
540 #define FRAME_LINES(f) (f)->text_lines
542 /* Width of frame F, measured in canonical character columns,
543 not including scroll bars if any. */
544 #define FRAME_COLS(f) (f)->text_cols
546 /* Number of lines of frame F used for menu bar.
547 This is relevant on terminal frames and on
548 X Windows when not using the X toolkit.
549 These lines are counted in FRAME_LINES. */
550 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
552 /* Nonzero if this frame should display a tool bar
553 in a way that does not use any text lines. */
554 #if defined (USE_GTK) || defined (MAC_OS)
555 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
556 #else
557 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
558 #endif
560 /* Number of lines of frame F used for the tool-bar. */
562 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
565 /* Lines above the top-most window in frame F. */
567 #define FRAME_TOP_MARGIN(F) \
568 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
570 /* Nonzero if this frame should display a menu bar
571 in a way that does not use any text lines. */
572 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
573 || defined (USE_GTK)
574 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
575 #else
576 #define FRAME_EXTERNAL_MENU_BAR(f) 0
577 #endif
578 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
580 /* Nonzero if frame F is currently visible but hidden. */
581 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
583 /* Nonzero if frame F is currently iconified. */
584 #define FRAME_ICONIFIED_P(f) (f)->iconified
586 #define FRAME_SET_VISIBLE(f,p) \
587 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
588 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
589 #define FRAME_GARBAGED_P(f) (f)->garbaged
591 /* Nonzero means do not allow splitting this frame's window. */
592 #define FRAME_NO_SPLIT_P(f) (f)->no_split
594 /* Not really implemented. */
595 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
597 /* Nonzero if a size change has been requested for frame F
598 but not yet really put into effect. This can be true temporarily
599 when an X event comes in at a bad time. */
600 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
602 /* The minibuffer window of frame F, if it has one; otherwise nil. */
603 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
605 /* The root window of the window tree of frame F. */
606 #define FRAME_ROOT_WINDOW(f) (f)->root_window
608 /* The currently selected window of the window tree of frame F. */
609 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
611 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
612 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
613 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
614 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
615 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
616 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
617 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
619 /* Nonzero if frame F supports scroll bars.
620 If this is zero, then it is impossible to enable scroll bars
621 on frame F. */
622 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
624 /* This frame slot says whether scroll bars are currently enabled for frame F,
625 and which side they are on. */
626 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
627 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
628 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
629 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
630 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
631 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
632 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
634 /* Width that a scroll bar in frame F should have, if there is one.
635 Measured in pixels.
636 If scroll bars are turned off, this is still nonzero. */
637 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
639 /* Width that a scroll bar in frame F should have, if there is one.
640 Measured in columns (characters).
641 If scroll bars are turned off, this is still nonzero. */
642 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
644 /* Width of a scroll bar in frame F, measured in columns (characters),
645 but only if scroll bars are on the left. If scroll bars are on
646 the right in this frame, or there are no scroll bars, value is 0. */
648 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
649 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
650 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
651 : 0)
653 /* Width of a left scroll bar in frame F, measured in pixels */
655 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
656 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
657 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
658 : 0)
660 /* Width of a scroll bar in frame F, measured in columns (characters),
661 but only if scroll bars are on the right. If scroll bars are on
662 the left in this frame, or there are no scroll bars, value is 0. */
664 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
665 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
666 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
667 : 0)
669 /* Width of a right scroll bar area in frame F, measured in pixels */
671 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
672 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
673 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
674 : 0)
676 /* Actual width of a scroll bar in frame F, measured in columns. */
678 #define FRAME_SCROLL_BAR_COLS(f) \
679 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
680 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
681 : 0)
683 /* Actual width of a scroll bar area in frame F, measured in pixels. */
685 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
686 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
687 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
688 : 0)
690 /* Total width of frame F, in columns (characters),
691 including the width used by scroll bars if any. */
693 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
695 /* Set the width of frame F to VAL.
696 VAL is the width of a full-frame window,
697 not including scroll bars and fringes. */
699 #define SET_FRAME_COLS(f, val) \
700 (FRAME_COLS (f) = (val), \
701 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
703 /* Given a value WIDTH for frame F's nominal width,
704 return the value that FRAME_TOTAL_COLS should have. */
706 #define FRAME_TOTAL_COLS_ARG(f, width) \
707 ((width) \
708 + FRAME_SCROLL_BAR_COLS (f) \
709 + FRAME_FRINGE_COLS (f))
711 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
713 #define FRAME_CURSOR_X_LIMIT(f) \
714 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
716 /* Nonzero if frame F has scroll bars. */
718 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
720 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
721 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
722 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
724 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
725 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
726 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
727 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
729 /* Return a pointer to the face cache of frame F. */
731 #define FRAME_FACE_CACHE(F) (F)->face_cache
733 /* Return the size of message_buf of the frame F. We multiply the
734 width of the frame by 4 because multi-byte form may require at most
735 4-byte for a character. */
737 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
739 /* Emacs's redisplay code could become confused if a frame's
740 visibility changes at arbitrary times. For example, if a frame is
741 visible while the desired glyphs are being built, but becomes
742 invisible before they are updated, then some rows of the
743 desired_glyphs will be left marked as enabled after redisplay is
744 complete, which should never happen. The next time the frame
745 becomes visible, redisplay will probably barf.
747 Currently, there are no similar situations involving iconified, but
748 the principle is the same.
750 So instead of having asynchronous input handlers directly set and
751 clear the frame's visibility and iconification flags, they just set
752 the async_visible and async_iconified flags; the redisplay code
753 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
754 which sets visible and iconified from their asynchronous
755 counterparts.
757 Synchronous code must use the FRAME_SET_VISIBLE macro.
759 Also, if a frame used to be invisible, but has just become visible,
760 it must be marked as garbaged, since redisplay hasn't been keeping
761 up its contents.
763 Note that a tty frame is visible if and only if it is the topmost
764 frame. */
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;
797 extern Lisp_Object Qtty, Qtty_type;
798 extern Lisp_Object Qterminal, Qterminal_live_p;
800 extern struct frame *last_nonminibuf_frame;
802 extern struct frame *make_initial_frame P_ ((void));
803 extern struct frame *make_terminal_frame P_ ((struct terminal *));
804 extern struct frame *make_frame P_ ((int));
805 #ifdef HAVE_WINDOW_SYSTEM
806 extern struct frame *make_minibuffer_frame P_ ((void));
807 extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object,
808 struct kboard *,
809 Lisp_Object));
810 #endif /* HAVE_WINDOW_SYSTEM */
811 extern int other_visible_frames P_ ((struct frame *));
813 extern Lisp_Object Vframe_list;
814 extern Lisp_Object Vdefault_frame_alist;
816 extern Lisp_Object Vterminal_frame;
818 extern Lisp_Object Vmouse_highlight;
820 /* The currently selected frame. */
822 extern Lisp_Object selected_frame;
824 /* Value is a pointer to the selected frame. If the selected frame
825 isn't live, abort. */
827 #define SELECTED_FRAME() \
828 ((FRAMEP (selected_frame) \
829 && FRAME_LIVE_P (XFRAME (selected_frame))) \
830 ? XFRAME (selected_frame) \
831 : (abort (), (struct frame *) 0))
834 /***********************************************************************
835 Display-related Macros
836 ***********************************************************************/
838 /* Canonical y-unit on frame F.
839 This value currently equals the line height of the frame (which is
840 the height of the default font of F). */
842 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
844 /* Canonical x-unit on frame F.
845 This value currently equals the average width of the default font of F. */
847 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
849 /* Space glyph width of the default font of frame F. */
851 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
854 /* Pixel width of areas used to display truncation marks, continuation
855 marks, overlay arrows. This is 0 for terminal frames. */
857 #ifdef HAVE_WINDOW_SYSTEM
859 /* Total width of fringes reserved for drawing truncation bitmaps,
860 continuation bitmaps and alike. The width is in canonical char
861 units of the frame. This must currently be the case because window
862 sizes aren't pixel values. If it weren't the case, we wouldn't be
863 able to split windows horizontally nicely. */
865 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
867 /* Pixel-width of the left and right fringe. */
869 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
870 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
872 /* Total width of fringes in pixels. */
874 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
875 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
878 /* Pixel-width of internal border lines */
880 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
882 #else /* not HAVE_WINDOW_SYSTEM */
884 #define FRAME_FRINGE_COLS(F) 0
885 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
886 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
887 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
888 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
890 #endif /* not HAVE_WINDOW_SYSTEM */
895 /***********************************************************************
896 Conversion between canonical units and pixels
897 ***********************************************************************/
899 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
900 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
901 represented as Lisp numbers, i.e. integers or floats. */
903 /* Convert canonical value X to pixels. F is the frame whose
904 canonical char width is to be used. X must be a Lisp integer or
905 float. Value is a C integer. */
907 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
908 (INTEGERP (X) \
909 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
910 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
912 /* Convert canonical value Y to pixels. F is the frame whose
913 canonical character height is to be used. X must be a Lisp integer
914 or float. Value is a C integer. */
916 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
917 (INTEGERP (Y) \
918 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
919 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
921 /* Convert pixel-value X to canonical units. F is the frame whose
922 canonical character width is to be used. X is a C integer. Result
923 is a Lisp float if X is not a multiple of the canon width,
924 otherwise it's a Lisp integer. */
926 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
927 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
928 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
929 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
931 /* Convert pixel-value Y to canonical units. F is the frame whose
932 canonical character height is to be used. Y is a C integer.
933 Result is a Lisp float if Y is not a multiple of the canon width,
934 otherwise it's a Lisp integer. */
936 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
937 ((Y) % FRAME_LINE_HEIGHT (F) \
938 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
939 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
943 /* Manipulating pixel sizes and character sizes.
944 Knowledge of which factors affect the overall size of the window should
945 be hidden in these macros, if that's possible.
947 Return the upper/left pixel position of the character cell on frame F
948 at ROW/COL. */
950 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
951 (FRAME_INTERNAL_BORDER_WIDTH (f) \
952 + (row) * FRAME_LINE_HEIGHT (f))
954 #define FRAME_COL_TO_PIXEL_X(f, col) \
955 (FRAME_INTERNAL_BORDER_WIDTH (f) \
956 + (col) * FRAME_COLUMN_WIDTH (f))
958 /* Return the pixel width/height of frame F if it has
959 COLS columns/LINES rows. */
961 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
962 (FRAME_COL_TO_PIXEL_X (f, cols) \
963 + (f)->scroll_bar_actual_width \
964 + FRAME_TOTAL_FRINGE_WIDTH (f) \
965 + FRAME_INTERNAL_BORDER_WIDTH (f))
967 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
968 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
969 + FRAME_INTERNAL_BORDER_WIDTH (f))
972 /* Return the row/column (zero-based) of the character cell containing
973 the pixel on FRAME at Y/X. */
975 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
976 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
977 / FRAME_LINE_HEIGHT (f))
979 #define FRAME_PIXEL_X_TO_COL(f, x) \
980 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
981 / FRAME_COLUMN_WIDTH (f))
983 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
984 frame F? */
986 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
987 (FRAME_PIXEL_X_TO_COL (f, ((width) \
988 - FRAME_INTERNAL_BORDER_WIDTH (f) \
989 - FRAME_TOTAL_FRINGE_WIDTH (f) \
990 - (f)->scroll_bar_actual_width)))
992 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
993 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
994 - FRAME_INTERNAL_BORDER_WIDTH (f))))
997 /***********************************************************************
998 Frame Parameters
999 ***********************************************************************/
1001 extern Lisp_Object Qauto_raise, Qauto_lower;
1002 extern Lisp_Object Qborder_color, Qborder_width;
1003 extern Lisp_Object Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list;
1004 extern Lisp_Object Qcursor_color, Qcursor_type;
1005 extern Lisp_Object Qfont;
1006 extern Lisp_Object Qbackground_color, Qforeground_color;
1007 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1008 extern Lisp_Object Qinternal_border_width;
1009 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines;
1010 extern Lisp_Object Qmouse_color;
1011 extern Lisp_Object Qname, Qtitle;
1012 extern Lisp_Object Qparent_id;
1013 extern Lisp_Object Qunsplittable, Qvisibility;
1014 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1015 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1016 extern Lisp_Object Qscreen_gamma;
1017 extern Lisp_Object Qline_spacing;
1018 extern Lisp_Object Qwait_for_wm;
1019 extern Lisp_Object Qfullscreen;
1020 extern Lisp_Object Qfont_backend;
1022 extern Lisp_Object Qleft_fringe, Qright_fringe;
1023 extern Lisp_Object Qheight, Qwidth;
1024 extern Lisp_Object Qminibuffer, Qmodeline;
1025 extern Lisp_Object Qonly;
1026 extern Lisp_Object Qx, Qw32, Qmac, Qpc;
1027 extern Lisp_Object Qvisible;
1028 extern Lisp_Object Qdisplay_type;
1029 extern Lisp_Object Qbackground_mode;
1031 extern Lisp_Object Qx_resource_name;
1033 extern Lisp_Object Qleft, Qright, Qtop, Qbox;
1034 extern Lisp_Object Qdisplay;
1036 extern Lisp_Object Qwindow_system;
1038 #ifdef HAVE_WINDOW_SYSTEM
1040 /* The class of this X application. */
1041 #define EMACS_CLASS "Emacs"
1043 enum
1045 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1046 FULLSCREEN_NONE = 0,
1047 FULLSCREEN_WIDTH = 1,
1048 FULLSCREEN_HEIGHT = 2,
1049 FULLSCREEN_BOTH = 3,
1050 FULLSCREEN_WAIT = 4
1054 /* These are in xterm.c, w32term.c, etc. */
1056 extern void x_set_scroll_bar_default_width P_ ((struct frame *));
1057 extern void x_set_offset P_ ((struct frame *, int, int, int));
1058 extern void x_wm_set_icon_position P_ ((struct frame *, int, int));
1060 extern Lisp_Object x_new_font P_ ((struct frame *, char *));
1061 extern Lisp_Object x_new_fontset P_ ((struct frame *, Lisp_Object));
1062 #ifdef USE_FONT_BACKEND
1063 extern Lisp_Object x_new_fontset2 P_ ((struct frame *, int, Lisp_Object));
1064 #endif /* USE_FONT_BACKEND */
1066 /* These are in frame.c */
1068 extern Lisp_Object Vx_resource_name;
1069 extern Lisp_Object Vx_resource_class;
1072 extern Lisp_Object Qface_set_after_frame_default;
1074 extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *,
1075 int *, int *));
1077 extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object));
1078 extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *));
1080 extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));
1081 extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));
1082 extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));
1083 extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));
1084 extern void x_set_font_backend P_ ((struct frame *, Lisp_Object, Lisp_Object));
1085 extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1086 extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));
1087 extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,
1088 Lisp_Object));
1089 extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));
1090 extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));
1091 extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));
1092 extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));
1093 extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,
1094 Lisp_Object));
1095 extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object,
1096 Lisp_Object));
1098 extern Lisp_Object x_icon_type P_ ((struct frame *));
1100 extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int));
1103 extern void validate_x_resource_name P_ ((void));
1105 #endif /* HAVE_WINDOW_SYSTEM */
1107 #endif /* not EMACS_FRAME_H */
1109 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1110 (do not change this comment) */