Add seq-set-equal-p to test for set equality
[emacs.git] / src / frame.h
blob4aa7c34a29a636a1f2caf6fd1959456002533083
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,
55 #endif /* HAVE_WINDOW_SYSTEM */
57 /* The structure representing a frame. */
59 struct frame
61 struct vectorlike_header header;
63 /* All Lisp_Object components must come first.
64 That ensures they are all aligned normally. */
66 /* Name of this frame: a Lisp string. It is used for looking up resources,
67 as well as for the title in some cases. */
68 Lisp_Object name;
70 /* The name to use for the icon, the last time
71 it was refreshed. nil means not explicitly specified. */
72 Lisp_Object icon_name;
74 /* This is the frame title specified explicitly, if any.
75 Usually it is nil. */
76 Lisp_Object title;
78 #if defined (HAVE_WINDOW_SYSTEM)
79 /* This frame's parent frame, if it has one. */
80 Lisp_Object parent_frame;
81 #endif /* HAVE_WINDOW_SYSTEM */
83 /* The frame which should receive keystrokes that occur in this
84 frame, or nil if they should go to the frame itself. This is
85 usually nil, but if the frame is minibufferless, we can use this
86 to redirect keystrokes to a surrogate minibuffer frame when
87 needed.
89 Note that a value of nil is different than having the field point
90 to the frame itself. Whenever the Fselect_frame function is used
91 to shift from one frame to the other, any redirections to the
92 original frame are shifted to the newly selected frame; if
93 focus_frame is nil, Fselect_frame will leave it alone. */
94 Lisp_Object focus_frame;
96 /* This frame's root window. Every frame has one.
97 If the frame has only a minibuffer window, this is it.
98 Otherwise, if the frame has a minibuffer window, this is its sibling. */
99 Lisp_Object root_window;
101 /* This frame's selected window.
102 Each frame has its own window hierarchy
103 and one of the windows in it is selected within the frame.
104 The selected window of the selected frame is Emacs's selected window. */
105 Lisp_Object selected_window;
107 /* This frame's minibuffer window.
108 Most frames have their own minibuffer windows,
109 but only the selected frame's minibuffer window
110 can actually appear to exist. */
111 Lisp_Object minibuffer_window;
113 /* Parameter alist of this frame.
114 These are the parameters specified when creating the frame
115 or modified with modify-frame-parameters. */
116 Lisp_Object param_alist;
118 /* List of scroll bars on this frame.
119 Actually, we don't specify exactly what is stored here at all; the
120 scroll bar implementation code can use it to store anything it likes.
121 This field is marked by the garbage collector. It is here
122 instead of in the `device' structure so that the garbage
123 collector doesn't need to look inside the window-system-dependent
124 structure. */
125 Lisp_Object scroll_bars;
126 Lisp_Object condemned_scroll_bars;
128 /* Vector describing the items to display in the menu bar.
129 Each item has four elements in this vector.
130 They are KEY, STRING, SUBMAP, and HPOS.
131 (HPOS is not used in when the X toolkit is in use.)
132 There are four additional elements of nil at the end, to terminate. */
133 Lisp_Object menu_bar_items;
135 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
136 Lisp_Object face_alist;
138 /* A vector that records the entire structure of this frame's menu bar.
139 For the format of the data, see extensive comments in xmenu.c.
140 Only the X toolkit version uses this. */
141 Lisp_Object menu_bar_vector;
143 /* Predicate for selecting buffers for other-buffer. */
144 Lisp_Object buffer_predicate;
146 /* List of buffers viewed in this frame, for other-buffer. */
147 Lisp_Object buffer_list;
149 /* List of buffers that were viewed, then buried in this frame. The
150 most recently buried buffer is first. For last-buffer. */
151 Lisp_Object buried_buffer_list;
153 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
154 /* A dummy window used to display menu bars under X when no X
155 toolkit support is available. */
156 Lisp_Object menu_bar_window;
157 #endif
159 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
160 /* A window used to display the tool-bar of a frame. */
161 Lisp_Object tool_bar_window;
163 /* Desired and current contents displayed in that window. */
164 Lisp_Object desired_tool_bar_string;
165 Lisp_Object current_tool_bar_string;
166 #endif
168 /* Desired and current tool-bar items. */
169 Lisp_Object tool_bar_items;
171 #ifdef USE_GTK
172 /* Where tool bar is, can be left, right, top or bottom.
173 Except with GTK, the only supported position is `top'. */
174 Lisp_Object tool_bar_position;
175 #endif
177 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
178 /* List of data specific to font-driver and frame, but common to faces. */
179 Lisp_Object font_data;
180 #endif
182 /* Beyond here, there should be no more Lisp_Object components. */
184 /* Cache of realized faces. */
185 struct face_cache *face_cache;
187 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
188 /* Tool-bar item index of the item on which a mouse button was pressed. */
189 int last_tool_bar_item;
190 #endif
192 /* Number of elements in `menu_bar_vector' that have meaningful data. */
193 int menu_bar_items_used;
195 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
196 /* A buffer to hold the frame's name. Since this is used by the
197 window system toolkit, we can't use the Lisp string's pointer
198 (`name', above) because it might get relocated. */
199 char *namebuf;
200 #endif
202 #ifdef USE_X_TOOLKIT
203 /* Used to pass geometry parameters to toolkit functions. */
204 char *shell_position;
205 #endif
207 /* Glyph pool and matrix. */
208 struct glyph_pool *current_pool;
209 struct glyph_pool *desired_pool;
210 struct glyph_matrix *desired_matrix;
211 struct glyph_matrix *current_matrix;
213 /* Bitfield area begins here. Keep them together to avoid extra padding. */
215 /* True means that glyphs on this frame have been initialized so it can
216 be used for output. */
217 bool_bf glyphs_initialized_p : 1;
219 /* Set to true in change_frame_size when size of frame changed
220 Clear the frame in clear_garbaged_frames if set. */
221 bool_bf resized_p : 1;
223 /* Set to true if the default face for the frame has been
224 realized. Reset to zero whenever the default face changes.
225 Used to see the difference between a font change and face change. */
226 bool_bf default_face_done_p : 1;
228 /* Set to true if this frame has already been hscrolled during
229 current redisplay. */
230 bool_bf already_hscrolled_p : 1;
232 /* Set to true when current redisplay has updated frame. */
233 bool_bf updated_p : 1;
235 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
236 /* Set to true to minimize tool-bar height even when
237 auto-resize-tool-bar is set to grow-only. */
238 bool_bf minimize_tool_bar_window_p : 1;
239 #endif
241 #if defined (USE_GTK) || defined (HAVE_NS)
242 /* True means using a tool bar that comes from the toolkit. */
243 bool_bf external_tool_bar : 1;
244 #endif
246 /* True means that fonts have been loaded since the last glyph
247 matrix adjustments. */
248 bool_bf fonts_changed : 1;
250 /* True means that cursor type has been changed. */
251 bool_bf cursor_type_changed : 1;
253 /* True if it needs to be redisplayed. */
254 bool_bf redisplay : 1;
256 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
257 || defined (HAVE_NS) || defined (USE_GTK)
258 /* True means using a menu bar that comes from the X toolkit. */
259 bool_bf external_menu_bar : 1;
260 #endif
262 /* Next two bitfields are mutually exclusive. They might both be
263 zero if the frame has been made invisible without an icon. */
265 /* Nonzero if the frame is currently displayed; we check
266 it to see if we should bother updating the frame's contents.
268 On ttys and on Windows NT/9X, to avoid wasting effort updating
269 visible frames that are actually completely obscured by other
270 windows on the display, we bend the meaning of visible slightly:
271 if equal to 2, then the frame is obscured - we still consider
272 it to be "visible" as seen from lisp, but we don't bother
273 updating it. */
274 unsigned visible : 2;
276 /* True if the frame is currently iconified. Do not
277 set this directly, use SET_FRAME_ICONIFIED instead. */
278 bool_bf iconified : 1;
280 /* True if this frame should be fully redisplayed. Disables all
281 optimizations while rebuilding matrices and redrawing. */
282 bool_bf garbaged : 1;
284 /* False means, if this frame has just one window,
285 show no modeline for that window. */
286 bool_bf wants_modeline : 1;
288 /* True means raise this frame to the top of the heap when selected. */
289 bool_bf auto_raise : 1;
291 /* True means lower this frame to the bottom of the stack when left. */
292 bool_bf auto_lower : 1;
294 /* True if frame's root window can't be split. */
295 bool_bf no_split : 1;
297 /* If this is set, then Emacs won't change the frame name to indicate
298 the current buffer, etcetera. If the user explicitly sets the frame
299 name, this gets set. If the user sets the name to Qnil, this is
300 cleared. */
301 bool_bf explicit_name : 1;
303 /* True if configuration of windows on this frame has changed since
304 last call of run_window_size_change_functions. */
305 bool_bf window_configuration_changed : 1;
307 /* True if the mouse has moved on this display device
308 since the last time we checked. */
309 bool_bf mouse_moved : 1;
311 /* True means that the pointer is invisible. */
312 bool_bf pointer_invisible : 1;
314 /* True means that all windows except mini-window and
315 selected window on this frame have frozen window starts. */
316 bool_bf frozen_window_starts : 1;
318 /* The output method says how the contents of this frame are
319 displayed. It could be using termcap, or using an X window.
320 This must be the same as the terminal->type. */
321 ENUM_BF (output_method) output_method : 3;
323 #ifdef HAVE_WINDOW_SYSTEM
324 /* See FULLSCREEN_ enum on top. */
325 ENUM_BF (fullscreen_type) want_fullscreen : 4;
327 /* If not vertical_scroll_bar_none, we should actually
328 display the scroll bars of this type on this frame. */
329 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
331 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
332 bool_bf horizontal_scroll_bars : 1;
333 #endif /* HAVE_WINDOW_SYSTEM */
335 #if defined (HAVE_WINDOW_SYSTEM)
336 /* True if this is an undecorated frame. */
337 bool_bf undecorated : 1;
339 #ifndef HAVE_NTGUI
340 /* True if this is an override_redirect frame. */
341 bool_bf override_redirect : 1;
342 #endif
344 /* Nonzero if this frame's icon should not appear on its display's taskbar. */
345 bool_bf skip_taskbar : 1;
347 /* Nonzero if this frame's window F's X window does not want to
348 receive input focus when it is mapped. */
349 bool_bf no_focus_on_map : 1;
351 /* Nonzero if this frame's window does not want to receive input focus
352 via mouse clicks or by moving the mouse into it. */
353 bool_bf no_accept_focus : 1;
355 /* The z-group this frame's window belongs to. */
356 ENUM_BF (z_group) z_group : 2;
357 #endif /* HAVE_WINDOW_SYSTEM and not HAVE_NS */
359 /* Whether new_height and new_width shall be interpreted
360 in pixels. */
361 bool_bf new_pixelwise : 1;
363 /* True means x_set_window_size requests can be processed for this
364 frame. */
365 bool_bf can_x_set_window_size : 1;
367 /* Set to true after this frame was made by `make-frame'. */
368 bool_bf after_make_frame : 1;
370 /* Whether the tool bar height change should be taken into account. */
371 bool_bf tool_bar_redisplayed : 1;
372 bool_bf tool_bar_resized : 1;
374 /* Inhibit implied resize before after_make_frame is set. */
375 bool_bf inhibit_horizontal_resize : 1;
376 bool_bf inhibit_vertical_resize : 1;
378 /* Non-zero if this frame's faces need to be recomputed. */
379 bool_bf face_change : 1;
381 /* Bitfield area ends here. */
383 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
384 int tool_bar_lines;
386 /* Height of frame internal tool bar in pixels. */
387 int tool_bar_height;
389 int n_tool_bar_rows;
390 int n_tool_bar_items;
392 /* A buffer for decode_mode_line. */
393 char *decode_mode_spec_buffer;
395 /* See do_line_insertion_deletion_costs for info on these arrays. */
396 /* Cost of inserting 1 line on this frame. */
397 int *insert_line_cost;
398 /* Cost of deleting 1 line on this frame. */
399 int *delete_line_cost;
400 /* Cost of inserting n lines on this frame. */
401 int *insert_n_lines_cost;
402 /* Cost of deleting n lines on this frame. */
403 int *delete_n_lines_cost;
405 /* Text width of this frame (excluding fringes, vertical scroll bar
406 and internal border widths) and text height (excluding menu bar,
407 tool bar, horizontal scroll bar and internal border widths) in
408 units of canonical characters. */
409 int text_cols, text_lines;
411 /* Total width of this frame (including fringes, vertical scroll bar
412 and internal border widths) and total height (including menu bar,
413 tool bar, horizontal scroll bar and internal border widths) in
414 units of canonical characters. */
415 int total_cols, total_lines;
417 /* Text width of this frame (excluding fringes, vertical scroll bar
418 and internal border widths) and text height (excluding menu bar,
419 tool bar, horizontal scroll bar and internal border widths) in
420 pixels. */
421 int text_width, text_height;
423 /* New text height and width for pending size change. 0 if no change
424 pending. These values represent pixels or canonical character units
425 according to the value of new_pixelwise and correlate to the the
426 text width/height of the frame. */
427 int new_width, new_height;
429 /* Pixel position of the frame window (x and y offsets in root window). */
430 int left_pos, top_pos;
432 /* Total width of this frame (including fringes, vertical scroll bar
433 and internal border widths) and total height (including internal
434 menu and tool bars, horizontal scroll bar and internal border
435 widths) in pixels. */
436 int pixel_width, pixel_height;
438 /* This is the gravity value for the specified window position. */
439 int win_gravity;
441 /* The geometry flags for this window. */
442 int size_hint_flags;
444 /* Border width of the frame window as known by the (X) window system. */
445 int border_width;
447 /* Width of the internal border. This is a line of background color
448 just inside the window's border. When the frame is selected,
449 a highlighting is displayed inside the internal border. */
450 int internal_border_width;
452 /* Widths of dividers between this frame's windows in pixels. */
453 int right_divider_width, bottom_divider_width;
455 /* Widths of fringes in pixels. */
456 int left_fringe_width, right_fringe_width;
458 /* Total width of fringes reserved for drawing truncation bitmaps,
459 continuation bitmaps and alike - REMOVE THIS !!!!. */
460 int fringe_cols;
462 /* Number of lines of menu bar. */
463 int menu_bar_lines;
465 /* Pixel height of menubar. */
466 int menu_bar_height;
468 /* Canonical X unit. Width of default font, in pixels. */
469 int column_width;
471 /* Canonical Y unit. Height of a line, in pixels. */
472 int line_height;
474 /* The terminal device that this frame uses. If this is NULL, then
475 the frame has been deleted. */
476 struct terminal *terminal;
478 /* Device-dependent, frame-local auxiliary data used for displaying
479 the contents. When the frame is deleted, this data is deleted as
480 well. */
481 union output_data
483 struct tty_output *tty; /* From termchar.h. */
484 struct x_output *x; /* From xterm.h. */
485 struct w32_output *w32; /* From w32term.h. */
486 struct ns_output *ns; /* From nsterm.h. */
487 intptr_t nothing;
489 output_data;
491 /* List of font-drivers available on the frame. */
492 struct font_driver_list *font_driver_list;
494 #if defined (HAVE_X_WINDOWS)
495 /* Used by x_wait_for_event when watching for an X event on this frame. */
496 int wait_event_type;
497 #endif
499 /* What kind of text cursor should we draw in the future?
500 This should always be filled_box_cursor or bar_cursor. */
501 enum text_cursor_kinds desired_cursor;
503 /* Width of bar cursor (if we are using that). */
504 int cursor_width;
506 /* What kind of text cursor should we draw when the cursor blinks off?
507 This can be filled_box_cursor or bar_cursor or no_cursor. */
508 enum text_cursor_kinds blink_off_cursor;
510 /* Width of bar cursor (if we are using that) for blink-off state. */
511 int blink_off_cursor_width;
513 /* Configured width of the scroll bar, in pixels and in characters.
514 config_scroll_bar_cols tracks config_scroll_bar_width if the
515 latter is positive; a zero value in config_scroll_bar_width means
516 to compute the actual width on the fly, using config_scroll_bar_cols
517 and the current font width. */
518 int config_scroll_bar_width;
519 int config_scroll_bar_cols;
521 /* Configured height of the scroll bar, in pixels and in characters.
522 config_scroll_bar_lines tracks config_scroll_bar_height if the
523 latter is positive; a zero value in config_scroll_bar_height means
524 to compute the actual width on the fly, using
525 config_scroll_bar_lines and the current font width. */
526 int config_scroll_bar_height;
527 int config_scroll_bar_lines;
529 /* The baud rate that was used to calculate costs for this frame. */
530 int cost_calculation_baud_rate;
532 /* Frame opacity
533 alpha[0]: alpha transparency of the active frame
534 alpha[1]: alpha transparency of inactive frames
535 Negative values mean not to change alpha. */
536 double alpha[2];
538 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
539 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
540 frame parameter. 0 means don't do gamma correction. */
541 double gamma;
543 /* Additional space to put between text lines on this frame. */
544 int extra_line_spacing;
546 /* All display backends seem to need these two pixel values. */
547 unsigned long background_pixel;
548 unsigned long foreground_pixel;
551 /* Most code should use these functions to set Lisp fields in struct frame. */
553 INLINE void
554 fset_buffer_list (struct frame *f, Lisp_Object val)
556 f->buffer_list = val;
558 INLINE void
559 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
561 f->buried_buffer_list = val;
563 INLINE void
564 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
566 f->condemned_scroll_bars = val;
568 INLINE void
569 fset_face_alist (struct frame *f, Lisp_Object val)
571 f->face_alist = val;
573 #if defined (HAVE_WINDOW_SYSTEM)
574 INLINE void
575 fset_parent_frame (struct frame *f, Lisp_Object val)
577 f->parent_frame = val;
579 #endif
580 INLINE void
581 fset_focus_frame (struct frame *f, Lisp_Object val)
583 f->focus_frame = val;
585 INLINE void
586 fset_icon_name (struct frame *f, Lisp_Object val)
588 f->icon_name = val;
590 INLINE void
591 fset_menu_bar_items (struct frame *f, Lisp_Object val)
593 f->menu_bar_items = val;
595 INLINE void
596 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
598 f->menu_bar_vector = val;
600 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
601 INLINE void
602 fset_menu_bar_window (struct frame *f, Lisp_Object val)
604 f->menu_bar_window = val;
606 #endif
607 INLINE void
608 fset_name (struct frame *f, Lisp_Object val)
610 f->name = val;
612 INLINE void
613 fset_param_alist (struct frame *f, Lisp_Object val)
615 f->param_alist = val;
617 INLINE void
618 fset_root_window (struct frame *f, Lisp_Object val)
620 f->root_window = val;
622 INLINE void
623 fset_scroll_bars (struct frame *f, Lisp_Object val)
625 f->scroll_bars = val;
627 INLINE void
628 fset_selected_window (struct frame *f, Lisp_Object val)
630 f->selected_window = val;
632 INLINE void
633 fset_title (struct frame *f, Lisp_Object val)
635 f->title = val;
637 INLINE void
638 fset_tool_bar_items (struct frame *f, Lisp_Object val)
640 f->tool_bar_items = val;
642 #ifdef USE_GTK
643 INLINE void
644 fset_tool_bar_position (struct frame *f, Lisp_Object val)
646 f->tool_bar_position = val;
648 #endif /* USE_GTK */
649 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
650 INLINE void
651 fset_tool_bar_window (struct frame *f, Lisp_Object val)
653 f->tool_bar_window = val;
655 INLINE void
656 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
658 f->current_tool_bar_string = val;
660 INLINE void
661 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
663 f->desired_tool_bar_string = val;
665 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
667 INLINE double
668 NUMVAL (Lisp_Object x)
670 return NUMBERP (x) ? XFLOATINT (x) : -1;
673 INLINE double
674 default_pixels_per_inch_x (void)
676 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
677 ? XCAR (Vdisplay_pixels_per_inch)
678 : Vdisplay_pixels_per_inch);
679 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
682 INLINE double
683 default_pixels_per_inch_y (void)
685 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
686 ? XCDR (Vdisplay_pixels_per_inch)
687 : Vdisplay_pixels_per_inch);
688 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
691 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
693 /* Return a pointer to the image cache of frame F. */
694 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
696 #define XFRAME(p) \
697 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
698 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
700 /* Given a window, return its frame as a Lisp_Object. */
701 #define WINDOW_FRAME(w) ((w)->frame)
703 /* Test a frame for particular kinds of display methods. */
704 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
705 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
706 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
707 #ifndef HAVE_NTGUI
708 #define FRAME_W32_P(f) false
709 #else
710 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
711 #endif
712 #ifndef MSDOS
713 #define FRAME_MSDOS_P(f) false
714 #else
715 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
716 #endif
717 #ifndef HAVE_NS
718 #define FRAME_NS_P(f) false
719 #else
720 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
721 #endif
723 /* FRAME_WINDOW_P tests whether the frame is a window, and is
724 defined to be the predicate for the window system being used. */
726 #ifdef HAVE_X_WINDOWS
727 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
728 #endif
729 #ifdef HAVE_NTGUI
730 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
731 #endif
732 #ifdef HAVE_NS
733 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
734 #endif
735 #ifndef FRAME_WINDOW_P
736 #define FRAME_WINDOW_P(f) ((void) (f), false)
737 #endif
739 /* Dots per inch of the screen the frame F is on. */
741 #ifdef HAVE_WINDOW_SYSTEM
743 #define FRAME_RES_X(f) \
744 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
745 #define FRAME_RES_Y(f) \
746 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
748 #else /* !HAVE_WINDOW_SYSTEM */
750 /* Defaults when no window system available. */
752 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
753 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
755 #endif /* HAVE_WINDOW_SYSTEM */
757 /* Return a pointer to the structure holding information about the
758 region of text, if any, that is currently shown in mouse-face on
759 frame F. We need to define two versions because a TTY-only build
760 does not have FRAME_DISPLAY_INFO. */
761 #ifdef HAVE_WINDOW_SYSTEM
762 # define MOUSE_HL_INFO(F) \
763 (FRAME_WINDOW_P(F) \
764 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
765 : &(F)->output_data.tty->display_info->mouse_highlight)
766 #else
767 # define MOUSE_HL_INFO(F) \
768 (&(F)->output_data.tty->display_info->mouse_highlight)
769 #endif
771 /* True if frame F is still alive (not deleted). */
772 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
774 /* True if frame F is a minibuffer-only frame. */
775 #define FRAME_MINIBUF_ONLY_P(f) \
776 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
778 /* True if frame F contains it's own minibuffer window. Frame always has
779 minibuffer window, but it could use minibuffer window of another frame. */
780 #define FRAME_HAS_MINIBUF_P(f) \
781 (WINDOWP (f->minibuffer_window) \
782 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
784 /* Pixel width of frame F. */
785 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
787 /* Pixel height of frame F. */
788 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
790 /* Width of frame F, measured in canonical character columns,
791 not including scroll bars if any. */
792 #define FRAME_COLS(f) (f)->text_cols
794 /* Height of frame F, measured in canonical lines, including
795 non-toolkit menu bar and non-toolkit tool bar lines. */
796 #define FRAME_LINES(f) (f)->text_lines
798 /* Width of frame F, measured in pixels not including the width for
799 fringes, scroll bar, and internal borders. */
800 #define FRAME_TEXT_WIDTH(f) (f)->text_width
802 /* Height of frame F, measured in pixels not including the height
803 for scroll bar and internal borders. */
804 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
806 /* Number of lines of frame F used for menu bar.
807 This is relevant on terminal frames and on
808 X Windows when not using the X toolkit.
809 These lines are counted in FRAME_LINES. */
810 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
812 /* Pixel height of frame F's menu bar. */
813 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
815 /* True if this frame should display a tool bar
816 in a way that does not use any text lines. */
817 #if defined (USE_GTK) || defined (HAVE_NS)
818 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
819 #else
820 #define FRAME_EXTERNAL_TOOL_BAR(f) false
821 #endif
823 /* This is really supported only with GTK. */
824 #ifdef USE_GTK
825 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
826 #else
827 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
828 #endif
830 /* Number of lines of frame F used for the tool-bar. */
831 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
833 /* Pixel height of frame F's tool-bar. */
834 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
836 /* Lines above the top-most window in frame F. */
837 #define FRAME_TOP_MARGIN(F) \
838 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
840 /* Pixel height of frame F's top margin. */
841 #define FRAME_TOP_MARGIN_HEIGHT(F) \
842 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
844 /* True if this frame should display a menu bar
845 in a way that does not use any text lines. */
846 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
847 || defined (HAVE_NS) || defined (USE_GTK)
848 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
849 #else
850 #define FRAME_EXTERNAL_MENU_BAR(f) false
851 #endif
853 /* True if frame F is currently visible. */
854 #define FRAME_VISIBLE_P(f) (f)->visible
856 /* True if frame F is currently visible but hidden. */
857 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
859 /* True if frame F is currently iconified. */
860 #define FRAME_ICONIFIED_P(f) (f)->iconified
862 /* Mark frame F as currently garbaged. */
863 #define SET_FRAME_GARBAGED(f) \
864 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
866 /* True if frame F is currently garbaged. */
867 #define FRAME_GARBAGED_P(f) (f)->garbaged
869 /* True means do not allow splitting this frame's window. */
870 #define FRAME_NO_SPLIT_P(f) (f)->no_split
872 /* Not really implemented. */
873 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
875 /* True if all windows except selected window and mini window
876 are frozen on frame F. */
877 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
879 /* True if the frame's window configuration has changed since last call
880 of run_window_size_change_functions. */
881 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
882 (f)->window_configuration_changed
884 /* The minibuffer window of frame F, if it has one; otherwise nil. */
885 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
887 /* The root window of the window tree of frame F. */
888 #define FRAME_ROOT_WINDOW(f) f->root_window
890 /* The currently selected window of the window tree of frame F. */
891 #define FRAME_SELECTED_WINDOW(f) f->selected_window
893 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
894 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
895 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
896 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
897 #define FRAME_FOCUS_FRAME(f) f->focus_frame
899 #ifdef HAVE_WINDOW_SYSTEM
900 /* This frame slot says whether scroll bars are currently enabled for frame F,
901 and which side they are on. */
902 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
903 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
904 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
905 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
906 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
907 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
908 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
909 #else /* not HAVE_WINDOW_SYSTEM */
910 /* If there is no window system, there are no scroll bars. */
911 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
912 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
913 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
914 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
915 #endif /* HAVE_WINDOW_SYSTEM */
917 #if defined (HAVE_WINDOW_SYSTEM)
918 #define FRAME_UNDECORATED(f) ((f)->undecorated)
919 #ifdef HAVE_NTGUI
920 #define FRAME_OVERRIDE_REDIRECT(f) ((void) f, 0)
921 #else
922 #define FRAME_OVERRIDE_REDIRECT(f) ((f)->override_redirect)
923 #endif
924 #define FRAME_PARENT_FRAME(f) \
925 (NILP ((f)->parent_frame) \
926 ? NULL \
927 : XFRAME ((f)->parent_frame))
928 #define FRAME_SKIP_TASKBAR(f) ((f)->skip_taskbar)
929 #define FRAME_NO_FOCUS_ON_MAP(f) ((f)->no_focus_on_map)
930 #define FRAME_NO_ACCEPT_FOCUS(f) ((f)->no_accept_focus)
931 #define FRAME_Z_GROUP(f) ((f)->z_group)
932 #define FRAME_Z_GROUP_NONE(f) ((f)->z_group == z_group_none)
933 #define FRAME_Z_GROUP_ABOVE(f) ((f)->z_group == z_group_above)
934 #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \
935 ((f)->z_group == z_group_above_suspended)
936 #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below)
937 #else /* not HAVE_WINDOW_SYSTEM */
938 #define FRAME_UNDECORATED(f) ((void) f, 0)
939 #define FRAME_OVERRIDE_REDIRECT(f) ((void) f, 0)
940 #define FRAME_PARENT_FRAME(f) ((void) f, NULL)
941 #define FRAME_SKIP_TASKBAR(f) ((void) f, 0)
942 #define FRAME_NO_FOCUS_ON_MAP(f) ((void) f, 0)
943 #define FRAME_NO_ACCEPT_FOCUS(f) ((void) f, 0)
944 #define FRAME_Z_GROUP(f) ((void) f, z_group_none)
945 #define FRAME_Z_GROUP_NONE(f) ((void) f, true)
946 #define FRAME_Z_GROUP_ABOVE(f) ((void) f, false)
947 #define FRAME_Z_GROUP_BELOW(f) ((void) f, false)
948 #endif /* HAVE_WINDOW_SYSTEM */
950 /* Whether horizontal scroll bars are currently enabled for frame F. */
951 #if USE_HORIZONTAL_SCROLL_BARS
952 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
953 ((f)->horizontal_scroll_bars)
954 #else
955 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
956 #endif
958 /* Width that a scroll bar in frame F should have, if there is one.
959 Measured in pixels.
960 If scroll bars are turned off, this is still nonzero. */
961 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
963 /* Height that a scroll bar in frame F should have, if there is one.
964 Measured in pixels.
965 If scroll bars are turned off, this is still nonzero. */
966 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
968 /* Width that a scroll bar in frame F should have, if there is one.
969 Measured in columns (characters).
970 If scroll bars are turned off, this is still nonzero. */
971 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
973 /* Height that a scroll bar in frame F should have, if there is one.
974 Measured in lines (characters).
975 If scroll bars are turned off, this is still nonzero. */
976 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
978 /* Width of a left scroll bar in frame F, measured in pixels */
979 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
980 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
981 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
982 : 0)
984 /* Width of a right scroll bar area in frame F, measured in pixels */
985 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
986 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
987 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
988 : 0)
990 /* Width of a left scroll bar in frame F, measured in columns
991 (characters), but only if scroll bars are on the left. If scroll
992 bars are on the right in this frame, or there are no scroll bars,
993 value is 0. */
994 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
995 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
996 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
997 : 0)
999 /* Width of a right scroll bar in frame F, measured in columns
1000 (characters), but only if scroll bars are on the right. If scroll
1001 bars are on the left in this frame, or there are no scroll bars,
1002 value is 0. */
1003 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
1004 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1005 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1006 : 0)
1008 /* Width of a vertical scroll bar area in frame F, measured in
1009 pixels. */
1010 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
1011 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1012 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1013 : 0)
1015 /* Height of horizontal scroll bar area in frame F, measured in
1016 pixels. */
1017 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
1018 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1019 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1020 : 0)
1022 /* Width of vertical scroll bar in frame F, measured in columns. */
1023 #define FRAME_SCROLL_BAR_COLS(f) \
1024 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1025 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1026 : 0)
1028 /* Height of horizontal scroll bar in frame F, measured in lines. */
1029 #define FRAME_SCROLL_BAR_LINES(f) \
1030 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1031 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
1032 : 0)
1034 /* Total width of frame F, in columns (characters),
1035 including the width used by scroll bars if any. */
1036 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
1038 /* Total height of frame F, in lines (characters),
1039 including the height used by scroll bars if any. */
1040 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
1042 /* Set the character widths of frame F. WIDTH specifies a nominal
1043 character text width. */
1044 #define SET_FRAME_COLS(f, width) \
1045 ((f)->text_cols = (width), \
1046 (f)->total_cols = ((width) \
1047 + FRAME_SCROLL_BAR_COLS (f) \
1048 + FRAME_FRINGE_COLS (f)))
1050 /* Set the character heights of frame F. HEIGHT specifies a nominal
1051 character text height. */
1052 #define SET_FRAME_LINES(f, height) \
1053 ((f)->text_lines = (height), \
1054 (f)->total_lines = ((height) \
1055 + FRAME_TOP_MARGIN (f) \
1056 + FRAME_SCROLL_BAR_LINES (f)))
1058 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
1059 width. */
1060 #define SET_FRAME_WIDTH(f, width) \
1061 ((f)->text_width = (width), \
1062 (f)->pixel_width = ((width) \
1063 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1064 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1065 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1067 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
1068 height. */
1069 #define SET_FRAME_HEIGHT(f, height) \
1070 ((f)->text_height = (height), \
1071 (f)->pixel_height = ((height) \
1072 + FRAME_TOP_MARGIN_HEIGHT (f) \
1073 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1074 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1076 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1077 #define FRAME_CURSOR_X_LIMIT(f) \
1078 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1080 /* Nonzero if frame F has scroll bars. */
1081 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1082 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1084 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1085 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1087 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1088 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1089 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1090 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1092 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1093 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1095 /* Return a pointer to the face cache of frame F. */
1097 #define FRAME_FACE_CACHE(F) (F)->face_cache
1099 /* Return the size of message_buf of the frame F. We multiply the
1100 width of the frame by 4 because multi-byte form may require at most
1101 4-byte for a character. */
1103 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1105 #define CHECK_FRAME(x) \
1106 CHECK_TYPE (FRAMEP (x), Qframep, x)
1108 #define CHECK_LIVE_FRAME(x) \
1109 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1111 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1112 `for' loop which iterates over the elements of Vframe_list. The
1113 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1114 Vframe_list in succession and execute the statement. Vframe_list
1115 should be nonempty, so the body is executed at least once. LIST_VAR
1116 should be a Lisp_Object too; it is used to iterate through the
1117 Vframe_list. Note that this macro walks over child frames and
1118 the tooltip frame as well.
1120 This macro is a holdover from a time when multiple frames weren't always
1121 supported. An alternate definition of the macro would expand to
1122 something which executes the statement once. */
1124 #define FOR_EACH_FRAME(list_var, frame_var) \
1125 for ((list_var) = (eassume (CONSP (Vframe_list)), Vframe_list); \
1126 (CONSP (list_var) \
1127 && (frame_var = XCAR (list_var), true)); \
1128 list_var = XCDR (list_var))
1130 /* Reflect mouse movement when a complete frame update is performed. */
1132 #define FRAME_MOUSE_UPDATE(frame) \
1133 do { \
1134 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1135 if (frame == hlinfo->mouse_face_mouse_frame) \
1137 block_input (); \
1138 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1139 hlinfo->mouse_face_mouse_x, \
1140 hlinfo->mouse_face_mouse_y); \
1141 unblock_input (); \
1143 } while (false)
1145 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1147 #define AUTO_FRAME_ARG(name, parameter, value) \
1148 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1150 /* False means there are no visible garbaged frames. */
1151 extern bool frame_garbaged;
1153 /* Set visibility of frame F.
1154 We call redisplay_other_windows to make sure the frame gets redisplayed
1155 if some changes were applied to it while it wasn't visible (and hence
1156 wasn't redisplayed). */
1158 INLINE void
1159 SET_FRAME_VISIBLE (struct frame *f, int v)
1161 eassert (0 <= v && v <= 2);
1162 if (v)
1164 if (v == 1 && f->visible != 1)
1165 redisplay_other_windows ();
1166 if (FRAME_GARBAGED_P (f))
1167 frame_garbaged = true;
1169 f->visible = v;
1172 /* Set iconify of frame F. */
1174 #define SET_FRAME_ICONIFIED(f, i) \
1175 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1177 extern Lisp_Object selected_frame;
1179 #if ! (defined USE_GTK || defined HAVE_NS)
1180 extern int frame_default_tool_bar_height;
1181 #endif
1183 #ifdef HAVE_WINDOW_SYSTEM
1184 # define WINDOW_SYSTEM_RETURN
1185 #else
1186 # define WINDOW_SYSTEM_RETURN _Noreturn
1187 #endif
1189 extern WINDOW_SYSTEM_RETURN struct frame *
1190 decode_window_system_frame (Lisp_Object);
1191 extern struct frame *decode_live_frame (Lisp_Object);
1192 extern struct frame *decode_any_frame (Lisp_Object);
1193 extern struct frame *make_initial_frame (void);
1194 extern struct frame *make_frame (bool);
1195 #ifdef HAVE_WINDOW_SYSTEM
1196 extern struct frame *make_minibuffer_frame (void);
1197 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1198 struct kboard *,
1199 Lisp_Object);
1200 extern bool display_available (void);
1201 #endif
1203 INLINE bool
1204 window_system_available (struct frame *f)
1206 #ifdef HAVE_WINDOW_SYSTEM
1207 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
1208 #else
1209 return false;
1210 #endif
1213 extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
1214 extern void frame_make_pointer_invisible (struct frame *);
1215 extern void frame_make_pointer_visible (struct frame *);
1216 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1217 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
1218 extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
1219 extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
1220 int width, int height, Lisp_Object rest);
1222 extern Lisp_Object Vframe_list;
1224 /* Value is a pointer to the selected frame. If the selected frame
1225 isn't live, abort. */
1227 #define SELECTED_FRAME() \
1228 ((FRAMEP (selected_frame) \
1229 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1230 ? XFRAME (selected_frame) \
1231 : (emacs_abort (), (struct frame *) 0))
1234 /***********************************************************************
1235 Display-related Macros
1236 ***********************************************************************/
1238 /* Canonical y-unit on frame F.
1239 This value currently equals the line height of the frame (which is
1240 the height of the default font of F). */
1241 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1243 /* Canonical x-unit on frame F.
1244 This value currently equals the average width of the default font of F. */
1245 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1247 /* Get a frame's window system dimension. If no window system, this is 0. */
1249 INLINE int
1250 frame_dimension (int x)
1252 #ifdef HAVE_WINDOW_SYSTEM
1253 return x;
1254 #else
1255 return 0;
1256 #endif
1259 /* Total width of fringes reserved for drawing truncation bitmaps,
1260 continuation bitmaps and alike. The width is in canonical char
1261 units of the frame. This must currently be the case because window
1262 sizes aren't pixel values. If it weren't the case, we wouldn't be
1263 able to split windows horizontally nicely. */
1264 INLINE int
1265 FRAME_FRINGE_COLS (struct frame *f)
1267 return frame_dimension (f->fringe_cols);
1270 /* Pixel-width of the left and right fringe. */
1272 INLINE int
1273 FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
1275 return frame_dimension (f->left_fringe_width);
1277 INLINE int
1278 FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
1280 return frame_dimension (f->right_fringe_width);
1283 /* Total width of fringes in pixels. */
1285 INLINE int
1286 FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
1288 return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
1291 /* Pixel-width of internal border lines */
1292 INLINE int
1293 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
1295 return frame_dimension (f->internal_border_width);
1298 /* Pixel-size of window divider lines */
1299 INLINE int
1300 FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
1302 return frame_dimension (f->right_divider_width);
1304 INLINE int
1305 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
1307 return frame_dimension (f->bottom_divider_width);
1310 /***********************************************************************
1311 Conversion between canonical units and pixels
1312 ***********************************************************************/
1314 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1315 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1316 represented as Lisp numbers, i.e. integers or floats. */
1318 /* Convert canonical value X to pixels. F is the frame whose
1319 canonical char width is to be used. X must be a Lisp integer or
1320 float. Value is a C integer. */
1321 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1322 (INTEGERP (X) \
1323 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1324 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1326 /* Convert canonical value Y to pixels. F is the frame whose
1327 canonical character height is to be used. X must be a Lisp integer
1328 or float. Value is a C integer. */
1329 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1330 (INTEGERP (Y) \
1331 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1332 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1334 /* Convert pixel-value X to canonical units. F is the frame whose
1335 canonical character width is to be used. X is a C integer. Result
1336 is a Lisp float if X is not a multiple of the canon width,
1337 otherwise it's a Lisp integer. */
1338 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1339 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1340 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1341 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1343 /* Convert pixel-value Y to canonical units. F is the frame whose
1344 canonical character height is to be used. Y is a C integer.
1345 Result is a Lisp float if Y is not a multiple of the canon width,
1346 otherwise it's a Lisp integer. */
1347 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1348 ((Y) % FRAME_LINE_HEIGHT (F) \
1349 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1350 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1354 /* Manipulating pixel sizes and character sizes.
1355 Knowledge of which factors affect the overall size of the window should
1356 be hidden in these macros, if that's possible.
1358 Return the upper/left pixel position of the character cell on frame F
1359 at ROW/COL. */
1360 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1361 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1362 + (row) * FRAME_LINE_HEIGHT (f))
1364 #define FRAME_COL_TO_PIXEL_X(f, col) \
1365 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1366 + (col) * FRAME_COLUMN_WIDTH (f))
1368 /* Return the pixel width/height of frame F if it has
1369 COLS columns/LINES rows. */
1370 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1371 ((cols) * FRAME_COLUMN_WIDTH (f) \
1372 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1373 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1374 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1376 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1377 ((lines) * FRAME_LINE_HEIGHT (f) \
1378 + FRAME_TOP_MARGIN_HEIGHT (f) \
1379 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1380 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1382 /* Return the row/column (zero-based) of the character cell containing
1383 the pixel on FRAME at Y/X. */
1384 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1385 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1386 ? (y) \
1387 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1388 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1389 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1390 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1391 /* Arrange for the division to round down. */ \
1392 + FRAME_LINE_HEIGHT (f) - 1) \
1393 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1394 / FRAME_LINE_HEIGHT (f))
1396 #define FRAME_PIXEL_X_TO_COL(f, x) \
1397 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1398 / FRAME_COLUMN_WIDTH (f))
1400 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1401 frame F (so we round down)? */
1402 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1403 (((width) \
1404 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1405 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1406 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1407 / FRAME_COLUMN_WIDTH (f)) \
1409 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1410 (((height) \
1411 - FRAME_TOP_MARGIN_HEIGHT (f) \
1412 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1413 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1414 / FRAME_LINE_HEIGHT (f))
1416 /* Return the pixel width/height of frame F with a text size of
1417 width/height. */
1418 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1419 ((width) \
1420 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1421 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1422 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1424 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1425 ((height) \
1426 + FRAME_TOP_MARGIN_HEIGHT (f) \
1427 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1428 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1430 /* Return the text width/height of frame F with a pixel size of
1431 width/height. */
1432 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1433 ((width) \
1434 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1435 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1436 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1438 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1439 ((height) \
1440 - FRAME_TOP_MARGIN_HEIGHT (f) \
1441 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1442 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1444 /* Return the width/height reserved for the windows of frame F. */
1445 #define FRAME_WINDOWS_WIDTH(f) \
1446 (FRAME_PIXEL_WIDTH (f) \
1447 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1449 #define FRAME_WINDOWS_HEIGHT(f) \
1450 (FRAME_PIXEL_HEIGHT (f) \
1451 - FRAME_TOP_MARGIN_HEIGHT (f) \
1452 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1454 /* Value is the smallest width of any character in any font on frame F. */
1455 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1456 FRAME_DISPLAY_INFO (f)->smallest_char_width
1458 /* Value is the smallest height of any font on frame F. */
1459 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1460 FRAME_DISPLAY_INFO (f)->smallest_font_height
1462 /***********************************************************************
1463 Frame Parameters
1464 ***********************************************************************/
1466 #ifdef HAVE_WINDOW_SYSTEM
1468 /* The class of this X application. */
1469 #define EMACS_CLASS "Emacs"
1471 extern void x_set_scroll_bar_default_width (struct frame *);
1472 extern void x_set_scroll_bar_default_height (struct frame *);
1473 extern void x_set_offset (struct frame *, int, int, int);
1474 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1475 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1476 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1477 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1478 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1479 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1480 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1481 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1482 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1483 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1484 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1485 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1486 Lisp_Object);
1487 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1488 Lisp_Object);
1489 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1490 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1491 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1492 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1493 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1494 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1495 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1496 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1498 extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, int *);
1500 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1502 extern void validate_x_resource_name (void);
1504 extern Lisp_Object display_x_get_resource (Display_Info *,
1505 Lisp_Object attribute,
1506 Lisp_Object class,
1507 Lisp_Object component,
1508 Lisp_Object subclass);
1510 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1511 extern void x_set_window_size (struct frame *f, bool change_gravity,
1512 int width, int height, bool pixelwise);
1513 extern Lisp_Object x_get_focus_frame (struct frame *);
1514 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1515 extern void x_make_frame_visible (struct frame *f);
1516 extern void x_make_frame_invisible (struct frame *f);
1517 extern void x_iconify_frame (struct frame *f);
1518 extern void x_set_frame_alpha (struct frame *f);
1519 extern void x_activate_menubar (struct frame *);
1520 extern void x_real_positions (struct frame *, int *, int *);
1521 extern void free_frame_menubar (struct frame *);
1522 extern void x_free_frame_resources (struct frame *);
1523 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
1525 #if defined HAVE_X_WINDOWS
1526 extern void x_wm_set_icon_position (struct frame *, int, int);
1527 #if !defined USE_X_TOOLKIT
1528 extern char *x_get_resource_string (const char *, const char *);
1529 #endif
1530 extern void x_sync (struct frame *);
1531 #endif /* HAVE_X_WINDOWS */
1533 extern void x_query_colors (struct frame *f, XColor *, int);
1534 extern void x_focus_frame (struct frame *, bool);
1536 #ifndef HAVE_NS
1538 extern bool x_bitmap_icon (struct frame *, Lisp_Object);
1540 /* Set F's bitmap icon, if specified among F's parameters. */
1542 INLINE void
1543 x_set_bitmap_icon (struct frame *f)
1545 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1547 if (CONSP (obj) && !NILP (XCDR (obj)))
1548 x_bitmap_icon (f, XCDR (obj));
1551 #endif /* !HAVE_NS */
1552 #endif /* HAVE_WINDOW_SYSTEM */
1554 INLINE void
1555 flush_frame (struct frame *f)
1557 struct redisplay_interface *rif = FRAME_RIF (f);
1559 if (rif && rif->flush_display)
1560 rif->flush_display (f);
1563 /***********************************************************************
1564 Multimonitor data
1565 ***********************************************************************/
1567 #ifdef HAVE_WINDOW_SYSTEM
1569 struct MonitorInfo {
1570 XRectangle geom, work;
1571 int mm_width, mm_height;
1572 char *name;
1575 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1576 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1577 int n_monitors,
1578 int primary_monitor,
1579 Lisp_Object monitor_frames,
1580 const char *source);
1582 #endif /* HAVE_WINDOW_SYSTEM */
1585 INLINE_HEADER_END
1587 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1588 This is for functions like x_set_horizontal_scroll_bars that have
1589 no effect in this case. */
1590 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1591 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1592 #endif
1594 #endif /* not EMACS_FRAME_H */