1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993, 1994, 1999, 2000, 2001, 2002, 2003, 2004,
3 2005 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 2, or (at your option)
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
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
38 extern int message_buf_print
;
41 /* The structure representing a frame. */
53 enum vertical_scroll_bar_type
55 vertical_scroll_bar_none
,
56 vertical_scroll_bar_left
,
57 vertical_scroll_bar_right
60 enum text_cursor_kinds
70 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
71 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
78 struct Lisp_Vector
*next
;
80 /* All Lisp_Object components must come first.
81 Only EMACS_INT values can be intermixed with them.
82 That ensures they are all aligned normally. */
84 /* Name of this frame: a Lisp string. It is used for looking up resources,
85 as well as for the title in some cases. */
88 /* The name to use for the icon, the last time
89 it was refreshed. nil means not explicitly specified. */
90 Lisp_Object icon_name
;
92 /* This is the frame title specified explicitly, if any.
96 /* The frame which should receive keystrokes that occur in this
97 frame, or nil if they should go to the frame itself. This is
98 usually nil, but if the frame is minibufferless, we can use this
99 to redirect keystrokes to a surrogate minibuffer frame when
102 Note that a value of nil is different than having the field point
103 to the frame itself. Whenever the Fselect_frame function is used
104 to shift from one frame to the other, any redirections to the
105 original frame are shifted to the newly selected frame; if
106 focus_frame is nil, Fselect_frame will leave it alone. */
107 Lisp_Object focus_frame
;
109 /* This frame's root window. Every frame has one.
110 If the frame has only a minibuffer window, this is it.
111 Otherwise, if the frame has a minibuffer window, this is its sibling. */
112 Lisp_Object root_window
;
114 /* This frame's selected window.
115 Each frame has its own window hierarchy
116 and one of the windows in it is selected within the frame.
117 The selected window of the selected frame is Emacs's selected window. */
118 Lisp_Object selected_window
;
120 /* This frame's minibuffer window.
121 Most frames have their own minibuffer windows,
122 but only the selected frame's minibuffer window
123 can actually appear to exist. */
124 Lisp_Object minibuffer_window
;
126 /* Parameter alist of this frame.
127 These are the parameters specified when creating the frame
128 or modified with modify-frame-parameters. */
129 Lisp_Object param_alist
;
131 /* List of scroll bars on this frame.
132 Actually, we don't specify exactly what is stored here at all; the
133 scroll bar implementation code can use it to store anything it likes.
134 This field is marked by the garbage collector. It is here
135 instead of in the `device' structure so that the garbage
136 collector doesn't need to look inside the window-system-dependent
138 Lisp_Object scroll_bars
;
139 Lisp_Object condemned_scroll_bars
;
141 /* Vector describing the items to display in the menu bar.
142 Each item has four elements in this vector.
143 They are KEY, STRING, SUBMAP, and HPOS.
144 (HPOS is not used in when the X toolkit is in use.)
145 There are four additional elements of nil at the end, to terminate. */
146 Lisp_Object menu_bar_items
;
148 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
149 Lisp_Object face_alist
;
151 /* A vector that records the entire structure of this frame's menu bar.
152 For the format of the data, see extensive comments in xmenu.c.
153 Only the X toolkit version uses this. */
154 Lisp_Object menu_bar_vector
;
155 /* Number of elements in the vector that have meaningful data. */
156 EMACS_INT menu_bar_items_used
;
158 /* Predicate for selecting buffers for other-buffer. */
159 Lisp_Object buffer_predicate
;
161 /* List of buffers viewed in this frame, for other-buffer. */
162 Lisp_Object buffer_list
;
164 /* A dummy window used to display menu bars under X when no X
165 toolkit support is available. */
166 Lisp_Object menu_bar_window
;
168 /* A window used to display the tool-bar of a frame. */
169 Lisp_Object tool_bar_window
;
171 /* Desired and current tool-bar items. */
172 Lisp_Object tool_bar_items
;
174 /* Desired and current contents displayed in tool_bar_window. */
175 Lisp_Object desired_tool_bar_string
, current_tool_bar_string
;
177 /* beyond here, there should be no more Lisp_Object components. */
179 /* Cache of realized faces. */
180 struct face_cache
*face_cache
;
182 /* A buffer to hold the frame's name. We can't use the Lisp
183 string's pointer (`name', above) because it might get relocated. */
186 /* Glyph pool and matrix. */
187 struct glyph_pool
*current_pool
;
188 struct glyph_pool
*desired_pool
;
189 struct glyph_matrix
*desired_matrix
;
190 struct glyph_matrix
*current_matrix
;
192 /* 1 means that glyphs on this frame have been initialized so it can
193 be used for output. */
194 unsigned glyphs_initialized_p
: 1;
196 #if defined (USE_GTK)
197 /* Nonzero means using a tool bar that comes from the toolkit. */
198 int external_tool_bar
;
201 /* Margin at the top of the frame. Used to display the tool-bar. */
204 int n_tool_bar_items
;
206 /* A buffer for decode_mode_line. */
207 char *decode_mode_spec_buffer
;
209 /* See do_line_insertion_deletion_costs for info on these arrays. */
210 /* Cost of inserting 1 line on this frame */
211 int *insert_line_cost
;
212 /* Cost of deleting 1 line on this frame */
213 int *delete_line_cost
;
214 /* Cost of inserting n lines on this frame */
215 int *insert_n_lines_cost
;
216 /* Cost of deleting n lines on this frame */
217 int *delete_n_lines_cost
;
219 /* Size of this frame, excluding fringes, scroll bars etc.,
220 in units of canonical characters. */
221 EMACS_INT text_lines
, text_cols
;
223 /* Total size of this frame (i.e. its native window), in units of
224 canonical characters. */
225 EMACS_INT total_lines
, total_cols
;
227 /* New text height and width for pending size change.
228 0 if no change pending. */
229 int new_text_lines
, new_text_cols
;
231 /* Pixel position of the frame window (x and y offsets in root window). */
232 int left_pos
, top_pos
;
234 /* Size of the frame window in pixels. */
235 int pixel_height
, pixel_width
;
237 /* These many pixels are the difference between the outer window (i.e. the
238 left and top of the window manager decoration) and FRAME_X_WINDOW. */
239 int x_pixels_diff
, y_pixels_diff
;
241 /* This is the gravity value for the specified window position. */
244 /* The geometry flags for this window. */
247 /* Border width of the frame window as known by the (X) window system. */
250 /* Width of the internal border. This is a line of background color
251 just inside the window's border. When the frame is selected,
252 a highlighting is displayed inside the internal border. */
253 int internal_border_width
;
255 /* Canonical X unit. Width of default font, in pixels. */
258 /* Widht of space glyph of default font, in pixels. */
261 /* Canonical Y unit. Height of a line, in pixels. */
264 /* The output method says how the contents of this frame are
265 displayed. It could be using termcap, or using an X window.
266 This must be the same as the device->type. */
267 enum output_method output_method
;
269 /* The display device that this frame uses. If this is NULL, then
270 the frame has been deleted. */
271 struct device
*device
;
273 /* Device-dependent, frame-local auxiliary data used for displaying
274 the contents. When the frame is deleted, this data is deleted as
278 struct tty_output
*tty
; /* termchar.h */
279 struct x_output
*x
; /* xterm.h */
280 struct w32_output
*w32
; /* w32term.h */
281 struct mac_output
*mac
; /* macterm.h */
286 /* Total width of fringes reserved for drawing truncation bitmaps,
287 continuation bitmaps and alike. The width is in canonical char
288 units of the frame. This must currently be the case because window
289 sizes aren't pixel values. If it weren't the case, we wouldn't be
290 able to split windows horizontally nicely. */
293 /* The extra width (in pixels) currently allotted for fringes. */
294 int left_fringe_width
, right_fringe_width
;
296 /* See FULLSCREEN_ enum below */
299 /* Number of lines of menu bar. */
302 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
304 /* Nonzero means using a menu bar that comes from the X toolkit. */
305 int external_menu_bar
;
308 /* Nonzero if last attempt at redisplay on this frame was preempted. */
309 char display_preempted
;
311 /* visible is nonzero if the frame is currently displayed; we check
312 it to see if we should bother updating the frame's contents.
313 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
315 Note that, since invisible frames aren't updated, whenever a
316 frame becomes visible again, it must be marked as garbaged. The
317 FRAME_SAMPLE_VISIBILITY macro takes care of this.
319 On ttys and on Windows NT/9X, to avoid wasting effort updating
320 visible frames that are actually completely obscured by other
321 windows on the display, we bend the meaning of visible slightly:
322 if greater than 1, then the frame is obscured - we still consider
323 it to be "visible" as seen from lisp, but we don't bother
324 updating it. We must take care to garbage the frame when it
325 ceaces to be obscured though.
327 iconified is nonzero if the frame is currently iconified.
329 Asynchronous input handlers should NOT change these directly;
330 instead, they should change async_visible or async_iconified, and
331 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
332 at the next redisplay.
334 These should probably be considered read-only by everyone except
335 FRAME_SAMPLE_VISIBILITY.
337 These two are mutually exclusive. They might both be zero, if the
338 frame has been made invisible without an icon. */
339 char visible
, iconified
;
341 /* Asynchronous input handlers change these, and
342 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
343 See FRAME_SAMPLE_VISIBILITY, below. */
344 volatile char async_visible
, async_iconified
;
346 /* Nonzero if this frame should be redrawn. */
347 volatile char garbaged
;
349 /* True if frame actually has a minibuffer window on it.
350 0 if using a minibuffer window that isn't on this frame. */
353 /* 0 means, if this frame has just one window,
354 show no modeline for that window. */
357 /* Non-zero if the hardware device this frame is displaying on can
358 support scroll bars. */
359 char can_have_scroll_bars
;
361 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
362 actually display them on this frame. */
363 enum vertical_scroll_bar_type vertical_scroll_bar_type
;
365 /* What kind of text cursor should we draw in the future?
366 This should always be filled_box_cursor or bar_cursor. */
367 enum text_cursor_kinds desired_cursor
;
369 /* Width of bar cursor (if we are using that). */
372 /* What kind of text cursor should we draw when the cursor blinks off?
373 This can be filled_box_cursor or bar_cursor or no_cursor. */
374 enum text_cursor_kinds blink_off_cursor
;
376 /* Width of bar cursor (if we are using that) for blink-off state. */
377 int blink_off_cursor_width
;
379 /* Non-0 means raise this frame to the top of the heap when selected. */
382 /* Non-0 means lower this frame to the bottom of the stack when left. */
385 /* True if frame's root window can't be split. */
388 /* If this is set, then Emacs won't change the frame name to indicate
389 the current buffer, etcetera. If the user explicitly sets the frame
390 name, this gets set. If the user sets the name to Qnil, this is
394 /* Nonzero if size of some window on this frame has changed. */
395 char window_sizes_changed
;
397 /* Storage for messages to this frame. */
400 /* Nonnegative if current redisplay should not do scroll computation
401 for lines beyond a certain vpos. This is the vpos. */
402 int scroll_bottom_vpos
;
404 /* Configured width of the scroll bar, in pixels and in characters.
405 config_scroll_bar_cols tracks config_scroll_bar_width if the
406 latter is positive; a zero value in config_scroll_bar_width means
407 to compute the actual width on the fly, using config_scroll_bar_cols
408 and the current font width. */
409 int config_scroll_bar_width
;
410 int config_scroll_bar_cols
;
412 /* The size of the extra width currently allotted for vertical
413 scroll bars in this frame, in pixels. */
414 int scroll_bar_actual_width
;
416 /* The baud rate that was used to calculate costs for this frame. */
417 int cost_calculation_baud_rate
;
419 /* Nonzero if the mouse has moved on this display device
420 since the last time we checked. */
423 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
424 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
425 frame parameter. 0 means don't do gamma correction. */
428 /* Additional space to put between text lines on this frame. */
429 int extra_line_spacing
;
431 /* Set to non-zero in change_frame_size when size of frame changed
432 Clear the frame in clear_garbaged_frames if set. */
433 unsigned resized_p
: 1;
435 /* Set to non-zero in when we want for force a flush_display in
436 update_frame, usually after resizing the frame. */
437 unsigned force_flush_display_p
: 1;
439 /* All display backends seem to need these two pixel values. */
440 unsigned long background_pixel
;
441 unsigned long foreground_pixel
;
443 /* Set to non-zero if the default face for the frame has been
444 realized. Reset to zero whenever the default face changes.
445 Used to see the difference between a font change and face change. */
446 unsigned default_face_done_p
: 1;
448 /* Set to non-zero if this frame has already been hscrolled during
449 current redisplay. */
450 unsigned already_hscrolled_p
: 1;
454 #define FRAME_KBOARD(f) ((f)->device->kboard)
456 #define FRAME_KBOARD(f) (&the_only_kboard)
459 typedef struct frame
*FRAME_PTR
;
461 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
462 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
464 /* Given a window, return its frame as a Lisp_Object. */
465 #define WINDOW_FRAME(w) (w)->frame
467 /* Test a frame for particular kinds of display methods. */
468 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
469 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
470 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
471 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
472 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
473 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
475 /* FRAME_WINDOW_P tests whether the frame is a window, and is
476 defined to be the predicate for the window system being used. */
478 #ifdef HAVE_X_WINDOWS
479 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
482 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
485 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
487 #ifndef FRAME_WINDOW_P
488 #define FRAME_WINDOW_P(f) (0)
491 /* Nonzero if frame F is still alive (not deleted). */
492 #define FRAME_LIVE_P(f) ((f)->device != 0)
494 /* Nonzero if frame F is a minibuffer-only frame. */
495 #define FRAME_MINIBUF_ONLY_P(f) \
496 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
498 /* Nonzero if frame F contains a minibuffer window.
499 (If this is 0, F must use some other minibuffer window.) */
500 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
502 /* Pixel height of frame F, including non-toolkit menu bar and
503 non-toolkit tool bar lines. */
504 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
506 /* Pixel width of frame F. */
507 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
509 /* Height of frame F, measured in canonical lines, including
510 non-toolkit menu bar and non-toolkit tool bar lines. */
511 #define FRAME_LINES(f) (f)->text_lines
513 /* Width of frame F, measured in canonical character columns,
514 not including scroll bars if any. */
515 #define FRAME_COLS(f) (f)->text_cols
517 /* Number of lines of frame F used for menu bar.
518 This is relevant on terminal frames and on
519 X Windows when not using the X toolkit.
520 These lines are counted in FRAME_LINES. */
521 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
523 /* Nonzero if this frame should display a tool bar
524 in a way that does not use any text lines. */
525 #if defined (USE_GTK)
526 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
528 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
531 /* Number of lines of frame F used for the tool-bar. */
533 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
536 /* Lines above the top-most window in frame F. */
538 #define FRAME_TOP_MARGIN(F) \
539 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
541 /* Nonzero if this frame should display a menu bar
542 in a way that does not use any text lines. */
543 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
545 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
547 #define FRAME_EXTERNAL_MENU_BAR(f) 0
549 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
551 /* Nonzero if frame F is currently visible but hidden. */
552 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
554 /* Nonzero if frame F is currently iconified. */
555 #define FRAME_ICONIFIED_P(f) (f)->iconified
557 #define FRAME_SET_VISIBLE(f,p) \
558 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
559 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
560 #define FRAME_GARBAGED_P(f) (f)->garbaged
562 /* Nonzero means do not allow splitting this frame's window. */
563 #define FRAME_NO_SPLIT_P(f) (f)->no_split
565 /* Not really implemented. */
566 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
568 /* Nonzero if a size change has been requested for frame F
569 but not yet really put into effect. This can be true temporarily
570 when an X event comes in at a bad time. */
571 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
573 /* The minibuffer window of frame F, if it has one; otherwise nil. */
574 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
576 /* The root window of the window tree of frame F. */
577 #define FRAME_ROOT_WINDOW(f) (f)->root_window
579 /* The currently selected window of the window tree of frame F. */
580 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
582 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
583 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
584 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
585 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
586 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
587 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
588 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
590 /* Nonzero if frame F supports scroll bars.
591 If this is zero, then it is impossible to enable scroll bars
593 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
595 /* This frame slot says whether scroll bars are currently enabled for frame F,
596 and which side they are on. */
597 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
598 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
599 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
600 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
601 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
602 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
603 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
605 /* Width that a scroll bar in frame F should have, if there is one.
607 If scroll bars are turned off, this is still nonzero. */
608 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
610 /* Width that a scroll bar in frame F should have, if there is one.
611 Measured in columns (characters).
612 If scroll bars are turned off, this is still nonzero. */
613 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
615 /* Width of a scroll bar in frame F, measured in columns (characters),
616 but only if scroll bars are on the left. If scroll bars are on
617 the right in this frame, or there are no scroll bars, value is 0. */
619 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
620 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
621 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
624 /* Width of a left scroll bar in frame F, measured in pixels */
626 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
627 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
628 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
631 /* Width of a scroll bar in frame F, measured in columns (characters),
632 but only if scroll bars are on the right. If scroll bars are on
633 the left in this frame, or there are no scroll bars, value is 0. */
635 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
636 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
637 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
640 /* Width of a right scroll bar area in frame F, measured in pixels */
642 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
643 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
644 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
647 /* Actual width of a scroll bar in frame F, measured in columns. */
649 #define FRAME_SCROLL_BAR_COLS(f) \
650 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
651 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
654 /* Actual width of a scroll bar area in frame F, measured in pixels. */
656 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
657 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
658 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
661 /* Total width of frame F, in columns (characters),
662 including the width used by scroll bars if any. */
664 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
666 /* Set the width of frame F to VAL.
667 VAL is the width of a full-frame window,
668 not including scroll bars and fringes. */
670 #define SET_FRAME_COLS(f, val) \
671 (FRAME_COLS (f) = (val), \
672 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
674 /* Given a value WIDTH for frame F's nominal width,
675 return the value that FRAME_TOTAL_COLS should have. */
677 #define FRAME_TOTAL_COLS_ARG(f, width) \
679 + FRAME_SCROLL_BAR_COLS (f) \
680 + FRAME_FRINGE_COLS (f))
682 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
684 #define FRAME_CURSOR_X_LIMIT(f) \
685 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
687 /* Nonzero if frame F has scroll bars. */
689 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
691 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
692 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
693 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
695 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
696 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
697 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
698 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
700 /* Return a pointer to the face cache of frame F. */
702 #define FRAME_FACE_CACHE(F) (F)->face_cache
704 /* Return the size of message_buf of the frame F. We multiply the
705 width of the frame by 4 because multi-byte form may require at most
706 4-byte for a character. */
708 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
710 /* Emacs's redisplay code could become confused if a frame's
711 visibility changes at arbitrary times. For example, if a frame is
712 visible while the desired glyphs are being built, but becomes
713 invisible before they are updated, then some rows of the
714 desired_glyphs will be left marked as enabled after redisplay is
715 complete, which should never happen. The next time the frame
716 becomes visible, redisplay will probably barf.
718 Currently, there are no similar situations involving iconified, but
719 the principle is the same.
721 So instead of having asynchronous input handlers directly set and
722 clear the frame's visibility and iconification flags, they just set
723 the async_visible and async_iconified flags; the redisplay code
724 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
725 which sets visible and iconified from their asynchronous
728 Synchronous code must use the FRAME_SET_VISIBLE macro.
730 Also, if a frame used to be invisible, but has just become visible,
731 it must be marked as garbaged, since redisplay hasn't been keeping
734 Note that a tty frame is visible if and only if it is the topmost
737 #define FRAME_SAMPLE_VISIBILITY(f) \
738 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
739 SET_FRAME_GARBAGED (f) : 0, \
740 (f)->visible = (f)->async_visible, \
741 (f)->iconified = (f)->async_iconified)
743 #define CHECK_FRAME(x) \
746 x = wrong_type_argument (Qframep, (x)); \
749 #define CHECK_LIVE_FRAME(x) \
752 || ! FRAME_LIVE_P (XFRAME (x))) \
753 x = wrong_type_argument (Qframe_live_p, (x)); \
756 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
757 `for' loop which iterates over the elements of Vframe_list. The
758 loop will set FRAME_VAR, a Lisp_Object, to each frame in
759 Vframe_list in succession and execute the statement. LIST_VAR
760 should be a Lisp_Object too; it is used to iterate through the
763 This macro is a holdover from a time when multiple frames weren't always
764 supported. An alternate definition of the macro would expand to
765 something which executes the statement once. */
767 #define FOR_EACH_FRAME(list_var, frame_var) \
768 for ((list_var) = Vframe_list; \
770 && (frame_var = XCAR (list_var), 1)); \
771 list_var = XCDR (list_var))
774 extern Lisp_Object Qframep
, Qframe_live_p
;
775 extern Lisp_Object Qtty
, Qtty_type
;
776 extern Lisp_Object Qdevice
, Qdisplay_live_p
;
778 extern struct frame
*last_nonminibuf_frame
;
780 extern struct frame
*make_initial_frame
P_ ((void));
781 extern struct frame
*make_terminal_frame
P_ ((struct device
*));
782 extern struct frame
*make_frame
P_ ((int));
783 #ifdef HAVE_WINDOW_SYSTEM
784 extern struct frame
*make_minibuffer_frame
P_ ((void));
785 extern struct frame
*make_frame_without_minibuffer
P_ ((Lisp_Object
,
788 #endif /* HAVE_WINDOW_SYSTEM */
789 extern int other_visible_frames
P_ ((struct frame
*));
791 extern Lisp_Object Vframe_list
;
792 extern Lisp_Object Vdefault_frame_alist
;
794 extern Lisp_Object Vterminal_frame
;
796 extern Lisp_Object Vmouse_highlight
;
798 /* The currently selected frame. */
800 extern Lisp_Object selected_frame
;
802 /* Value is a pointer to the selected frame. If the selected frame
803 isn't live, abort. */
805 #define SELECTED_FRAME() \
806 ((FRAMEP (selected_frame) \
807 && FRAME_LIVE_P (XFRAME (selected_frame))) \
808 ? XFRAME (selected_frame) \
809 : (abort (), (struct frame *) 0))
812 /***********************************************************************
813 Display-related Macros
814 ***********************************************************************/
816 /* Canonical y-unit on frame F.
817 This value currently equals the line height of the frame (which is
818 the height of the default font of F). */
820 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
822 /* Canonical x-unit on frame F.
823 This value currently equals the average width of the default font of F. */
825 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
827 /* Space glyph width of the default font of frame F. */
829 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
832 /* Pixel width of areas used to display truncation marks, continuation
833 marks, overlay arrows. This is 0 for terminal frames. */
835 #ifdef HAVE_WINDOW_SYSTEM
837 /* Total width of fringes reserved for drawing truncation bitmaps,
838 continuation bitmaps and alike. The width is in canonical char
839 units of the frame. This must currently be the case because window
840 sizes aren't pixel values. If it weren't the case, we wouldn't be
841 able to split windows horizontally nicely. */
843 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
845 /* Pixel-width of the left and right fringe. */
847 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
848 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
850 /* Total width of fringes in pixels. */
852 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
853 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
856 /* Pixel-width of internal border lines */
858 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
860 #else /* not HAVE_WINDOW_SYSTEM */
862 #define FRAME_FRINGE_COLS(F) 0
863 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
864 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
865 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
866 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
868 #endif /* not HAVE_WINDOW_SYSTEM */
873 /***********************************************************************
874 Conversion between canonical units and pixels
875 ***********************************************************************/
877 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
878 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
879 represented as Lisp numbers, i.e. integers or floats. */
881 /* Convert canonical value X to pixels. F is the frame whose
882 canonical char width is to be used. X must be a Lisp integer or
883 float. Value is a C integer. */
885 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
887 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
888 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
890 /* Convert canonical value Y to pixels. F is the frame whose
891 canonical character height is to be used. X must be a Lisp integer
892 or float. Value is a C integer. */
894 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
896 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
897 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
899 /* Convert pixel-value X to canonical units. F is the frame whose
900 canonical character width is to be used. X is a C integer. Result
901 is a Lisp float if X is not a multiple of the canon width,
902 otherwise it's a Lisp integer. */
904 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
905 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
906 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
907 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
909 /* Convert pixel-value Y to canonical units. F is the frame whose
910 canonical character height is to be used. Y is a C integer.
911 Result is a Lisp float if Y is not a multiple of the canon width,
912 otherwise it's a Lisp integer. */
914 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
915 ((Y) % FRAME_LINE_HEIGHT (F) \
916 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
917 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
921 /* Manipulating pixel sizes and character sizes.
922 Knowledge of which factors affect the overall size of the window should
923 be hidden in these macros, if that's possible.
925 Return the upper/left pixel position of the character cell on frame F
928 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
929 (FRAME_INTERNAL_BORDER_WIDTH (f) \
930 + (row) * FRAME_LINE_HEIGHT (f))
932 #define FRAME_COL_TO_PIXEL_X(f, col) \
933 (FRAME_INTERNAL_BORDER_WIDTH (f) \
934 + (col) * FRAME_COLUMN_WIDTH (f))
936 /* Return the pixel width/height of frame F if it has
937 COLS columns/LINES rows. */
939 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
940 (FRAME_COL_TO_PIXEL_X (f, cols) \
941 + (f)->scroll_bar_actual_width \
942 + FRAME_TOTAL_FRINGE_WIDTH (f) \
943 + FRAME_INTERNAL_BORDER_WIDTH (f))
945 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
946 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
947 + FRAME_INTERNAL_BORDER_WIDTH (f))
950 /* Return the row/column (zero-based) of the character cell containing
951 the pixel on FRAME at Y/X. */
953 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
954 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
955 / FRAME_LINE_HEIGHT (f))
957 #define FRAME_PIXEL_X_TO_COL(f, x) \
958 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
959 / FRAME_COLUMN_WIDTH (f))
961 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
964 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
965 (FRAME_PIXEL_X_TO_COL (f, ((width) \
966 - FRAME_INTERNAL_BORDER_WIDTH (f) \
967 - FRAME_TOTAL_FRINGE_WIDTH (f) \
968 - (f)->scroll_bar_actual_width)))
970 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
971 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
972 - FRAME_INTERNAL_BORDER_WIDTH (f))))
975 /***********************************************************************
977 ***********************************************************************/
979 extern Lisp_Object Qauto_raise
, Qauto_lower
;
980 extern Lisp_Object Qborder_color
, Qborder_width
;
981 extern Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
982 extern Lisp_Object Qcursor_color
, Qcursor_type
;
983 extern Lisp_Object Qfont
;
984 extern Lisp_Object Qbackground_color
, Qforeground_color
;
985 extern Lisp_Object Qicon
, Qicon_name
, Qicon_type
, Qicon_left
, Qicon_top
;
986 extern Lisp_Object Qinternal_border_width
;
987 extern Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
988 extern Lisp_Object Qmouse_color
;
989 extern Lisp_Object Qname
, Qtitle
;
990 extern Lisp_Object Qparent_id
;
991 extern Lisp_Object Qunsplittable
, Qvisibility
;
992 extern Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
993 extern Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
994 extern Lisp_Object Qscreen_gamma
;
995 extern Lisp_Object Qline_spacing
;
996 extern Lisp_Object Qwait_for_wm
;
997 extern Lisp_Object Qfullscreen
;
999 extern Lisp_Object Qleft_fringe
, Qright_fringe
;
1000 extern Lisp_Object Qheight
, Qwidth
;
1001 extern Lisp_Object Qminibuffer
, Qmodeline
;
1002 extern Lisp_Object Qonly
;
1003 extern Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
1004 extern Lisp_Object Qvisible
;
1005 extern Lisp_Object Qdisplay_type
;
1006 extern Lisp_Object Qbackground_mode
;
1008 extern Lisp_Object Qx_resource_name
;
1010 extern Lisp_Object Qleft
, Qright
, Qtop
, Qbox
;
1011 extern Lisp_Object Qdisplay
;
1013 extern Lisp_Object Qwindow_system
;
1015 #ifdef HAVE_WINDOW_SYSTEM
1017 /* The class of this X application. */
1018 #define EMACS_CLASS "Emacs"
1022 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1023 FULLSCREEN_NONE
= 0,
1024 FULLSCREEN_WIDTH
= 1,
1025 FULLSCREEN_HEIGHT
= 2,
1026 FULLSCREEN_BOTH
= 3,
1027 FULLSCREEN_WAIT
= 4,
1031 /* These are in xterm.c, w32term.c, etc. */
1033 extern void x_set_scroll_bar_default_width
P_ ((struct frame
*));
1034 extern void x_set_offset
P_ ((struct frame
*, int, int, int));
1035 extern void x_wm_set_icon_position
P_ ((struct frame
*, int, int));
1037 extern Lisp_Object x_new_font
P_ ((struct frame
*, char *));
1038 extern Lisp_Object x_new_fontset
P_ ((struct frame
*, char *));
1041 /* These are in frame.c */
1043 extern Lisp_Object Vx_resource_name
;
1044 extern Lisp_Object Vx_resource_class
;
1047 extern Lisp_Object Qface_set_after_frame_default
;
1049 extern void x_fullscreen_adjust
P_ ((struct frame
*f
, int *, int *,
1052 extern void x_set_frame_parameters
P_ ((struct frame
*, Lisp_Object
));
1053 extern void x_report_frame_params
P_ ((struct frame
*, Lisp_Object
*));
1055 extern void x_set_fullscreen
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1056 extern void x_set_line_spacing
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1057 extern void x_set_screen_gamma
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1058 extern void x_set_font
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1059 extern void x_set_fringe_width
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1060 extern void x_set_border_width
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1061 extern void x_set_internal_border_width
P_ ((struct frame
*, Lisp_Object
,
1063 extern void x_set_visibility
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1064 extern void x_set_autoraise
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1065 extern void x_set_autolower
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1066 extern void x_set_unsplittable
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1067 extern void x_set_vertical_scroll_bars
P_ ((struct frame
*, Lisp_Object
,
1069 extern void x_set_scroll_bar_width
P_ ((struct frame
*, Lisp_Object
,
1072 extern Lisp_Object x_icon_type
P_ ((struct frame
*));
1074 extern int x_figure_window_size
P_ ((struct frame
*, Lisp_Object
, int));
1077 extern void validate_x_resource_name
P_ ((void));
1079 #endif /* HAVE_WINDOW_SYSTEM */
1081 #endif /* not EMACS_FRAME_H */
1083 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1084 (do not change this comment) */