* lisp/window.el (with-displayed-buffer-window): New macro.
[emacs.git] / src / frame.h
blob4fb98278a51ab10fe28391b50c3c10124376eb35
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2014 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 /* Don't multiply include: dispextern.h includes macterm.h which
20 includes frame.h some emacs source includes both dispextern.h and
21 frame.h. */
23 #ifndef EMACS_FRAME_H
24 #define EMACS_FRAME_H
26 #include "dispextern.h"
27 #include "termhooks.h"
28 #include "window.h"
30 INLINE_HEADER_BEGIN
32 enum vertical_scroll_bar_type
34 vertical_scroll_bar_none,
35 vertical_scroll_bar_left,
36 vertical_scroll_bar_right
39 enum fullscreen_type
41 FULLSCREEN_NONE,
42 FULLSCREEN_WIDTH = 0x001,
43 FULLSCREEN_HEIGHT = 0x002,
44 FULLSCREEN_BOTH = 0x003,
45 FULLSCREEN_MAXIMIZED = 0x013,
46 FULLSCREEN_WAIT = 0x100
49 /* The structure representing a frame. */
51 struct frame
53 struct vectorlike_header header;
55 /* All Lisp_Object components must come first.
56 That ensures they are all aligned normally. */
58 /* Name of this frame: a Lisp string. It is used for looking up resources,
59 as well as for the title in some cases. */
60 Lisp_Object name;
62 /* The name to use for the icon, the last time
63 it was refreshed. nil means not explicitly specified. */
64 Lisp_Object icon_name;
66 /* This is the frame title specified explicitly, if any.
67 Usually it is nil. */
68 Lisp_Object title;
70 /* The frame which should receive keystrokes that occur in this
71 frame, or nil if they should go to the frame itself. This is
72 usually nil, but if the frame is minibufferless, we can use this
73 to redirect keystrokes to a surrogate minibuffer frame when
74 needed.
76 Note that a value of nil is different than having the field point
77 to the frame itself. Whenever the Fselect_frame function is used
78 to shift from one frame to the other, any redirections to the
79 original frame are shifted to the newly selected frame; if
80 focus_frame is nil, Fselect_frame will leave it alone. */
81 Lisp_Object focus_frame;
83 /* This frame's root window. Every frame has one.
84 If the frame has only a minibuffer window, this is it.
85 Otherwise, if the frame has a minibuffer window, this is its sibling. */
86 Lisp_Object root_window;
88 /* This frame's selected window.
89 Each frame has its own window hierarchy
90 and one of the windows in it is selected within the frame.
91 The selected window of the selected frame is Emacs's selected window. */
92 Lisp_Object selected_window;
94 /* This frame's minibuffer window.
95 Most frames have their own minibuffer windows,
96 but only the selected frame's minibuffer window
97 can actually appear to exist. */
98 Lisp_Object minibuffer_window;
100 /* Parameter alist of this frame.
101 These are the parameters specified when creating the frame
102 or modified with modify-frame-parameters. */
103 Lisp_Object param_alist;
105 /* List of scroll bars on this frame.
106 Actually, we don't specify exactly what is stored here at all; the
107 scroll bar implementation code can use it to store anything it likes.
108 This field is marked by the garbage collector. It is here
109 instead of in the `device' structure so that the garbage
110 collector doesn't need to look inside the window-system-dependent
111 structure. */
112 Lisp_Object scroll_bars;
113 Lisp_Object condemned_scroll_bars;
115 /* Vector describing the items to display in the menu bar.
116 Each item has four elements in this vector.
117 They are KEY, STRING, SUBMAP, and HPOS.
118 (HPOS is not used in when the X toolkit is in use.)
119 There are four additional elements of nil at the end, to terminate. */
120 Lisp_Object menu_bar_items;
122 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
123 Lisp_Object face_alist;
125 /* A vector that records the entire structure of this frame's menu bar.
126 For the format of the data, see extensive comments in xmenu.c.
127 Only the X toolkit version uses this. */
128 Lisp_Object menu_bar_vector;
130 /* Predicate for selecting buffers for other-buffer. */
131 Lisp_Object buffer_predicate;
133 /* List of buffers viewed in this frame, for other-buffer. */
134 Lisp_Object buffer_list;
136 /* List of buffers that were viewed, then buried in this frame. The
137 most recently buried buffer is first. For last-buffer. */
138 Lisp_Object buried_buffer_list;
140 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
141 /* A dummy window used to display menu bars under X when no X
142 toolkit support is available. */
143 Lisp_Object menu_bar_window;
144 #endif
146 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
147 /* A window used to display the tool-bar of a frame. */
148 Lisp_Object tool_bar_window;
150 /* Desired and current contents displayed in that window. */
151 Lisp_Object desired_tool_bar_string;
152 Lisp_Object current_tool_bar_string;
153 #endif
155 /* Desired and current tool-bar items. */
156 Lisp_Object tool_bar_items;
158 /* Where tool bar is, can be left, right, top or bottom. The native
159 tool bar only supports top. */
160 Lisp_Object tool_bar_position;
162 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
163 /* List of data specific to font-driver and frame, but common to faces. */
164 Lisp_Object font_data;
165 #endif
167 /* Beyond here, there should be no more Lisp_Object components. */
169 /* Cache of realized faces. */
170 struct face_cache *face_cache;
172 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
173 /* Tool-bar item index of the item on which a mouse button was pressed. */
174 int last_tool_bar_item;
175 #endif
177 /* Number of elements in `menu_bar_vector' that have meaningful data. */
178 int menu_bar_items_used;
180 /* A buffer to hold the frame's name. We can't use the Lisp
181 string's pointer (`name', above) because it might get relocated. */
182 char *namebuf;
184 /* Glyph pool and matrix. */
185 struct glyph_pool *current_pool;
186 struct glyph_pool *desired_pool;
187 struct glyph_matrix *desired_matrix;
188 struct glyph_matrix *current_matrix;
190 /* True means that glyphs on this frame have been initialized so it can
191 be used for output. */
192 bool_bf glyphs_initialized_p : 1;
194 /* Set to true in change_frame_size when size of frame changed
195 Clear the frame in clear_garbaged_frames if set. */
196 bool_bf resized_p : 1;
198 /* Set to true if the default face for the frame has been
199 realized. Reset to zero whenever the default face changes.
200 Used to see the difference between a font change and face change. */
201 bool_bf default_face_done_p : 1;
203 /* Set to true if this frame has already been hscrolled during
204 current redisplay. */
205 bool_bf already_hscrolled_p : 1;
207 /* Set to true when current redisplay has updated frame. */
208 bool_bf updated_p : 1;
210 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
211 /* Set to true to minimize tool-bar height even when
212 auto-resize-tool-bar is set to grow-only. */
213 bool_bf minimize_tool_bar_window_p : 1;
214 #endif
216 #if defined (USE_GTK) || defined (HAVE_NS)
217 /* True means using a tool bar that comes from the toolkit. */
218 bool_bf external_tool_bar : 1;
219 #endif
221 /* True means that fonts have been loaded since the last glyph
222 matrix adjustments. */
223 bool_bf fonts_changed : 1;
225 /* True means that cursor type has been changed. */
226 bool_bf cursor_type_changed : 1;
228 /* True if it needs to be redisplayed. */
229 bool_bf redisplay : 1;
231 /* Margin at the top of the frame. Used to display the tool-bar. */
232 int tool_bar_lines;
234 /* Pixel height of tool bar. */
235 int tool_bar_height;
237 int n_tool_bar_rows;
238 int n_tool_bar_items;
240 /* A buffer for decode_mode_line. */
241 char *decode_mode_spec_buffer;
243 /* See do_line_insertion_deletion_costs for info on these arrays. */
244 /* Cost of inserting 1 line on this frame. */
245 int *insert_line_cost;
246 /* Cost of deleting 1 line on this frame. */
247 int *delete_line_cost;
248 /* Cost of inserting n lines on this frame. */
249 int *insert_n_lines_cost;
250 /* Cost of deleting n lines on this frame. */
251 int *delete_n_lines_cost;
253 /* Text width of this frame (excluding fringes, scroll bars and
254 internal border width) and text height (excluding internal border
255 width) in units of canonical characters. */
256 int text_cols, text_lines;
258 /* Total width of this frame (including fringes and scroll bars) in
259 units of canonical characters. */
260 int total_cols;
262 /* Text width of this frame (excluding fringes, scroll bars and
263 internal border width) and text height (excluding internal border
264 width) in pixels. */
265 int text_width, text_height;
267 /* New text height and width for pending size change. 0 if no change
268 pending. These values represent pixels or canonical character units
269 according to the value of new_pixelwise and correlate to the the
270 text width/height of the frame. */
271 int new_width, new_height;
273 /* Whether new_height and new_width shall be interpreted
274 in pixels. */
275 bool new_pixelwise;
277 /* Pixel position of the frame window (x and y offsets in root window). */
278 int left_pos, top_pos;
280 /* Size of the frame window (including internal border widths) in
281 pixels. */
282 int pixel_width, pixel_height;
284 /* These many pixels are the difference between the outer window (i.e. the
285 left and top of the window manager decoration) and FRAME_X_WINDOW. */
286 int x_pixels_diff, y_pixels_diff;
288 /* This is the gravity value for the specified window position. */
289 int win_gravity;
291 /* The geometry flags for this window. */
292 int size_hint_flags;
294 /* Border width of the frame window as known by the (X) window system. */
295 int border_width;
297 /* Width of the internal border. This is a line of background color
298 just inside the window's border. When the frame is selected,
299 a highlighting is displayed inside the internal border. */
300 int internal_border_width;
302 /* Width of borders between this frame's windows. */
303 int right_divider_width;
304 int bottom_divider_width;
306 /* Canonical X unit. Width of default font, in pixels. */
307 int column_width;
309 /* Canonical Y unit. Height of a line, in pixels. */
310 int line_height;
312 /* The output method says how the contents of this frame are
313 displayed. It could be using termcap, or using an X window.
314 This must be the same as the terminal->type. */
315 enum output_method output_method;
317 /* The terminal device that this frame uses. If this is NULL, then
318 the frame has been deleted. */
319 struct terminal *terminal;
321 /* Device-dependent, frame-local auxiliary data used for displaying
322 the contents. When the frame is deleted, this data is deleted as
323 well. */
324 union output_data
326 struct tty_output *tty; /* From termchar.h. */
327 struct x_output *x; /* From xterm.h. */
328 struct w32_output *w32; /* From w32term.h. */
329 struct ns_output *ns; /* From nsterm.h. */
330 intptr_t nothing;
332 output_data;
334 /* List of font-drivers available on the frame. */
335 struct font_driver_list *font_driver_list;
337 /* Total width of fringes reserved for drawing truncation bitmaps,
338 continuation bitmaps and alike. The width is in canonical char
339 units of the frame. This must currently be the case because window
340 sizes aren't pixel values. If it weren't the case, we wouldn't be
341 able to split windows horizontally nicely. */
342 int fringe_cols;
344 /* The extra width (in pixels) currently allotted for fringes. */
345 int left_fringe_width, right_fringe_width;
347 /* See FULLSCREEN_ enum below. */
348 enum fullscreen_type want_fullscreen;
350 /* Number of lines of menu bar. */
351 int menu_bar_lines;
353 /* Pixel height of menubar. */
354 int menu_bar_height;
356 #if defined (HAVE_X_WINDOWS)
357 /* Used by x_wait_for_event when watching for an X event on this frame. */
358 int wait_event_type;
359 #endif
361 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
362 || defined (HAVE_NS) || defined (USE_GTK)
363 /* True means using a menu bar that comes from the X toolkit. */
364 bool_bf external_menu_bar : 1;
365 #endif
367 /* Next two bitfields are mutually exclusive. They might both be
368 zero if the frame has been made invisible without an icon. */
370 /* Nonzero if the frame is currently displayed; we check
371 it to see if we should bother updating the frame's contents.
373 On ttys and on Windows NT/9X, to avoid wasting effort updating
374 visible frames that are actually completely obscured by other
375 windows on the display, we bend the meaning of visible slightly:
376 if equal to 2, then the frame is obscured - we still consider
377 it to be "visible" as seen from lisp, but we don't bother
378 updating it. */
379 unsigned visible : 2;
381 /* True if the frame is currently iconified. Do not
382 set this directly, use SET_FRAME_ICONIFIED instead. */
383 bool_bf iconified : 1;
385 /* True if this frame should be fully redisplayed. Disables all
386 optimizations while rebuilding matrices and redrawing. */
387 bool_bf garbaged : 1;
389 /* False means, if this frame has just one window,
390 show no modeline for that window. */
391 bool_bf wants_modeline : 1;
393 /* True means raise this frame to the top of the heap when selected. */
394 bool_bf auto_raise : 1;
396 /* True means lower this frame to the bottom of the stack when left. */
397 bool_bf auto_lower : 1;
399 /* True if frame's root window can't be split. */
400 bool_bf no_split : 1;
402 /* If this is set, then Emacs won't change the frame name to indicate
403 the current buffer, etcetera. If the user explicitly sets the frame
404 name, this gets set. If the user sets the name to Qnil, this is
405 cleared. */
406 bool_bf explicit_name : 1;
408 /* True if size of some window on this frame has changed. */
409 bool_bf window_sizes_changed : 1;
411 /* True if the mouse has moved on this display device
412 since the last time we checked. */
413 bool_bf mouse_moved : 1;
415 /* True means that the pointer is invisible. */
416 bool_bf pointer_invisible : 1;
418 /* True means that all windows except mini-window and
419 selected window on this frame have frozen window starts. */
420 bool_bf frozen_window_starts : 1;
422 /* Nonzero if we should actually display the scroll bars on this frame. */
423 enum vertical_scroll_bar_type vertical_scroll_bar_type;
425 /* What kind of text cursor should we draw in the future?
426 This should always be filled_box_cursor or bar_cursor. */
427 enum text_cursor_kinds desired_cursor;
429 /* Width of bar cursor (if we are using that). */
430 int cursor_width;
432 /* What kind of text cursor should we draw when the cursor blinks off?
433 This can be filled_box_cursor or bar_cursor or no_cursor. */
434 enum text_cursor_kinds blink_off_cursor;
436 /* Width of bar cursor (if we are using that) for blink-off state. */
437 int blink_off_cursor_width;
439 /* Configured width of the scroll bar, in pixels and in characters.
440 config_scroll_bar_cols tracks config_scroll_bar_width if the
441 latter is positive; a zero value in config_scroll_bar_width means
442 to compute the actual width on the fly, using config_scroll_bar_cols
443 and the current font width. */
444 int config_scroll_bar_width;
445 int config_scroll_bar_cols;
447 /* The baud rate that was used to calculate costs for this frame. */
448 int cost_calculation_baud_rate;
450 /* Frame opacity
451 alpha[0]: alpha transparency of the active frame
452 alpha[1]: alpha transparency of inactive frames
453 Negative values mean not to change alpha. */
454 double alpha[2];
456 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
457 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
458 frame parameter. 0 means don't do gamma correction. */
459 double gamma;
461 /* Additional space to put between text lines on this frame. */
462 int extra_line_spacing;
464 /* All display backends seem to need these two pixel values. */
465 unsigned long background_pixel;
466 unsigned long foreground_pixel;
469 /* Most code should use these functions to set Lisp fields in struct frame. */
471 INLINE void
472 fset_buffer_list (struct frame *f, Lisp_Object val)
474 f->buffer_list = val;
476 INLINE void
477 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
479 f->buried_buffer_list = val;
481 INLINE void
482 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
484 f->condemned_scroll_bars = val;
486 INLINE void
487 fset_face_alist (struct frame *f, Lisp_Object val)
489 f->face_alist = val;
491 INLINE void
492 fset_focus_frame (struct frame *f, Lisp_Object val)
494 f->focus_frame = val;
496 INLINE void
497 fset_icon_name (struct frame *f, Lisp_Object val)
499 f->icon_name = val;
501 INLINE void
502 fset_menu_bar_items (struct frame *f, Lisp_Object val)
504 f->menu_bar_items = val;
506 INLINE void
507 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
509 f->menu_bar_vector = val;
511 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
512 INLINE void
513 fset_menu_bar_window (struct frame *f, Lisp_Object val)
515 f->menu_bar_window = val;
517 #endif
518 INLINE void
519 fset_name (struct frame *f, Lisp_Object val)
521 f->name = val;
523 INLINE void
524 fset_param_alist (struct frame *f, Lisp_Object val)
526 f->param_alist = val;
528 INLINE void
529 fset_root_window (struct frame *f, Lisp_Object val)
531 f->root_window = val;
533 INLINE void
534 fset_scroll_bars (struct frame *f, Lisp_Object val)
536 f->scroll_bars = val;
538 INLINE void
539 fset_selected_window (struct frame *f, Lisp_Object val)
541 f->selected_window = val;
543 INLINE void
544 fset_title (struct frame *f, Lisp_Object val)
546 f->title = val;
548 INLINE void
549 fset_tool_bar_items (struct frame *f, Lisp_Object val)
551 f->tool_bar_items = val;
553 INLINE void
554 fset_tool_bar_position (struct frame *f, Lisp_Object val)
556 f->tool_bar_position = val;
558 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
559 INLINE void
560 fset_tool_bar_window (struct frame *f, Lisp_Object val)
562 f->tool_bar_window = val;
564 INLINE void
565 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
567 f->current_tool_bar_string = val;
569 INLINE void
570 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
572 f->desired_tool_bar_string = val;
574 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
576 #define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
578 INLINE double
579 default_pixels_per_inch_x (void)
581 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
582 ? XCAR (Vdisplay_pixels_per_inch)
583 : Vdisplay_pixels_per_inch);
584 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
587 INLINE double
588 default_pixels_per_inch_y (void)
590 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
591 ? XCDR (Vdisplay_pixels_per_inch)
592 : Vdisplay_pixels_per_inch);
593 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
596 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
598 /* Return a pointer to the image cache of frame F. */
599 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
601 #define XFRAME(p) \
602 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
603 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
605 /* Given a window, return its frame as a Lisp_Object. */
606 #define WINDOW_FRAME(w) ((w)->frame)
608 /* Test a frame for particular kinds of display methods. */
609 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
610 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
611 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
612 #ifndef HAVE_NTGUI
613 #define FRAME_W32_P(f) false
614 #else
615 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
616 #endif
617 #ifndef MSDOS
618 #define FRAME_MSDOS_P(f) false
619 #else
620 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
621 #endif
622 #ifndef HAVE_NS
623 #define FRAME_NS_P(f) false
624 #else
625 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
626 #endif
628 /* FRAME_WINDOW_P tests whether the frame is a window, and is
629 defined to be the predicate for the window system being used. */
631 #ifdef HAVE_X_WINDOWS
632 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
633 #endif
634 #ifdef HAVE_NTGUI
635 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
636 #endif
637 #ifdef HAVE_NS
638 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
639 #endif
640 #ifndef FRAME_WINDOW_P
641 #define FRAME_WINDOW_P(f) ((void) (f), false)
642 #endif
644 /* Dots per inch of the screen the frame F is on. */
646 #ifdef HAVE_WINDOW_SYSTEM
648 #define FRAME_RES_X(f) \
649 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
650 #define FRAME_RES_Y(f) \
651 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
653 #else /* !HAVE_WINDOW_SYSTEM */
655 /* Defaults when no window system available. */
657 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
658 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
660 #endif /* HAVE_WINDOW_SYSTEM */
662 /* Return a pointer to the structure holding information about the
663 region of text, if any, that is currently shown in mouse-face on
664 frame F. We need to define two versions because a TTY-only build
665 does not have FRAME_DISPLAY_INFO. */
666 #ifdef HAVE_WINDOW_SYSTEM
667 # define MOUSE_HL_INFO(F) \
668 (FRAME_WINDOW_P(F) \
669 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
670 : &(F)->output_data.tty->display_info->mouse_highlight)
671 #else
672 # define MOUSE_HL_INFO(F) \
673 (&(F)->output_data.tty->display_info->mouse_highlight)
674 #endif
676 /* True if frame F is still alive (not deleted). */
677 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
679 /* True if frame F is a minibuffer-only frame. */
680 #define FRAME_MINIBUF_ONLY_P(f) \
681 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
683 /* True if frame F contains it's own minibuffer window. Frame always has
684 minibuffer window, but it could use minibuffer window of another frame. */
685 #define FRAME_HAS_MINIBUF_P(f) \
686 (WINDOWP (f->minibuffer_window) \
687 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
689 /* Pixel width of frame F. */
690 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
692 /* Pixel height of frame F, including non-toolkit menu bar and
693 non-toolkit tool bar lines. */
694 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
696 /* Width of frame F, measured in canonical character columns,
697 not including scroll bars if any. */
698 #define FRAME_COLS(f) (f)->text_cols
700 /* Height of frame F, measured in canonical lines, including
701 non-toolkit menu bar and non-toolkit tool bar lines. */
702 #define FRAME_LINES(f) (f)->text_lines
704 /* Width of frame F, measured in pixels not including the width for
705 fringes, scroll bar, and internal borders. */
706 #define FRAME_TEXT_WIDTH(f) (f)->text_width
708 /* Height of frame F, measured in pixels not including the height
709 for internal borders. */
710 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
712 /* Number of lines of frame F used for menu bar.
713 This is relevant on terminal frames and on
714 X Windows when not using the X toolkit.
715 These lines are counted in FRAME_LINES. */
716 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
718 /* Pixel height of frame F's menu bar. */
719 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
721 /* True if this frame should display a tool bar
722 in a way that does not use any text lines. */
723 #if defined (USE_GTK) || defined (HAVE_NS)
724 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
725 #else
726 #define FRAME_EXTERNAL_TOOL_BAR(f) false
727 #endif
729 /* Number of lines of frame F used for the tool-bar. */
730 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
732 /* Pixel height of frame F's tool-bar. */
733 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
735 /* Lines above the top-most window in frame F. */
736 #define FRAME_TOP_MARGIN(F) \
737 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
739 /* Pixel height of frame F's top margin. */
740 #define FRAME_TOP_MARGIN_HEIGHT(F) \
741 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
743 /* True if this frame should display a menu bar
744 in a way that does not use any text lines. */
745 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
746 || defined (HAVE_NS) || defined (USE_GTK)
747 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
748 #else
749 #define FRAME_EXTERNAL_MENU_BAR(f) false
750 #endif
751 #define FRAME_VISIBLE_P(f) (f)->visible
753 /* True if frame F is currently visible but hidden. */
754 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
756 /* True if frame F is currently iconified. */
757 #define FRAME_ICONIFIED_P(f) (f)->iconified
759 /* Mark frame F as currently garbaged. */
760 #define SET_FRAME_GARBAGED(f) \
761 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
763 /* True if frame F is currently garbaged. */
764 #define FRAME_GARBAGED_P(f) (f)->garbaged
766 /* True means do not allow splitting this frame's window. */
767 #define FRAME_NO_SPLIT_P(f) (f)->no_split
769 /* Not really implemented. */
770 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
772 /* True if all windows except selected window and mini window
773 are frozen on frame F. */
774 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
776 /* True if a size change has been requested for frame F
777 but not yet really put into effect. This can be true temporarily
778 when an X event comes in at a bad time. */
779 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
781 /* The minibuffer window of frame F, if it has one; otherwise nil. */
782 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
784 /* The root window of the window tree of frame F. */
785 #define FRAME_ROOT_WINDOW(f) f->root_window
787 /* The currently selected window of the window tree of frame F. */
788 #define FRAME_SELECTED_WINDOW(f) f->selected_window
790 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
791 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
792 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
793 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
794 #define FRAME_FOCUS_FRAME(f) f->focus_frame
796 /* This frame slot says whether scroll bars are currently enabled for frame F,
797 and which side they are on. */
798 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
799 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
800 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
801 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
802 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
803 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
804 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
806 /* Width that a scroll bar in frame F should have, if there is one.
807 Measured in pixels.
808 If scroll bars are turned off, this is still nonzero. */
809 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
811 /* Width that a scroll bar in frame F should have, if there is one.
812 Measured in columns (characters).
813 If scroll bars are turned off, this is still nonzero. */
814 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
816 /* Width of a scroll bar in frame F, measured in columns (characters),
817 but only if scroll bars are on the left. If scroll bars are on
818 the right in this frame, or there are no scroll bars, value is 0. */
820 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
821 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
822 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
823 : 0)
825 /* Width of a left scroll bar in frame F, measured in pixels */
827 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
828 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
829 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
830 : 0)
832 /* Width of a scroll bar in frame F, measured in columns (characters),
833 but only if scroll bars are on the right. If scroll bars are on
834 the left in this frame, or there are no scroll bars, value is 0. */
836 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
837 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
838 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
839 : 0)
841 /* Width of a right scroll bar area in frame F, measured in pixels */
843 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
844 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
845 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
846 : 0)
848 /* Actual width of a scroll bar in frame F, measured in columns. */
850 #define FRAME_SCROLL_BAR_COLS(f) \
851 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
852 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
853 : 0)
855 /* Actual width of a scroll bar area in frame F, measured in pixels. */
857 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
858 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
859 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
860 : 0)
862 /* Total width of frame F, in columns (characters),
863 including the width used by scroll bars if any. */
864 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
866 /* Set the character widths of frame F. WIDTH specifies a nominal
867 character text width. */
868 #define SET_FRAME_COLS(f, width) \
869 ((f)->text_cols = (width), \
870 (f)->total_cols = ((width) \
871 + FRAME_SCROLL_BAR_COLS (f) \
872 + FRAME_FRINGE_COLS (f)))
874 /* Set the pixel widths of frame F. WIDTH specifies a nominal pixel
875 text width. */
876 #define SET_FRAME_WIDTH(f, width) \
877 ((f)->text_width = (width), \
878 (f)->pixel_width = ((width) \
879 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
880 + FRAME_TOTAL_FRINGE_WIDTH (f) \
881 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
883 /* Set the pixel heights of frame F. HEIGHT specifies a nominal pixel
884 text width. */
885 #define SET_FRAME_HEIGHT(f, height) \
886 ((f)->text_height = (height), \
887 (f)->pixel_height = ((height) \
888 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
890 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
892 #define FRAME_CURSOR_X_LIMIT(f) \
893 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
895 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
897 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
898 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
899 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
901 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
902 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
903 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
904 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
906 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
907 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
909 /* Return a pointer to the face cache of frame F. */
911 #define FRAME_FACE_CACHE(F) (F)->face_cache
913 /* Return the size of message_buf of the frame F. We multiply the
914 width of the frame by 4 because multi-byte form may require at most
915 4-byte for a character. */
917 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
919 #define CHECK_FRAME(x) \
920 CHECK_TYPE (FRAMEP (x), Qframep, x)
922 #define CHECK_LIVE_FRAME(x) \
923 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
925 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
926 `for' loop which iterates over the elements of Vframe_list. The
927 loop will set FRAME_VAR, a Lisp_Object, to each frame in
928 Vframe_list in succession and execute the statement. LIST_VAR
929 should be a Lisp_Object too; it is used to iterate through the
930 Vframe_list.
932 This macro is a holdover from a time when multiple frames weren't always
933 supported. An alternate definition of the macro would expand to
934 something which executes the statement once. */
936 #define FOR_EACH_FRAME(list_var, frame_var) \
937 for ((list_var) = Vframe_list; \
938 (CONSP (list_var) \
939 && (frame_var = XCAR (list_var), true)); \
940 list_var = XCDR (list_var))
942 /* Reflect mouse movement when a complete frame update is performed. */
944 #define FRAME_MOUSE_UPDATE(frame) \
945 do { \
946 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
947 if (frame == hlinfo->mouse_face_mouse_frame) \
949 block_input (); \
950 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
951 hlinfo->mouse_face_mouse_x, \
952 hlinfo->mouse_face_mouse_y); \
953 unblock_input (); \
955 } while (false)
957 /* False means there are no visible garbaged frames. */
958 extern bool frame_garbaged;
960 /* Set visibility of frame F.
961 We call redisplay_other_windows to make sure the frame gets redisplayed
962 if some changes were applied to it while it wasn't visible (and hence
963 wasn't redisplayed). */
965 INLINE void
966 SET_FRAME_VISIBLE (struct frame *f, int v)
968 eassert (0 <= v && v <= 2);
969 if (v)
971 if (v == 1 && f->visible != 1)
972 redisplay_other_windows ();
973 if (FRAME_GARBAGED_P (f))
974 frame_garbaged = true;
976 f->visible = v;
979 /* Set iconify of frame F. */
981 #define SET_FRAME_ICONIFIED(f, i) \
982 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
984 extern Lisp_Object selected_frame;
985 extern Lisp_Object Qframep, Qframe_live_p;
986 extern Lisp_Object Qtty, Qtty_type;
987 extern Lisp_Object Qtty_color_mode;
988 extern Lisp_Object Qterminal;
989 extern Lisp_Object Qnoelisp;
991 extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
992 extern struct frame *decode_window_system_frame (Lisp_Object);
993 extern struct frame *decode_live_frame (Lisp_Object);
994 extern struct frame *decode_any_frame (Lisp_Object);
995 extern struct frame *make_initial_frame (void);
996 extern struct frame *make_frame (bool);
997 #ifdef HAVE_WINDOW_SYSTEM
998 extern struct frame *make_minibuffer_frame (void);
999 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1000 struct kboard *,
1001 Lisp_Object);
1002 extern bool window_system_available (struct frame *);
1003 #else /* not HAVE_WINDOW_SYSTEM */
1004 #define window_system_available(f) ((void) (f), false)
1005 #endif /* HAVE_WINDOW_SYSTEM */
1006 extern void check_window_system (struct frame *);
1007 extern void frame_make_pointer_invisible (struct frame *);
1008 extern void frame_make_pointer_visible (struct frame *);
1009 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1011 extern Lisp_Object Vframe_list;
1013 /* Value is a pointer to the selected frame. If the selected frame
1014 isn't live, abort. */
1016 #define SELECTED_FRAME() \
1017 ((FRAMEP (selected_frame) \
1018 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1019 ? XFRAME (selected_frame) \
1020 : (emacs_abort (), (struct frame *) 0))
1023 /***********************************************************************
1024 Display-related Macros
1025 ***********************************************************************/
1027 /* Canonical y-unit on frame F.
1028 This value currently equals the line height of the frame (which is
1029 the height of the default font of F). */
1031 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1033 /* Canonical x-unit on frame F.
1034 This value currently equals the average width of the default font of F. */
1036 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1038 /* Pixel width of areas used to display truncation marks, continuation
1039 marks, overlay arrows. This is 0 for terminal frames. */
1041 #ifdef HAVE_WINDOW_SYSTEM
1043 /* Total width of fringes reserved for drawing truncation bitmaps,
1044 continuation bitmaps and alike. The width is in canonical char
1045 units of the frame. This must currently be the case because window
1046 sizes aren't pixel values. If it weren't the case, we wouldn't be
1047 able to split windows horizontally nicely. */
1049 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
1051 /* Pixel-width of the left and right fringe. */
1053 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
1054 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
1056 /* Total width of fringes in pixels. */
1058 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
1059 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
1061 /* Pixel-width of internal border lines */
1062 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
1064 /* Pixel-size of window border lines */
1065 #define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width)
1066 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width)
1068 #else /* not HAVE_WINDOW_SYSTEM */
1070 #define FRAME_FRINGE_COLS(F) 0
1071 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
1072 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
1073 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
1074 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
1075 #define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1076 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1078 #endif /* not HAVE_WINDOW_SYSTEM */
1080 /***********************************************************************
1081 Conversion between canonical units and pixels
1082 ***********************************************************************/
1084 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1085 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1086 represented as Lisp numbers, i.e. integers or floats. */
1088 /* Convert canonical value X to pixels. F is the frame whose
1089 canonical char width is to be used. X must be a Lisp integer or
1090 float. Value is a C integer. */
1092 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1093 (INTEGERP (X) \
1094 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1095 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1097 /* Convert canonical value Y to pixels. F is the frame whose
1098 canonical character height is to be used. X must be a Lisp integer
1099 or float. Value is a C integer. */
1101 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1102 (INTEGERP (Y) \
1103 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1104 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1106 /* Convert pixel-value X to canonical units. F is the frame whose
1107 canonical character width is to be used. X is a C integer. Result
1108 is a Lisp float if X is not a multiple of the canon width,
1109 otherwise it's a Lisp integer. */
1111 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1112 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1113 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1114 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1116 /* Convert pixel-value Y to canonical units. F is the frame whose
1117 canonical character height is to be used. Y is a C integer.
1118 Result is a Lisp float if Y is not a multiple of the canon width,
1119 otherwise it's a Lisp integer. */
1121 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1122 ((Y) % FRAME_LINE_HEIGHT (F) \
1123 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1124 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1128 /* Manipulating pixel sizes and character sizes.
1129 Knowledge of which factors affect the overall size of the window should
1130 be hidden in these macros, if that's possible.
1132 Return the upper/left pixel position of the character cell on frame F
1133 at ROW/COL. */
1135 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1136 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1137 + (row) * FRAME_LINE_HEIGHT (f))
1139 #define FRAME_COL_TO_PIXEL_X(f, col) \
1140 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1141 + (col) * FRAME_COLUMN_WIDTH (f))
1143 /* Return the pixel width/height of frame F if it has
1144 COLS columns/LINES rows. */
1146 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1147 (FRAME_COL_TO_PIXEL_X (f, cols) \
1148 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1149 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1150 + FRAME_INTERNAL_BORDER_WIDTH (f))
1152 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1153 ((lines) * FRAME_LINE_HEIGHT (f) \
1154 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1156 /* Return the row/column (zero-based) of the character cell containing
1157 the pixel on FRAME at Y/X. */
1159 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1160 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1161 ? (y) \
1162 : ((y) < FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1163 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1164 /* Arrange for the division to round down. */ \
1165 + FRAME_LINE_HEIGHT (f) - 1) \
1166 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1167 / FRAME_LINE_HEIGHT (f))
1169 #define FRAME_PIXEL_X_TO_COL(f, x) \
1170 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1171 / FRAME_COLUMN_WIDTH (f))
1173 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1174 frame F? */
1176 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1177 (FRAME_PIXEL_X_TO_COL (f, ((width) \
1178 - FRAME_INTERNAL_BORDER_WIDTH (f) \
1179 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1180 - FRAME_SCROLL_BAR_AREA_WIDTH (f)))) \
1182 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1183 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
1184 - FRAME_INTERNAL_BORDER_WIDTH (f))))
1186 /* Return the pixel width/height of frame F with a text size of
1187 width/height. */
1189 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1190 ((width) \
1191 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1192 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1193 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1195 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1196 ((height) + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1198 /* Return the text width/height of frame F with a pixel size of
1199 width/height. */
1201 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1202 ((width) \
1203 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1204 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1205 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1207 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1208 ((height) - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1210 /* Value is the smallest width of any character in any font on frame F. */
1212 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1213 FRAME_DISPLAY_INFO (f)->smallest_char_width
1215 /* Value is the smallest height of any font on frame F. */
1217 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1218 FRAME_DISPLAY_INFO (f)->smallest_font_height
1220 /***********************************************************************
1221 Frame Parameters
1222 ***********************************************************************/
1224 extern Lisp_Object Qauto_raise, Qauto_lower;
1225 extern Lisp_Object Qborder_color, Qborder_width;
1226 extern Lisp_Object Qbuffer_predicate;
1227 extern Lisp_Object Qcursor_color, Qcursor_type;
1228 extern Lisp_Object Qfont;
1229 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1230 extern Lisp_Object Qinternal_border_width;
1231 extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
1232 extern Lisp_Object Qtooltip;
1233 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
1234 extern Lisp_Object Qmouse_color;
1235 extern Lisp_Object Qname, Qtitle;
1236 extern Lisp_Object Qparent_id;
1237 extern Lisp_Object Qunsplittable, Qvisibility;
1238 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1239 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1240 extern Lisp_Object Qscreen_gamma;
1241 extern Lisp_Object Qline_spacing;
1242 extern Lisp_Object Qwait_for_wm;
1243 extern Lisp_Object Qfullscreen;
1244 extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
1245 extern Lisp_Object Qsticky;
1246 extern Lisp_Object Qfont_backend;
1247 extern Lisp_Object Qalpha;
1249 extern Lisp_Object Qleft_fringe, Qright_fringe;
1250 extern Lisp_Object Qheight, Qwidth;
1251 extern Lisp_Object Qminibuffer, Qmodeline;
1252 extern Lisp_Object Qx, Qw32, Qpc, Qns;
1253 extern Lisp_Object Qvisible;
1254 extern Lisp_Object Qdisplay_type;
1256 extern Lisp_Object Qx_resource_name;
1258 extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom;
1259 extern Lisp_Object Qdisplay;
1261 extern Lisp_Object Qrun_hook_with_args;
1263 #ifdef HAVE_WINDOW_SYSTEM
1265 /* The class of this X application. */
1266 #define EMACS_CLASS "Emacs"
1268 /* These are in xterm.c, w32term.c, etc. */
1270 extern void x_set_scroll_bar_default_width (struct frame *);
1271 extern void x_set_offset (struct frame *, int, int, int);
1272 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1274 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1277 extern Lisp_Object Qface_set_after_frame_default;
1279 #ifdef HAVE_NTGUI
1280 extern void x_fullscreen_adjust (struct frame *f, int *, int *,
1281 int *, int *);
1282 #endif
1284 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1286 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1287 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1288 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1289 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1290 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1291 extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object);
1292 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1293 extern void x_set_internal_border_width (struct frame *, Lisp_Object,
1294 Lisp_Object);
1295 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1296 Lisp_Object);
1297 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1298 Lisp_Object);
1299 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1300 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1301 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1302 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1303 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object,
1304 Lisp_Object);
1305 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object,
1306 Lisp_Object);
1308 extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
1310 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1312 extern void validate_x_resource_name (void);
1314 extern Lisp_Object display_x_get_resource (Display_Info *,
1315 Lisp_Object attribute,
1316 Lisp_Object class,
1317 Lisp_Object component,
1318 Lisp_Object subclass);
1320 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1321 extern void x_set_window_size (struct frame *f, int change_grav,
1322 int width, int height, bool pixelwise);
1323 extern Lisp_Object x_get_focus_frame (struct frame *);
1324 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1325 extern void x_make_frame_visible (struct frame *f);
1326 extern void x_make_frame_invisible (struct frame *f);
1327 extern void x_iconify_frame (struct frame *f);
1328 extern void x_set_frame_alpha (struct frame *f);
1329 extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1330 extern void x_activate_menubar (struct frame *);
1331 extern void x_real_positions (struct frame *, int *, int *);
1332 extern void free_frame_menubar (struct frame *);
1333 extern void x_free_frame_resources (struct frame *);
1335 #if defined HAVE_X_WINDOWS
1336 extern void x_wm_set_icon_position (struct frame *, int, int);
1337 #if !defined USE_X_TOOLKIT
1338 extern char *x_get_resource_string (const char *, const char *);
1339 #endif
1340 extern void x_sync (struct frame *);
1341 #endif /* HAVE_X_WINDOWS */
1343 extern void x_query_colors (struct frame *f, XColor *, int);
1344 extern void x_query_color (struct frame *f, XColor *);
1345 extern void x_focus_frame (struct frame *);
1347 #ifndef HAVE_NS
1349 extern int x_bitmap_icon (struct frame *, Lisp_Object);
1351 /* Set F's bitmap icon, if specified among F's parameters. */
1353 INLINE void
1354 x_set_bitmap_icon (struct frame *f)
1356 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1358 if (CONSP (obj))
1359 x_bitmap_icon (f, XCDR (obj));
1362 #endif /* !HAVE_NS */
1363 #endif /* HAVE_WINDOW_SYSTEM */
1365 INLINE void
1366 flush_frame (struct frame *f)
1368 struct redisplay_interface *rif = FRAME_RIF (f);
1370 if (rif && rif->flush_display)
1371 rif->flush_display (f);
1374 /***********************************************************************
1375 Multimonitor data
1376 ***********************************************************************/
1378 #ifdef HAVE_WINDOW_SYSTEM
1380 struct MonitorInfo {
1381 XRectangle geom, work;
1382 int mm_width, mm_height;
1383 char *name;
1386 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1387 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1388 int n_monitors,
1389 int primary_monitor,
1390 Lisp_Object monitor_frames,
1391 const char *source);
1393 #endif /* HAVE_WINDOW_SYSTEM */
1396 INLINE_HEADER_END
1398 #endif /* not EMACS_FRAME_H */