Implement HiDPI support for underwave on MS-Windows
[emacs.git] / src / frame.h
blob154dc9a3bb4e8f24e582aa52735131eba7b936fe
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2017 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 <http://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,
68 #endif /* HAVE_WINDOW_SYSTEM */
70 /* The structure representing a frame. */
72 struct frame
74 struct vectorlike_header header;
76 /* All Lisp_Object components must come first.
77 That ensures they are all aligned normally. */
79 /* Name of this frame: a Lisp string. It is used for looking up resources,
80 as well as for the title in some cases. */
81 Lisp_Object name;
83 /* The name to use for the icon, the last time
84 it was refreshed. nil means not explicitly specified. */
85 Lisp_Object icon_name;
87 /* This is the frame title specified explicitly, if any.
88 Usually it is nil. */
89 Lisp_Object title;
91 #if defined (HAVE_WINDOW_SYSTEM)
92 /* This frame's parent frame, if it has one. */
93 Lisp_Object parent_frame;
94 #endif /* HAVE_WINDOW_SYSTEM */
96 /* The frame which should receive keystrokes that occur in this
97 frame, or nil if they should go to the frame itself. This is
98 usually nil, but if the frame is minibufferless, we can use this
99 to redirect keystrokes to a surrogate minibuffer frame when
100 needed.
102 Note that a value of nil is different than having the field point
103 to the frame itself. Whenever the Fselect_frame function is used
104 to shift from one frame to the other, any redirections to the
105 original frame are shifted to the newly selected frame; if
106 focus_frame is nil, Fselect_frame will leave it alone. */
107 Lisp_Object focus_frame;
109 /* This frame's root window. Every frame has one.
110 If the frame has only a minibuffer window, this is it.
111 Otherwise, if the frame has a minibuffer window, this is its sibling. */
112 Lisp_Object root_window;
114 /* This frame's selected window.
115 Each frame has its own window hierarchy
116 and one of the windows in it is selected within the frame.
117 The selected window of the selected frame is Emacs's selected window. */
118 Lisp_Object selected_window;
120 /* This frame's minibuffer window.
121 Most frames have their own minibuffer windows,
122 but only the selected frame's minibuffer window
123 can actually appear to exist. */
124 Lisp_Object minibuffer_window;
126 /* Parameter alist of this frame.
127 These are the parameters specified when creating the frame
128 or modified with modify-frame-parameters. */
129 Lisp_Object param_alist;
131 /* List of scroll bars on this frame.
132 Actually, we don't specify exactly what is stored here at all; the
133 scroll bar implementation code can use it to store anything it likes.
134 This field is marked by the garbage collector. It is here
135 instead of in the `device' structure so that the garbage
136 collector doesn't need to look inside the window-system-dependent
137 structure. */
138 Lisp_Object scroll_bars;
139 Lisp_Object condemned_scroll_bars;
141 /* Vector describing the items to display in the menu bar.
142 Each item has four elements in this vector.
143 They are KEY, STRING, SUBMAP, and HPOS.
144 (HPOS is not used in when the X toolkit is in use.)
145 There are four additional elements of nil at the end, to terminate. */
146 Lisp_Object menu_bar_items;
148 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
149 Lisp_Object face_alist;
151 /* A vector that records the entire structure of this frame's menu bar.
152 For the format of the data, see extensive comments in xmenu.c.
153 Only the X toolkit version uses this. */
154 Lisp_Object menu_bar_vector;
156 /* Predicate for selecting buffers for other-buffer. */
157 Lisp_Object buffer_predicate;
159 /* List of buffers viewed in this frame, for other-buffer. */
160 Lisp_Object buffer_list;
162 /* List of buffers that were viewed, then buried in this frame. The
163 most recently buried buffer is first. For last-buffer. */
164 Lisp_Object buried_buffer_list;
166 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
167 /* A dummy window used to display menu bars under X when no X
168 toolkit support is available. */
169 Lisp_Object menu_bar_window;
170 #endif
172 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
173 /* A window used to display the tool-bar of a frame. */
174 Lisp_Object tool_bar_window;
176 /* Desired and current contents displayed in that window. */
177 Lisp_Object desired_tool_bar_string;
178 Lisp_Object current_tool_bar_string;
179 #endif
181 /* Desired and current tool-bar items. */
182 Lisp_Object tool_bar_items;
184 #ifdef USE_GTK
185 /* Where tool bar is, can be left, right, top or bottom.
186 Except with GTK, the only supported position is `top'. */
187 Lisp_Object tool_bar_position;
188 #endif
190 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
191 /* List of data specific to font-driver and frame, but common to faces. */
192 Lisp_Object font_data;
193 #endif
195 /* Beyond here, there should be no more Lisp_Object components. */
197 /* Cache of realized faces. */
198 struct face_cache *face_cache;
200 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
201 /* Tool-bar item index of the item on which a mouse button was pressed. */
202 int last_tool_bar_item;
203 #endif
205 /* Number of elements in `menu_bar_vector' that have meaningful data. */
206 int menu_bar_items_used;
208 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
209 /* A buffer to hold the frame's name. Since this is used by the
210 window system toolkit, we can't use the Lisp string's pointer
211 (`name', above) because it might get relocated. */
212 char *namebuf;
213 #endif
215 #ifdef USE_X_TOOLKIT
216 /* Used to pass geometry parameters to toolkit functions. */
217 char *shell_position;
218 #endif
220 /* Glyph pool and matrix. */
221 struct glyph_pool *current_pool;
222 struct glyph_pool *desired_pool;
223 struct glyph_matrix *desired_matrix;
224 struct glyph_matrix *current_matrix;
226 /* Bitfield area begins here. Keep them together to avoid extra padding. */
228 /* True means that glyphs on this frame have been initialized so it can
229 be used for output. */
230 bool_bf glyphs_initialized_p : 1;
232 /* Set to true in change_frame_size when size of frame changed
233 Clear the frame in clear_garbaged_frames if set. */
234 bool_bf resized_p : 1;
236 /* Set to true if the default face for the frame has been
237 realized. Reset to zero whenever the default face changes.
238 Used to see the difference between a font change and face change. */
239 bool_bf default_face_done_p : 1;
241 /* Set to true if this frame has already been hscrolled during
242 current redisplay. */
243 bool_bf already_hscrolled_p : 1;
245 /* Set to true when current redisplay has updated frame. */
246 bool_bf updated_p : 1;
248 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
249 /* Set to true to minimize tool-bar height even when
250 auto-resize-tool-bar is set to grow-only. */
251 bool_bf minimize_tool_bar_window_p : 1;
252 #endif
254 #if defined (USE_GTK) || defined (HAVE_NS)
255 /* True means using a tool bar that comes from the toolkit. */
256 bool_bf external_tool_bar : 1;
257 #endif
259 /* True means that fonts have been loaded since the last glyph
260 matrix adjustments. */
261 bool_bf fonts_changed : 1;
263 /* True means that cursor type has been changed. */
264 bool_bf cursor_type_changed : 1;
266 /* True if it needs to be redisplayed. */
267 bool_bf redisplay : 1;
269 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
270 || defined (HAVE_NS) || defined (USE_GTK)
271 /* True means using a menu bar that comes from the X toolkit. */
272 bool_bf external_menu_bar : 1;
273 #endif
275 /* Next two bitfields are mutually exclusive. They might both be
276 zero if the frame has been made invisible without an icon. */
278 /* Nonzero if the frame is currently displayed; we check
279 it to see if we should bother updating the frame's contents.
281 On ttys and on Windows NT/9X, to avoid wasting effort updating
282 visible frames that are actually completely obscured by other
283 windows on the display, we bend the meaning of visible slightly:
284 if equal to 2, then the frame is obscured - we still consider
285 it to be "visible" as seen from lisp, but we don't bother
286 updating it. */
287 unsigned visible : 2;
289 /* True if the frame is currently iconified. Do not
290 set this directly, use SET_FRAME_ICONIFIED instead. */
291 bool_bf iconified : 1;
293 /* True if this frame should be fully redisplayed. Disables all
294 optimizations while rebuilding matrices and redrawing. */
295 bool_bf garbaged : 1;
297 /* False means, if this frame has just one window,
298 show no modeline for that window. */
299 bool_bf wants_modeline : 1;
301 /* True means raise this frame to the top of the heap when selected. */
302 bool_bf auto_raise : 1;
304 /* True means lower this frame to the bottom of the stack when left. */
305 bool_bf auto_lower : 1;
307 /* True if frame's root window can't be split. */
308 bool_bf no_split : 1;
310 /* If this is set, then Emacs won't change the frame name to indicate
311 the current buffer, etcetera. If the user explicitly sets the frame
312 name, this gets set. If the user sets the name to Qnil, this is
313 cleared. */
314 bool_bf explicit_name : 1;
316 /* True if configuration of windows on this frame has changed since
317 last call of run_window_size_change_functions. */
318 bool_bf window_configuration_changed : 1;
320 /* True if the mouse has moved on this display device
321 since the last time we checked. */
322 bool_bf mouse_moved : 1;
324 /* True means that the pointer is invisible. */
325 bool_bf pointer_invisible : 1;
327 /* True means that all windows except mini-window and
328 selected window on this frame have frozen window starts. */
329 bool_bf frozen_window_starts : 1;
331 /* The output method says how the contents of this frame are
332 displayed. It could be using termcap, or using an X window.
333 This must be the same as the terminal->type. */
334 ENUM_BF (output_method) output_method : 3;
336 #ifdef HAVE_WINDOW_SYSTEM
337 /* See FULLSCREEN_ enum on top. */
338 ENUM_BF (fullscreen_type) want_fullscreen : 4;
340 /* If not vertical_scroll_bar_none, we should actually
341 display the scroll bars of this type on this frame. */
342 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
344 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
345 bool_bf horizontal_scroll_bars : 1;
346 #endif /* HAVE_WINDOW_SYSTEM */
348 #if defined (HAVE_WINDOW_SYSTEM)
349 /* True if this is an undecorated frame. */
350 bool_bf undecorated : 1;
352 #ifndef HAVE_NTGUI
353 /* True if this is an override_redirect frame. */
354 bool_bf override_redirect : 1;
355 #endif
357 /* Nonzero if this frame's icon should not appear on its display's taskbar. */
358 bool_bf skip_taskbar : 1;
360 /* Nonzero if this frame's window F's X window does not want to
361 receive input focus when it is mapped. */
362 bool_bf no_focus_on_map : 1;
364 /* Nonzero if this frame's window does not want to receive input focus
365 via mouse clicks or by moving the mouse into it. */
366 bool_bf no_accept_focus : 1;
368 /* The z-group this frame's window belongs to. */
369 ENUM_BF (z_group) z_group : 2;
371 /* Non-zero if display of truncation and continuation glyphs outside
372 the fringes is suppressed. */
373 bool_bf no_special_glyphs : 1;
374 #endif /* HAVE_WINDOW_SYSTEM */
376 /* Whether new_height and new_width shall be interpreted
377 in pixels. */
378 bool_bf new_pixelwise : 1;
380 /* True means x_set_window_size requests can be processed for this
381 frame. */
382 bool_bf can_x_set_window_size : 1;
384 /* Set to true after this frame was made by `make-frame'. */
385 bool_bf after_make_frame : 1;
387 /* Whether the tool bar height change should be taken into account. */
388 bool_bf tool_bar_redisplayed : 1;
389 bool_bf tool_bar_resized : 1;
391 /* Inhibit implied resize before after_make_frame is set. */
392 bool_bf inhibit_horizontal_resize : 1;
393 bool_bf inhibit_vertical_resize : 1;
395 /* Non-zero if this frame's faces need to be recomputed. */
396 bool_bf face_change : 1;
398 /* Bitfield area ends here. */
400 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
401 int tool_bar_lines;
403 /* Height of frame internal tool bar in pixels. */
404 int tool_bar_height;
406 int n_tool_bar_rows;
407 int n_tool_bar_items;
409 /* A buffer for decode_mode_line. */
410 char *decode_mode_spec_buffer;
412 /* See do_line_insertion_deletion_costs for info on these arrays. */
413 /* Cost of inserting 1 line on this frame. */
414 int *insert_line_cost;
415 /* Cost of deleting 1 line on this frame. */
416 int *delete_line_cost;
417 /* Cost of inserting n lines on this frame. */
418 int *insert_n_lines_cost;
419 /* Cost of deleting n lines on this frame. */
420 int *delete_n_lines_cost;
422 /* Text width of this frame (excluding fringes, vertical scroll bar
423 and internal border widths) and text height (excluding menu bar,
424 tool bar, horizontal scroll bar and internal border widths) in
425 units of canonical characters. */
426 int text_cols, text_lines;
428 /* Total width of this frame (including fringes, vertical scroll bar
429 and internal border widths) and total height (including menu bar,
430 tool bar, horizontal scroll bar and internal border widths) in
431 units of canonical characters. */
432 int total_cols, total_lines;
434 /* Text width of this frame (excluding fringes, vertical scroll bar
435 and internal border widths) and text height (excluding menu bar,
436 tool bar, horizontal scroll bar and internal border widths) in
437 pixels. */
438 int text_width, text_height;
440 /* New text height and width for pending size change. 0 if no change
441 pending. These values represent pixels or canonical character units
442 according to the value of new_pixelwise and correlate to the the
443 text width/height of the frame. */
444 int new_width, new_height;
446 /* Pixel position of the frame window (x and y offsets in root window). */
447 int left_pos, top_pos;
449 /* Total width of this frame (including fringes, vertical scroll bar
450 and internal border widths) and total height (including internal
451 menu and tool bars, horizontal scroll bar and internal border
452 widths) in pixels. */
453 int pixel_width, pixel_height;
455 /* This is the gravity value for the specified window position. */
456 int win_gravity;
458 /* The geometry flags for this window. */
459 int size_hint_flags;
461 /* Border width of the frame window as known by the (X) window system. */
462 int border_width;
464 /* Width of the internal border. This is a line of background color
465 just inside the window's border. When the frame is selected,
466 a highlighting is displayed inside the internal border. */
467 int internal_border_width;
469 /* Widths of dividers between this frame's windows in pixels. */
470 int right_divider_width, bottom_divider_width;
472 /* Widths of fringes in pixels. */
473 int left_fringe_width, right_fringe_width;
475 /* Total width of fringes reserved for drawing truncation bitmaps,
476 continuation bitmaps and alike - REMOVE THIS !!!!. */
477 int fringe_cols;
479 /* Number of lines of menu bar. */
480 int menu_bar_lines;
482 /* Pixel height of menubar. */
483 int menu_bar_height;
485 /* Canonical X unit. Width of default font, in pixels. */
486 int column_width;
488 /* Canonical Y unit. Height of a line, in pixels. */
489 int line_height;
491 /* The terminal device that this frame uses. If this is NULL, then
492 the frame has been deleted. */
493 struct terminal *terminal;
495 /* Device-dependent, frame-local auxiliary data used for displaying
496 the contents. When the frame is deleted, this data is deleted as
497 well. */
498 union output_data
500 struct tty_output *tty; /* From termchar.h. */
501 struct x_output *x; /* From xterm.h. */
502 struct w32_output *w32; /* From w32term.h. */
503 struct ns_output *ns; /* From nsterm.h. */
504 intptr_t nothing;
506 output_data;
508 /* List of font-drivers available on the frame. */
509 struct font_driver_list *font_driver_list;
511 #if defined (HAVE_X_WINDOWS)
512 /* Used by x_wait_for_event when watching for an X event on this frame. */
513 int wait_event_type;
514 #endif
516 /* What kind of text cursor should we draw in the future?
517 This should always be filled_box_cursor or bar_cursor. */
518 enum text_cursor_kinds desired_cursor;
520 /* Width of bar cursor (if we are using that). */
521 int cursor_width;
523 /* What kind of text cursor should we draw when the cursor blinks off?
524 This can be filled_box_cursor or bar_cursor or no_cursor. */
525 enum text_cursor_kinds blink_off_cursor;
527 /* Width of bar cursor (if we are using that) for blink-off state. */
528 int blink_off_cursor_width;
530 /* Configured width of the scroll bar, in pixels and in characters.
531 config_scroll_bar_cols tracks config_scroll_bar_width if the
532 latter is positive; a zero value in config_scroll_bar_width means
533 to compute the actual width on the fly, using config_scroll_bar_cols
534 and the current font width. */
535 int config_scroll_bar_width;
536 int config_scroll_bar_cols;
538 /* Configured height of the scroll bar, in pixels and in characters.
539 config_scroll_bar_lines tracks config_scroll_bar_height if the
540 latter is positive; a zero value in config_scroll_bar_height means
541 to compute the actual width on the fly, using
542 config_scroll_bar_lines and the current font width. */
543 int config_scroll_bar_height;
544 int config_scroll_bar_lines;
546 /* The baud rate that was used to calculate costs for this frame. */
547 int cost_calculation_baud_rate;
549 /* Frame opacity
550 alpha[0]: alpha transparency of the active frame
551 alpha[1]: alpha transparency of inactive frames
552 Negative values mean not to change alpha. */
553 double alpha[2];
555 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
556 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
557 frame parameter. 0 means don't do gamma correction. */
558 double gamma;
560 /* Additional space to put between text lines on this frame. */
561 int extra_line_spacing;
563 /* All display backends seem to need these two pixel values. */
564 unsigned long background_pixel;
565 unsigned long foreground_pixel;
568 /* Most code should use these functions to set Lisp fields in struct frame. */
570 INLINE void
571 fset_buffer_list (struct frame *f, Lisp_Object val)
573 f->buffer_list = val;
575 INLINE void
576 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
578 f->buried_buffer_list = val;
580 INLINE void
581 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
583 f->condemned_scroll_bars = val;
585 INLINE void
586 fset_face_alist (struct frame *f, Lisp_Object val)
588 f->face_alist = val;
590 #if defined (HAVE_WINDOW_SYSTEM)
591 INLINE void
592 fset_parent_frame (struct frame *f, Lisp_Object val)
594 f->parent_frame = val;
596 #endif
597 INLINE void
598 fset_focus_frame (struct frame *f, Lisp_Object val)
600 f->focus_frame = val;
602 INLINE void
603 fset_icon_name (struct frame *f, Lisp_Object val)
605 f->icon_name = val;
607 INLINE void
608 fset_menu_bar_items (struct frame *f, Lisp_Object val)
610 f->menu_bar_items = val;
612 INLINE void
613 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
615 f->menu_bar_vector = val;
617 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
618 INLINE void
619 fset_menu_bar_window (struct frame *f, Lisp_Object val)
621 f->menu_bar_window = val;
623 #endif
624 INLINE void
625 fset_name (struct frame *f, Lisp_Object val)
627 f->name = val;
629 INLINE void
630 fset_param_alist (struct frame *f, Lisp_Object val)
632 f->param_alist = val;
634 INLINE void
635 fset_root_window (struct frame *f, Lisp_Object val)
637 f->root_window = val;
639 INLINE void
640 fset_scroll_bars (struct frame *f, Lisp_Object val)
642 f->scroll_bars = val;
644 INLINE void
645 fset_selected_window (struct frame *f, Lisp_Object val)
647 f->selected_window = val;
649 INLINE void
650 fset_title (struct frame *f, Lisp_Object val)
652 f->title = val;
654 INLINE void
655 fset_tool_bar_items (struct frame *f, Lisp_Object val)
657 f->tool_bar_items = val;
659 #ifdef USE_GTK
660 INLINE void
661 fset_tool_bar_position (struct frame *f, Lisp_Object val)
663 f->tool_bar_position = val;
665 #endif /* USE_GTK */
666 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
667 INLINE void
668 fset_tool_bar_window (struct frame *f, Lisp_Object val)
670 f->tool_bar_window = val;
672 INLINE void
673 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
675 f->current_tool_bar_string = val;
677 INLINE void
678 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
680 f->desired_tool_bar_string = val;
682 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
684 INLINE double
685 NUMVAL (Lisp_Object x)
687 return NUMBERP (x) ? XFLOATINT (x) : -1;
690 INLINE double
691 default_pixels_per_inch_x (void)
693 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
694 ? XCAR (Vdisplay_pixels_per_inch)
695 : Vdisplay_pixels_per_inch);
696 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
699 INLINE double
700 default_pixels_per_inch_y (void)
702 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
703 ? XCDR (Vdisplay_pixels_per_inch)
704 : Vdisplay_pixels_per_inch);
705 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
708 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
710 /* Return a pointer to the image cache of frame F. */
711 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
713 #define XFRAME(p) \
714 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
715 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
717 /* Given a window, return its frame as a Lisp_Object. */
718 #define WINDOW_FRAME(w) ((w)->frame)
720 /* Test a frame for particular kinds of display methods. */
721 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
722 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
723 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
724 #ifndef HAVE_NTGUI
725 #define FRAME_W32_P(f) false
726 #else
727 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
728 #endif
729 #ifndef MSDOS
730 #define FRAME_MSDOS_P(f) false
731 #else
732 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
733 #endif
734 #ifndef HAVE_NS
735 #define FRAME_NS_P(f) false
736 #else
737 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
738 #endif
740 /* FRAME_WINDOW_P tests whether the frame is a window, and is
741 defined to be the predicate for the window system being used. */
743 #ifdef HAVE_X_WINDOWS
744 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
745 #endif
746 #ifdef HAVE_NTGUI
747 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
748 #endif
749 #ifdef HAVE_NS
750 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
751 #endif
752 #ifndef FRAME_WINDOW_P
753 #define FRAME_WINDOW_P(f) ((void) (f), false)
754 #endif
756 /* Dots per inch of the screen the frame F is on. */
758 #ifdef HAVE_WINDOW_SYSTEM
760 #define FRAME_RES_X(f) \
761 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
762 #define FRAME_RES_Y(f) \
763 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
765 #else /* !HAVE_WINDOW_SYSTEM */
767 /* Defaults when no window system available. */
769 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
770 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
772 #endif /* HAVE_WINDOW_SYSTEM */
774 /* Return a pointer to the structure holding information about the
775 region of text, if any, that is currently shown in mouse-face on
776 frame F. We need to define two versions because a TTY-only build
777 does not have FRAME_DISPLAY_INFO. */
778 #ifdef HAVE_WINDOW_SYSTEM
779 # define MOUSE_HL_INFO(F) \
780 (FRAME_WINDOW_P(F) \
781 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
782 : &(F)->output_data.tty->display_info->mouse_highlight)
783 #else
784 # define MOUSE_HL_INFO(F) \
785 (&(F)->output_data.tty->display_info->mouse_highlight)
786 #endif
788 /* True if frame F is still alive (not deleted). */
789 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
791 /* True if frame F is a minibuffer-only frame. */
792 #define FRAME_MINIBUF_ONLY_P(f) \
793 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
795 /* True if frame F contains it's own minibuffer window. Frame always has
796 minibuffer window, but it could use minibuffer window of another frame. */
797 #define FRAME_HAS_MINIBUF_P(f) \
798 (WINDOWP (f->minibuffer_window) \
799 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
801 /* Pixel width of frame F. */
802 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
804 /* Pixel height of frame F. */
805 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
807 /* Width of frame F, measured in canonical character columns,
808 not including scroll bars if any. */
809 #define FRAME_COLS(f) (f)->text_cols
811 /* Height of frame F, measured in canonical lines, including
812 non-toolkit menu bar and non-toolkit tool bar lines. */
813 #define FRAME_LINES(f) (f)->text_lines
815 /* Width of frame F, measured in pixels not including the width for
816 fringes, scroll bar, and internal borders. */
817 #define FRAME_TEXT_WIDTH(f) (f)->text_width
819 /* Height of frame F, measured in pixels not including the height
820 for scroll bar and internal borders. */
821 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
823 /* Number of lines of frame F used for menu bar.
824 This is relevant on terminal frames and on
825 X Windows when not using the X toolkit.
826 These lines are counted in FRAME_LINES. */
827 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
829 /* Pixel height of frame F's menu bar. */
830 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
832 /* True if this frame should display a tool bar
833 in a way that does not use any text lines. */
834 #if defined (USE_GTK) || defined (HAVE_NS)
835 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
836 #else
837 #define FRAME_EXTERNAL_TOOL_BAR(f) false
838 #endif
840 /* This is really supported only with GTK. */
841 #ifdef USE_GTK
842 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
843 #else
844 #define FRAME_TOOL_BAR_POSITION(f) ((void) (f), Qtop)
845 #endif
847 /* Number of lines of frame F used for the tool-bar. */
848 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
850 /* Pixel height of frame F's tool-bar. */
851 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
853 /* Lines above the top-most window in frame F. */
854 #define FRAME_TOP_MARGIN(F) \
855 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
857 /* Pixel height of frame F's top margin. */
858 #define FRAME_TOP_MARGIN_HEIGHT(F) \
859 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
861 /* True if this frame should display a menu bar
862 in a way that does not use any text lines. */
863 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
864 || defined (HAVE_NS) || defined (USE_GTK)
865 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
866 #else
867 #define FRAME_EXTERNAL_MENU_BAR(f) false
868 #endif
870 /* True if frame F is currently visible. */
871 #define FRAME_VISIBLE_P(f) (f)->visible
873 /* True if frame F is currently visible but hidden. */
874 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
876 /* True if frame F is currently iconified. */
877 #define FRAME_ICONIFIED_P(f) (f)->iconified
879 /* Mark frame F as currently garbaged. */
880 #define SET_FRAME_GARBAGED(f) \
881 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
883 /* True if frame F is currently garbaged. */
884 #define FRAME_GARBAGED_P(f) (f)->garbaged
886 /* True means do not allow splitting this frame's window. */
887 #define FRAME_NO_SPLIT_P(f) (f)->no_split
889 /* Not really implemented. */
890 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
892 /* True if all windows except selected window and mini window
893 are frozen on frame F. */
894 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
896 /* True if the frame's window configuration has changed since last call
897 of run_window_size_change_functions. */
898 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
899 (f)->window_configuration_changed
901 /* The minibuffer window of frame F, if it has one; otherwise nil. */
902 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
904 /* The root window of the window tree of frame F. */
905 #define FRAME_ROOT_WINDOW(f) f->root_window
907 /* The currently selected window of the window tree of frame F. */
908 #define FRAME_SELECTED_WINDOW(f) f->selected_window
910 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
911 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
912 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
913 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
914 #define FRAME_FOCUS_FRAME(f) f->focus_frame
916 #ifdef HAVE_WINDOW_SYSTEM
917 /* This frame slot says whether scroll bars are currently enabled for frame F,
918 and which side they are on. */
919 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
920 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
921 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
922 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
923 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
924 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
925 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
926 #else /* not HAVE_WINDOW_SYSTEM */
927 /* If there is no window system, there are no scroll bars. */
928 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) \
929 ((void) (f), vertical_scroll_bar_none)
930 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) (f), 0)
931 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) (f), 0)
932 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) (f), 0)
933 #endif /* HAVE_WINDOW_SYSTEM */
935 #if defined (HAVE_WINDOW_SYSTEM)
936 #define FRAME_UNDECORATED(f) ((f)->undecorated)
937 #ifdef HAVE_NTGUI
938 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
939 #else
940 #define FRAME_OVERRIDE_REDIRECT(f) ((f)->override_redirect)
941 #endif
942 #define FRAME_PARENT_FRAME(f) \
943 (NILP ((f)->parent_frame) \
944 ? NULL \
945 : XFRAME ((f)->parent_frame))
946 #define FRAME_SKIP_TASKBAR(f) ((f)->skip_taskbar)
947 #define FRAME_NO_FOCUS_ON_MAP(f) ((f)->no_focus_on_map)
948 #define FRAME_NO_ACCEPT_FOCUS(f) ((f)->no_accept_focus)
949 #define FRAME_NO_SPECIAL_GLYPHS(f) ((f)->no_special_glyphs)
950 #define FRAME_Z_GROUP(f) ((f)->z_group)
951 #define FRAME_Z_GROUP_NONE(f) ((f)->z_group == z_group_none)
952 #define FRAME_Z_GROUP_ABOVE(f) ((f)->z_group == z_group_above)
953 #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \
954 ((f)->z_group == z_group_above_suspended)
955 #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below)
956 #else /* not HAVE_WINDOW_SYSTEM */
957 #define FRAME_UNDECORATED(f) ((void) (f), 0)
958 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
959 #define FRAME_PARENT_FRAME(f) ((void) (f), NULL)
960 #define FRAME_SKIP_TASKBAR(f) ((void) (f), 0)
961 #define FRAME_NO_FOCUS_ON_MAP(f) ((void) (f), 0)
962 #define FRAME_NO_ACCEPT_FOCUS(f) ((void) (f), 0)
963 #define FRAME_NO_SPECIAL_GLYPHS(f) ((void) (f), 0)
964 #define FRAME_Z_GROUP(f) ((void) (f), z_group_none)
965 #define FRAME_Z_GROUP_NONE(f) ((void) (f), true)
966 #define FRAME_Z_GROUP_ABOVE(f) ((void) (f), false)
967 #define FRAME_Z_GROUP_BELOW(f) ((void) (f), false)
968 #endif /* HAVE_WINDOW_SYSTEM */
970 /* Whether horizontal scroll bars are currently enabled for frame F. */
971 #if USE_HORIZONTAL_SCROLL_BARS
972 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
973 ((f)->horizontal_scroll_bars)
974 #else
975 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) (f), 0)
976 #endif
978 /* Width that a scroll bar in frame F should have, if there is one.
979 Measured in pixels.
980 If scroll bars are turned off, this is still nonzero. */
981 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
983 /* Height that a scroll bar in frame F should have, if there is one.
984 Measured in pixels.
985 If scroll bars are turned off, this is still nonzero. */
986 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
988 /* Width that a scroll bar in frame F should have, if there is one.
989 Measured in columns (characters).
990 If scroll bars are turned off, this is still nonzero. */
991 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
993 /* Height that a scroll bar in frame F should have, if there is one.
994 Measured in lines (characters).
995 If scroll bars are turned off, this is still nonzero. */
996 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
998 /* Width of a left scroll bar in frame F, measured in pixels */
999 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
1000 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1001 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1002 : 0)
1004 /* Width of a right scroll bar area in frame F, measured in pixels */
1005 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
1006 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1007 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1008 : 0)
1010 /* Width of a left scroll bar in frame F, measured in columns
1011 (characters), but only if scroll bars are on the left. If scroll
1012 bars are on the right in this frame, or there are no scroll bars,
1013 value is 0. */
1014 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
1015 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1016 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1017 : 0)
1019 /* Width of a right scroll bar in frame F, measured in columns
1020 (characters), but only if scroll bars are on the right. If scroll
1021 bars are on the left in this frame, or there are no scroll bars,
1022 value is 0. */
1023 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
1024 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1025 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1026 : 0)
1028 /* Width of a vertical scroll bar area in frame F, measured in
1029 pixels. */
1030 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
1031 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1032 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1033 : 0)
1035 /* Height of horizontal scroll bar area in frame F, measured in
1036 pixels. */
1037 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
1038 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1039 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1040 : 0)
1042 /* Width of vertical scroll bar in frame F, measured in columns. */
1043 #define FRAME_SCROLL_BAR_COLS(f) \
1044 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1045 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1046 : 0)
1048 /* Height of horizontal scroll bar in frame F, measured in lines. */
1049 #define FRAME_SCROLL_BAR_LINES(f) \
1050 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1051 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
1052 : 0)
1054 /* Total width of frame F, in columns (characters),
1055 including the width used by scroll bars if any. */
1056 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
1058 /* Total height of frame F, in lines (characters),
1059 including the height used by scroll bars if any. */
1060 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
1062 /* Set the character widths of frame F. WIDTH specifies a nominal
1063 character text width. */
1064 #define SET_FRAME_COLS(f, width) \
1065 ((f)->text_cols = (width), \
1066 (f)->total_cols = ((width) \
1067 + FRAME_SCROLL_BAR_COLS (f) \
1068 + FRAME_FRINGE_COLS (f)))
1070 /* Set the character heights of frame F. HEIGHT specifies a nominal
1071 character text height. */
1072 #define SET_FRAME_LINES(f, height) \
1073 ((f)->text_lines = (height), \
1074 (f)->total_lines = ((height) \
1075 + FRAME_TOP_MARGIN (f) \
1076 + FRAME_SCROLL_BAR_LINES (f)))
1078 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
1079 width. */
1080 #define SET_FRAME_WIDTH(f, width) \
1081 ((f)->text_width = (width), \
1082 (f)->pixel_width = ((width) \
1083 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1084 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1085 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1087 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
1088 height. */
1089 #define SET_FRAME_HEIGHT(f, height) \
1090 ((f)->text_height = (height), \
1091 (f)->pixel_height = ((height) \
1092 + FRAME_TOP_MARGIN_HEIGHT (f) \
1093 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1094 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1096 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1097 #define FRAME_CURSOR_X_LIMIT(f) \
1098 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1100 /* Nonzero if frame F has scroll bars. */
1101 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1102 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1104 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1105 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1107 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1108 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1109 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1110 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1112 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1113 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1115 /* Return a pointer to the face cache of frame F. */
1117 #define FRAME_FACE_CACHE(F) (F)->face_cache
1119 /* Return the size of message_buf of the frame F. We multiply the
1120 width of the frame by 4 because multi-byte form may require at most
1121 4-byte for a character. */
1123 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1125 #define CHECK_FRAME(x) \
1126 CHECK_TYPE (FRAMEP (x), Qframep, x)
1128 #define CHECK_LIVE_FRAME(x) \
1129 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1131 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1132 `for' loop which iterates over the elements of Vframe_list. The
1133 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1134 Vframe_list in succession and execute the statement. Vframe_list
1135 should be nonempty, so the body is executed at least once. LIST_VAR
1136 should be a Lisp_Object too; it is used to iterate through the
1137 Vframe_list. Note that this macro walks over child frames and
1138 the tooltip frame as well.
1140 This macro is a holdover from a time when multiple frames weren't always
1141 supported. An alternate definition of the macro would expand to
1142 something which executes the statement once. */
1144 #define FOR_EACH_FRAME(list_var, frame_var) \
1145 for ((list_var) = (eassume (CONSP (Vframe_list)), Vframe_list); \
1146 (CONSP (list_var) \
1147 && (frame_var = XCAR (list_var), true)); \
1148 list_var = XCDR (list_var))
1150 /* Reflect mouse movement when a complete frame update is performed. */
1152 #define FRAME_MOUSE_UPDATE(frame) \
1153 do { \
1154 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1155 if (frame == hlinfo->mouse_face_mouse_frame) \
1157 block_input (); \
1158 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1159 hlinfo->mouse_face_mouse_x, \
1160 hlinfo->mouse_face_mouse_y); \
1161 unblock_input (); \
1163 } while (false)
1165 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1167 #define AUTO_FRAME_ARG(name, parameter, value) \
1168 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1170 /* False means there are no visible garbaged frames. */
1171 extern bool frame_garbaged;
1173 /* Set visibility of frame F.
1174 We call redisplay_other_windows to make sure the frame gets redisplayed
1175 if some changes were applied to it while it wasn't visible (and hence
1176 wasn't redisplayed). */
1178 INLINE void
1179 SET_FRAME_VISIBLE (struct frame *f, int v)
1181 eassert (0 <= v && v <= 2);
1182 if (v)
1184 if (v == 1 && f->visible != 1)
1185 redisplay_other_windows ();
1186 if (FRAME_GARBAGED_P (f))
1187 frame_garbaged = true;
1189 f->visible = v;
1192 /* Set iconify of frame F. */
1194 #define SET_FRAME_ICONIFIED(f, i) \
1195 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1197 extern Lisp_Object selected_frame;
1199 #if ! (defined USE_GTK || defined HAVE_NS)
1200 extern int frame_default_tool_bar_height;
1201 #endif
1203 #ifdef HAVE_WINDOW_SYSTEM
1204 # define WINDOW_SYSTEM_RETURN
1205 #else
1206 # define WINDOW_SYSTEM_RETURN _Noreturn
1207 #endif
1209 extern WINDOW_SYSTEM_RETURN struct frame *
1210 decode_window_system_frame (Lisp_Object);
1211 extern struct frame *decode_live_frame (Lisp_Object);
1212 extern struct frame *decode_any_frame (Lisp_Object);
1213 extern struct frame *make_initial_frame (void);
1214 extern struct frame *make_frame (bool);
1215 #ifdef HAVE_WINDOW_SYSTEM
1216 extern struct frame *make_minibuffer_frame (void);
1217 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1218 struct kboard *,
1219 Lisp_Object);
1220 extern bool display_available (void);
1221 #endif
1223 INLINE bool
1224 window_system_available (struct frame *f)
1226 #ifdef HAVE_WINDOW_SYSTEM
1227 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
1228 #else
1229 return false;
1230 #endif
1233 extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
1234 extern void frame_make_pointer_invisible (struct frame *);
1235 extern void frame_make_pointer_visible (struct frame *);
1236 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1237 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
1238 extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
1239 extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
1240 int width, int height, Lisp_Object rest);
1242 extern Lisp_Object Vframe_list;
1244 /* Value is a pointer to the selected frame. If the selected frame
1245 isn't live, abort. */
1247 #define SELECTED_FRAME() \
1248 ((FRAMEP (selected_frame) \
1249 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1250 ? XFRAME (selected_frame) \
1251 : (emacs_abort (), (struct frame *) 0))
1254 /***********************************************************************
1255 Display-related Macros
1256 ***********************************************************************/
1258 /* Canonical y-unit on frame F.
1259 This value currently equals the line height of the frame (which is
1260 the height of the default font of F). */
1261 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1263 /* Canonical x-unit on frame F.
1264 This value currently equals the average width of the default font of F. */
1265 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1267 /* Get a frame's window system dimension. If no window system, this is 0. */
1269 INLINE int
1270 frame_dimension (int x)
1272 #ifdef HAVE_WINDOW_SYSTEM
1273 return x;
1274 #else
1275 return 0;
1276 #endif
1279 /* Total width of fringes reserved for drawing truncation bitmaps,
1280 continuation bitmaps and alike. The width is in canonical char
1281 units of the frame. This must currently be the case because window
1282 sizes aren't pixel values. If it weren't the case, we wouldn't be
1283 able to split windows horizontally nicely. */
1284 INLINE int
1285 FRAME_FRINGE_COLS (struct frame *f)
1287 return frame_dimension (f->fringe_cols);
1290 /* Pixel-width of the left and right fringe. */
1292 INLINE int
1293 FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
1295 return frame_dimension (f->left_fringe_width);
1297 INLINE int
1298 FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
1300 return frame_dimension (f->right_fringe_width);
1303 /* Total width of fringes in pixels. */
1305 INLINE int
1306 FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
1308 return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
1311 /* Pixel-width of internal border lines. */
1312 INLINE int
1313 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
1315 return frame_dimension (f->internal_border_width);
1318 /* Pixel-size of window divider lines. */
1319 INLINE int
1320 FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
1322 return frame_dimension (f->right_divider_width);
1325 INLINE int
1326 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
1328 return frame_dimension (f->bottom_divider_width);
1331 /***********************************************************************
1332 Conversion between canonical units and pixels
1333 ***********************************************************************/
1335 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1336 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1337 represented as Lisp numbers, i.e. integers or floats. */
1339 /* Convert canonical value X to pixels. F is the frame whose
1340 canonical char width is to be used. X must be a Lisp integer or
1341 float. Value is a C integer. */
1342 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1343 (INTEGERP (X) \
1344 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1345 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1347 /* Convert canonical value Y to pixels. F is the frame whose
1348 canonical character height is to be used. X must be a Lisp integer
1349 or float. Value is a C integer. */
1350 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1351 (INTEGERP (Y) \
1352 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1353 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1355 /* Convert pixel-value X to canonical units. F is the frame whose
1356 canonical character width is to be used. X is a C integer. Result
1357 is a Lisp float if X is not a multiple of the canon width,
1358 otherwise it's a Lisp integer. */
1359 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1360 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1361 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1362 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1364 /* Convert pixel-value Y to canonical units. F is the frame whose
1365 canonical character height is to be used. Y is a C integer.
1366 Result is a Lisp float if Y is not a multiple of the canon width,
1367 otherwise it's a Lisp integer. */
1368 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1369 ((Y) % FRAME_LINE_HEIGHT (F) \
1370 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1371 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1375 /* Manipulating pixel sizes and character sizes.
1376 Knowledge of which factors affect the overall size of the window should
1377 be hidden in these macros, if that's possible.
1379 Return the upper/left pixel position of the character cell on frame F
1380 at ROW/COL. */
1381 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1382 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1383 + (row) * FRAME_LINE_HEIGHT (f))
1385 #define FRAME_COL_TO_PIXEL_X(f, col) \
1386 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1387 + (col) * FRAME_COLUMN_WIDTH (f))
1389 /* Return the pixel width/height of frame F if it has
1390 COLS columns/LINES rows. */
1391 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1392 ((cols) * FRAME_COLUMN_WIDTH (f) \
1393 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1394 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1395 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1397 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1398 ((lines) * FRAME_LINE_HEIGHT (f) \
1399 + FRAME_TOP_MARGIN_HEIGHT (f) \
1400 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1401 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1403 /* Return the row/column (zero-based) of the character cell containing
1404 the pixel on FRAME at Y/X. */
1405 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1406 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1407 ? (y) \
1408 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1409 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1410 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1411 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1412 /* Arrange for the division to round down. */ \
1413 + FRAME_LINE_HEIGHT (f) - 1) \
1414 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1415 / FRAME_LINE_HEIGHT (f))
1417 #define FRAME_PIXEL_X_TO_COL(f, x) \
1418 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1419 / FRAME_COLUMN_WIDTH (f))
1421 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1422 frame F (so we round down)? */
1423 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1424 (((width) \
1425 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1426 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1427 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1428 / FRAME_COLUMN_WIDTH (f)) \
1430 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1431 (((height) \
1432 - FRAME_TOP_MARGIN_HEIGHT (f) \
1433 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1434 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1435 / FRAME_LINE_HEIGHT (f))
1437 /* Return the pixel width/height of frame F with a text size of
1438 width/height. */
1439 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1440 ((width) \
1441 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1442 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1443 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1445 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1446 ((height) \
1447 + FRAME_TOP_MARGIN_HEIGHT (f) \
1448 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1449 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1451 /* Return the text width/height of frame F with a pixel size of
1452 width/height. */
1453 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1454 ((width) \
1455 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1456 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1457 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1459 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1460 ((height) \
1461 - FRAME_TOP_MARGIN_HEIGHT (f) \
1462 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1463 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1465 /* Return the width/height reserved for the windows of frame F. */
1466 #define FRAME_WINDOWS_WIDTH(f) \
1467 (FRAME_PIXEL_WIDTH (f) \
1468 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1470 #define FRAME_WINDOWS_HEIGHT(f) \
1471 (FRAME_PIXEL_HEIGHT (f) \
1472 - FRAME_TOP_MARGIN_HEIGHT (f) \
1473 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1475 /* Value is the smallest width of any character in any font on frame F. */
1476 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1477 FRAME_DISPLAY_INFO (f)->smallest_char_width
1479 /* Value is the smallest height of any font on frame F. */
1480 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1481 FRAME_DISPLAY_INFO (f)->smallest_font_height
1483 /***********************************************************************
1484 Frame Parameters
1485 ***********************************************************************/
1487 #ifdef HAVE_WINDOW_SYSTEM
1489 /* The class of this X application. */
1490 #define EMACS_CLASS "Emacs"
1492 extern void x_set_scroll_bar_default_width (struct frame *);
1493 extern void x_set_scroll_bar_default_height (struct frame *);
1494 extern void x_set_offset (struct frame *, int, int, int);
1495 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1496 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1497 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1498 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1499 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1500 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1501 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1502 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1503 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1504 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1505 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1506 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1507 Lisp_Object);
1508 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1509 Lisp_Object);
1510 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1511 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1512 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1513 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1514 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1515 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1516 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1517 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1519 extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, int *);
1521 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1522 extern void x_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object);
1524 extern void validate_x_resource_name (void);
1526 extern Lisp_Object display_x_get_resource (Display_Info *,
1527 Lisp_Object attribute,
1528 Lisp_Object class,
1529 Lisp_Object component,
1530 Lisp_Object subclass);
1532 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1533 extern void x_set_window_size (struct frame *f, bool change_gravity,
1534 int width, int height, bool pixelwise);
1535 extern Lisp_Object x_get_focus_frame (struct frame *);
1536 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1537 extern void x_make_frame_visible (struct frame *f);
1538 extern void x_make_frame_invisible (struct frame *f);
1539 extern void x_iconify_frame (struct frame *f);
1540 extern void x_set_frame_alpha (struct frame *f);
1541 extern void x_activate_menubar (struct frame *);
1542 extern void x_real_positions (struct frame *, int *, int *);
1543 extern void free_frame_menubar (struct frame *);
1544 extern void x_free_frame_resources (struct frame *);
1545 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
1546 extern enum internal_border_part frame_internal_border_part (struct frame *f, int x, int y);
1548 #if defined HAVE_X_WINDOWS
1549 extern void x_wm_set_icon_position (struct frame *, int, int);
1550 #if !defined USE_X_TOOLKIT
1551 extern char *x_get_resource_string (const char *, const char *);
1552 #endif
1553 extern void x_sync (struct frame *);
1554 #endif /* HAVE_X_WINDOWS */
1556 extern void x_query_colors (struct frame *f, XColor *, int);
1557 extern void x_focus_frame (struct frame *, bool);
1559 #ifndef HAVE_NS
1561 extern bool x_bitmap_icon (struct frame *, Lisp_Object);
1563 /* Set F's bitmap icon, if specified among F's parameters. */
1565 INLINE void
1566 x_set_bitmap_icon (struct frame *f)
1568 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1570 if (CONSP (obj) && !NILP (XCDR (obj)))
1571 x_bitmap_icon (f, XCDR (obj));
1574 #endif /* !HAVE_NS */
1575 #endif /* HAVE_WINDOW_SYSTEM */
1577 INLINE void
1578 flush_frame (struct frame *f)
1580 struct redisplay_interface *rif = FRAME_RIF (f);
1582 if (rif && rif->flush_display)
1583 rif->flush_display (f);
1586 /***********************************************************************
1587 Multimonitor data
1588 ***********************************************************************/
1590 #ifdef HAVE_WINDOW_SYSTEM
1592 struct MonitorInfo {
1593 XRectangle geom, work;
1594 int mm_width, mm_height;
1595 char *name;
1598 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1599 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1600 int n_monitors,
1601 int primary_monitor,
1602 Lisp_Object monitor_frames,
1603 const char *source);
1605 #endif /* HAVE_WINDOW_SYSTEM */
1608 INLINE_HEADER_END
1610 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1611 This is for functions like x_set_horizontal_scroll_bars that have
1612 no effect in this case. */
1613 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1614 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1615 #endif
1617 #endif /* not EMACS_FRAME_H */