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 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 don't assume anything about current contents of
33 actual terminal frame */
35 extern int frame_garbaged
;
37 /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by
40 extern int message_buf_print
;
43 /* The structure representing a frame. */
54 enum vertical_scroll_bar_type
56 vertical_scroll_bar_none
,
57 vertical_scroll_bar_left
,
58 vertical_scroll_bar_right
61 enum text_cursor_kinds
71 #if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS)
73 #if !defined(HAVE_X_WINDOWS)
75 #define PIX_TYPE unsigned long
77 /* A (mostly empty) x_output structure definition for building Emacs
78 on Unix and GNU/Linux without X support. */
81 PIX_TYPE background_pixel
;
82 PIX_TYPE foreground_pixel
;
85 #endif /* ! HAVE_X_WINDOWS */
88 #define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
89 #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
91 /* A structure describing a termcap frame display. */
92 extern struct x_output tty_display
;
94 #endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */
96 #ifdef USE_FONT_BACKEND
97 struct font_driver_list
;
98 #endif /* USE_FONT_BACKEND */
103 struct Lisp_Vector
*next
;
105 /* All Lisp_Object components must come first.
106 Only EMACS_INT values can be intermixed with them.
107 That ensures they are all aligned normally. */
109 /* Name of this frame: a Lisp string. It is used for looking up resources,
110 as well as for the title in some cases. */
113 /* The name to use for the icon, the last time
114 it was refreshed. nil means not explicitly specified. */
115 Lisp_Object icon_name
;
117 /* This is the frame title specified explicitly, if any.
118 Usually it is nil. */
121 /* The frame which should receive keystrokes that occur in this
122 frame, or nil if they should go to the frame itself. This is
123 usually nil, but if the frame is minibufferless, we can use this
124 to redirect keystrokes to a surrogate minibuffer frame when
127 Note that a value of nil is different than having the field point
128 to the frame itself. Whenever the Fselect_frame function is used
129 to shift from one frame to the other, any redirections to the
130 original frame are shifted to the newly selected frame; if
131 focus_frame is nil, Fselect_frame will leave it alone. */
132 Lisp_Object focus_frame
;
134 /* This frame's root window. Every frame has one.
135 If the frame has only a minibuffer window, this is it.
136 Otherwise, if the frame has a minibuffer window, this is its sibling. */
137 Lisp_Object root_window
;
139 /* This frame's selected window.
140 Each frame has its own window hierarchy
141 and one of the windows in it is selected within the frame.
142 The selected window of the selected frame is Emacs's selected window. */
143 Lisp_Object selected_window
;
145 /* This frame's minibuffer window.
146 Most frames have their own minibuffer windows,
147 but only the selected frame's minibuffer window
148 can actually appear to exist. */
149 Lisp_Object minibuffer_window
;
151 /* Parameter alist of this frame.
152 These are the parameters specified when creating the frame
153 or modified with modify-frame-parameters. */
154 Lisp_Object param_alist
;
156 /* List of scroll bars on this frame.
157 Actually, we don't specify exactly what is stored here at all; the
158 scroll bar implementation code can use it to store anything it likes.
159 This field is marked by the garbage collector. It is here
160 instead of in the `display' structure so that the garbage
161 collector doesn't need to look inside the window-system-dependent
163 Lisp_Object scroll_bars
;
164 Lisp_Object condemned_scroll_bars
;
166 /* Vector describing the items to display in the menu bar.
167 Each item has four elements in this vector.
168 They are KEY, STRING, SUBMAP, and HPOS.
169 (HPOS is not used in when the X toolkit is in use.)
170 There are four additional elements of nil at the end, to terminate. */
171 Lisp_Object menu_bar_items
;
173 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
174 Lisp_Object face_alist
;
176 /* A vector that records the entire structure of this frame's menu bar.
177 For the format of the data, see extensive comments in xmenu.c.
178 Only the X toolkit version uses this. */
179 Lisp_Object menu_bar_vector
;
180 /* Number of elements in the vector that have meaningful data. */
181 EMACS_INT menu_bar_items_used
;
183 /* Predicate for selecting buffers for other-buffer. */
184 Lisp_Object buffer_predicate
;
186 /* List of buffers viewed in this frame, for other-buffer. */
187 Lisp_Object buffer_list
;
189 /* A dummy window used to display menu bars under X when no X
190 toolkit support is available. */
191 Lisp_Object menu_bar_window
;
193 /* A window used to display the tool-bar of a frame. */
194 Lisp_Object tool_bar_window
;
196 /* Desired and current tool-bar items. */
197 Lisp_Object tool_bar_items
;
199 /* Desired and current contents displayed in tool_bar_window. */
200 Lisp_Object desired_tool_bar_string
, current_tool_bar_string
;
202 /* beyond here, there should be no more Lisp_Object components. */
204 /* Cache of realized faces. */
205 struct face_cache
*face_cache
;
207 /* A buffer to hold the frame's name. We can't use the Lisp
208 string's pointer (`name', above) because it might get relocated. */
211 /* Glyph pool and matrix. */
212 struct glyph_pool
*current_pool
;
213 struct glyph_pool
*desired_pool
;
214 struct glyph_matrix
*desired_matrix
;
215 struct glyph_matrix
*current_matrix
;
217 /* 1 means that glyphs on this frame have been initialized so it can
218 be used for output. */
219 unsigned glyphs_initialized_p
: 1;
221 #if defined (USE_GTK)
222 /* Nonzero means using a tool bar that comes from the toolkit. */
223 int external_tool_bar
;
226 /* Margin at the top of the frame. Used to display the tool-bar. */
230 int n_tool_bar_items
;
232 /* A buffer for decode_mode_line. */
233 char *decode_mode_spec_buffer
;
235 /* See do_line_insertion_deletion_costs for info on these arrays. */
236 /* Cost of inserting 1 line on this frame */
237 int *insert_line_cost
;
238 /* Cost of deleting 1 line on this frame */
239 int *delete_line_cost
;
240 /* Cost of inserting n lines on this frame */
241 int *insert_n_lines_cost
;
242 /* Cost of deleting n lines on this frame */
243 int *delete_n_lines_cost
;
245 /* Size of this frame, excluding fringes, scroll bars etc.,
246 in units of canonical characters. */
247 EMACS_INT text_lines
, text_cols
;
249 /* Total size of this frame (i.e. its native window), in units of
250 canonical characters. */
251 EMACS_INT total_lines
, total_cols
;
253 /* New text height and width for pending size change.
254 0 if no change pending. */
255 int new_text_lines
, new_text_cols
;
257 /* Pixel position of the frame window (x and y offsets in root window). */
258 int left_pos
, top_pos
;
260 /* Size of the frame window in pixels. */
261 int pixel_height
, pixel_width
;
263 /* Dots per inch of the screen the frame is on. */
266 /* These many pixels are the difference between the outer window (i.e. the
267 left and top of the window manager decoration) and FRAME_X_WINDOW. */
268 int x_pixels_diff
, y_pixels_diff
;
270 /* This is the gravity value for the specified window position. */
273 /* The geometry flags for this window. */
276 /* Border width of the frame window as known by the (X) window system. */
279 /* Width of the internal border. This is a line of background color
280 just inside the window's border. When the frame is selected,
281 a highlighting is displayed inside the internal border. */
282 int internal_border_width
;
284 /* Canonical X unit. Width of default font, in pixels. */
287 /* Widht of space glyph of default font, in pixels. */
290 /* Canonical Y unit. Height of a line, in pixels. */
293 /* The output method says how the contents of this frame
294 are displayed. It could be using termcap, or using an X window. */
295 enum output_method output_method
;
297 /* A structure of auxiliary data used for displaying the contents.
298 struct x_output is used for X window frames;
299 it is defined in xterm.h.
300 struct w32_output is used for W32 window frames;
301 it is defined in w32term.h. */
305 struct w32_output
*w32
;
306 struct mac_output
*mac
;
311 #ifdef USE_FONT_BACKEND
312 /* List of font-drivers available on the frame. */
313 struct font_driver_list
*font_driver_list
;
314 #endif /* USE_FONT_BACKEND */
316 /* Total width of fringes reserved for drawing truncation bitmaps,
317 continuation bitmaps and alike. The width is in canonical char
318 units of the frame. This must currently be the case because window
319 sizes aren't pixel values. If it weren't the case, we wouldn't be
320 able to split windows horizontally nicely. */
323 /* The extra width (in pixels) currently allotted for fringes. */
324 int left_fringe_width
, right_fringe_width
;
327 /* A pointer to the kboard structure associated with this frame.
328 For termcap frames, this points to initial_kboard. For X frames,
329 it will be the same as display.x->display_info->kboard. */
330 struct kboard
*kboard
;
333 /* See FULLSCREEN_ enum below */
336 /* Number of lines of menu bar. */
339 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
341 /* Nonzero means using a menu bar that comes from the X toolkit. */
342 int external_menu_bar
;
345 /* Nonzero if last attempt at redisplay on this frame was preempted. */
346 char display_preempted
;
348 /* visible is nonzero if the frame is currently displayed; we check
349 it to see if we should bother updating the frame's contents.
350 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
352 Note that, since invisible frames aren't updated, whenever a
353 frame becomes visible again, it must be marked as garbaged. The
354 FRAME_SAMPLE_VISIBILITY macro takes care of this.
356 On Windows NT/9X, to avoid wasting effort updating visible frames
357 that are actually completely obscured by other windows on the
358 display, we bend the meaning of visible slightly: if greater than
359 1, then the frame is obscured - we still consider it to be
360 "visible" as seen from lisp, but we don't bother updating it. We
361 must take care to garbage the frame when it ceaces to be obscured
362 though. Note that these semantics are only used on NT/9X.
364 iconified is nonzero if the frame is currently iconified.
366 Asynchronous input handlers should NOT change these directly;
367 instead, they should change async_visible or async_iconified, and
368 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
369 at the next redisplay.
371 These should probably be considered read-only by everyone except
372 FRAME_SAMPLE_VISIBILITY.
374 These two are mutually exclusive. They might both be zero, if the
375 frame has been made invisible without an icon. */
376 char visible
, iconified
;
378 /* Asynchronous input handlers change these, and
379 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified.
380 See FRAME_SAMPLE_VISIBILITY, below. */
381 volatile char async_visible
, async_iconified
;
383 /* Nonzero if this frame should be redrawn. */
384 volatile char garbaged
;
386 /* True if frame actually has a minibuffer window on it.
387 0 if using a minibuffer window that isn't on this frame. */
390 /* 0 means, if this frame has just one window,
391 show no modeline for that window. */
394 /* Non-zero if the hardware device this frame is displaying on can
395 support scroll bars. */
396 char can_have_scroll_bars
;
398 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
399 actually display them on this frame. */
400 enum vertical_scroll_bar_type vertical_scroll_bar_type
;
402 /* What kind of text cursor should we draw in the future?
403 This should always be filled_box_cursor or bar_cursor. */
404 enum text_cursor_kinds desired_cursor
;
406 /* Width of bar cursor (if we are using that). */
409 /* What kind of text cursor should we draw when the cursor blinks off?
410 This can be filled_box_cursor or bar_cursor or no_cursor. */
411 enum text_cursor_kinds blink_off_cursor
;
413 /* Width of bar cursor (if we are using that) for blink-off state. */
414 int blink_off_cursor_width
;
416 /* Non-0 means raise this frame to the top of the heap when selected. */
419 /* Non-0 means lower this frame to the bottom of the stack when left. */
422 /* True if frame's root window can't be split. */
425 /* If this is set, then Emacs won't change the frame name to indicate
426 the current buffer, etcetera. If the user explicitly sets the frame
427 name, this gets set. If the user sets the name to Qnil, this is
431 /* Nonzero if size of some window on this frame has changed. */
432 char window_sizes_changed
;
434 /* Storage for messages to this frame. */
437 /* Nonnegative if current redisplay should not do scroll computation
438 for lines beyond a certain vpos. This is the vpos. */
439 int scroll_bottom_vpos
;
441 /* Configured width of the scroll bar, in pixels and in characters.
442 config_scroll_bar_cols tracks config_scroll_bar_width if the
443 latter is positive; a zero value in config_scroll_bar_width means
444 to compute the actual width on the fly, using config_scroll_bar_cols
445 and the current font width. */
446 int config_scroll_bar_width
;
447 int config_scroll_bar_cols
;
449 /* The size of the extra width currently allotted for vertical
450 scroll bars in this frame, in pixels. */
451 int scroll_bar_actual_width
;
453 /* The baud rate that was used to calculate costs for this frame. */
454 int cost_calculation_baud_rate
;
456 /* Nonzero if the mouse has moved on this display
457 since the last time we checked. */
460 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
461 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
462 frame parameter. 0 means don't do gamma correction. */
465 /* Additional space to put between text lines on this frame. */
466 int extra_line_spacing
;
468 /* Set to non-zero in change_frame_size when size of frame changed
469 Clear the frame in clear_garbaged_frames if set. */
470 unsigned resized_p
: 1;
472 /* Set to non-zero in when we want for force a flush_display in
473 update_frame, usually after resizing the frame. */
474 unsigned force_flush_display_p
: 1;
476 /* Set to non-zero if the default face for the frame has been
477 realized. Reset to zero whenever the default face changes.
478 Used to see the difference between a font change and face change. */
479 unsigned default_face_done_p
: 1;
481 /* Set to non-zero if this frame has already been hscrolled during
482 current redisplay. */
483 unsigned already_hscrolled_p
: 1;
485 /* Set to non-zero when current redisplay has updated frame. */
486 unsigned updated_p
: 1;
488 /* Set to non-zero to minimize tool-bar height even when
489 auto-resize-tool-bar is set to grow-only. */
490 unsigned minimize_tool_bar_window_p
: 1;
494 #define FRAME_KBOARD(f) ((f)->kboard)
496 #define FRAME_KBOARD(f) (&the_only_kboard)
499 typedef struct frame
*FRAME_PTR
;
501 #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p))
502 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
504 /* Given a window, return its frame as a Lisp_Object. */
505 #define WINDOW_FRAME(w) (w)->frame
507 /* Test a frame for particular kinds of display methods. */
508 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
509 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
510 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
511 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
512 #define FRAME_MAC_P(f) ((f)->output_method == output_mac)
514 /* FRAME_WINDOW_P tests whether the frame is a window, and is
515 defined to be the predicate for the window system being used. */
517 #ifdef HAVE_X_WINDOWS
518 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
521 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
524 #define FRAME_WINDOW_P(f) FRAME_MAC_P (f)
526 #ifndef FRAME_WINDOW_P
527 #define FRAME_WINDOW_P(f) (0)
530 /* Nonzero if frame F is still alive (not deleted). */
531 #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0)
533 /* Nonzero if frame F is a minibuffer-only frame. */
534 #define FRAME_MINIBUF_ONLY_P(f) \
535 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
537 /* Nonzero if frame F contains a minibuffer window.
538 (If this is 0, F must use some other minibuffer window.) */
539 #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer)
541 /* Pixel height of frame F, including non-toolkit menu bar and
542 non-toolkit tool bar lines. */
543 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
545 /* Pixel width of frame F. */
546 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
548 /* Height of frame F, measured in canonical lines, including
549 non-toolkit menu bar and non-toolkit tool bar lines. */
550 #define FRAME_LINES(f) (f)->text_lines
552 /* Width of frame F, measured in canonical character columns,
553 not including scroll bars if any. */
554 #define FRAME_COLS(f) (f)->text_cols
556 /* Number of lines of frame F used for menu bar.
557 This is relevant on terminal frames and on
558 X Windows when not using the X toolkit.
559 These lines are counted in FRAME_LINES. */
560 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
562 /* Nonzero if this frame should display a tool bar
563 in a way that does not use any text lines. */
564 #if defined (USE_GTK)
565 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
567 #define FRAME_EXTERNAL_TOOL_BAR(f) 0
570 /* Number of lines of frame F used for the tool-bar. */
572 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
575 /* Lines above the top-most window in frame F. */
577 #define FRAME_TOP_MARGIN(F) \
578 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
580 /* Nonzero if this frame should display a menu bar
581 in a way that does not use any text lines. */
582 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \
584 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
586 #define FRAME_EXTERNAL_MENU_BAR(f) 0
588 #define FRAME_VISIBLE_P(f) ((f)->visible != 0)
590 /* Nonzero if frame F is currently visible but hidden. */
591 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
593 /* Nonzero if frame F is currently iconified. */
594 #define FRAME_ICONIFIED_P(f) (f)->iconified
596 #define FRAME_SET_VISIBLE(f,p) \
597 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
598 #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
599 #define FRAME_GARBAGED_P(f) (f)->garbaged
601 /* Nonzero means do not allow splitting this frame's window. */
602 #define FRAME_NO_SPLIT_P(f) (f)->no_split
604 /* Not really implemented. */
605 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
607 /* Nonzero if a size change has been requested for frame F
608 but not yet really put into effect. This can be true temporarily
609 when an X event comes in at a bad time. */
610 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
612 /* The minibuffer window of frame F, if it has one; otherwise nil. */
613 #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window
615 /* The root window of the window tree of frame F. */
616 #define FRAME_ROOT_WINDOW(f) (f)->root_window
618 /* The currently selected window of the window tree of frame F. */
619 #define FRAME_SELECTED_WINDOW(f) (f)->selected_window
621 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
622 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
623 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
624 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
625 #define FRAME_MESSAGE_BUF(f) (f)->message_buf
626 #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos
627 #define FRAME_FOCUS_FRAME(f) (f)->focus_frame
629 /* Nonzero if frame F supports scroll bars.
630 If this is zero, then it is impossible to enable scroll bars
632 #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars)
634 /* This frame slot says whether scroll bars are currently enabled for frame F,
635 and which side they are on. */
636 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
637 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
638 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
639 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
640 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
641 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
642 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
644 /* Width that a scroll bar in frame F should have, if there is one.
646 If scroll bars are turned off, this is still nonzero. */
647 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
649 /* Width that a scroll bar in frame F should have, if there is one.
650 Measured in columns (characters).
651 If scroll bars are turned off, this is still nonzero. */
652 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
654 /* Width of a scroll bar in frame F, measured in columns (characters),
655 but only if scroll bars are on the left. If scroll bars are on
656 the right in this frame, or there are no scroll bars, value is 0. */
658 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
659 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
660 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
663 /* Width of a left scroll bar in frame F, measured in pixels */
665 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
666 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
667 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
670 /* Width of a scroll bar in frame F, measured in columns (characters),
671 but only if scroll bars are on the right. If scroll bars are on
672 the left in this frame, or there are no scroll bars, value is 0. */
674 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
675 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
676 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
679 /* Width of a right scroll bar area in frame F, measured in pixels */
681 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
682 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
683 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
686 /* Actual width of a scroll bar in frame F, measured in columns. */
688 #define FRAME_SCROLL_BAR_COLS(f) \
689 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
690 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
693 /* Actual width of a scroll bar area in frame F, measured in pixels. */
695 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
696 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
697 ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \
700 /* Total width of frame F, in columns (characters),
701 including the width used by scroll bars if any. */
703 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
705 /* Set the width of frame F to VAL.
706 VAL is the width of a full-frame window,
707 not including scroll bars and fringes. */
709 #define SET_FRAME_COLS(f, val) \
710 (FRAME_COLS (f) = (val), \
711 (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f)))
713 /* Given a value WIDTH for frame F's nominal width,
714 return the value that FRAME_TOTAL_COLS should have. */
716 #define FRAME_TOTAL_COLS_ARG(f, width) \
718 + FRAME_SCROLL_BAR_COLS (f) \
719 + FRAME_FRINGE_COLS (f))
721 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
723 #define FRAME_CURSOR_X_LIMIT(f) \
724 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
726 /* Nonzero if frame F has scroll bars. */
728 #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars)
730 #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars)
731 #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items)
732 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
734 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
735 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
736 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
737 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
739 /* Return a pointer to the face cache of frame F. */
741 #define FRAME_FACE_CACHE(F) (F)->face_cache
743 /* Return the size of message_buf of the frame F. We multiply the
744 width of the frame by 4 because multi-byte form may require at most
745 4-byte for a character. */
747 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
749 /* Emacs's redisplay code could become confused if a frame's
750 visibility changes at arbitrary times. For example, if a frame is
751 visible while the desired glyphs are being built, but becomes
752 invisible before they are updated, then some rows of the
753 desired_glyphs will be left marked as enabled after redisplay is
754 complete, which should never happen. The next time the frame
755 becomes visible, redisplay will probably barf.
757 Currently, there are no similar situations involving iconified, but
758 the principle is the same.
760 So instead of having asynchronous input handlers directly set and
761 clear the frame's visibility and iconification flags, they just set
762 the async_visible and async_iconified flags; the redisplay code
763 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
764 which sets visible and iconified from their asynchronous
767 Synchronous code must use the FRAME_SET_VISIBLE macro.
769 Also, if a frame used to be invisible, but has just become visible,
770 it must be marked as garbaged, since redisplay hasn't been keeping
773 #define FRAME_SAMPLE_VISIBILITY(f) \
774 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
775 SET_FRAME_GARBAGED (f) : 0, \
776 (f)->visible = (f)->async_visible, \
777 (f)->iconified = (f)->async_iconified)
779 #define CHECK_FRAME(x) \
780 CHECK_TYPE (FRAMEP (x), Qframep, x)
782 #define CHECK_LIVE_FRAME(x) \
783 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
785 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
786 `for' loop which iterates over the elements of Vframe_list. The
787 loop will set FRAME_VAR, a Lisp_Object, to each frame in
788 Vframe_list in succession and execute the statement. LIST_VAR
789 should be a Lisp_Object too; it is used to iterate through the
792 This macro is a holdover from a time when multiple frames weren't always
793 supported. An alternate definition of the macro would expand to
794 something which executes the statement once. */
796 #define FOR_EACH_FRAME(list_var, frame_var) \
797 for ((list_var) = Vframe_list; \
799 && (frame_var = XCAR (list_var), 1)); \
800 list_var = XCDR (list_var))
803 extern Lisp_Object Qframep
, Qframe_live_p
;
805 extern struct frame
*last_nonminibuf_frame
;
807 extern struct frame
*make_terminal_frame
P_ ((void));
808 extern struct frame
*make_frame
P_ ((int));
809 #ifdef HAVE_WINDOW_SYSTEM
810 extern struct frame
*make_minibuffer_frame
P_ ((void));
811 extern struct frame
*make_frame_without_minibuffer
P_ ((Lisp_Object
,
814 #endif /* HAVE_WINDOW_SYSTEM */
815 extern int other_visible_frames
P_ ((struct frame
*));
817 extern Lisp_Object Vframe_list
;
818 extern Lisp_Object Vdefault_frame_alist
;
820 extern Lisp_Object Vterminal_frame
;
822 extern Lisp_Object Vmouse_highlight
;
824 /* The currently selected frame. */
826 extern Lisp_Object selected_frame
;
828 /* Value is a pointer to the selected frame. If the selected frame
829 isn't live, abort. */
831 #define SELECTED_FRAME() \
832 ((FRAMEP (selected_frame) \
833 && FRAME_LIVE_P (XFRAME (selected_frame))) \
834 ? XFRAME (selected_frame) \
835 : (abort (), (struct frame *) 0))
838 /***********************************************************************
839 Display-related Macros
840 ***********************************************************************/
842 /* Canonical y-unit on frame F.
843 This value currently equals the line height of the frame (which is
844 the height of the default font of F). */
846 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
848 /* Canonical x-unit on frame F.
849 This value currently equals the average width of the default font of F. */
851 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
853 /* Space glyph width of the default font of frame F. */
855 #define FRAME_SPACE_WIDTH(F) ((F)->space_width)
858 /* Pixel width of areas used to display truncation marks, continuation
859 marks, overlay arrows. This is 0 for terminal frames. */
861 #ifdef HAVE_WINDOW_SYSTEM
863 /* Total width of fringes reserved for drawing truncation bitmaps,
864 continuation bitmaps and alike. The width is in canonical char
865 units of the frame. This must currently be the case because window
866 sizes aren't pixel values. If it weren't the case, we wouldn't be
867 able to split windows horizontally nicely. */
869 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
871 /* Pixel-width of the left and right fringe. */
873 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
874 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
876 /* Total width of fringes in pixels. */
878 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
879 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
882 /* Pixel-width of internal border lines */
884 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
886 #else /* not HAVE_WINDOW_SYSTEM */
888 #define FRAME_FRINGE_COLS(F) 0
889 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
890 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
891 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
892 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
894 #endif /* not HAVE_WINDOW_SYSTEM */
899 /***********************************************************************
900 Conversion between canonical units and pixels
901 ***********************************************************************/
903 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
904 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
905 represented as Lisp numbers, i.e. integers or floats. */
907 /* Convert canonical value X to pixels. F is the frame whose
908 canonical char width is to be used. X must be a Lisp integer or
909 float. Value is a C integer. */
911 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
913 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
914 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
916 /* Convert canonical value Y to pixels. F is the frame whose
917 canonical character height is to be used. X must be a Lisp integer
918 or float. Value is a C integer. */
920 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
922 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
923 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
925 /* Convert pixel-value X to canonical units. F is the frame whose
926 canonical character width is to be used. X is a C integer. Result
927 is a Lisp float if X is not a multiple of the canon width,
928 otherwise it's a Lisp integer. */
930 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
931 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
932 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
933 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
935 /* Convert pixel-value Y to canonical units. F is the frame whose
936 canonical character height is to be used. Y is a C integer.
937 Result is a Lisp float if Y is not a multiple of the canon width,
938 otherwise it's a Lisp integer. */
940 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
941 ((Y) % FRAME_LINE_HEIGHT (F) \
942 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
943 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
947 /* Manipulating pixel sizes and character sizes.
948 Knowledge of which factors affect the overall size of the window should
949 be hidden in these macros, if that's possible.
951 Return the upper/left pixel position of the character cell on frame F
954 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
955 (FRAME_INTERNAL_BORDER_WIDTH (f) \
956 + (row) * FRAME_LINE_HEIGHT (f))
958 #define FRAME_COL_TO_PIXEL_X(f, col) \
959 (FRAME_INTERNAL_BORDER_WIDTH (f) \
960 + (col) * FRAME_COLUMN_WIDTH (f))
962 /* Return the pixel width/height of frame F if it has
963 COLS columns/LINES rows. */
965 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
966 (FRAME_COL_TO_PIXEL_X (f, cols) \
967 + (f)->scroll_bar_actual_width \
968 + FRAME_TOTAL_FRINGE_WIDTH (f) \
969 + FRAME_INTERNAL_BORDER_WIDTH (f))
971 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
972 (FRAME_LINE_TO_PIXEL_Y (f, lines) \
973 + FRAME_INTERNAL_BORDER_WIDTH (f))
976 /* Return the row/column (zero-based) of the character cell containing
977 the pixel on FRAME at Y/X. */
979 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
980 (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
981 / FRAME_LINE_HEIGHT (f))
983 #define FRAME_PIXEL_X_TO_COL(f, x) \
984 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
985 / FRAME_COLUMN_WIDTH (f))
987 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
990 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
991 (FRAME_PIXEL_X_TO_COL (f, ((width) \
992 - FRAME_INTERNAL_BORDER_WIDTH (f) \
993 - FRAME_TOTAL_FRINGE_WIDTH (f) \
994 - (f)->scroll_bar_actual_width)))
996 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
997 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
998 - FRAME_INTERNAL_BORDER_WIDTH (f))))
1001 /***********************************************************************
1003 ***********************************************************************/
1005 extern Lisp_Object Qauto_raise
, Qauto_lower
;
1006 extern Lisp_Object Qborder_color
, Qborder_width
;
1007 extern Lisp_Object Qbuffer_predicate
, Qbuffer_list
;
1008 extern Lisp_Object Qcursor_color
, Qcursor_type
;
1009 extern Lisp_Object Qfont
;
1010 extern Lisp_Object Qbackground_color
, Qforeground_color
;
1011 extern Lisp_Object Qicon
, Qicon_name
, Qicon_type
, Qicon_left
, Qicon_top
;
1012 extern Lisp_Object Qinternal_border_width
;
1013 extern Lisp_Object Qmenu_bar_lines
, Qtool_bar_lines
;
1014 extern Lisp_Object Qmouse_color
;
1015 extern Lisp_Object Qname
, Qtitle
;
1016 extern Lisp_Object Qparent_id
;
1017 extern Lisp_Object Qunsplittable
, Qvisibility
;
1018 extern Lisp_Object Qscroll_bar_width
, Qvertical_scroll_bars
;
1019 extern Lisp_Object Qscroll_bar_foreground
, Qscroll_bar_background
;
1020 extern Lisp_Object Qscreen_gamma
;
1021 extern Lisp_Object Qline_spacing
;
1022 extern Lisp_Object Qwait_for_wm
;
1023 extern Lisp_Object Qfullscreen
;
1024 extern Lisp_Object Qfont_backend
;
1026 extern Lisp_Object Qleft_fringe
, Qright_fringe
;
1027 extern Lisp_Object Qheight
, Qwidth
;
1028 extern Lisp_Object Qminibuffer
, Qmodeline
;
1029 extern Lisp_Object Qonly
;
1030 extern Lisp_Object Qx
, Qw32
, Qmac
, Qpc
;
1031 extern Lisp_Object Qvisible
;
1032 extern Lisp_Object Qdisplay_type
;
1033 extern Lisp_Object Qbackground_mode
;
1035 extern Lisp_Object Qx_resource_name
;
1037 extern Lisp_Object Qleft
, Qright
, Qtop
, Qbox
;
1038 extern Lisp_Object Qdisplay
;
1040 #ifdef HAVE_WINDOW_SYSTEM
1042 /* The class of this X application. */
1043 #define EMACS_CLASS "Emacs"
1047 /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */
1048 FULLSCREEN_NONE
= 0,
1049 FULLSCREEN_WIDTH
= 1,
1050 FULLSCREEN_HEIGHT
= 2,
1051 FULLSCREEN_BOTH
= 3,
1052 FULLSCREEN_WAIT
= 4,
1056 /* These are in xterm.c, w32term.c, etc. */
1058 extern void x_set_scroll_bar_default_width
P_ ((struct frame
*));
1059 extern void x_set_offset
P_ ((struct frame
*, int, int, int));
1060 extern void x_wm_set_icon_position
P_ ((struct frame
*, int, int));
1062 extern Lisp_Object x_new_font
P_ ((struct frame
*, char *));
1063 extern Lisp_Object x_new_fontset
P_ ((struct frame
*, Lisp_Object
));
1064 #ifdef USE_FONT_BACKEND
1065 extern Lisp_Object x_new_fontset2
P_ ((struct frame
*, int, Lisp_Object
));
1066 #endif /* USE_FONT_BACKEND */
1068 /* These are in frame.c */
1070 extern Lisp_Object Vx_resource_name
;
1071 extern Lisp_Object Vx_resource_class
;
1074 extern Lisp_Object Qface_set_after_frame_default
;
1076 extern void x_fullscreen_adjust
P_ ((struct frame
*f
, int *, int *,
1079 extern void x_set_frame_parameters
P_ ((struct frame
*, Lisp_Object
));
1080 extern void x_report_frame_params
P_ ((struct frame
*, Lisp_Object
*));
1082 extern void x_set_fullscreen
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1083 extern void x_set_line_spacing
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1084 extern void x_set_screen_gamma
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1085 extern void x_set_font
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1086 extern void x_set_font_backend
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1087 extern void x_set_fringe_width
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1088 extern void x_set_border_width
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1089 extern void x_set_internal_border_width
P_ ((struct frame
*, Lisp_Object
,
1091 extern void x_set_visibility
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1092 extern void x_set_autoraise
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1093 extern void x_set_autolower
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1094 extern void x_set_unsplittable
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
1095 extern void x_set_vertical_scroll_bars
P_ ((struct frame
*, Lisp_Object
,
1097 extern void x_set_scroll_bar_width
P_ ((struct frame
*, Lisp_Object
,
1100 extern Lisp_Object x_icon_type
P_ ((struct frame
*));
1102 extern int x_figure_window_size
P_ ((struct frame
*, Lisp_Object
, int));
1105 extern void validate_x_resource_name
P_ ((void));
1107 #endif /* HAVE_WINDOW_SYSTEM */
1109 #endif /* not EMACS_FRAME_H */
1111 /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4
1112 (do not change this comment) */