Improve responsiveness while in 'replace-buffer-contents'
[emacs.git] / src / frame.h
blob402d6c0a7b20736a54b9b810740f385ac839a667
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2018 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 (at
9 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 <https://www.gnu.org/licenses/>. */
19 #ifndef EMACS_FRAME_H
20 #define EMACS_FRAME_H
22 #include "termhooks.h"
23 #include "window.h"
25 INLINE_HEADER_BEGIN
27 enum vertical_scroll_bar_type
29 vertical_scroll_bar_none,
30 vertical_scroll_bar_left,
31 vertical_scroll_bar_right
34 #ifdef HAVE_WINDOW_SYSTEM
36 enum fullscreen_type
38 FULLSCREEN_NONE,
39 FULLSCREEN_WIDTH = 0x1,
40 FULLSCREEN_HEIGHT = 0x2,
41 FULLSCREEN_BOTH = 0x3, /* Not a typo but means "width and height". */
42 FULLSCREEN_MAXIMIZED = 0x4,
43 #ifdef HAVE_NTGUI
44 FULLSCREEN_WAIT = 0x8
45 #endif
48 enum z_group
50 z_group_none,
51 z_group_above,
52 z_group_below,
53 z_group_above_suspended,
56 enum internal_border_part
58 INTERNAL_BORDER_NONE,
59 INTERNAL_BORDER_LEFT_EDGE,
60 INTERNAL_BORDER_TOP_LEFT_CORNER,
61 INTERNAL_BORDER_TOP_EDGE,
62 INTERNAL_BORDER_TOP_RIGHT_CORNER,
63 INTERNAL_BORDER_RIGHT_EDGE,
64 INTERNAL_BORDER_BOTTOM_RIGHT_CORNER,
65 INTERNAL_BORDER_BOTTOM_EDGE,
66 INTERNAL_BORDER_BOTTOM_LEFT_CORNER,
69 #ifdef NS_IMPL_COCOA
70 enum ns_appearance_type
72 ns_appearance_aqua,
73 ns_appearance_vibrant_dark
75 #endif
76 #endif /* HAVE_WINDOW_SYSTEM */
78 /* The structure representing a frame. */
80 struct frame
82 union vectorlike_header header;
84 /* All Lisp_Object components must come first.
85 That ensures they are all aligned normally. */
87 /* Name of this frame: a Lisp string. It is used for looking up resources,
88 as well as for the title in some cases. */
89 Lisp_Object name;
91 /* The name to use for the icon, the last time
92 it was refreshed. nil means not explicitly specified. */
93 Lisp_Object icon_name;
95 /* This is the frame title specified explicitly, if any.
96 Usually it is nil. */
97 Lisp_Object title;
99 #if defined (HAVE_WINDOW_SYSTEM)
100 /* This frame's parent frame, if it has one. */
101 Lisp_Object parent_frame;
102 #endif /* HAVE_WINDOW_SYSTEM */
104 /* The frame which should receive keystrokes that occur in this
105 frame, or nil if they should go to the frame itself. This is
106 usually nil, but if the frame is minibufferless, we can use this
107 to redirect keystrokes to a surrogate minibuffer frame when
108 needed.
110 Note that a value of nil is different than having the field point
111 to the frame itself. Whenever the Fselect_frame function is used
112 to shift from one frame to the other, any redirections to the
113 original frame are shifted to the newly selected frame; if
114 focus_frame is nil, Fselect_frame will leave it alone. */
115 Lisp_Object focus_frame;
117 /* This frame's root window. Every frame has one.
118 If the frame has only a minibuffer window, this is it.
119 Otherwise, if the frame has a minibuffer window, this is its sibling. */
120 Lisp_Object root_window;
122 /* This frame's selected window.
123 Each frame has its own window hierarchy
124 and one of the windows in it is selected within the frame.
125 The selected window of the selected frame is Emacs's selected window. */
126 Lisp_Object selected_window;
128 /* This frame's minibuffer window.
129 Most frames have their own minibuffer windows,
130 but only the selected frame's minibuffer window
131 can actually appear to exist. */
132 Lisp_Object minibuffer_window;
134 /* Parameter alist of this frame.
135 These are the parameters specified when creating the frame
136 or modified with modify-frame-parameters. */
137 Lisp_Object param_alist;
139 /* List of scroll bars on this frame.
140 Actually, we don't specify exactly what is stored here at all; the
141 scroll bar implementation code can use it to store anything it likes.
142 This field is marked by the garbage collector. It is here
143 instead of in the `device' structure so that the garbage
144 collector doesn't need to look inside the window-system-dependent
145 structure. */
146 Lisp_Object scroll_bars;
147 Lisp_Object condemned_scroll_bars;
149 /* Vector describing the items to display in the menu bar.
150 Each item has four elements in this vector.
151 They are KEY, STRING, SUBMAP, and HPOS.
152 (HPOS is not used in when the X toolkit is in use.)
153 There are four additional elements of nil at the end, to terminate. */
154 Lisp_Object menu_bar_items;
156 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
157 Lisp_Object face_alist;
159 /* A vector that records the entire structure of this frame's menu bar.
160 For the format of the data, see extensive comments in xmenu.c.
161 Only the X toolkit version uses this. */
162 Lisp_Object menu_bar_vector;
164 /* Predicate for selecting buffers for other-buffer. */
165 Lisp_Object buffer_predicate;
167 /* List of buffers viewed in this frame, for other-buffer. */
168 Lisp_Object buffer_list;
170 /* List of buffers that were viewed, then buried in this frame. The
171 most recently buried buffer is first. For last-buffer. */
172 Lisp_Object buried_buffer_list;
174 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
175 /* A dummy window used to display menu bars under X when no X
176 toolkit support is available. */
177 Lisp_Object menu_bar_window;
178 #endif
180 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
181 /* A window used to display the tool-bar of a frame. */
182 Lisp_Object tool_bar_window;
184 /* Desired and current contents displayed in that window. */
185 Lisp_Object desired_tool_bar_string;
186 Lisp_Object current_tool_bar_string;
187 #endif
189 /* Desired and current tool-bar items. */
190 Lisp_Object tool_bar_items;
192 #ifdef USE_GTK
193 /* Where tool bar is, can be left, right, top or bottom.
194 Except with GTK, the only supported position is `top'. */
195 Lisp_Object tool_bar_position;
196 #endif
198 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
199 /* List of data specific to font-driver and frame, but common to faces. */
200 Lisp_Object font_data;
201 #endif
203 /* Beyond here, there should be no more Lisp_Object components. */
205 /* Cache of realized faces. */
206 struct face_cache *face_cache;
208 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
209 /* Tool-bar item index of the item on which a mouse button was pressed. */
210 int last_tool_bar_item;
211 #endif
213 /* Number of elements in `menu_bar_vector' that have meaningful data. */
214 int menu_bar_items_used;
216 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
217 /* A buffer to hold the frame's name. Since this is used by the
218 window system toolkit, we can't use the Lisp string's pointer
219 (`name', above) because it might get relocated. */
220 char *namebuf;
221 #endif
223 #ifdef USE_X_TOOLKIT
224 /* Used to pass geometry parameters to toolkit functions. */
225 char *shell_position;
226 #endif
228 /* Glyph pool and matrix. */
229 struct glyph_pool *current_pool;
230 struct glyph_pool *desired_pool;
231 struct glyph_matrix *desired_matrix;
232 struct glyph_matrix *current_matrix;
234 /* Bitfield area begins here. Keep them together to avoid extra padding. */
236 /* True means that glyphs on this frame have been initialized so it can
237 be used for output. */
238 bool_bf glyphs_initialized_p : 1;
240 /* Set to true in change_frame_size when size of frame changed
241 Clear the frame in clear_garbaged_frames if set. */
242 bool_bf resized_p : 1;
244 /* Set to true if the default face for the frame has been
245 realized. Reset to zero whenever the default face changes.
246 Used to see the difference between a font change and face change. */
247 bool_bf default_face_done_p : 1;
249 /* Set to true if this frame has already been hscrolled during
250 current redisplay. */
251 bool_bf already_hscrolled_p : 1;
253 /* Set to true when current redisplay has updated frame. */
254 bool_bf updated_p : 1;
256 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
257 /* Set to true to minimize tool-bar height even when
258 auto-resize-tool-bar is set to grow-only. */
259 bool_bf minimize_tool_bar_window_p : 1;
260 #endif
262 #if defined (USE_GTK) || defined (HAVE_NS)
263 /* True means using a tool bar that comes from the toolkit. */
264 bool_bf external_tool_bar : 1;
265 #endif
267 /* True means that fonts have been loaded since the last glyph
268 matrix adjustments. */
269 bool_bf fonts_changed : 1;
271 /* True means that cursor type has been changed. */
272 bool_bf cursor_type_changed : 1;
274 /* True if it needs to be redisplayed. */
275 bool_bf redisplay : 1;
277 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
278 || defined (HAVE_NS) || defined (USE_GTK)
279 /* True means using a menu bar that comes from the X toolkit. */
280 bool_bf external_menu_bar : 1;
281 #endif
283 /* Next two bitfields are mutually exclusive. They might both be
284 zero if the frame has been made invisible without an icon. */
286 /* Nonzero if the frame is currently displayed; we check
287 it to see if we should bother updating the frame's contents.
289 On ttys and on Windows NT/9X, to avoid wasting effort updating
290 visible frames that are actually completely obscured by other
291 windows on the display, we bend the meaning of visible slightly:
292 if equal to 2, then the frame is obscured - we still consider
293 it to be "visible" as seen from lisp, but we don't bother
294 updating it. */
295 unsigned visible : 2;
297 /* True if the frame is currently iconified. Do not
298 set this directly, use SET_FRAME_ICONIFIED instead. */
299 bool_bf iconified : 1;
301 /* True if this frame should be fully redisplayed. Disables all
302 optimizations while rebuilding matrices and redrawing. */
303 bool_bf garbaged : 1;
305 /* False means, if this frame has just one window,
306 show no modeline for that window. */
307 bool_bf wants_modeline : 1;
309 /* True means raise this frame to the top of the heap when selected. */
310 bool_bf auto_raise : 1;
312 /* True means lower this frame to the bottom of the stack when left. */
313 bool_bf auto_lower : 1;
315 /* True if frame's root window can't be split. */
316 bool_bf no_split : 1;
318 /* If this is set, then Emacs won't change the frame name to indicate
319 the current buffer, etcetera. If the user explicitly sets the frame
320 name, this gets set. If the user sets the name to Qnil, this is
321 cleared. */
322 bool_bf explicit_name : 1;
324 /* True if configuration of windows on this frame has changed since
325 last call of run_window_size_change_functions. */
326 bool_bf window_configuration_changed : 1;
328 /* True if the mouse has moved on this display device
329 since the last time we checked. */
330 bool_bf mouse_moved : 1;
332 /* True means that the pointer is invisible. */
333 bool_bf pointer_invisible : 1;
335 /* True means that all windows except mini-window and
336 selected window on this frame have frozen window starts. */
337 bool_bf frozen_window_starts : 1;
339 /* The output method says how the contents of this frame are
340 displayed. It could be using termcap, or using an X window.
341 This must be the same as the terminal->type. */
342 ENUM_BF (output_method) output_method : 3;
344 #ifdef HAVE_WINDOW_SYSTEM
345 /* See FULLSCREEN_ enum on top. */
346 ENUM_BF (fullscreen_type) want_fullscreen : 4;
348 /* If not vertical_scroll_bar_none, we should actually
349 display the scroll bars of this type on this frame. */
350 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
352 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
353 bool_bf horizontal_scroll_bars : 1;
354 #endif /* HAVE_WINDOW_SYSTEM */
356 #if defined (HAVE_WINDOW_SYSTEM)
357 /* True if this is an undecorated frame. */
358 bool_bf undecorated : 1;
360 #ifndef HAVE_NTGUI
361 /* True if this is an override_redirect frame. */
362 bool_bf override_redirect : 1;
363 #endif
365 /* Nonzero if this frame's icon should not appear on its display's taskbar. */
366 bool_bf skip_taskbar : 1;
368 /* Nonzero if this frame's window F's X window does not want to
369 receive input focus when it is mapped. */
370 bool_bf no_focus_on_map : 1;
372 /* Nonzero if this frame's window does not want to receive input focus
373 via mouse clicks or by moving the mouse into it. */
374 bool_bf no_accept_focus : 1;
376 /* The z-group this frame's window belongs to. */
377 ENUM_BF (z_group) z_group : 2;
379 /* Non-zero if display of truncation and continuation glyphs outside
380 the fringes is suppressed. */
381 bool_bf no_special_glyphs : 1;
382 #endif /* HAVE_WINDOW_SYSTEM */
384 /* Whether new_height and new_width shall be interpreted
385 in pixels. */
386 bool_bf new_pixelwise : 1;
388 /* True means x_set_window_size requests can be processed for this
389 frame. */
390 bool_bf can_x_set_window_size : 1;
392 /* Set to true after this frame was made by `make-frame'. */
393 bool_bf after_make_frame : 1;
395 /* Whether the tool bar height change should be taken into account. */
396 bool_bf tool_bar_redisplayed : 1;
397 bool_bf tool_bar_resized : 1;
399 /* Inhibit implied resize before after_make_frame is set. */
400 bool_bf inhibit_horizontal_resize : 1;
401 bool_bf inhibit_vertical_resize : 1;
403 /* Non-zero if this frame's faces need to be recomputed. */
404 bool_bf face_change : 1;
406 /* Bitfield area ends here. */
408 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
409 int tool_bar_lines;
411 /* Height of frame internal tool bar in pixels. */
412 int tool_bar_height;
414 int n_tool_bar_rows;
415 int n_tool_bar_items;
417 /* A buffer for decode_mode_line. */
418 char *decode_mode_spec_buffer;
420 /* See do_line_insertion_deletion_costs for info on these arrays. */
421 /* Cost of inserting 1 line on this frame. */
422 int *insert_line_cost;
423 /* Cost of deleting 1 line on this frame. */
424 int *delete_line_cost;
425 /* Cost of inserting n lines on this frame. */
426 int *insert_n_lines_cost;
427 /* Cost of deleting n lines on this frame. */
428 int *delete_n_lines_cost;
430 /* Text width of this frame (excluding fringes, vertical scroll bar
431 and internal border widths) and text height (excluding menu bar,
432 tool bar, horizontal scroll bar and internal border widths) in
433 units of canonical characters. */
434 int text_cols, text_lines;
436 /* Total width of this frame (including fringes, vertical scroll bar
437 and internal border widths) and total height (including menu bar,
438 tool bar, horizontal scroll bar and internal border widths) in
439 units of canonical characters. */
440 int total_cols, total_lines;
442 /* Text width of this frame (excluding fringes, vertical scroll bar
443 and internal border widths) and text height (excluding menu bar,
444 tool bar, horizontal scroll bar and internal border widths) in
445 pixels. */
446 int text_width, text_height;
448 /* New text height and width for pending size change. 0 if no change
449 pending. These values represent pixels or canonical character units
450 according to the value of new_pixelwise and correlate to the
451 text width/height of the frame. */
452 int new_width, new_height;
454 /* Pixel position of the frame window (x and y offsets in root window). */
455 int left_pos, top_pos;
457 /* Total width of this frame (including fringes, vertical scroll bar
458 and internal border widths) and total height (including internal
459 menu and tool bars, horizontal scroll bar and internal border
460 widths) in pixels. */
461 int pixel_width, pixel_height;
463 /* This is the gravity value for the specified window position. */
464 int win_gravity;
466 /* The geometry flags for this window. */
467 int size_hint_flags;
469 /* Border width of the frame window as known by the (X) window system. */
470 int border_width;
472 /* Width of the internal border. This is a line of background color
473 just inside the window's border. When the frame is selected,
474 a highlighting is displayed inside the internal border. */
475 int internal_border_width;
477 /* Widths of dividers between this frame's windows in pixels. */
478 int right_divider_width, bottom_divider_width;
480 /* Widths of fringes in pixels. */
481 int left_fringe_width, right_fringe_width;
483 /* Total width of fringes reserved for drawing truncation bitmaps,
484 continuation bitmaps and alike - REMOVE THIS !!!!. */
485 int fringe_cols;
487 /* Number of lines of menu bar. */
488 int menu_bar_lines;
490 /* Pixel height of menubar. */
491 int menu_bar_height;
493 /* Canonical X unit. Width of default font, in pixels. */
494 int column_width;
496 /* Canonical Y unit. Height of a line, in pixels. */
497 int line_height;
499 /* The terminal device that this frame uses. If this is NULL, then
500 the frame has been deleted. */
501 struct terminal *terminal;
503 /* Device-dependent, frame-local auxiliary data used for displaying
504 the contents. When the frame is deleted, this data is deleted as
505 well. */
506 union output_data
508 struct tty_output *tty; /* From termchar.h. */
509 struct x_output *x; /* From xterm.h. */
510 struct w32_output *w32; /* From w32term.h. */
511 struct ns_output *ns; /* From nsterm.h. */
512 intptr_t nothing;
514 output_data;
516 /* List of font-drivers available on the frame. */
517 struct font_driver_list *font_driver_list;
519 #if defined (HAVE_X_WINDOWS)
520 /* Used by x_wait_for_event when watching for an X event on this frame. */
521 int wait_event_type;
522 #endif
524 /* What kind of text cursor should we draw in the future?
525 This should always be filled_box_cursor or bar_cursor. */
526 enum text_cursor_kinds desired_cursor;
528 /* Width of bar cursor (if we are using that). */
529 int cursor_width;
531 /* What kind of text cursor should we draw when the cursor blinks off?
532 This can be filled_box_cursor or bar_cursor or no_cursor. */
533 enum text_cursor_kinds blink_off_cursor;
535 /* Width of bar cursor (if we are using that) for blink-off state. */
536 int blink_off_cursor_width;
538 /* Configured width of the scroll bar, in pixels and in characters.
539 config_scroll_bar_cols tracks config_scroll_bar_width if the
540 latter is positive; a zero value in config_scroll_bar_width means
541 to compute the actual width on the fly, using config_scroll_bar_cols
542 and the current font width. */
543 int config_scroll_bar_width;
544 int config_scroll_bar_cols;
546 /* Configured height of the scroll bar, in pixels and in characters.
547 config_scroll_bar_lines tracks config_scroll_bar_height if the
548 latter is positive; a zero value in config_scroll_bar_height means
549 to compute the actual width on the fly, using
550 config_scroll_bar_lines and the current font width. */
551 int config_scroll_bar_height;
552 int config_scroll_bar_lines;
554 /* The baud rate that was used to calculate costs for this frame. */
555 int cost_calculation_baud_rate;
557 /* Frame opacity
558 alpha[0]: alpha transparency of the active frame
559 alpha[1]: alpha transparency of inactive frames
560 Negative values mean not to change alpha. */
561 double alpha[2];
563 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
564 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
565 frame parameter. 0 means don't do gamma correction. */
566 double gamma;
568 /* Additional space to put between text lines on this frame. */
569 int extra_line_spacing;
571 /* All display backends seem to need these two pixel values. */
572 unsigned long background_pixel;
573 unsigned long foreground_pixel;
575 #ifdef NS_IMPL_COCOA
576 /* NSAppearance theme used on this frame. */
577 enum ns_appearance_type ns_appearance;
578 bool_bf ns_transparent_titlebar;
579 #endif
582 /* Most code should use these functions to set Lisp fields in struct frame. */
584 INLINE void
585 fset_buffer_list (struct frame *f, Lisp_Object val)
587 f->buffer_list = val;
589 INLINE void
590 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
592 f->buried_buffer_list = val;
594 INLINE void
595 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
597 f->condemned_scroll_bars = val;
599 INLINE void
600 fset_face_alist (struct frame *f, Lisp_Object val)
602 f->face_alist = val;
604 #if defined (HAVE_WINDOW_SYSTEM)
605 INLINE void
606 fset_parent_frame (struct frame *f, Lisp_Object val)
608 f->parent_frame = val;
610 #endif
611 INLINE void
612 fset_focus_frame (struct frame *f, Lisp_Object val)
614 f->focus_frame = val;
616 INLINE void
617 fset_icon_name (struct frame *f, Lisp_Object val)
619 f->icon_name = val;
621 INLINE void
622 fset_menu_bar_items (struct frame *f, Lisp_Object val)
624 f->menu_bar_items = val;
626 INLINE void
627 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
629 f->menu_bar_vector = val;
631 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
632 INLINE void
633 fset_menu_bar_window (struct frame *f, Lisp_Object val)
635 f->menu_bar_window = val;
637 #endif
638 INLINE void
639 fset_name (struct frame *f, Lisp_Object val)
641 f->name = val;
643 INLINE void
644 fset_param_alist (struct frame *f, Lisp_Object val)
646 f->param_alist = val;
648 INLINE void
649 fset_root_window (struct frame *f, Lisp_Object val)
651 f->root_window = val;
653 INLINE void
654 fset_scroll_bars (struct frame *f, Lisp_Object val)
656 f->scroll_bars = val;
658 INLINE void
659 fset_selected_window (struct frame *f, Lisp_Object val)
661 f->selected_window = val;
663 INLINE void
664 fset_title (struct frame *f, Lisp_Object val)
666 f->title = val;
668 INLINE void
669 fset_tool_bar_items (struct frame *f, Lisp_Object val)
671 f->tool_bar_items = val;
673 #ifdef USE_GTK
674 INLINE void
675 fset_tool_bar_position (struct frame *f, Lisp_Object val)
677 f->tool_bar_position = val;
679 #endif /* USE_GTK */
680 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
681 INLINE void
682 fset_tool_bar_window (struct frame *f, Lisp_Object val)
684 f->tool_bar_window = val;
686 INLINE void
687 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
689 f->current_tool_bar_string = val;
691 INLINE void
692 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
694 f->desired_tool_bar_string = val;
696 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
698 INLINE double
699 NUMVAL (Lisp_Object x)
701 return NUMBERP (x) ? XFLOATINT (x) : -1;
704 INLINE double
705 default_pixels_per_inch_x (void)
707 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
708 ? XCAR (Vdisplay_pixels_per_inch)
709 : Vdisplay_pixels_per_inch);
710 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
713 INLINE double
714 default_pixels_per_inch_y (void)
716 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
717 ? XCDR (Vdisplay_pixels_per_inch)
718 : Vdisplay_pixels_per_inch);
719 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
722 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
724 /* Return a pointer to the image cache of frame F. */
725 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
727 #define XFRAME(p) \
728 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
729 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
731 /* Given a window, return its frame as a Lisp_Object. */
732 #define WINDOW_FRAME(w) ((w)->frame)
734 /* Test a frame for particular kinds of display methods. */
735 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
736 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
737 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
738 #ifndef HAVE_NTGUI
739 #define FRAME_W32_P(f) false
740 #else
741 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
742 #endif
743 #ifndef MSDOS
744 #define FRAME_MSDOS_P(f) false
745 #else
746 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
747 #endif
748 #ifndef HAVE_NS
749 #define FRAME_NS_P(f) false
750 #else
751 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
752 #endif
754 /* FRAME_WINDOW_P tests whether the frame is a window, and is
755 defined to be the predicate for the window system being used. */
757 #ifdef HAVE_X_WINDOWS
758 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
759 #endif
760 #ifdef HAVE_NTGUI
761 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
762 #endif
763 #ifdef HAVE_NS
764 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
765 #endif
766 #ifndef FRAME_WINDOW_P
767 #define FRAME_WINDOW_P(f) ((void) (f), false)
768 #endif
770 /* Dots per inch of the screen the frame F is on. */
772 #ifdef HAVE_WINDOW_SYSTEM
774 #define FRAME_RES_X(f) \
775 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
776 #define FRAME_RES_Y(f) \
777 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
779 #else /* !HAVE_WINDOW_SYSTEM */
781 /* Defaults when no window system available. */
783 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
784 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
786 #endif /* HAVE_WINDOW_SYSTEM */
788 /* Return a pointer to the structure holding information about the
789 region of text, if any, that is currently shown in mouse-face on
790 frame F. We need to define two versions because a TTY-only build
791 does not have FRAME_DISPLAY_INFO. */
792 #ifdef HAVE_WINDOW_SYSTEM
793 # define MOUSE_HL_INFO(F) \
794 (FRAME_WINDOW_P(F) \
795 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
796 : &(F)->output_data.tty->display_info->mouse_highlight)
797 #else
798 # define MOUSE_HL_INFO(F) \
799 (&(F)->output_data.tty->display_info->mouse_highlight)
800 #endif
802 /* True if frame F is still alive (not deleted). */
803 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
805 /* True if frame F is a minibuffer-only frame. */
806 #define FRAME_MINIBUF_ONLY_P(f) \
807 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
809 /* True if frame F contains it's own minibuffer window. Frame always has
810 minibuffer window, but it could use minibuffer window of another frame. */
811 #define FRAME_HAS_MINIBUF_P(f) \
812 (WINDOWP (f->minibuffer_window) \
813 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
815 /* Pixel width of frame F. */
816 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
818 /* Pixel height of frame F. */
819 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
821 /* Width of frame F, measured in canonical character columns,
822 not including scroll bars if any. */
823 #define FRAME_COLS(f) (f)->text_cols
825 /* Height of frame F, measured in canonical lines, including
826 non-toolkit menu bar and non-toolkit tool bar lines. */
827 #define FRAME_LINES(f) (f)->text_lines
829 /* Width of frame F, measured in pixels not including the width for
830 fringes, scroll bar, and internal borders. */
831 #define FRAME_TEXT_WIDTH(f) (f)->text_width
833 /* Height of frame F, measured in pixels not including the height
834 for scroll bar and internal borders. */
835 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
837 /* Number of lines of frame F used for menu bar.
838 This is relevant on terminal frames and on
839 X Windows when not using the X toolkit.
840 These lines are counted in FRAME_LINES. */
841 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
843 /* Pixel height of frame F's menu bar. */
844 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
846 /* True if this frame should display a tool bar
847 in a way that does not use any text lines. */
848 #if defined (USE_GTK) || defined (HAVE_NS)
849 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
850 #else
851 #define FRAME_EXTERNAL_TOOL_BAR(f) false
852 #endif
854 /* This is really supported only with GTK. */
855 #ifdef USE_GTK
856 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
857 #else
858 #define FRAME_TOOL_BAR_POSITION(f) ((void) (f), Qtop)
859 #endif
861 /* Number of lines of frame F used for the tool-bar. */
862 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
864 /* Pixel height of frame F's tool-bar. */
865 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
867 /* Lines above the top-most window in frame F. */
868 #define FRAME_TOP_MARGIN(F) \
869 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
871 /* Pixel height of frame F's top margin. */
872 #define FRAME_TOP_MARGIN_HEIGHT(F) \
873 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
875 /* True if this frame should display a menu bar
876 in a way that does not use any text lines. */
877 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
878 || defined (HAVE_NS) || defined (USE_GTK)
879 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
880 #else
881 #define FRAME_EXTERNAL_MENU_BAR(f) false
882 #endif
884 /* True if frame F is currently visible. */
885 #define FRAME_VISIBLE_P(f) (f)->visible
887 /* True if frame F is currently visible but hidden. */
888 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
890 /* True if frame F is currently iconified. */
891 #define FRAME_ICONIFIED_P(f) (f)->iconified
893 /* Mark frame F as currently garbaged. */
894 #define SET_FRAME_GARBAGED(f) \
895 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
897 /* True if frame F is currently garbaged. */
898 #define FRAME_GARBAGED_P(f) (f)->garbaged
900 /* True means do not allow splitting this frame's window. */
901 #define FRAME_NO_SPLIT_P(f) (f)->no_split
903 /* Not really implemented. */
904 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
906 /* True if all windows except selected window and mini window
907 are frozen on frame F. */
908 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
910 /* True if the frame's window configuration has changed since last call
911 of run_window_size_change_functions. */
912 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
913 (f)->window_configuration_changed
915 /* The minibuffer window of frame F, if it has one; otherwise nil. */
916 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
918 /* The root window of the window tree of frame F. */
919 #define FRAME_ROOT_WINDOW(f) f->root_window
921 /* The currently selected window of the window tree of frame F. */
922 #define FRAME_SELECTED_WINDOW(f) f->selected_window
924 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
925 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
926 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
927 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
928 #define FRAME_FOCUS_FRAME(f) f->focus_frame
930 #ifdef HAVE_WINDOW_SYSTEM
931 /* This frame slot says whether scroll bars are currently enabled for frame F,
932 and which side they are on. */
933 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
934 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
935 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
936 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
937 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
938 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
939 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
940 #else /* not HAVE_WINDOW_SYSTEM */
941 /* If there is no window system, there are no scroll bars. */
942 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) \
943 ((void) (f), vertical_scroll_bar_none)
944 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) (f), 0)
945 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) (f), 0)
946 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) (f), 0)
947 #endif /* HAVE_WINDOW_SYSTEM */
949 #if defined (HAVE_WINDOW_SYSTEM)
950 #define FRAME_UNDECORATED(f) ((f)->undecorated)
951 #ifdef HAVE_NTGUI
952 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
953 #else
954 #define FRAME_OVERRIDE_REDIRECT(f) ((f)->override_redirect)
955 #endif
956 #define FRAME_PARENT_FRAME(f) \
957 (NILP ((f)->parent_frame) \
958 ? NULL \
959 : XFRAME ((f)->parent_frame))
960 #define FRAME_SKIP_TASKBAR(f) ((f)->skip_taskbar)
961 #define FRAME_NO_FOCUS_ON_MAP(f) ((f)->no_focus_on_map)
962 #define FRAME_NO_ACCEPT_FOCUS(f) ((f)->no_accept_focus)
963 #define FRAME_NO_SPECIAL_GLYPHS(f) ((f)->no_special_glyphs)
964 #define FRAME_Z_GROUP(f) ((f)->z_group)
965 #define FRAME_Z_GROUP_NONE(f) ((f)->z_group == z_group_none)
966 #define FRAME_Z_GROUP_ABOVE(f) ((f)->z_group == z_group_above)
967 #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \
968 ((f)->z_group == z_group_above_suspended)
969 #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below)
970 #ifdef NS_IMPL_COCOA
971 #define FRAME_NS_APPEARANCE(f) ((f)->ns_appearance)
972 #define FRAME_NS_TRANSPARENT_TITLEBAR(f) ((f)->ns_transparent_titlebar)
973 #endif
974 #else /* not HAVE_WINDOW_SYSTEM */
975 #define FRAME_UNDECORATED(f) ((void) (f), 0)
976 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
977 #define FRAME_PARENT_FRAME(f) ((void) (f), NULL)
978 #define FRAME_SKIP_TASKBAR(f) ((void) (f), 0)
979 #define FRAME_NO_FOCUS_ON_MAP(f) ((void) (f), 0)
980 #define FRAME_NO_ACCEPT_FOCUS(f) ((void) (f), 0)
981 #define FRAME_NO_SPECIAL_GLYPHS(f) ((void) (f), 0)
982 #define FRAME_Z_GROUP(f) ((void) (f), z_group_none)
983 #define FRAME_Z_GROUP_NONE(f) ((void) (f), true)
984 #define FRAME_Z_GROUP_ABOVE(f) ((void) (f), false)
985 #define FRAME_Z_GROUP_BELOW(f) ((void) (f), false)
986 #endif /* HAVE_WINDOW_SYSTEM */
988 /* Whether horizontal scroll bars are currently enabled for frame F. */
989 #if USE_HORIZONTAL_SCROLL_BARS
990 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
991 ((f)->horizontal_scroll_bars)
992 #else
993 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) (f), 0)
994 #endif
996 /* Width that a scroll bar in frame F should have, if there is one.
997 Measured in pixels.
998 If scroll bars are turned off, this is still nonzero. */
999 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
1001 /* Height that a scroll bar in frame F should have, if there is one.
1002 Measured in pixels.
1003 If scroll bars are turned off, this is still nonzero. */
1004 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
1006 /* Width that a scroll bar in frame F should have, if there is one.
1007 Measured in columns (characters).
1008 If scroll bars are turned off, this is still nonzero. */
1009 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
1011 /* Height that a scroll bar in frame F should have, if there is one.
1012 Measured in lines (characters).
1013 If scroll bars are turned off, this is still nonzero. */
1014 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
1016 /* Width of a left scroll bar in frame F, measured in pixels */
1017 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
1018 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1019 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1020 : 0)
1022 /* Width of a right scroll bar area in frame F, measured in pixels */
1023 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
1024 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1025 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1026 : 0)
1028 /* Width of a left scroll bar in frame F, measured in columns
1029 (characters), but only if scroll bars are on the left. If scroll
1030 bars are on the right in this frame, or there are no scroll bars,
1031 value is 0. */
1032 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
1033 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1034 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1035 : 0)
1037 /* Width of a right scroll bar in frame F, measured in columns
1038 (characters), but only if scroll bars are on the right. If scroll
1039 bars are on the left in this frame, or there are no scroll bars,
1040 value is 0. */
1041 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
1042 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1043 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1044 : 0)
1046 /* Width of a vertical scroll bar area in frame F, measured in
1047 pixels. */
1048 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
1049 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1050 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1051 : 0)
1053 /* Height of horizontal scroll bar area in frame F, measured in
1054 pixels. */
1055 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
1056 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1057 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1058 : 0)
1060 /* Width of vertical scroll bar in frame F, measured in columns. */
1061 #define FRAME_SCROLL_BAR_COLS(f) \
1062 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1063 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1064 : 0)
1066 /* Height of horizontal scroll bar in frame F, measured in lines. */
1067 #define FRAME_SCROLL_BAR_LINES(f) \
1068 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1069 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
1070 : 0)
1072 /* Total width of frame F, in columns (characters),
1073 including the width used by scroll bars if any. */
1074 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
1076 /* Total height of frame F, in lines (characters),
1077 including the height used by scroll bars if any. */
1078 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
1080 /* Set the character widths of frame F. WIDTH specifies a nominal
1081 character text width. */
1082 #define SET_FRAME_COLS(f, width) \
1083 ((f)->text_cols = (width), \
1084 (f)->total_cols = ((width) \
1085 + FRAME_SCROLL_BAR_COLS (f) \
1086 + FRAME_FRINGE_COLS (f)))
1088 /* Set the character heights of frame F. HEIGHT specifies a nominal
1089 character text height. */
1090 #define SET_FRAME_LINES(f, height) \
1091 ((f)->text_lines = (height), \
1092 (f)->total_lines = ((height) \
1093 + FRAME_TOP_MARGIN (f) \
1094 + FRAME_SCROLL_BAR_LINES (f)))
1096 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
1097 width. */
1098 #define SET_FRAME_WIDTH(f, width) \
1099 ((f)->text_width = (width), \
1100 (f)->pixel_width = ((width) \
1101 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1102 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1103 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1105 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
1106 height. */
1107 #define SET_FRAME_HEIGHT(f, height) \
1108 ((f)->text_height = (height), \
1109 (f)->pixel_height = ((height) \
1110 + FRAME_TOP_MARGIN_HEIGHT (f) \
1111 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1112 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1114 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1115 #define FRAME_CURSOR_X_LIMIT(f) \
1116 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1118 /* Nonzero if frame F has scroll bars. */
1119 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1120 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1122 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1123 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1125 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1126 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1127 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1128 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1130 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1131 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1133 /* Return a pointer to the face cache of frame F. */
1135 #define FRAME_FACE_CACHE(F) (F)->face_cache
1137 /* Return the size of message_buf of the frame F. We multiply the
1138 width of the frame by 4 because multi-byte form may require at most
1139 4-byte for a character. */
1141 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1143 #define CHECK_FRAME(x) \
1144 CHECK_TYPE (FRAMEP (x), Qframep, x)
1146 #define CHECK_LIVE_FRAME(x) \
1147 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1149 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1150 `for' loop which iterates over the elements of Vframe_list. The
1151 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1152 Vframe_list in succession and execute the statement. LIST_VAR
1153 should be a Lisp_Object too; it is used to iterate through the
1154 Vframe_list. Note that this macro walks over child frames and
1155 the tooltip frame as well.
1157 This macro is a holdover from a time when multiple frames weren't always
1158 supported. An alternate definition of the macro would expand to
1159 something which executes the statement once. */
1161 #define FOR_EACH_FRAME(list_var, frame_var) \
1162 for ((list_var) = Vframe_list; \
1163 (CONSP (list_var) \
1164 && (frame_var = XCAR (list_var), true)); \
1165 list_var = XCDR (list_var))
1167 /* Reflect mouse movement when a complete frame update is performed. */
1169 #define FRAME_MOUSE_UPDATE(frame) \
1170 do { \
1171 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1172 if (frame == hlinfo->mouse_face_mouse_frame) \
1174 block_input (); \
1175 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1176 hlinfo->mouse_face_mouse_x, \
1177 hlinfo->mouse_face_mouse_y); \
1178 unblock_input (); \
1180 } while (false)
1182 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1184 #define AUTO_FRAME_ARG(name, parameter, value) \
1185 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1187 /* False means there are no visible garbaged frames. */
1188 extern bool frame_garbaged;
1190 /* Set visibility of frame F.
1191 We call redisplay_other_windows to make sure the frame gets redisplayed
1192 if some changes were applied to it while it wasn't visible (and hence
1193 wasn't redisplayed). */
1195 INLINE void
1196 SET_FRAME_VISIBLE (struct frame *f, int v)
1198 eassert (0 <= v && v <= 2);
1199 if (v)
1201 if (v == 1 && f->visible != 1)
1202 redisplay_other_windows ();
1203 if (FRAME_GARBAGED_P (f))
1204 frame_garbaged = true;
1206 f->visible = v;
1209 /* Set iconify of frame F. */
1211 #define SET_FRAME_ICONIFIED(f, i) \
1212 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1214 extern Lisp_Object selected_frame;
1216 #if ! (defined USE_GTK || defined HAVE_NS)
1217 extern int frame_default_tool_bar_height;
1218 #endif
1220 #ifdef HAVE_WINDOW_SYSTEM
1221 # define WINDOW_SYSTEM_RETURN
1222 #else
1223 # define WINDOW_SYSTEM_RETURN _Noreturn
1224 #endif
1226 extern WINDOW_SYSTEM_RETURN struct frame *
1227 decode_window_system_frame (Lisp_Object);
1228 extern struct frame *decode_live_frame (Lisp_Object);
1229 extern struct frame *decode_any_frame (Lisp_Object);
1230 extern struct frame *make_initial_frame (void);
1231 extern struct frame *make_frame (bool);
1232 #ifdef HAVE_WINDOW_SYSTEM
1233 extern struct frame *make_minibuffer_frame (void);
1234 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1235 struct kboard *,
1236 Lisp_Object);
1237 extern bool display_available (void);
1238 #endif
1240 INLINE bool
1241 window_system_available (struct frame *f)
1243 #ifdef HAVE_WINDOW_SYSTEM
1244 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
1245 #else
1246 return false;
1247 #endif
1250 extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
1251 extern void frame_make_pointer_invisible (struct frame *);
1252 extern void frame_make_pointer_visible (struct frame *);
1253 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1254 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
1255 extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
1256 extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
1257 int width, int height, Lisp_Object rest);
1259 extern Lisp_Object Vframe_list;
1261 /* Value is a pointer to the selected frame. If the selected frame
1262 isn't live, abort. */
1264 #define SELECTED_FRAME() \
1265 ((FRAMEP (selected_frame) \
1266 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1267 ? XFRAME (selected_frame) \
1268 : (emacs_abort (), (struct frame *) 0))
1271 /***********************************************************************
1272 Display-related Macros
1273 ***********************************************************************/
1275 /* Canonical y-unit on frame F.
1276 This value currently equals the line height of the frame (which is
1277 the height of the default font of F). */
1278 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1280 /* Canonical x-unit on frame F.
1281 This value currently equals the average width of the default font of F. */
1282 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1284 /* Get a frame's window system dimension. If no window system, this is 0. */
1286 INLINE int
1287 frame_dimension (int x)
1289 #ifdef HAVE_WINDOW_SYSTEM
1290 return x;
1291 #else
1292 return 0;
1293 #endif
1296 /* Total width of fringes reserved for drawing truncation bitmaps,
1297 continuation bitmaps and alike. The width is in canonical char
1298 units of the frame. This must currently be the case because window
1299 sizes aren't pixel values. If it weren't the case, we wouldn't be
1300 able to split windows horizontally nicely. */
1301 INLINE int
1302 FRAME_FRINGE_COLS (struct frame *f)
1304 return frame_dimension (f->fringe_cols);
1307 /* Pixel-width of the left and right fringe. */
1309 INLINE int
1310 FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
1312 return frame_dimension (f->left_fringe_width);
1314 INLINE int
1315 FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
1317 return frame_dimension (f->right_fringe_width);
1320 /* Total width of fringes in pixels. */
1322 INLINE int
1323 FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
1325 return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
1328 /* Pixel-width of internal border lines. */
1329 INLINE int
1330 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
1332 return frame_dimension (f->internal_border_width);
1335 /* Pixel-size of window divider lines. */
1336 INLINE int
1337 FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
1339 return frame_dimension (f->right_divider_width);
1342 INLINE int
1343 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
1345 return frame_dimension (f->bottom_divider_width);
1348 /***********************************************************************
1349 Conversion between canonical units and pixels
1350 ***********************************************************************/
1352 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1353 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1354 represented as Lisp numbers, i.e. integers or floats. */
1356 /* Convert canonical value X to pixels. F is the frame whose
1357 canonical char width is to be used. X must be a Lisp integer or
1358 float. Value is a C integer. */
1359 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1360 (INTEGERP (X) \
1361 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1362 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1364 /* Convert canonical value Y to pixels. F is the frame whose
1365 canonical character height is to be used. X must be a Lisp integer
1366 or float. Value is a C integer. */
1367 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1368 (INTEGERP (Y) \
1369 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1370 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1372 /* Convert pixel-value X to canonical units. F is the frame whose
1373 canonical character width is to be used. X is a C integer. Result
1374 is a Lisp float if X is not a multiple of the canon width,
1375 otherwise it's a Lisp integer. */
1376 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1377 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1378 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1379 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1381 /* Convert pixel-value Y to canonical units. F is the frame whose
1382 canonical character height is to be used. Y is a C integer.
1383 Result is a Lisp float if Y is not a multiple of the canon width,
1384 otherwise it's a Lisp integer. */
1385 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1386 ((Y) % FRAME_LINE_HEIGHT (F) \
1387 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1388 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1392 /* Manipulating pixel sizes and character sizes.
1393 Knowledge of which factors affect the overall size of the window should
1394 be hidden in these macros, if that's possible.
1396 Return the upper/left pixel position of the character cell on frame F
1397 at ROW/COL. */
1398 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1399 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1400 + (row) * FRAME_LINE_HEIGHT (f))
1402 #define FRAME_COL_TO_PIXEL_X(f, col) \
1403 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1404 + (col) * FRAME_COLUMN_WIDTH (f))
1406 /* Return the pixel width/height of frame F if it has
1407 COLS columns/LINES rows. */
1408 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1409 ((cols) * FRAME_COLUMN_WIDTH (f) \
1410 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1411 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1412 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1414 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1415 ((lines) * FRAME_LINE_HEIGHT (f) \
1416 + FRAME_TOP_MARGIN_HEIGHT (f) \
1417 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1418 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1420 /* Return the row/column (zero-based) of the character cell containing
1421 the pixel on FRAME at Y/X. */
1422 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1423 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1424 ? (y) \
1425 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1426 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1427 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1428 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1429 /* Arrange for the division to round down. */ \
1430 + FRAME_LINE_HEIGHT (f) - 1) \
1431 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1432 / FRAME_LINE_HEIGHT (f))
1434 #define FRAME_PIXEL_X_TO_COL(f, x) \
1435 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1436 / FRAME_COLUMN_WIDTH (f))
1438 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1439 frame F (so we round down)? */
1440 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1441 (((width) \
1442 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1443 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1444 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1445 / FRAME_COLUMN_WIDTH (f)) \
1447 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1448 (((height) \
1449 - FRAME_TOP_MARGIN_HEIGHT (f) \
1450 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1451 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1452 / FRAME_LINE_HEIGHT (f))
1454 /* Return the pixel width/height of frame F with a text size of
1455 width/height. */
1456 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1457 ((width) \
1458 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1459 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1460 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1462 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1463 ((height) \
1464 + FRAME_TOP_MARGIN_HEIGHT (f) \
1465 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1466 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1468 /* Return the text width/height of frame F with a pixel size of
1469 width/height. */
1470 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1471 ((width) \
1472 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1473 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1474 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1476 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1477 ((height) \
1478 - FRAME_TOP_MARGIN_HEIGHT (f) \
1479 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1480 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1482 /* Return the width/height reserved for the windows of frame F. */
1483 #define FRAME_WINDOWS_WIDTH(f) \
1484 (FRAME_PIXEL_WIDTH (f) \
1485 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1487 #define FRAME_WINDOWS_HEIGHT(f) \
1488 (FRAME_PIXEL_HEIGHT (f) \
1489 - FRAME_TOP_MARGIN_HEIGHT (f) \
1490 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1492 /* Value is the smallest width of any character in any font on frame F. */
1493 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1494 FRAME_DISPLAY_INFO (f)->smallest_char_width
1496 /* Value is the smallest height of any font on frame F. */
1497 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1498 FRAME_DISPLAY_INFO (f)->smallest_font_height
1500 /***********************************************************************
1501 Frame Parameters
1502 ***********************************************************************/
1504 #ifdef HAVE_WINDOW_SYSTEM
1506 /* The class of this X application. */
1507 #define EMACS_CLASS "Emacs"
1509 extern void x_set_scroll_bar_default_width (struct frame *);
1510 extern void x_set_scroll_bar_default_height (struct frame *);
1511 extern void x_set_offset (struct frame *, int, int, int);
1512 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1513 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1514 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1515 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1516 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1517 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1518 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1519 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1520 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1521 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1522 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1523 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1524 Lisp_Object);
1525 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1526 Lisp_Object);
1527 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1528 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1529 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1530 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1531 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1532 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1533 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1534 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1536 extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, int *);
1538 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1539 extern void x_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object);
1541 extern void validate_x_resource_name (void);
1543 extern Lisp_Object display_x_get_resource (Display_Info *,
1544 Lisp_Object attribute,
1545 Lisp_Object class,
1546 Lisp_Object component,
1547 Lisp_Object subclass);
1549 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1550 extern void x_set_window_size (struct frame *f, bool change_gravity,
1551 int width, int height, bool pixelwise);
1552 extern Lisp_Object x_get_focus_frame (struct frame *);
1553 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1554 extern void x_make_frame_visible (struct frame *f);
1555 extern void x_make_frame_invisible (struct frame *f);
1556 extern void x_iconify_frame (struct frame *f);
1557 extern void x_set_frame_alpha (struct frame *f);
1558 extern void x_activate_menubar (struct frame *);
1559 extern void x_real_positions (struct frame *, int *, int *);
1560 extern void free_frame_menubar (struct frame *);
1561 extern void x_free_frame_resources (struct frame *);
1562 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
1563 extern enum internal_border_part frame_internal_border_part (struct frame *f, int x, int y);
1565 #if defined HAVE_X_WINDOWS
1566 extern void x_wm_set_icon_position (struct frame *, int, int);
1567 #if !defined USE_X_TOOLKIT
1568 extern char *x_get_resource_string (const char *, const char *);
1569 #endif
1570 extern void x_sync (struct frame *);
1571 #endif /* HAVE_X_WINDOWS */
1573 extern void x_query_colors (struct frame *f, XColor *, int);
1574 extern void x_focus_frame (struct frame *, bool);
1576 #ifndef HAVE_NS
1578 extern bool x_bitmap_icon (struct frame *, Lisp_Object);
1580 /* Set F's bitmap icon, if specified among F's parameters. */
1582 INLINE void
1583 x_set_bitmap_icon (struct frame *f)
1585 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1587 if (CONSP (obj) && !NILP (XCDR (obj)))
1588 x_bitmap_icon (f, XCDR (obj));
1591 #endif /* !HAVE_NS */
1592 #endif /* HAVE_WINDOW_SYSTEM */
1594 INLINE void
1595 flush_frame (struct frame *f)
1597 struct redisplay_interface *rif = FRAME_RIF (f);
1599 if (rif && rif->flush_display)
1600 rif->flush_display (f);
1603 /***********************************************************************
1604 Multimonitor data
1605 ***********************************************************************/
1607 #ifdef HAVE_WINDOW_SYSTEM
1609 struct MonitorInfo {
1610 XRectangle geom, work;
1611 int mm_width, mm_height;
1612 char *name;
1615 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1616 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1617 int n_monitors,
1618 int primary_monitor,
1619 Lisp_Object monitor_frames,
1620 const char *source);
1622 #endif /* HAVE_WINDOW_SYSTEM */
1625 INLINE_HEADER_END
1627 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1628 This is for functions like x_set_horizontal_scroll_bars that have
1629 no effect in this case. */
1630 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1631 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1632 #endif
1634 #endif /* not EMACS_FRAME_H */