* lisp/ecomplete.el: Add completion-table; use lexical-binding and cl-lib
[emacs.git] / src / frame.h
blob2c9c4143886191605e26adcf57bb9995d9dd645a
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 /* True if this frame is a tooltip frame. */
346 bool_bf tooltip : 1;
348 /* See FULLSCREEN_ enum on top. */
349 ENUM_BF (fullscreen_type) want_fullscreen : 4;
351 /* If not vertical_scroll_bar_none, we should actually
352 display the scroll bars of this type on this frame. */
353 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
355 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
356 bool_bf horizontal_scroll_bars : 1;
358 /* True if this is an undecorated frame. */
359 bool_bf undecorated : 1;
361 #ifndef HAVE_NTGUI
362 /* True if this is an override_redirect frame. */
363 bool_bf override_redirect : 1;
364 #endif
366 /* Nonzero if this frame's icon should not appear on its display's taskbar. */
367 bool_bf skip_taskbar : 1;
369 /* Nonzero if this frame's window F's X window does not want to
370 receive input focus when it is mapped. */
371 bool_bf no_focus_on_map : 1;
373 /* Nonzero if this frame's window does not want to receive input focus
374 via mouse clicks or by moving the mouse into it. */
375 bool_bf no_accept_focus : 1;
377 /* The z-group this frame's window belongs to. */
378 ENUM_BF (z_group) z_group : 2;
380 /* Non-zero if display of truncation and continuation glyphs outside
381 the fringes is suppressed. */
382 bool_bf no_special_glyphs : 1;
383 #endif /* HAVE_WINDOW_SYSTEM */
385 /* Whether new_height and new_width shall be interpreted
386 in pixels. */
387 bool_bf new_pixelwise : 1;
389 /* True means x_set_window_size requests can be processed for this
390 frame. */
391 bool_bf can_x_set_window_size : 1;
393 /* Set to true after this frame was made by `make-frame'. */
394 bool_bf after_make_frame : 1;
396 /* Whether the tool bar height change should be taken into account. */
397 bool_bf tool_bar_redisplayed : 1;
398 bool_bf tool_bar_resized : 1;
400 /* Inhibit implied resize before after_make_frame is set. */
401 bool_bf inhibit_horizontal_resize : 1;
402 bool_bf inhibit_vertical_resize : 1;
404 /* Non-zero if this frame's faces need to be recomputed. */
405 bool_bf face_change : 1;
407 /* Bitfield area ends here. */
409 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
410 int tool_bar_lines;
412 /* Height of frame internal tool bar in pixels. */
413 int tool_bar_height;
415 int n_tool_bar_rows;
416 int n_tool_bar_items;
418 /* A buffer for decode_mode_line. */
419 char *decode_mode_spec_buffer;
421 /* See do_line_insertion_deletion_costs for info on these arrays. */
422 /* Cost of inserting 1 line on this frame. */
423 int *insert_line_cost;
424 /* Cost of deleting 1 line on this frame. */
425 int *delete_line_cost;
426 /* Cost of inserting n lines on this frame. */
427 int *insert_n_lines_cost;
428 /* Cost of deleting n lines on this frame. */
429 int *delete_n_lines_cost;
431 /* Text width of this frame (excluding fringes, vertical scroll bar
432 and internal border widths) and text height (excluding menu bar,
433 tool bar, horizontal scroll bar and internal border widths) in
434 units of canonical characters. */
435 int text_cols, text_lines;
437 /* Total width of this frame (including fringes, vertical scroll bar
438 and internal border widths) and total height (including menu bar,
439 tool bar, horizontal scroll bar and internal border widths) in
440 units of canonical characters. */
441 int total_cols, total_lines;
443 /* Text width of this frame (excluding fringes, vertical scroll bar
444 and internal border widths) and text height (excluding menu bar,
445 tool bar, horizontal scroll bar and internal border widths) in
446 pixels. */
447 int text_width, text_height;
449 /* New text height and width for pending size change. 0 if no change
450 pending. These values represent pixels or canonical character units
451 according to the value of new_pixelwise and correlate to the
452 text width/height of the frame. */
453 int new_width, new_height;
455 /* Pixel position of the frame window (x and y offsets in root window). */
456 int left_pos, top_pos;
458 /* Total width of this frame (including fringes, vertical scroll bar
459 and internal border widths) and total height (including internal
460 menu and tool bars, horizontal scroll bar and internal border
461 widths) in pixels. */
462 int pixel_width, pixel_height;
464 /* This is the gravity value for the specified window position. */
465 int win_gravity;
467 /* The geometry flags for this window. */
468 int size_hint_flags;
470 /* Border width of the frame window as known by the (X) window system. */
471 int border_width;
473 /* Width of the internal border. This is a line of background color
474 just inside the window's border. When the frame is selected,
475 a highlighting is displayed inside the internal border. */
476 int internal_border_width;
478 /* Widths of dividers between this frame's windows in pixels. */
479 int right_divider_width, bottom_divider_width;
481 /* Widths of fringes in pixels. */
482 int left_fringe_width, right_fringe_width;
484 /* Total width of fringes reserved for drawing truncation bitmaps,
485 continuation bitmaps and alike - REMOVE THIS !!!!. */
486 int fringe_cols;
488 /* Number of lines of menu bar. */
489 int menu_bar_lines;
491 /* Pixel height of menubar. */
492 int menu_bar_height;
494 /* Canonical X unit. Width of default font, in pixels. */
495 int column_width;
497 /* Canonical Y unit. Height of a line, in pixels. */
498 int line_height;
500 /* The terminal device that this frame uses. If this is NULL, then
501 the frame has been deleted. */
502 struct terminal *terminal;
504 /* Device-dependent, frame-local auxiliary data used for displaying
505 the contents. When the frame is deleted, this data is deleted as
506 well. */
507 union output_data
509 struct tty_output *tty; /* From termchar.h. */
510 struct x_output *x; /* From xterm.h. */
511 struct w32_output *w32; /* From w32term.h. */
512 struct ns_output *ns; /* From nsterm.h. */
513 intptr_t nothing;
515 output_data;
517 /* List of font-drivers available on the frame. */
518 struct font_driver_list *font_driver_list;
520 #if defined (HAVE_X_WINDOWS)
521 /* Used by x_wait_for_event when watching for an X event on this frame. */
522 int wait_event_type;
523 #endif
525 /* What kind of text cursor should we draw in the future?
526 This should always be filled_box_cursor or bar_cursor. */
527 enum text_cursor_kinds desired_cursor;
529 /* Width of bar cursor (if we are using that). */
530 int cursor_width;
532 /* What kind of text cursor should we draw when the cursor blinks off?
533 This can be filled_box_cursor or bar_cursor or no_cursor. */
534 enum text_cursor_kinds blink_off_cursor;
536 /* Width of bar cursor (if we are using that) for blink-off state. */
537 int blink_off_cursor_width;
539 /* Configured width of the scroll bar, in pixels and in characters.
540 config_scroll_bar_cols tracks config_scroll_bar_width if the
541 latter is positive; a zero value in config_scroll_bar_width means
542 to compute the actual width on the fly, using config_scroll_bar_cols
543 and the current font width. */
544 int config_scroll_bar_width;
545 int config_scroll_bar_cols;
547 /* Configured height of the scroll bar, in pixels and in characters.
548 config_scroll_bar_lines tracks config_scroll_bar_height if the
549 latter is positive; a zero value in config_scroll_bar_height means
550 to compute the actual width on the fly, using
551 config_scroll_bar_lines and the current font width. */
552 int config_scroll_bar_height;
553 int config_scroll_bar_lines;
555 /* The baud rate that was used to calculate costs for this frame. */
556 int cost_calculation_baud_rate;
558 /* Frame opacity
559 alpha[0]: alpha transparency of the active frame
560 alpha[1]: alpha transparency of inactive frames
561 Negative values mean not to change alpha. */
562 double alpha[2];
564 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
565 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
566 frame parameter. 0 means don't do gamma correction. */
567 double gamma;
569 /* Additional space to put between text lines on this frame. */
570 int extra_line_spacing;
572 /* All display backends seem to need these two pixel values. */
573 unsigned long background_pixel;
574 unsigned long foreground_pixel;
576 #ifdef NS_IMPL_COCOA
577 /* NSAppearance theme used on this frame. */
578 enum ns_appearance_type ns_appearance;
579 bool_bf ns_transparent_titlebar;
580 #endif
583 /* Most code should use these functions to set Lisp fields in struct frame. */
585 INLINE void
586 fset_buffer_list (struct frame *f, Lisp_Object val)
588 f->buffer_list = val;
590 INLINE void
591 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
593 f->buried_buffer_list = val;
595 INLINE void
596 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
598 f->condemned_scroll_bars = val;
600 INLINE void
601 fset_face_alist (struct frame *f, Lisp_Object val)
603 f->face_alist = val;
605 #if defined (HAVE_WINDOW_SYSTEM)
606 INLINE void
607 fset_parent_frame (struct frame *f, Lisp_Object val)
609 f->parent_frame = val;
611 #endif
612 INLINE void
613 fset_focus_frame (struct frame *f, Lisp_Object val)
615 f->focus_frame = val;
617 INLINE void
618 fset_icon_name (struct frame *f, Lisp_Object val)
620 f->icon_name = val;
622 INLINE void
623 fset_menu_bar_items (struct frame *f, Lisp_Object val)
625 f->menu_bar_items = val;
627 INLINE void
628 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
630 f->menu_bar_vector = val;
632 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
633 INLINE void
634 fset_menu_bar_window (struct frame *f, Lisp_Object val)
636 f->menu_bar_window = val;
638 #endif
639 INLINE void
640 fset_name (struct frame *f, Lisp_Object val)
642 f->name = val;
644 INLINE void
645 fset_param_alist (struct frame *f, Lisp_Object val)
647 f->param_alist = val;
649 INLINE void
650 fset_root_window (struct frame *f, Lisp_Object val)
652 f->root_window = val;
654 INLINE void
655 fset_scroll_bars (struct frame *f, Lisp_Object val)
657 f->scroll_bars = val;
659 INLINE void
660 fset_selected_window (struct frame *f, Lisp_Object val)
662 f->selected_window = val;
664 INLINE void
665 fset_title (struct frame *f, Lisp_Object val)
667 f->title = val;
669 INLINE void
670 fset_tool_bar_items (struct frame *f, Lisp_Object val)
672 f->tool_bar_items = val;
674 #ifdef USE_GTK
675 INLINE void
676 fset_tool_bar_position (struct frame *f, Lisp_Object val)
678 f->tool_bar_position = val;
680 #endif /* USE_GTK */
681 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
682 INLINE void
683 fset_tool_bar_window (struct frame *f, Lisp_Object val)
685 f->tool_bar_window = val;
687 INLINE void
688 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
690 f->current_tool_bar_string = val;
692 INLINE void
693 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
695 f->desired_tool_bar_string = val;
697 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
699 INLINE double
700 NUMVAL (Lisp_Object x)
702 return NUMBERP (x) ? XFLOATINT (x) : -1;
705 INLINE double
706 default_pixels_per_inch_x (void)
708 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
709 ? XCAR (Vdisplay_pixels_per_inch)
710 : Vdisplay_pixels_per_inch);
711 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
714 INLINE double
715 default_pixels_per_inch_y (void)
717 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
718 ? XCDR (Vdisplay_pixels_per_inch)
719 : Vdisplay_pixels_per_inch);
720 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
723 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
725 /* Return a pointer to the image cache of frame F. */
726 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
728 #define XFRAME(p) \
729 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
730 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
732 /* Given a window, return its frame as a Lisp_Object. */
733 #define WINDOW_FRAME(w) ((w)->frame)
735 /* Test a frame for particular kinds of display methods. */
736 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
737 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
738 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
739 #ifndef HAVE_NTGUI
740 #define FRAME_W32_P(f) false
741 #else
742 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
743 #endif
744 #ifndef MSDOS
745 #define FRAME_MSDOS_P(f) false
746 #else
747 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
748 #endif
749 #ifndef HAVE_NS
750 #define FRAME_NS_P(f) false
751 #else
752 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
753 #endif
755 /* FRAME_WINDOW_P tests whether the frame is a window, and is
756 defined to be the predicate for the window system being used. */
758 #ifdef HAVE_X_WINDOWS
759 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
760 #endif
761 #ifdef HAVE_NTGUI
762 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
763 #endif
764 #ifdef HAVE_NS
765 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
766 #endif
767 #ifndef FRAME_WINDOW_P
768 #define FRAME_WINDOW_P(f) ((void) (f), false)
769 #endif
771 /* Dots per inch of the screen the frame F is on. */
773 #ifdef HAVE_WINDOW_SYSTEM
775 #define FRAME_RES_X(f) \
776 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
777 #define FRAME_RES_Y(f) \
778 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
780 #else /* !HAVE_WINDOW_SYSTEM */
782 /* Defaults when no window system available. */
784 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
785 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
787 #endif /* HAVE_WINDOW_SYSTEM */
789 /* Return a pointer to the structure holding information about the
790 region of text, if any, that is currently shown in mouse-face on
791 frame F. We need to define two versions because a TTY-only build
792 does not have FRAME_DISPLAY_INFO. */
793 #ifdef HAVE_WINDOW_SYSTEM
794 # define MOUSE_HL_INFO(F) \
795 (FRAME_WINDOW_P(F) \
796 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
797 : &(F)->output_data.tty->display_info->mouse_highlight)
798 #else
799 # define MOUSE_HL_INFO(F) \
800 (&(F)->output_data.tty->display_info->mouse_highlight)
801 #endif
803 /* True if frame F is still alive (not deleted). */
804 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
806 /* True if frame F is a minibuffer-only frame. */
807 #define FRAME_MINIBUF_ONLY_P(f) \
808 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
810 /* True if frame F contains it's own minibuffer window. Frame always has
811 minibuffer window, but it could use minibuffer window of another frame. */
812 #define FRAME_HAS_MINIBUF_P(f) \
813 (WINDOWP (f->minibuffer_window) \
814 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
816 /* Pixel width of frame F. */
817 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
819 /* Pixel height of frame F. */
820 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
822 /* Width of frame F, measured in canonical character columns,
823 not including scroll bars if any. */
824 #define FRAME_COLS(f) (f)->text_cols
826 /* Height of frame F, measured in canonical lines, including
827 non-toolkit menu bar and non-toolkit tool bar lines. */
828 #define FRAME_LINES(f) (f)->text_lines
830 /* Width of frame F, measured in pixels not including the width for
831 fringes, scroll bar, and internal borders. */
832 #define FRAME_TEXT_WIDTH(f) (f)->text_width
834 /* Height of frame F, measured in pixels not including the height
835 for scroll bar and internal borders. */
836 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
838 /* Number of lines of frame F used for menu bar.
839 This is relevant on terminal frames and on
840 X Windows when not using the X toolkit.
841 These lines are counted in FRAME_LINES. */
842 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
844 /* Pixel height of frame F's menu bar. */
845 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
847 /* True if this frame should display a tool bar
848 in a way that does not use any text lines. */
849 #if defined (USE_GTK) || defined (HAVE_NS)
850 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
851 #else
852 #define FRAME_EXTERNAL_TOOL_BAR(f) false
853 #endif
855 /* This is really supported only with GTK. */
856 #ifdef USE_GTK
857 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
858 #else
859 #define FRAME_TOOL_BAR_POSITION(f) ((void) (f), Qtop)
860 #endif
862 /* Number of lines of frame F used for the tool-bar. */
863 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
865 /* Pixel height of frame F's tool-bar. */
866 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
868 /* Lines above the top-most window in frame F. */
869 #define FRAME_TOP_MARGIN(F) \
870 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
872 /* Pixel height of frame F's top margin. */
873 #define FRAME_TOP_MARGIN_HEIGHT(F) \
874 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
876 /* True if this frame should display a menu bar
877 in a way that does not use any text lines. */
878 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
879 || defined (HAVE_NS) || defined (USE_GTK)
880 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
881 #else
882 #define FRAME_EXTERNAL_MENU_BAR(f) false
883 #endif
885 /* True if frame F is currently visible. */
886 #define FRAME_VISIBLE_P(f) (f)->visible
888 /* True if frame F is currently visible but hidden. */
889 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
891 /* True if frame F is currently iconified. */
892 #define FRAME_ICONIFIED_P(f) (f)->iconified
894 /* Mark frame F as currently garbaged. */
895 #define SET_FRAME_GARBAGED(f) \
896 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
898 /* True if frame F is currently garbaged. */
899 #define FRAME_GARBAGED_P(f) (f)->garbaged
901 /* True means do not allow splitting this frame's window. */
902 #define FRAME_NO_SPLIT_P(f) (f)->no_split
904 /* Not really implemented. */
905 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
907 /* True if all windows except selected window and mini window
908 are frozen on frame F. */
909 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
911 /* True if the frame's window configuration has changed since last call
912 of run_window_size_change_functions. */
913 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
914 (f)->window_configuration_changed
916 /* The minibuffer window of frame F, if it has one; otherwise nil. */
917 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
919 /* The root window of the window tree of frame F. */
920 #define FRAME_ROOT_WINDOW(f) f->root_window
922 /* The currently selected window of the window tree of frame F. */
923 #define FRAME_SELECTED_WINDOW(f) f->selected_window
925 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
926 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
927 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
928 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
929 #define FRAME_FOCUS_FRAME(f) f->focus_frame
931 #ifdef HAVE_WINDOW_SYSTEM
932 /* This frame slot says whether scroll bars are currently enabled for frame F,
933 and which side they are on. */
934 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
935 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
936 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
937 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
938 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
939 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
940 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
941 #else /* not HAVE_WINDOW_SYSTEM */
942 /* If there is no window system, there are no scroll bars. */
943 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) \
944 ((void) (f), vertical_scroll_bar_none)
945 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) (f), 0)
946 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) (f), 0)
947 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) (f), 0)
948 #endif /* HAVE_WINDOW_SYSTEM */
950 #if defined (HAVE_WINDOW_SYSTEM)
951 #define FRAME_UNDECORATED(f) ((f)->undecorated)
952 #ifdef HAVE_NTGUI
953 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
954 #else
955 #define FRAME_OVERRIDE_REDIRECT(f) ((f)->override_redirect)
956 #endif
957 #define FRAME_PARENT_FRAME(f) \
958 (NILP ((f)->parent_frame) \
959 ? NULL \
960 : XFRAME ((f)->parent_frame))
961 #define FRAME_SKIP_TASKBAR(f) ((f)->skip_taskbar)
962 #define FRAME_NO_FOCUS_ON_MAP(f) ((f)->no_focus_on_map)
963 #define FRAME_NO_ACCEPT_FOCUS(f) ((f)->no_accept_focus)
964 #define FRAME_NO_SPECIAL_GLYPHS(f) ((f)->no_special_glyphs)
965 #define FRAME_Z_GROUP(f) ((f)->z_group)
966 #define FRAME_Z_GROUP_NONE(f) ((f)->z_group == z_group_none)
967 #define FRAME_Z_GROUP_ABOVE(f) ((f)->z_group == z_group_above)
968 #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \
969 ((f)->z_group == z_group_above_suspended)
970 #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below)
971 #define FRAME_TOOLTIP_P(f) ((f)->tooltip)
972 #ifdef NS_IMPL_COCOA
973 #define FRAME_NS_APPEARANCE(f) ((f)->ns_appearance)
974 #define FRAME_NS_TRANSPARENT_TITLEBAR(f) ((f)->ns_transparent_titlebar)
975 #endif
976 #else /* not HAVE_WINDOW_SYSTEM */
977 #define FRAME_UNDECORATED(f) ((void) (f), 0)
978 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
979 #define FRAME_PARENT_FRAME(f) ((void) (f), NULL)
980 #define FRAME_SKIP_TASKBAR(f) ((void) (f), 0)
981 #define FRAME_NO_FOCUS_ON_MAP(f) ((void) (f), 0)
982 #define FRAME_NO_ACCEPT_FOCUS(f) ((void) (f), 0)
983 #define FRAME_NO_SPECIAL_GLYPHS(f) ((void) (f), 0)
984 #define FRAME_Z_GROUP(f) ((void) (f), z_group_none)
985 #define FRAME_Z_GROUP_NONE(f) ((void) (f), true)
986 #define FRAME_Z_GROUP_ABOVE(f) ((void) (f), false)
987 #define FRAME_Z_GROUP_BELOW(f) ((void) (f), false)
988 #define FRAME_TOOLTIP_P(f) ((void) f, false)
989 #endif /* HAVE_WINDOW_SYSTEM */
991 /* Whether horizontal scroll bars are currently enabled for frame F. */
992 #if USE_HORIZONTAL_SCROLL_BARS
993 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
994 ((f)->horizontal_scroll_bars)
995 #else
996 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) (f), 0)
997 #endif
999 /* Width that a scroll bar in frame F should have, if there is one.
1000 Measured in pixels.
1001 If scroll bars are turned off, this is still nonzero. */
1002 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
1004 /* Height that a scroll bar in frame F should have, if there is one.
1005 Measured in pixels.
1006 If scroll bars are turned off, this is still nonzero. */
1007 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
1009 /* Width that a scroll bar in frame F should have, if there is one.
1010 Measured in columns (characters).
1011 If scroll bars are turned off, this is still nonzero. */
1012 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
1014 /* Height that a scroll bar in frame F should have, if there is one.
1015 Measured in lines (characters).
1016 If scroll bars are turned off, this is still nonzero. */
1017 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
1019 /* Width of a left scroll bar in frame F, measured in pixels */
1020 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
1021 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1022 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1023 : 0)
1025 /* Width of a right scroll bar area in frame F, measured in pixels */
1026 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
1027 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1028 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1029 : 0)
1031 /* Width of a left scroll bar in frame F, measured in columns
1032 (characters), but only if scroll bars are on the left. If scroll
1033 bars are on the right in this frame, or there are no scroll bars,
1034 value is 0. */
1035 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
1036 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1037 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1038 : 0)
1040 /* Width of a right scroll bar in frame F, measured in columns
1041 (characters), but only if scroll bars are on the right. If scroll
1042 bars are on the left in this frame, or there are no scroll bars,
1043 value is 0. */
1044 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
1045 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1046 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1047 : 0)
1049 /* Width of a vertical scroll bar area in frame F, measured in
1050 pixels. */
1051 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
1052 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1053 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1054 : 0)
1056 /* Height of horizontal scroll bar area in frame F, measured in
1057 pixels. */
1058 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
1059 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1060 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1061 : 0)
1063 /* Width of vertical scroll bar in frame F, measured in columns. */
1064 #define FRAME_SCROLL_BAR_COLS(f) \
1065 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1066 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1067 : 0)
1069 /* Height of horizontal scroll bar in frame F, measured in lines. */
1070 #define FRAME_SCROLL_BAR_LINES(f) \
1071 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1072 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
1073 : 0)
1075 /* Total width of frame F, in columns (characters),
1076 including the width used by scroll bars if any. */
1077 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
1079 /* Total height of frame F, in lines (characters),
1080 including the height used by scroll bars if any. */
1081 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
1083 /* Set the character widths of frame F. WIDTH specifies a nominal
1084 character text width. */
1085 #define SET_FRAME_COLS(f, width) \
1086 ((f)->text_cols = (width), \
1087 (f)->total_cols = ((width) \
1088 + FRAME_SCROLL_BAR_COLS (f) \
1089 + FRAME_FRINGE_COLS (f)))
1091 /* Set the character heights of frame F. HEIGHT specifies a nominal
1092 character text height. */
1093 #define SET_FRAME_LINES(f, height) \
1094 ((f)->text_lines = (height), \
1095 (f)->total_lines = ((height) \
1096 + FRAME_TOP_MARGIN (f) \
1097 + FRAME_SCROLL_BAR_LINES (f)))
1099 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
1100 width. */
1101 #define SET_FRAME_WIDTH(f, width) \
1102 ((f)->text_width = (width), \
1103 (f)->pixel_width = ((width) \
1104 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1105 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1106 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1108 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
1109 height. */
1110 #define SET_FRAME_HEIGHT(f, height) \
1111 ((f)->text_height = (height), \
1112 (f)->pixel_height = ((height) \
1113 + FRAME_TOP_MARGIN_HEIGHT (f) \
1114 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1115 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1117 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1118 #define FRAME_CURSOR_X_LIMIT(f) \
1119 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1121 /* Nonzero if frame F has scroll bars. */
1122 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1123 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1125 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1126 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1128 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1129 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1130 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1131 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1133 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1134 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1136 /* Return a pointer to the face cache of frame F. */
1138 #define FRAME_FACE_CACHE(F) (F)->face_cache
1140 /* Return the size of message_buf of the frame F. We multiply the
1141 width of the frame by 4 because multi-byte form may require at most
1142 4-byte for a character. */
1144 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1146 #define CHECK_FRAME(x) \
1147 CHECK_TYPE (FRAMEP (x), Qframep, x)
1149 #define CHECK_LIVE_FRAME(x) \
1150 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1152 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1153 `for' loop which iterates over the elements of Vframe_list. The
1154 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1155 Vframe_list in succession and execute the statement. LIST_VAR
1156 should be a Lisp_Object too; it is used to iterate through the
1157 Vframe_list. Note that this macro walks over child frames and
1158 the tooltip frame as well.
1160 This macro is a holdover from a time when multiple frames weren't always
1161 supported. An alternate definition of the macro would expand to
1162 something which executes the statement once. */
1164 #define FOR_EACH_FRAME(list_var, frame_var) \
1165 for ((list_var) = Vframe_list; \
1166 (CONSP (list_var) \
1167 && (frame_var = XCAR (list_var), true)); \
1168 list_var = XCDR (list_var))
1170 /* Reflect mouse movement when a complete frame update is performed. */
1172 #define FRAME_MOUSE_UPDATE(frame) \
1173 do { \
1174 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1175 if (frame == hlinfo->mouse_face_mouse_frame) \
1177 block_input (); \
1178 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1179 hlinfo->mouse_face_mouse_x, \
1180 hlinfo->mouse_face_mouse_y); \
1181 unblock_input (); \
1183 } while (false)
1185 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1187 #define AUTO_FRAME_ARG(name, parameter, value) \
1188 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1190 /* False means there are no visible garbaged frames. */
1191 extern bool frame_garbaged;
1193 /* Set visibility of frame F.
1194 We call redisplay_other_windows to make sure the frame gets redisplayed
1195 if some changes were applied to it while it wasn't visible (and hence
1196 wasn't redisplayed). */
1198 INLINE void
1199 SET_FRAME_VISIBLE (struct frame *f, int v)
1201 eassert (0 <= v && v <= 2);
1202 if (v)
1204 if (v == 1 && f->visible != 1)
1205 redisplay_other_windows ();
1206 if (FRAME_GARBAGED_P (f))
1207 frame_garbaged = true;
1209 f->visible = v;
1212 /* Set iconify of frame F. */
1214 #define SET_FRAME_ICONIFIED(f, i) \
1215 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1217 extern Lisp_Object selected_frame;
1219 #if ! (defined USE_GTK || defined HAVE_NS)
1220 extern int frame_default_tool_bar_height;
1221 #endif
1223 #ifdef HAVE_WINDOW_SYSTEM
1224 # define WINDOW_SYSTEM_RETURN
1225 #else
1226 # define WINDOW_SYSTEM_RETURN _Noreturn
1227 #endif
1229 extern WINDOW_SYSTEM_RETURN struct frame *
1230 decode_window_system_frame (Lisp_Object);
1231 extern struct frame *decode_live_frame (Lisp_Object);
1232 extern struct frame *decode_any_frame (Lisp_Object);
1233 extern struct frame *make_initial_frame (void);
1234 extern struct frame *make_frame (bool);
1235 #ifdef HAVE_WINDOW_SYSTEM
1236 extern struct frame *make_minibuffer_frame (void);
1237 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1238 struct kboard *,
1239 Lisp_Object);
1240 extern bool display_available (void);
1241 #endif
1243 INLINE bool
1244 window_system_available (struct frame *f)
1246 #ifdef HAVE_WINDOW_SYSTEM
1247 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
1248 #else
1249 return false;
1250 #endif
1253 extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
1254 extern void frame_make_pointer_invisible (struct frame *);
1255 extern void frame_make_pointer_visible (struct frame *);
1256 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1257 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
1258 extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
1259 extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
1260 int width, int height, Lisp_Object rest);
1262 extern Lisp_Object Vframe_list;
1264 /* Value is a pointer to the selected frame. If the selected frame
1265 isn't live, abort. */
1267 #define SELECTED_FRAME() \
1268 ((FRAMEP (selected_frame) \
1269 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1270 ? XFRAME (selected_frame) \
1271 : (emacs_abort (), (struct frame *) 0))
1274 /***********************************************************************
1275 Display-related Macros
1276 ***********************************************************************/
1278 /* Canonical y-unit on frame F.
1279 This value currently equals the line height of the frame (which is
1280 the height of the default font of F). */
1281 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1283 /* Canonical x-unit on frame F.
1284 This value currently equals the average width of the default font of F. */
1285 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1287 /* Get a frame's window system dimension. If no window system, this is 0. */
1289 INLINE int
1290 frame_dimension (int x)
1292 #ifdef HAVE_WINDOW_SYSTEM
1293 return x;
1294 #else
1295 return 0;
1296 #endif
1299 /* Total width of fringes reserved for drawing truncation bitmaps,
1300 continuation bitmaps and alike. The width is in canonical char
1301 units of the frame. This must currently be the case because window
1302 sizes aren't pixel values. If it weren't the case, we wouldn't be
1303 able to split windows horizontally nicely. */
1304 INLINE int
1305 FRAME_FRINGE_COLS (struct frame *f)
1307 return frame_dimension (f->fringe_cols);
1310 /* Pixel-width of the left and right fringe. */
1312 INLINE int
1313 FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
1315 return frame_dimension (f->left_fringe_width);
1317 INLINE int
1318 FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
1320 return frame_dimension (f->right_fringe_width);
1323 /* Total width of fringes in pixels. */
1325 INLINE int
1326 FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
1328 return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
1331 /* Pixel-width of internal border lines. */
1332 INLINE int
1333 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
1335 return frame_dimension (f->internal_border_width);
1338 /* Pixel-size of window divider lines. */
1339 INLINE int
1340 FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
1342 return frame_dimension (f->right_divider_width);
1345 INLINE int
1346 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
1348 return frame_dimension (f->bottom_divider_width);
1351 /***********************************************************************
1352 Conversion between canonical units and pixels
1353 ***********************************************************************/
1355 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1356 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1357 represented as Lisp numbers, i.e. integers or floats. */
1359 /* Convert canonical value X to pixels. F is the frame whose
1360 canonical char width is to be used. X must be a Lisp integer or
1361 float. Value is a C integer. */
1362 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1363 (INTEGERP (X) \
1364 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1365 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1367 /* Convert canonical value Y to pixels. F is the frame whose
1368 canonical character height is to be used. X must be a Lisp integer
1369 or float. Value is a C integer. */
1370 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1371 (INTEGERP (Y) \
1372 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1373 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1375 /* Convert pixel-value X to canonical units. F is the frame whose
1376 canonical character width is to be used. X is a C integer. Result
1377 is a Lisp float if X is not a multiple of the canon width,
1378 otherwise it's a Lisp integer. */
1379 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1380 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1381 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1382 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1384 /* Convert pixel-value Y to canonical units. F is the frame whose
1385 canonical character height is to be used. Y is a C integer.
1386 Result is a Lisp float if Y is not a multiple of the canon width,
1387 otherwise it's a Lisp integer. */
1388 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1389 ((Y) % FRAME_LINE_HEIGHT (F) \
1390 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1391 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1395 /* Manipulating pixel sizes and character sizes.
1396 Knowledge of which factors affect the overall size of the window should
1397 be hidden in these macros, if that's possible.
1399 Return the upper/left pixel position of the character cell on frame F
1400 at ROW/COL. */
1401 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1402 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1403 + (row) * FRAME_LINE_HEIGHT (f))
1405 #define FRAME_COL_TO_PIXEL_X(f, col) \
1406 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1407 + (col) * FRAME_COLUMN_WIDTH (f))
1409 /* Return the pixel width/height of frame F if it has
1410 COLS columns/LINES rows. */
1411 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1412 ((cols) * FRAME_COLUMN_WIDTH (f) \
1413 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1414 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1415 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1417 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1418 ((lines) * FRAME_LINE_HEIGHT (f) \
1419 + FRAME_TOP_MARGIN_HEIGHT (f) \
1420 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1421 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1423 /* Return the row/column (zero-based) of the character cell containing
1424 the pixel on FRAME at Y/X. */
1425 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1426 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1427 ? (y) \
1428 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1429 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1430 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1431 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1432 /* Arrange for the division to round down. */ \
1433 + FRAME_LINE_HEIGHT (f) - 1) \
1434 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1435 / FRAME_LINE_HEIGHT (f))
1437 #define FRAME_PIXEL_X_TO_COL(f, x) \
1438 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1439 / FRAME_COLUMN_WIDTH (f))
1441 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1442 frame F (so we round down)? */
1443 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1444 (((width) \
1445 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1446 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1447 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1448 / FRAME_COLUMN_WIDTH (f)) \
1450 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1451 (((height) \
1452 - FRAME_TOP_MARGIN_HEIGHT (f) \
1453 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1454 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1455 / FRAME_LINE_HEIGHT (f))
1457 /* Return the pixel width/height of frame F with a text size of
1458 width/height. */
1459 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1460 ((width) \
1461 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1462 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1463 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1465 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1466 ((height) \
1467 + FRAME_TOP_MARGIN_HEIGHT (f) \
1468 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1469 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1471 /* Return the text width/height of frame F with a pixel size of
1472 width/height. */
1473 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1474 ((width) \
1475 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1476 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1477 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1479 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1480 ((height) \
1481 - FRAME_TOP_MARGIN_HEIGHT (f) \
1482 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1483 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1485 /* Return the width/height reserved for the windows of frame F. */
1486 #define FRAME_WINDOWS_WIDTH(f) \
1487 (FRAME_PIXEL_WIDTH (f) \
1488 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1490 #define FRAME_WINDOWS_HEIGHT(f) \
1491 (FRAME_PIXEL_HEIGHT (f) \
1492 - FRAME_TOP_MARGIN_HEIGHT (f) \
1493 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1495 /* Value is the smallest width of any character in any font on frame F. */
1496 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1497 FRAME_DISPLAY_INFO (f)->smallest_char_width
1499 /* Value is the smallest height of any font on frame F. */
1500 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1501 FRAME_DISPLAY_INFO (f)->smallest_font_height
1503 /***********************************************************************
1504 Frame Parameters
1505 ***********************************************************************/
1507 #ifdef HAVE_WINDOW_SYSTEM
1509 /* The class of this X application. */
1510 #define EMACS_CLASS "Emacs"
1512 extern void x_set_scroll_bar_default_width (struct frame *);
1513 extern void x_set_scroll_bar_default_height (struct frame *);
1514 extern void x_set_offset (struct frame *, int, int, int);
1515 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1516 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1517 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1518 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1519 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1520 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1521 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1522 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1523 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1524 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1525 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1526 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1527 Lisp_Object);
1528 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1529 Lisp_Object);
1530 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1531 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1532 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1533 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1534 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1535 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1536 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1537 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1539 extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, int *);
1541 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1542 extern void x_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object);
1544 extern void validate_x_resource_name (void);
1546 extern Lisp_Object display_x_get_resource (Display_Info *,
1547 Lisp_Object attribute,
1548 Lisp_Object class,
1549 Lisp_Object component,
1550 Lisp_Object subclass);
1552 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1553 extern void x_set_window_size (struct frame *f, bool change_gravity,
1554 int width, int height, bool pixelwise);
1555 extern Lisp_Object x_get_focus_frame (struct frame *);
1556 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1557 extern void x_make_frame_visible (struct frame *f);
1558 extern void x_make_frame_invisible (struct frame *f);
1559 extern void x_iconify_frame (struct frame *f);
1560 extern void x_set_frame_alpha (struct frame *f);
1561 extern void x_activate_menubar (struct frame *);
1562 extern void x_real_positions (struct frame *, int *, int *);
1563 extern void free_frame_menubar (struct frame *);
1564 extern void x_free_frame_resources (struct frame *);
1565 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
1566 extern enum internal_border_part frame_internal_border_part (struct frame *f, int x, int y);
1568 #if defined HAVE_X_WINDOWS
1569 extern void x_wm_set_icon_position (struct frame *, int, int);
1570 #if !defined USE_X_TOOLKIT
1571 extern char *x_get_resource_string (const char *, const char *);
1572 #endif
1573 extern void x_sync (struct frame *);
1574 #endif /* HAVE_X_WINDOWS */
1576 extern void x_query_colors (struct frame *f, XColor *, int);
1577 extern void x_focus_frame (struct frame *, bool);
1579 #ifndef HAVE_NS
1581 extern bool x_bitmap_icon (struct frame *, Lisp_Object);
1583 /* Set F's bitmap icon, if specified among F's parameters. */
1585 INLINE void
1586 x_set_bitmap_icon (struct frame *f)
1588 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1590 if (CONSP (obj) && !NILP (XCDR (obj)))
1591 x_bitmap_icon (f, XCDR (obj));
1594 #endif /* !HAVE_NS */
1595 #endif /* HAVE_WINDOW_SYSTEM */
1597 INLINE void
1598 flush_frame (struct frame *f)
1600 struct redisplay_interface *rif = FRAME_RIF (f);
1602 if (rif && rif->flush_display)
1603 rif->flush_display (f);
1606 /***********************************************************************
1607 Multimonitor data
1608 ***********************************************************************/
1610 #ifdef HAVE_WINDOW_SYSTEM
1612 struct MonitorInfo {
1613 XRectangle geom, work;
1614 int mm_width, mm_height;
1615 char *name;
1618 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1619 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1620 int n_monitors,
1621 int primary_monitor,
1622 Lisp_Object monitor_frames,
1623 const char *source);
1625 #endif /* HAVE_WINDOW_SYSTEM */
1628 INLINE_HEADER_END
1630 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1631 This is for functions like x_set_horizontal_scroll_bars that have
1632 no effect in this case. */
1633 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1634 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1635 #endif
1637 #endif /* not EMACS_FRAME_H */