; Fix a typo in comment
[emacs.git] / src / frame.h
blob5323c9a5f0b163907a94e70cd9ddd6c349e46986
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 #endif /* HAVE_WINDOW_SYSTEM */
50 /* The structure representing a frame. */
52 struct frame
54 struct vectorlike_header header;
56 /* All Lisp_Object components must come first.
57 That ensures they are all aligned normally. */
59 /* Name of this frame: a Lisp string. It is used for looking up resources,
60 as well as for the title in some cases. */
61 Lisp_Object name;
63 /* The name to use for the icon, the last time
64 it was refreshed. nil means not explicitly specified. */
65 Lisp_Object icon_name;
67 /* This is the frame title specified explicitly, if any.
68 Usually it is nil. */
69 Lisp_Object title;
71 /* The frame which should receive keystrokes that occur in this
72 frame, or nil if they should go to the frame itself. This is
73 usually nil, but if the frame is minibufferless, we can use this
74 to redirect keystrokes to a surrogate minibuffer frame when
75 needed.
77 Note that a value of nil is different than having the field point
78 to the frame itself. Whenever the Fselect_frame function is used
79 to shift from one frame to the other, any redirections to the
80 original frame are shifted to the newly selected frame; if
81 focus_frame is nil, Fselect_frame will leave it alone. */
82 Lisp_Object focus_frame;
84 /* This frame's root window. Every frame has one.
85 If the frame has only a minibuffer window, this is it.
86 Otherwise, if the frame has a minibuffer window, this is its sibling. */
87 Lisp_Object root_window;
89 /* This frame's selected window.
90 Each frame has its own window hierarchy
91 and one of the windows in it is selected within the frame.
92 The selected window of the selected frame is Emacs's selected window. */
93 Lisp_Object selected_window;
95 /* This frame's minibuffer window.
96 Most frames have their own minibuffer windows,
97 but only the selected frame's minibuffer window
98 can actually appear to exist. */
99 Lisp_Object minibuffer_window;
101 /* Parameter alist of this frame.
102 These are the parameters specified when creating the frame
103 or modified with modify-frame-parameters. */
104 Lisp_Object param_alist;
106 /* List of scroll bars on this frame.
107 Actually, we don't specify exactly what is stored here at all; the
108 scroll bar implementation code can use it to store anything it likes.
109 This field is marked by the garbage collector. It is here
110 instead of in the `device' structure so that the garbage
111 collector doesn't need to look inside the window-system-dependent
112 structure. */
113 Lisp_Object scroll_bars;
114 Lisp_Object condemned_scroll_bars;
116 /* Vector describing the items to display in the menu bar.
117 Each item has four elements in this vector.
118 They are KEY, STRING, SUBMAP, and HPOS.
119 (HPOS is not used in when the X toolkit is in use.)
120 There are four additional elements of nil at the end, to terminate. */
121 Lisp_Object menu_bar_items;
123 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
124 Lisp_Object face_alist;
126 /* A vector that records the entire structure of this frame's menu bar.
127 For the format of the data, see extensive comments in xmenu.c.
128 Only the X toolkit version uses this. */
129 Lisp_Object menu_bar_vector;
131 /* Predicate for selecting buffers for other-buffer. */
132 Lisp_Object buffer_predicate;
134 /* List of buffers viewed in this frame, for other-buffer. */
135 Lisp_Object buffer_list;
137 /* List of buffers that were viewed, then buried in this frame. The
138 most recently buried buffer is first. For last-buffer. */
139 Lisp_Object buried_buffer_list;
141 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
142 /* A dummy window used to display menu bars under X when no X
143 toolkit support is available. */
144 Lisp_Object menu_bar_window;
145 #endif
147 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
148 /* A window used to display the tool-bar of a frame. */
149 Lisp_Object tool_bar_window;
151 /* Desired and current contents displayed in that window. */
152 Lisp_Object desired_tool_bar_string;
153 Lisp_Object current_tool_bar_string;
154 #endif
156 /* Desired and current tool-bar items. */
157 Lisp_Object tool_bar_items;
159 #ifdef USE_GTK
160 /* Where tool bar is, can be left, right, top or bottom.
161 Except with GTK, the only supported position is `top'. */
162 Lisp_Object tool_bar_position;
163 #endif
165 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
166 /* List of data specific to font-driver and frame, but common to faces. */
167 Lisp_Object font_data;
168 #endif
170 /* Beyond here, there should be no more Lisp_Object components. */
172 /* Cache of realized faces. */
173 struct face_cache *face_cache;
175 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
176 /* Tool-bar item index of the item on which a mouse button was pressed. */
177 int last_tool_bar_item;
178 #endif
180 /* Number of elements in `menu_bar_vector' that have meaningful data. */
181 int menu_bar_items_used;
183 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
184 /* A buffer to hold the frame's name. Since this is used by the
185 window system toolkit, we can't use the Lisp string's pointer
186 (`name', above) because it might get relocated. */
187 char *namebuf;
188 #endif
190 #ifdef USE_X_TOOLKIT
191 /* Used to pass geometry parameters to toolkit functions. */
192 char *shell_position;
193 #endif
195 /* Glyph pool and matrix. */
196 struct glyph_pool *current_pool;
197 struct glyph_pool *desired_pool;
198 struct glyph_matrix *desired_matrix;
199 struct glyph_matrix *current_matrix;
201 /* Bitfield area begins here. Keep them together to avoid extra padding. */
203 /* True means that glyphs on this frame have been initialized so it can
204 be used for output. */
205 bool_bf glyphs_initialized_p : 1;
207 /* Set to true in change_frame_size when size of frame changed
208 Clear the frame in clear_garbaged_frames if set. */
209 bool_bf resized_p : 1;
211 /* Set to true if the default face for the frame has been
212 realized. Reset to zero whenever the default face changes.
213 Used to see the difference between a font change and face change. */
214 bool_bf default_face_done_p : 1;
216 /* Set to true if this frame has already been hscrolled during
217 current redisplay. */
218 bool_bf already_hscrolled_p : 1;
220 /* Set to true when current redisplay has updated frame. */
221 bool_bf updated_p : 1;
223 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
224 /* Set to true to minimize tool-bar height even when
225 auto-resize-tool-bar is set to grow-only. */
226 bool_bf minimize_tool_bar_window_p : 1;
227 #endif
229 #if defined (USE_GTK) || defined (HAVE_NS)
230 /* True means using a tool bar that comes from the toolkit. */
231 bool_bf external_tool_bar : 1;
232 #endif
234 /* True means that fonts have been loaded since the last glyph
235 matrix adjustments. */
236 bool_bf fonts_changed : 1;
238 /* True means that cursor type has been changed. */
239 bool_bf cursor_type_changed : 1;
241 /* True if it needs to be redisplayed. */
242 bool_bf redisplay : 1;
244 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
245 || defined (HAVE_NS) || defined (USE_GTK)
246 /* True means using a menu bar that comes from the X toolkit. */
247 bool_bf external_menu_bar : 1;
248 #endif
250 /* Next two bitfields are mutually exclusive. They might both be
251 zero if the frame has been made invisible without an icon. */
253 /* Nonzero if the frame is currently displayed; we check
254 it to see if we should bother updating the frame's contents.
256 On ttys and on Windows NT/9X, to avoid wasting effort updating
257 visible frames that are actually completely obscured by other
258 windows on the display, we bend the meaning of visible slightly:
259 if equal to 2, then the frame is obscured - we still consider
260 it to be "visible" as seen from lisp, but we don't bother
261 updating it. */
262 unsigned visible : 2;
264 /* True if the frame is currently iconified. Do not
265 set this directly, use SET_FRAME_ICONIFIED instead. */
266 bool_bf iconified : 1;
268 /* True if this frame should be fully redisplayed. Disables all
269 optimizations while rebuilding matrices and redrawing. */
270 bool_bf garbaged : 1;
272 /* False means, if this frame has just one window,
273 show no modeline for that window. */
274 bool_bf wants_modeline : 1;
276 /* True means raise this frame to the top of the heap when selected. */
277 bool_bf auto_raise : 1;
279 /* True means lower this frame to the bottom of the stack when left. */
280 bool_bf auto_lower : 1;
282 /* True if frame's root window can't be split. */
283 bool_bf no_split : 1;
285 /* If this is set, then Emacs won't change the frame name to indicate
286 the current buffer, etcetera. If the user explicitly sets the frame
287 name, this gets set. If the user sets the name to Qnil, this is
288 cleared. */
289 bool_bf explicit_name : 1;
291 /* True if size of some window on this frame has changed. */
292 bool_bf window_sizes_changed : 1;
294 /* True if the mouse has moved on this display device
295 since the last time we checked. */
296 bool_bf mouse_moved : 1;
298 /* True means that the pointer is invisible. */
299 bool_bf pointer_invisible : 1;
301 /* True means that all windows except mini-window and
302 selected window on this frame have frozen window starts. */
303 bool_bf frozen_window_starts : 1;
305 /* The output method says how the contents of this frame are
306 displayed. It could be using termcap, or using an X window.
307 This must be the same as the terminal->type. */
308 ENUM_BF (output_method) output_method : 3;
310 #ifdef HAVE_WINDOW_SYSTEM
311 /* See FULLSCREEN_ enum on top. */
312 ENUM_BF (fullscreen_type) want_fullscreen : 4;
314 /* If not vertical_scroll_bar_none, we should actually
315 display the scroll bars of this type on this frame. */
316 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
318 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
319 bool_bf horizontal_scroll_bars : 1;
320 #endif /* HAVE_WINDOW_SYSTEM */
322 /* Whether new_height and new_width shall be interpreted
323 in pixels. */
324 bool_bf new_pixelwise : 1;
326 /* True means x_set_window_size requests can be processed for this
327 frame. */
328 bool_bf can_x_set_window_size : 1;
330 /* Set to true after this frame was made by `make-frame'. */
331 bool_bf after_make_frame : 1;
333 /* Whether the tool bar height change should be taken into account. */
334 bool_bf tool_bar_redisplayed : 1;
335 bool_bf tool_bar_resized : 1;
337 /* Inhibit implied resize before after_make_frame is set. */
338 bool_bf inhibit_horizontal_resize : 1;
339 bool_bf inhibit_vertical_resize : 1;
341 /* Non-zero if this frame's faces need to be recomputed. */
342 bool_bf face_change : 1;
344 /* Bitfield area ends here. */
346 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
347 int tool_bar_lines;
349 /* Height of frame internal tool bar in pixels. */
350 int tool_bar_height;
352 int n_tool_bar_rows;
353 int n_tool_bar_items;
355 /* A buffer for decode_mode_line. */
356 char *decode_mode_spec_buffer;
358 /* See do_line_insertion_deletion_costs for info on these arrays. */
359 /* Cost of inserting 1 line on this frame. */
360 int *insert_line_cost;
361 /* Cost of deleting 1 line on this frame. */
362 int *delete_line_cost;
363 /* Cost of inserting n lines on this frame. */
364 int *insert_n_lines_cost;
365 /* Cost of deleting n lines on this frame. */
366 int *delete_n_lines_cost;
368 /* Text width of this frame (excluding fringes, vertical scroll bar
369 and internal border widths) and text height (excluding menu bar,
370 tool bar, horizontal scroll bar and internal border widths) in
371 units of canonical characters. */
372 int text_cols, text_lines;
374 /* Total width of this frame (including fringes, vertical scroll bar
375 and internal border widths) and total height (including menu bar,
376 tool bar, horizontal scroll bar and internal border widths) in
377 units of canonical characters. */
378 int total_cols, total_lines;
380 /* Text width of this frame (excluding fringes, vertical scroll bar
381 and internal border widths) and text height (excluding menu bar,
382 tool bar, horizontal scroll bar and internal border widths) in
383 pixels. */
384 int text_width, text_height;
386 /* New text height and width for pending size change. 0 if no change
387 pending. These values represent pixels or canonical character units
388 according to the value of new_pixelwise and correlate to the the
389 text width/height of the frame. */
390 int new_width, new_height;
392 /* Pixel position of the frame window (x and y offsets in root window). */
393 int left_pos, top_pos;
395 /* Total width of this frame (including fringes, vertical scroll bar
396 and internal border widths) and total height (including internal
397 menu and tool bars, horizontal scroll bar and internal border
398 widths) in pixels. */
399 int pixel_width, pixel_height;
401 /* This is the gravity value for the specified window position. */
402 int win_gravity;
404 /* The geometry flags for this window. */
405 int size_hint_flags;
407 /* Border width of the frame window as known by the (X) window system. */
408 int border_width;
410 /* Width of the internal border. This is a line of background color
411 just inside the window's border. When the frame is selected,
412 a highlighting is displayed inside the internal border. */
413 int internal_border_width;
415 /* Widths of dividers between this frame's windows in pixels. */
416 int right_divider_width, bottom_divider_width;
418 /* Widths of fringes in pixels. */
419 int left_fringe_width, right_fringe_width;
421 /* Total width of fringes reserved for drawing truncation bitmaps,
422 continuation bitmaps and alike - REMOVE THIS !!!!. */
423 int fringe_cols;
425 /* Number of lines of menu bar. */
426 int menu_bar_lines;
428 /* Pixel height of menubar. */
429 int menu_bar_height;
431 /* Canonical X unit. Width of default font, in pixels. */
432 int column_width;
434 /* Canonical Y unit. Height of a line, in pixels. */
435 int line_height;
437 /* The terminal device that this frame uses. If this is NULL, then
438 the frame has been deleted. */
439 struct terminal *terminal;
441 /* Device-dependent, frame-local auxiliary data used for displaying
442 the contents. When the frame is deleted, this data is deleted as
443 well. */
444 union output_data
446 struct tty_output *tty; /* From termchar.h. */
447 struct x_output *x; /* From xterm.h. */
448 struct w32_output *w32; /* From w32term.h. */
449 struct ns_output *ns; /* From nsterm.h. */
450 intptr_t nothing;
452 output_data;
454 /* List of font-drivers available on the frame. */
455 struct font_driver_list *font_driver_list;
457 #if defined (HAVE_X_WINDOWS)
458 /* Used by x_wait_for_event when watching for an X event on this frame. */
459 int wait_event_type;
460 #endif
462 /* What kind of text cursor should we draw in the future?
463 This should always be filled_box_cursor or bar_cursor. */
464 enum text_cursor_kinds desired_cursor;
466 /* Width of bar cursor (if we are using that). */
467 int cursor_width;
469 /* What kind of text cursor should we draw when the cursor blinks off?
470 This can be filled_box_cursor or bar_cursor or no_cursor. */
471 enum text_cursor_kinds blink_off_cursor;
473 /* Width of bar cursor (if we are using that) for blink-off state. */
474 int blink_off_cursor_width;
476 /* Configured width of the scroll bar, in pixels and in characters.
477 config_scroll_bar_cols tracks config_scroll_bar_width if the
478 latter is positive; a zero value in config_scroll_bar_width means
479 to compute the actual width on the fly, using config_scroll_bar_cols
480 and the current font width. */
481 int config_scroll_bar_width;
482 int config_scroll_bar_cols;
484 /* Configured height of the scroll bar, in pixels and in characters.
485 config_scroll_bar_lines tracks config_scroll_bar_height if the
486 latter is positive; a zero value in config_scroll_bar_height means
487 to compute the actual width on the fly, using
488 config_scroll_bar_lines and the current font width. */
489 int config_scroll_bar_height;
490 int config_scroll_bar_lines;
492 /* The baud rate that was used to calculate costs for this frame. */
493 int cost_calculation_baud_rate;
495 /* Frame opacity
496 alpha[0]: alpha transparency of the active frame
497 alpha[1]: alpha transparency of inactive frames
498 Negative values mean not to change alpha. */
499 double alpha[2];
501 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
502 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
503 frame parameter. 0 means don't do gamma correction. */
504 double gamma;
506 /* Additional space to put between text lines on this frame. */
507 int extra_line_spacing;
509 /* All display backends seem to need these two pixel values. */
510 unsigned long background_pixel;
511 unsigned long foreground_pixel;
514 /* Most code should use these functions to set Lisp fields in struct frame. */
516 INLINE void
517 fset_buffer_list (struct frame *f, Lisp_Object val)
519 f->buffer_list = val;
521 INLINE void
522 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
524 f->buried_buffer_list = val;
526 INLINE void
527 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
529 f->condemned_scroll_bars = val;
531 INLINE void
532 fset_face_alist (struct frame *f, Lisp_Object val)
534 f->face_alist = val;
536 INLINE void
537 fset_focus_frame (struct frame *f, Lisp_Object val)
539 f->focus_frame = val;
541 INLINE void
542 fset_icon_name (struct frame *f, Lisp_Object val)
544 f->icon_name = val;
546 INLINE void
547 fset_menu_bar_items (struct frame *f, Lisp_Object val)
549 f->menu_bar_items = val;
551 INLINE void
552 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
554 f->menu_bar_vector = val;
556 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
557 INLINE void
558 fset_menu_bar_window (struct frame *f, Lisp_Object val)
560 f->menu_bar_window = val;
562 #endif
563 INLINE void
564 fset_name (struct frame *f, Lisp_Object val)
566 f->name = val;
568 INLINE void
569 fset_param_alist (struct frame *f, Lisp_Object val)
571 f->param_alist = val;
573 INLINE void
574 fset_root_window (struct frame *f, Lisp_Object val)
576 f->root_window = val;
578 INLINE void
579 fset_scroll_bars (struct frame *f, Lisp_Object val)
581 f->scroll_bars = val;
583 INLINE void
584 fset_selected_window (struct frame *f, Lisp_Object val)
586 f->selected_window = val;
588 INLINE void
589 fset_title (struct frame *f, Lisp_Object val)
591 f->title = val;
593 INLINE void
594 fset_tool_bar_items (struct frame *f, Lisp_Object val)
596 f->tool_bar_items = val;
598 #ifdef USE_GTK
599 INLINE void
600 fset_tool_bar_position (struct frame *f, Lisp_Object val)
602 f->tool_bar_position = val;
604 #endif /* USE_GTK */
605 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
606 INLINE void
607 fset_tool_bar_window (struct frame *f, Lisp_Object val)
609 f->tool_bar_window = val;
611 INLINE void
612 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
614 f->current_tool_bar_string = val;
616 INLINE void
617 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
619 f->desired_tool_bar_string = val;
621 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
623 #define NUMVAL(X) (NUMBERP (X) ? XFLOATINT (X) : -1)
625 INLINE double
626 default_pixels_per_inch_x (void)
628 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
629 ? XCAR (Vdisplay_pixels_per_inch)
630 : Vdisplay_pixels_per_inch);
631 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
634 INLINE double
635 default_pixels_per_inch_y (void)
637 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
638 ? XCDR (Vdisplay_pixels_per_inch)
639 : Vdisplay_pixels_per_inch);
640 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
643 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
645 /* Return a pointer to the image cache of frame F. */
646 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
648 #define XFRAME(p) \
649 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
650 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
652 /* Given a window, return its frame as a Lisp_Object. */
653 #define WINDOW_FRAME(w) ((w)->frame)
655 /* Test a frame for particular kinds of display methods. */
656 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
657 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
658 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
659 #ifndef HAVE_NTGUI
660 #define FRAME_W32_P(f) false
661 #else
662 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
663 #endif
664 #ifndef MSDOS
665 #define FRAME_MSDOS_P(f) false
666 #else
667 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
668 #endif
669 #ifndef HAVE_NS
670 #define FRAME_NS_P(f) false
671 #else
672 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
673 #endif
675 /* FRAME_WINDOW_P tests whether the frame is a window, and is
676 defined to be the predicate for the window system being used. */
678 #ifdef HAVE_X_WINDOWS
679 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
680 #endif
681 #ifdef HAVE_NTGUI
682 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
683 #endif
684 #ifdef HAVE_NS
685 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
686 #endif
687 #ifndef FRAME_WINDOW_P
688 #define FRAME_WINDOW_P(f) ((void) (f), false)
689 #endif
691 /* Dots per inch of the screen the frame F is on. */
693 #ifdef HAVE_WINDOW_SYSTEM
695 #define FRAME_RES_X(f) \
696 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
697 #define FRAME_RES_Y(f) \
698 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
700 #else /* !HAVE_WINDOW_SYSTEM */
702 /* Defaults when no window system available. */
704 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
705 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
707 #endif /* HAVE_WINDOW_SYSTEM */
709 /* Return a pointer to the structure holding information about the
710 region of text, if any, that is currently shown in mouse-face on
711 frame F. We need to define two versions because a TTY-only build
712 does not have FRAME_DISPLAY_INFO. */
713 #ifdef HAVE_WINDOW_SYSTEM
714 # define MOUSE_HL_INFO(F) \
715 (FRAME_WINDOW_P(F) \
716 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
717 : &(F)->output_data.tty->display_info->mouse_highlight)
718 #else
719 # define MOUSE_HL_INFO(F) \
720 (&(F)->output_data.tty->display_info->mouse_highlight)
721 #endif
723 /* True if frame F is still alive (not deleted). */
724 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
726 /* True if frame F is a minibuffer-only frame. */
727 #define FRAME_MINIBUF_ONLY_P(f) \
728 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
730 /* True if frame F contains it's own minibuffer window. Frame always has
731 minibuffer window, but it could use minibuffer window of another frame. */
732 #define FRAME_HAS_MINIBUF_P(f) \
733 (WINDOWP (f->minibuffer_window) \
734 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
736 /* Pixel width of frame F. */
737 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
739 /* Pixel height of frame F. */
740 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
742 /* Width of frame F, measured in canonical character columns,
743 not including scroll bars if any. */
744 #define FRAME_COLS(f) (f)->text_cols
746 /* Height of frame F, measured in canonical lines, including
747 non-toolkit menu bar and non-toolkit tool bar lines. */
748 #define FRAME_LINES(f) (f)->text_lines
750 /* Width of frame F, measured in pixels not including the width for
751 fringes, scroll bar, and internal borders. */
752 #define FRAME_TEXT_WIDTH(f) (f)->text_width
754 /* Height of frame F, measured in pixels not including the height
755 for scroll bar and internal borders. */
756 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
758 /* Number of lines of frame F used for menu bar.
759 This is relevant on terminal frames and on
760 X Windows when not using the X toolkit.
761 These lines are counted in FRAME_LINES. */
762 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
764 /* Pixel height of frame F's menu bar. */
765 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
767 /* True if this frame should display a tool bar
768 in a way that does not use any text lines. */
769 #if defined (USE_GTK) || defined (HAVE_NS)
770 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
771 #else
772 #define FRAME_EXTERNAL_TOOL_BAR(f) false
773 #endif
775 /* This is really supported only with GTK. */
776 #ifdef USE_GTK
777 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
778 #else
779 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
780 #endif
782 /* Number of lines of frame F used for the tool-bar. */
783 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
785 /* Pixel height of frame F's tool-bar. */
786 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
788 /* Lines above the top-most window in frame F. */
789 #define FRAME_TOP_MARGIN(F) \
790 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
792 /* Pixel height of frame F's top margin. */
793 #define FRAME_TOP_MARGIN_HEIGHT(F) \
794 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
796 /* True if this frame should display a menu bar
797 in a way that does not use any text lines. */
798 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
799 || defined (HAVE_NS) || defined (USE_GTK)
800 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
801 #else
802 #define FRAME_EXTERNAL_MENU_BAR(f) false
803 #endif
805 /* True if frame F is currently visible. */
806 #define FRAME_VISIBLE_P(f) (f)->visible
808 /* True if frame F is currently visible but hidden. */
809 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
811 /* True if frame F is currently iconified. */
812 #define FRAME_ICONIFIED_P(f) (f)->iconified
814 /* Mark frame F as currently garbaged. */
815 #define SET_FRAME_GARBAGED(f) \
816 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
818 /* True if frame F is currently garbaged. */
819 #define FRAME_GARBAGED_P(f) (f)->garbaged
821 /* True means do not allow splitting this frame's window. */
822 #define FRAME_NO_SPLIT_P(f) (f)->no_split
824 /* Not really implemented. */
825 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
827 /* True if all windows except selected window and mini window
828 are frozen on frame F. */
829 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
831 /* True if a size change has been requested for frame F
832 but not yet really put into effect. This can be true temporarily
833 when an X event comes in at a bad time. */
834 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
836 /* The minibuffer window of frame F, if it has one; otherwise nil. */
837 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
839 /* The root window of the window tree of frame F. */
840 #define FRAME_ROOT_WINDOW(f) f->root_window
842 /* The currently selected window of the window tree of frame F. */
843 #define FRAME_SELECTED_WINDOW(f) f->selected_window
845 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
846 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
847 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
848 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
849 #define FRAME_FOCUS_FRAME(f) f->focus_frame
851 #ifdef HAVE_WINDOW_SYSTEM
853 /* This frame slot says whether scroll bars are currently enabled for frame F,
854 and which side they are on. */
855 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
856 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
857 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
858 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
859 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
860 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
861 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
863 #else /* not HAVE_WINDOW_SYSTEM */
865 /* If there is no window system, there are no scroll bars. */
866 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
867 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
868 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
869 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
871 #endif /* HAVE_WINDOW_SYSTEM */
873 /* Whether horizontal scroll bars are currently enabled for frame F. */
874 #if USE_HORIZONTAL_SCROLL_BARS
875 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
876 ((f)->horizontal_scroll_bars)
877 #else
878 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
879 #endif
881 /* Width that a scroll bar in frame F should have, if there is one.
882 Measured in pixels.
883 If scroll bars are turned off, this is still nonzero. */
884 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
886 /* Height that a scroll bar in frame F should have, if there is one.
887 Measured in pixels.
888 If scroll bars are turned off, this is still nonzero. */
889 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
891 /* Width that a scroll bar in frame F should have, if there is one.
892 Measured in columns (characters).
893 If scroll bars are turned off, this is still nonzero. */
894 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
896 /* Height that a scroll bar in frame F should have, if there is one.
897 Measured in lines (characters).
898 If scroll bars are turned off, this is still nonzero. */
899 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
901 /* Width of a left scroll bar in frame F, measured in pixels */
902 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
903 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
904 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
905 : 0)
907 /* Width of a right scroll bar area in frame F, measured in pixels */
908 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
909 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
910 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
911 : 0)
913 /* Width of a left scroll bar in frame F, measured in columns
914 (characters), but only if scroll bars are on the left. If scroll
915 bars are on the right in this frame, or there are no scroll bars,
916 value is 0. */
917 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
918 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
919 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
920 : 0)
922 /* Width of a right scroll bar in frame F, measured in columns
923 (characters), but only if scroll bars are on the right. If scroll
924 bars are on the left in this frame, or there are no scroll bars,
925 value is 0. */
926 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
927 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
928 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
929 : 0)
931 /* Width of a vertical scroll bar area in frame F, measured in
932 pixels. */
933 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
934 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
935 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
936 : 0)
938 /* Height of horizontal scroll bar area in frame F, measured in
939 pixels. */
940 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
941 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
942 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
943 : 0)
945 /* Width of vertical scroll bar in frame F, measured in columns. */
946 #define FRAME_SCROLL_BAR_COLS(f) \
947 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
948 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
949 : 0)
951 /* Height of horizontal scroll bar in frame F, measured in lines. */
952 #define FRAME_SCROLL_BAR_LINES(f) \
953 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
954 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
955 : 0)
957 /* Total width of frame F, in columns (characters),
958 including the width used by scroll bars if any. */
959 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
961 /* Total height of frame F, in lines (characters),
962 including the height used by scroll bars if any. */
963 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
965 /* Set the character widths of frame F. WIDTH specifies a nominal
966 character text width. */
967 #define SET_FRAME_COLS(f, width) \
968 ((f)->text_cols = (width), \
969 (f)->total_cols = ((width) \
970 + FRAME_SCROLL_BAR_COLS (f) \
971 + FRAME_FRINGE_COLS (f)))
973 /* Set the character heights of frame F. HEIGHT specifies a nominal
974 character text height. */
975 #define SET_FRAME_LINES(f, height) \
976 ((f)->text_lines = (height), \
977 (f)->total_lines = ((height) \
978 + FRAME_TOP_MARGIN (f) \
979 + FRAME_SCROLL_BAR_LINES (f)))
981 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
982 width. */
983 #define SET_FRAME_WIDTH(f, width) \
984 ((f)->text_width = (width), \
985 (f)->pixel_width = ((width) \
986 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
987 + FRAME_TOTAL_FRINGE_WIDTH (f) \
988 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
990 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
991 height. */
992 #define SET_FRAME_HEIGHT(f, height) \
993 ((f)->text_height = (height), \
994 (f)->pixel_height = ((height) \
995 + FRAME_TOP_MARGIN_HEIGHT (f) \
996 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
997 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
999 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1000 #define FRAME_CURSOR_X_LIMIT(f) \
1001 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1003 /* Nonzero if frame F has scroll bars. */
1004 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1005 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1007 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1008 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1010 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1011 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1012 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1013 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1015 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1016 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1018 /* Return a pointer to the face cache of frame F. */
1020 #define FRAME_FACE_CACHE(F) (F)->face_cache
1022 /* Return the size of message_buf of the frame F. We multiply the
1023 width of the frame by 4 because multi-byte form may require at most
1024 4-byte for a character. */
1026 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1028 #define CHECK_FRAME(x) \
1029 CHECK_TYPE (FRAMEP (x), Qframep, x)
1031 #define CHECK_LIVE_FRAME(x) \
1032 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1034 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1035 `for' loop which iterates over the elements of Vframe_list. The
1036 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1037 Vframe_list in succession and execute the statement. LIST_VAR
1038 should be a Lisp_Object too; it is used to iterate through the
1039 Vframe_list.
1041 This macro is a holdover from a time when multiple frames weren't always
1042 supported. An alternate definition of the macro would expand to
1043 something which executes the statement once. */
1045 #define FOR_EACH_FRAME(list_var, frame_var) \
1046 for ((list_var) = Vframe_list; \
1047 (CONSP (list_var) \
1048 && (frame_var = XCAR (list_var), true)); \
1049 list_var = XCDR (list_var))
1051 /* Reflect mouse movement when a complete frame update is performed. */
1053 #define FRAME_MOUSE_UPDATE(frame) \
1054 do { \
1055 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1056 if (frame == hlinfo->mouse_face_mouse_frame) \
1058 block_input (); \
1059 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1060 hlinfo->mouse_face_mouse_x, \
1061 hlinfo->mouse_face_mouse_y); \
1062 unblock_input (); \
1064 } while (false)
1066 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1068 #define AUTO_FRAME_ARG(name, parameter, value) \
1069 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1071 /* False means there are no visible garbaged frames. */
1072 extern bool frame_garbaged;
1074 /* Set visibility of frame F.
1075 We call redisplay_other_windows to make sure the frame gets redisplayed
1076 if some changes were applied to it while it wasn't visible (and hence
1077 wasn't redisplayed). */
1079 INLINE void
1080 SET_FRAME_VISIBLE (struct frame *f, int v)
1082 eassert (0 <= v && v <= 2);
1083 if (v)
1085 if (v == 1 && f->visible != 1)
1086 redisplay_other_windows ();
1087 if (FRAME_GARBAGED_P (f))
1088 frame_garbaged = true;
1090 f->visible = v;
1093 /* Set iconify of frame F. */
1095 #define SET_FRAME_ICONIFIED(f, i) \
1096 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1098 extern Lisp_Object selected_frame;
1100 #if ! (defined USE_GTK || defined HAVE_NS)
1101 extern int frame_default_tool_bar_height;
1102 #endif
1104 extern struct frame *decode_window_system_frame (Lisp_Object);
1105 extern struct frame *decode_live_frame (Lisp_Object);
1106 extern struct frame *decode_any_frame (Lisp_Object);
1107 extern struct frame *make_initial_frame (void);
1108 extern struct frame *make_frame (bool);
1109 #ifdef HAVE_WINDOW_SYSTEM
1110 extern struct frame *make_minibuffer_frame (void);
1111 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1112 struct kboard *,
1113 Lisp_Object);
1114 extern bool window_system_available (struct frame *);
1115 #else /* not HAVE_WINDOW_SYSTEM */
1116 #define window_system_available(f) ((void) (f), false)
1117 #endif /* HAVE_WINDOW_SYSTEM */
1118 extern void check_window_system (struct frame *);
1119 extern void frame_make_pointer_invisible (struct frame *);
1120 extern void frame_make_pointer_visible (struct frame *);
1121 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1122 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
1123 extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
1124 extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
1125 int width, int height, Lisp_Object rest);
1127 extern Lisp_Object Vframe_list;
1129 /* Value is a pointer to the selected frame. If the selected frame
1130 isn't live, abort. */
1132 #define SELECTED_FRAME() \
1133 ((FRAMEP (selected_frame) \
1134 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1135 ? XFRAME (selected_frame) \
1136 : (emacs_abort (), (struct frame *) 0))
1139 /***********************************************************************
1140 Display-related Macros
1141 ***********************************************************************/
1143 /* Canonical y-unit on frame F.
1144 This value currently equals the line height of the frame (which is
1145 the height of the default font of F). */
1146 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1148 /* Canonical x-unit on frame F.
1149 This value currently equals the average width of the default font of F. */
1150 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1152 /* Pixel width of areas used to display truncation marks, continuation
1153 marks, overlay arrows. This is 0 for terminal frames. */
1155 #ifdef HAVE_WINDOW_SYSTEM
1157 /* Total width of fringes reserved for drawing truncation bitmaps,
1158 continuation bitmaps and alike. The width is in canonical char
1159 units of the frame. This must currently be the case because window
1160 sizes aren't pixel values. If it weren't the case, we wouldn't be
1161 able to split windows horizontally nicely. */
1162 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
1164 /* Pixel-width of the left and right fringe. */
1166 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
1167 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
1169 /* Total width of fringes in pixels. */
1171 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
1172 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
1174 /* Pixel-width of internal border lines */
1175 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
1177 /* Pixel-size of window border lines */
1178 #define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width)
1179 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width)
1181 #else /* not HAVE_WINDOW_SYSTEM */
1183 #define FRAME_FRINGE_COLS(F) 0
1184 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
1185 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
1186 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
1187 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
1188 #define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1189 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1191 #endif /* not HAVE_WINDOW_SYSTEM */
1193 /***********************************************************************
1194 Conversion between canonical units and pixels
1195 ***********************************************************************/
1197 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1198 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1199 represented as Lisp numbers, i.e. integers or floats. */
1201 /* Convert canonical value X to pixels. F is the frame whose
1202 canonical char width is to be used. X must be a Lisp integer or
1203 float. Value is a C integer. */
1204 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1205 (INTEGERP (X) \
1206 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1207 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1209 /* Convert canonical value Y to pixels. F is the frame whose
1210 canonical character height is to be used. X must be a Lisp integer
1211 or float. Value is a C integer. */
1212 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1213 (INTEGERP (Y) \
1214 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1215 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1217 /* Convert pixel-value X to canonical units. F is the frame whose
1218 canonical character width is to be used. X is a C integer. Result
1219 is a Lisp float if X is not a multiple of the canon width,
1220 otherwise it's a Lisp integer. */
1221 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1222 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1223 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1224 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1226 /* Convert pixel-value Y to canonical units. F is the frame whose
1227 canonical character height is to be used. Y is a C integer.
1228 Result is a Lisp float if Y is not a multiple of the canon width,
1229 otherwise it's a Lisp integer. */
1230 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1231 ((Y) % FRAME_LINE_HEIGHT (F) \
1232 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1233 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1237 /* Manipulating pixel sizes and character sizes.
1238 Knowledge of which factors affect the overall size of the window should
1239 be hidden in these macros, if that's possible.
1241 Return the upper/left pixel position of the character cell on frame F
1242 at ROW/COL. */
1243 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1244 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1245 + (row) * FRAME_LINE_HEIGHT (f))
1247 #define FRAME_COL_TO_PIXEL_X(f, col) \
1248 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1249 + (col) * FRAME_COLUMN_WIDTH (f))
1251 /* Return the pixel width/height of frame F if it has
1252 COLS columns/LINES rows. */
1253 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1254 ((cols) * FRAME_COLUMN_WIDTH (f) \
1255 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1256 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1257 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1259 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1260 ((lines) * FRAME_LINE_HEIGHT (f) \
1261 + FRAME_TOP_MARGIN_HEIGHT (f) \
1262 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1263 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1265 /* Return the row/column (zero-based) of the character cell containing
1266 the pixel on FRAME at Y/X. */
1267 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1268 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1269 ? (y) \
1270 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1271 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1272 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1273 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1274 /* Arrange for the division to round down. */ \
1275 + FRAME_LINE_HEIGHT (f) - 1) \
1276 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1277 / FRAME_LINE_HEIGHT (f))
1279 #define FRAME_PIXEL_X_TO_COL(f, x) \
1280 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1281 / FRAME_COLUMN_WIDTH (f))
1283 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1284 frame F (so we round down)? */
1285 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1286 (((width) \
1287 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1288 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1289 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1290 / FRAME_COLUMN_WIDTH (f)) \
1292 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1293 (((height) \
1294 - FRAME_TOP_MARGIN_HEIGHT (f) \
1295 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1296 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1297 / FRAME_LINE_HEIGHT (f))
1299 /* Return the pixel width/height of frame F with a text size of
1300 width/height. */
1301 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1302 ((width) \
1303 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1304 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1305 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1307 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1308 ((height) \
1309 + FRAME_TOP_MARGIN_HEIGHT (f) \
1310 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1311 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1313 /* Return the text width/height of frame F with a pixel size of
1314 width/height. */
1315 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1316 ((width) \
1317 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1318 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1319 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1321 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1322 ((height) \
1323 - FRAME_TOP_MARGIN_HEIGHT (f) \
1324 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1325 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1327 /* Return the width/height reserved for the windows of frame F. */
1328 #define FRAME_WINDOWS_WIDTH(f) \
1329 (FRAME_PIXEL_WIDTH (f) \
1330 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1332 #define FRAME_WINDOWS_HEIGHT(f) \
1333 (FRAME_PIXEL_HEIGHT (f) \
1334 - FRAME_TOP_MARGIN_HEIGHT (f) \
1335 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1337 /* Value is the smallest width of any character in any font on frame F. */
1338 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1339 FRAME_DISPLAY_INFO (f)->smallest_char_width
1341 /* Value is the smallest height of any font on frame F. */
1342 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1343 FRAME_DISPLAY_INFO (f)->smallest_font_height
1345 /***********************************************************************
1346 Frame Parameters
1347 ***********************************************************************/
1349 #ifdef HAVE_WINDOW_SYSTEM
1351 /* The class of this X application. */
1352 #define EMACS_CLASS "Emacs"
1354 extern void x_set_scroll_bar_default_width (struct frame *);
1355 extern void x_set_scroll_bar_default_height (struct frame *);
1356 extern void x_set_offset (struct frame *, int, int, int);
1357 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1358 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1359 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1360 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1361 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1362 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1363 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1364 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1365 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1366 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1367 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1368 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1369 Lisp_Object);
1370 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1371 Lisp_Object);
1372 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1373 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1374 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1375 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1376 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1377 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1378 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1379 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1381 extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, int *);
1383 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1385 extern void validate_x_resource_name (void);
1387 extern Lisp_Object display_x_get_resource (Display_Info *,
1388 Lisp_Object attribute,
1389 Lisp_Object class,
1390 Lisp_Object component,
1391 Lisp_Object subclass);
1393 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1394 extern void x_set_window_size (struct frame *f, bool change_gravity,
1395 int width, int height, bool pixelwise);
1396 extern Lisp_Object x_get_focus_frame (struct frame *);
1397 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1398 extern void x_make_frame_visible (struct frame *f);
1399 extern void x_make_frame_invisible (struct frame *f);
1400 extern void x_iconify_frame (struct frame *f);
1401 extern void x_set_frame_alpha (struct frame *f);
1402 extern void x_activate_menubar (struct frame *);
1403 extern void x_real_positions (struct frame *, int *, int *);
1404 extern void free_frame_menubar (struct frame *);
1405 extern void x_free_frame_resources (struct frame *);
1407 #if defined HAVE_X_WINDOWS
1408 extern void x_wm_set_icon_position (struct frame *, int, int);
1409 #if !defined USE_X_TOOLKIT
1410 extern char *x_get_resource_string (const char *, const char *);
1411 #endif
1412 extern void x_sync (struct frame *);
1413 #endif /* HAVE_X_WINDOWS */
1415 extern void x_query_colors (struct frame *f, XColor *, int);
1416 extern void x_focus_frame (struct frame *);
1418 #ifndef HAVE_NS
1420 extern bool x_bitmap_icon (struct frame *, Lisp_Object);
1422 /* Set F's bitmap icon, if specified among F's parameters. */
1424 INLINE void
1425 x_set_bitmap_icon (struct frame *f)
1427 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1429 if (CONSP (obj) && !NILP (XCDR (obj)))
1430 x_bitmap_icon (f, XCDR (obj));
1433 #endif /* !HAVE_NS */
1434 #endif /* HAVE_WINDOW_SYSTEM */
1436 INLINE void
1437 flush_frame (struct frame *f)
1439 struct redisplay_interface *rif = FRAME_RIF (f);
1441 if (rif && rif->flush_display)
1442 rif->flush_display (f);
1445 /***********************************************************************
1446 Multimonitor data
1447 ***********************************************************************/
1449 #ifdef HAVE_WINDOW_SYSTEM
1451 struct MonitorInfo {
1452 XRectangle geom, work;
1453 int mm_width, mm_height;
1454 char *name;
1457 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1458 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1459 int n_monitors,
1460 int primary_monitor,
1461 Lisp_Object monitor_frames,
1462 const char *source);
1464 #endif /* HAVE_WINDOW_SYSTEM */
1467 INLINE_HEADER_END
1469 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1470 This is for functions like x_set_horizontal_scroll_bars that have
1471 no effect in this case. */
1472 #if ! USE_HORIZONTAL_SCROLL_BARS && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
1473 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1474 #endif
1476 #endif /* not EMACS_FRAME_H */