* lisp/rect.el (rectangle--string-preview): Don't assume there
[emacs.git] / src / frame.h
blobfaeac2ad6259c6f22db3a1328057045713842061
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2014 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
9 (at 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 /* Don't multiply include: dispextern.h includes macterm.h which
20 includes frame.h some emacs source includes both dispextern.h and
21 frame.h. */
23 #ifndef EMACS_FRAME_H
24 #define EMACS_FRAME_H
26 #include "dispextern.h"
27 #include "termhooks.h"
28 #include "window.h"
30 INLINE_HEADER_BEGIN
32 enum vertical_scroll_bar_type
34 vertical_scroll_bar_none,
35 vertical_scroll_bar_left,
36 vertical_scroll_bar_right
39 #ifdef HAVE_WINDOW_SYSTEM
41 enum fullscreen_type
43 FULLSCREEN_NONE,
44 FULLSCREEN_WIDTH = 0x1,
45 FULLSCREEN_HEIGHT = 0x2,
46 FULLSCREEN_BOTH = 0x3, /* Not a typo but means "width and height". */
47 FULLSCREEN_MAXIMIZED = 0x4,
48 #ifdef HAVE_NTGUI
49 FULLSCREEN_WAIT = 0x8
50 #endif
53 #endif /* HAVE_WINDOW_SYSTEM */
55 /* The structure representing a frame. */
57 struct frame
59 struct vectorlike_header header;
61 /* All Lisp_Object components must come first.
62 That ensures they are all aligned normally. */
64 /* Name of this frame: a Lisp string. It is used for looking up resources,
65 as well as for the title in some cases. */
66 Lisp_Object name;
68 /* The name to use for the icon, the last time
69 it was refreshed. nil means not explicitly specified. */
70 Lisp_Object icon_name;
72 /* This is the frame title specified explicitly, if any.
73 Usually it is nil. */
74 Lisp_Object title;
76 /* The frame which should receive keystrokes that occur in this
77 frame, or nil if they should go to the frame itself. This is
78 usually nil, but if the frame is minibufferless, we can use this
79 to redirect keystrokes to a surrogate minibuffer frame when
80 needed.
82 Note that a value of nil is different than having the field point
83 to the frame itself. Whenever the Fselect_frame function is used
84 to shift from one frame to the other, any redirections to the
85 original frame are shifted to the newly selected frame; if
86 focus_frame is nil, Fselect_frame will leave it alone. */
87 Lisp_Object focus_frame;
89 /* This frame's root window. Every frame has one.
90 If the frame has only a minibuffer window, this is it.
91 Otherwise, if the frame has a minibuffer window, this is its sibling. */
92 Lisp_Object root_window;
94 /* This frame's selected window.
95 Each frame has its own window hierarchy
96 and one of the windows in it is selected within the frame.
97 The selected window of the selected frame is Emacs's selected window. */
98 Lisp_Object selected_window;
100 /* This frame's minibuffer window.
101 Most frames have their own minibuffer windows,
102 but only the selected frame's minibuffer window
103 can actually appear to exist. */
104 Lisp_Object minibuffer_window;
106 /* Parameter alist of this frame.
107 These are the parameters specified when creating the frame
108 or modified with modify-frame-parameters. */
109 Lisp_Object param_alist;
111 /* List of scroll bars on this frame.
112 Actually, we don't specify exactly what is stored here at all; the
113 scroll bar implementation code can use it to store anything it likes.
114 This field is marked by the garbage collector. It is here
115 instead of in the `device' structure so that the garbage
116 collector doesn't need to look inside the window-system-dependent
117 structure. */
118 Lisp_Object scroll_bars;
119 Lisp_Object condemned_scroll_bars;
121 /* Vector describing the items to display in the menu bar.
122 Each item has four elements in this vector.
123 They are KEY, STRING, SUBMAP, and HPOS.
124 (HPOS is not used in when the X toolkit is in use.)
125 There are four additional elements of nil at the end, to terminate. */
126 Lisp_Object menu_bar_items;
128 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
129 Lisp_Object face_alist;
131 /* A vector that records the entire structure of this frame's menu bar.
132 For the format of the data, see extensive comments in xmenu.c.
133 Only the X toolkit version uses this. */
134 Lisp_Object menu_bar_vector;
136 /* Predicate for selecting buffers for other-buffer. */
137 Lisp_Object buffer_predicate;
139 /* List of buffers viewed in this frame, for other-buffer. */
140 Lisp_Object buffer_list;
142 /* List of buffers that were viewed, then buried in this frame. The
143 most recently buried buffer is first. For last-buffer. */
144 Lisp_Object buried_buffer_list;
146 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
147 /* A dummy window used to display menu bars under X when no X
148 toolkit support is available. */
149 Lisp_Object menu_bar_window;
150 #endif
152 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
153 /* A window used to display the tool-bar of a frame. */
154 Lisp_Object tool_bar_window;
156 /* Desired and current contents displayed in that window. */
157 Lisp_Object desired_tool_bar_string;
158 Lisp_Object current_tool_bar_string;
159 #endif
161 /* Desired and current tool-bar items. */
162 Lisp_Object tool_bar_items;
164 #ifdef USE_GTK
165 /* Where tool bar is, can be left, right, top or bottom.
166 Except with GTK, the only supported position is `top'. */
167 Lisp_Object tool_bar_position;
168 #endif
170 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
171 /* List of data specific to font-driver and frame, but common to faces. */
172 Lisp_Object font_data;
173 #endif
175 /* Beyond here, there should be no more Lisp_Object components. */
177 /* Cache of realized faces. */
178 struct face_cache *face_cache;
180 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
181 /* Tool-bar item index of the item on which a mouse button was pressed. */
182 int last_tool_bar_item;
183 #endif
185 /* Number of elements in `menu_bar_vector' that have meaningful data. */
186 int menu_bar_items_used;
188 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
189 /* A buffer to hold the frame's name. Since this is used by the
190 window system toolkit, we can't use the Lisp string's pointer
191 (`name', above) because it might get relocated. */
192 char *namebuf;
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
312 /* See FULLSCREEN_ enum on top. */
313 ENUM_BF (fullscreen_type) want_fullscreen : 4;
315 /* If not vertical_scroll_bar_none, we should actually
316 display the scroll bars of this type on this frame. */
317 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
319 #endif /* HAVE_WINDOW_SYSTEM */
321 /* Bitfield area ends here. */
323 /* Margin at the top of the frame. Used to display the tool-bar. */
324 int tool_bar_lines;
326 /* Pixel height of tool bar. */
327 int tool_bar_height;
329 int n_tool_bar_rows;
330 int n_tool_bar_items;
332 /* A buffer for decode_mode_line. */
333 char *decode_mode_spec_buffer;
335 /* See do_line_insertion_deletion_costs for info on these arrays. */
336 /* Cost of inserting 1 line on this frame. */
337 int *insert_line_cost;
338 /* Cost of deleting 1 line on this frame. */
339 int *delete_line_cost;
340 /* Cost of inserting n lines on this frame. */
341 int *insert_n_lines_cost;
342 /* Cost of deleting n lines on this frame. */
343 int *delete_n_lines_cost;
345 /* Text width of this frame (excluding fringes, scroll bars and
346 internal border width) and text height (excluding internal border
347 width) in units of canonical characters. */
348 int text_cols, text_lines;
350 /* Total width of this frame (including fringes and scroll bars) in
351 units of canonical characters. */
352 int total_cols;
354 /* Text width of this frame (excluding fringes, scroll bars and
355 internal border width) and text height (excluding internal border
356 width) in pixels. */
357 int text_width, text_height;
359 /* New text height and width for pending size change. 0 if no change
360 pending. These values represent pixels or canonical character units
361 according to the value of new_pixelwise and correlate to the the
362 text width/height of the frame. */
363 int new_width, new_height;
365 /* Whether new_height and new_width shall be interpreted
366 in pixels. */
367 bool new_pixelwise;
369 /* Pixel position of the frame window (x and y offsets in root window). */
370 int left_pos, top_pos;
372 /* Size of the frame window (including internal border widths) in
373 pixels. */
374 int pixel_width, pixel_height;
376 /* These many pixels are the difference between the outer window (i.e. the
377 left and top of the window manager decoration) and FRAME_X_WINDOW. */
378 int x_pixels_diff, y_pixels_diff;
380 /* This is the gravity value for the specified window position. */
381 int win_gravity;
383 /* The geometry flags for this window. */
384 int size_hint_flags;
386 /* Border width of the frame window as known by the (X) window system. */
387 int border_width;
389 /* Width of the internal border. This is a line of background color
390 just inside the window's border. When the frame is selected,
391 a highlighting is displayed inside the internal border. */
392 int internal_border_width;
394 /* Width of borders between this frame's windows. */
395 int right_divider_width;
396 int bottom_divider_width;
398 /* Canonical X unit. Width of default font, in pixels. */
399 int column_width;
401 /* Canonical Y unit. Height of a line, in pixels. */
402 int line_height;
404 /* The terminal device that this frame uses. If this is NULL, then
405 the frame has been deleted. */
406 struct terminal *terminal;
408 /* Device-dependent, frame-local auxiliary data used for displaying
409 the contents. When the frame is deleted, this data is deleted as
410 well. */
411 union output_data
413 struct tty_output *tty; /* From termchar.h. */
414 struct x_output *x; /* From xterm.h. */
415 struct w32_output *w32; /* From w32term.h. */
416 struct ns_output *ns; /* From nsterm.h. */
417 intptr_t nothing;
419 output_data;
421 /* List of font-drivers available on the frame. */
422 struct font_driver_list *font_driver_list;
424 /* Total width of fringes reserved for drawing truncation bitmaps,
425 continuation bitmaps and alike. The width is in canonical char
426 units of the frame. This must currently be the case because window
427 sizes aren't pixel values. If it weren't the case, we wouldn't be
428 able to split windows horizontally nicely. */
429 int fringe_cols;
431 /* The extra width (in pixels) currently allotted for fringes. */
432 int left_fringe_width, right_fringe_width;
434 /* Number of lines of menu bar. */
435 int menu_bar_lines;
437 /* Pixel height of menubar. */
438 int menu_bar_height;
440 #if defined (HAVE_X_WINDOWS)
441 /* Used by x_wait_for_event when watching for an X event on this frame. */
442 int wait_event_type;
443 #endif
445 /* What kind of text cursor should we draw in the future?
446 This should always be filled_box_cursor or bar_cursor. */
447 enum text_cursor_kinds desired_cursor;
449 /* Width of bar cursor (if we are using that). */
450 int cursor_width;
452 /* What kind of text cursor should we draw when the cursor blinks off?
453 This can be filled_box_cursor or bar_cursor or no_cursor. */
454 enum text_cursor_kinds blink_off_cursor;
456 /* Width of bar cursor (if we are using that) for blink-off state. */
457 int blink_off_cursor_width;
459 /* Configured width of the scroll bar, in pixels and in characters.
460 config_scroll_bar_cols tracks config_scroll_bar_width if the
461 latter is positive; a zero value in config_scroll_bar_width means
462 to compute the actual width on the fly, using config_scroll_bar_cols
463 and the current font width. */
464 int config_scroll_bar_width;
465 int config_scroll_bar_cols;
467 /* The baud rate that was used to calculate costs for this frame. */
468 int cost_calculation_baud_rate;
470 /* Frame opacity
471 alpha[0]: alpha transparency of the active frame
472 alpha[1]: alpha transparency of inactive frames
473 Negative values mean not to change alpha. */
474 double alpha[2];
476 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
477 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
478 frame parameter. 0 means don't do gamma correction. */
479 double gamma;
481 /* Additional space to put between text lines on this frame. */
482 int extra_line_spacing;
484 /* All display backends seem to need these two pixel values. */
485 unsigned long background_pixel;
486 unsigned long foreground_pixel;
489 /* Most code should use these functions to set Lisp fields in struct frame. */
491 INLINE void
492 fset_buffer_list (struct frame *f, Lisp_Object val)
494 f->buffer_list = val;
496 INLINE void
497 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
499 f->buried_buffer_list = val;
501 INLINE void
502 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
504 f->condemned_scroll_bars = val;
506 INLINE void
507 fset_face_alist (struct frame *f, Lisp_Object val)
509 f->face_alist = val;
511 INLINE void
512 fset_focus_frame (struct frame *f, Lisp_Object val)
514 f->focus_frame = val;
516 INLINE void
517 fset_icon_name (struct frame *f, Lisp_Object val)
519 f->icon_name = val;
521 INLINE void
522 fset_menu_bar_items (struct frame *f, Lisp_Object val)
524 f->menu_bar_items = val;
526 INLINE void
527 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
529 f->menu_bar_vector = val;
531 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
532 INLINE void
533 fset_menu_bar_window (struct frame *f, Lisp_Object val)
535 f->menu_bar_window = val;
537 #endif
538 INLINE void
539 fset_name (struct frame *f, Lisp_Object val)
541 f->name = val;
543 INLINE void
544 fset_param_alist (struct frame *f, Lisp_Object val)
546 f->param_alist = val;
548 INLINE void
549 fset_root_window (struct frame *f, Lisp_Object val)
551 f->root_window = val;
553 INLINE void
554 fset_scroll_bars (struct frame *f, Lisp_Object val)
556 f->scroll_bars = val;
558 INLINE void
559 fset_selected_window (struct frame *f, Lisp_Object val)
561 f->selected_window = val;
563 INLINE void
564 fset_title (struct frame *f, Lisp_Object val)
566 f->title = val;
568 INLINE void
569 fset_tool_bar_items (struct frame *f, Lisp_Object val)
571 f->tool_bar_items = val;
573 #ifdef USE_GTK
574 INLINE void
575 fset_tool_bar_position (struct frame *f, Lisp_Object val)
577 f->tool_bar_position = val;
579 #endif /* USE_GTK */
580 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
581 INLINE void
582 fset_tool_bar_window (struct frame *f, Lisp_Object val)
584 f->tool_bar_window = val;
586 INLINE void
587 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
589 f->current_tool_bar_string = val;
591 INLINE void
592 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
594 f->desired_tool_bar_string = val;
596 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
598 #define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
600 INLINE double
601 default_pixels_per_inch_x (void)
603 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
604 ? XCAR (Vdisplay_pixels_per_inch)
605 : Vdisplay_pixels_per_inch);
606 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
609 INLINE double
610 default_pixels_per_inch_y (void)
612 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
613 ? XCDR (Vdisplay_pixels_per_inch)
614 : Vdisplay_pixels_per_inch);
615 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
618 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
620 /* Return a pointer to the image cache of frame F. */
621 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
623 #define XFRAME(p) \
624 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
625 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
627 /* Given a window, return its frame as a Lisp_Object. */
628 #define WINDOW_FRAME(w) ((w)->frame)
630 /* Test a frame for particular kinds of display methods. */
631 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
632 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
633 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
634 #ifndef HAVE_NTGUI
635 #define FRAME_W32_P(f) false
636 #else
637 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
638 #endif
639 #ifndef MSDOS
640 #define FRAME_MSDOS_P(f) false
641 #else
642 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
643 #endif
644 #ifndef HAVE_NS
645 #define FRAME_NS_P(f) false
646 #else
647 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
648 #endif
650 /* FRAME_WINDOW_P tests whether the frame is a window, and is
651 defined to be the predicate for the window system being used. */
653 #ifdef HAVE_X_WINDOWS
654 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
655 #endif
656 #ifdef HAVE_NTGUI
657 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
658 #endif
659 #ifdef HAVE_NS
660 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
661 #endif
662 #ifndef FRAME_WINDOW_P
663 #define FRAME_WINDOW_P(f) ((void) (f), false)
664 #endif
666 /* Dots per inch of the screen the frame F is on. */
668 #ifdef HAVE_WINDOW_SYSTEM
670 #define FRAME_RES_X(f) \
671 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
672 #define FRAME_RES_Y(f) \
673 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
675 #else /* !HAVE_WINDOW_SYSTEM */
677 /* Defaults when no window system available. */
679 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
680 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
682 #endif /* HAVE_WINDOW_SYSTEM */
684 /* Return a pointer to the structure holding information about the
685 region of text, if any, that is currently shown in mouse-face on
686 frame F. We need to define two versions because a TTY-only build
687 does not have FRAME_DISPLAY_INFO. */
688 #ifdef HAVE_WINDOW_SYSTEM
689 # define MOUSE_HL_INFO(F) \
690 (FRAME_WINDOW_P(F) \
691 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
692 : &(F)->output_data.tty->display_info->mouse_highlight)
693 #else
694 # define MOUSE_HL_INFO(F) \
695 (&(F)->output_data.tty->display_info->mouse_highlight)
696 #endif
698 /* True if frame F is still alive (not deleted). */
699 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
701 /* True if frame F is a minibuffer-only frame. */
702 #define FRAME_MINIBUF_ONLY_P(f) \
703 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
705 /* True if frame F contains it's own minibuffer window. Frame always has
706 minibuffer window, but it could use minibuffer window of another frame. */
707 #define FRAME_HAS_MINIBUF_P(f) \
708 (WINDOWP (f->minibuffer_window) \
709 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
711 /* Pixel width of frame F. */
712 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
714 /* Pixel height of frame F, including non-toolkit menu bar and
715 non-toolkit tool bar lines. */
716 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
718 /* Width of frame F, measured in canonical character columns,
719 not including scroll bars if any. */
720 #define FRAME_COLS(f) (f)->text_cols
722 /* Height of frame F, measured in canonical lines, including
723 non-toolkit menu bar and non-toolkit tool bar lines. */
724 #define FRAME_LINES(f) (f)->text_lines
726 /* Width of frame F, measured in pixels not including the width for
727 fringes, scroll bar, and internal borders. */
728 #define FRAME_TEXT_WIDTH(f) (f)->text_width
730 /* Height of frame F, measured in pixels not including the height
731 for internal borders. */
732 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
734 /* Number of lines of frame F used for menu bar.
735 This is relevant on terminal frames and on
736 X Windows when not using the X toolkit.
737 These lines are counted in FRAME_LINES. */
738 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
740 /* Pixel height of frame F's menu bar. */
741 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
743 /* True if this frame should display a tool bar
744 in a way that does not use any text lines. */
745 #if defined (USE_GTK) || defined (HAVE_NS)
746 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
747 #else
748 #define FRAME_EXTERNAL_TOOL_BAR(f) false
749 #endif
751 /* This is really supported only with GTK. */
752 #ifdef USE_GTK
753 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
754 #else
755 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
756 #endif
758 /* Number of lines of frame F used for the tool-bar. */
759 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
761 /* Pixel height of frame F's tool-bar. */
762 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
764 /* Lines above the top-most window in frame F. */
765 #define FRAME_TOP_MARGIN(F) \
766 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
768 /* Pixel height of frame F's top margin. */
769 #define FRAME_TOP_MARGIN_HEIGHT(F) \
770 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
772 /* True if this frame should display a menu bar
773 in a way that does not use any text lines. */
774 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
775 || defined (HAVE_NS) || defined (USE_GTK)
776 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
777 #else
778 #define FRAME_EXTERNAL_MENU_BAR(f) false
779 #endif
780 #define FRAME_VISIBLE_P(f) (f)->visible
782 /* True if frame F is currently visible but hidden. */
783 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
785 /* True if frame F is currently iconified. */
786 #define FRAME_ICONIFIED_P(f) (f)->iconified
788 /* Mark frame F as currently garbaged. */
789 #define SET_FRAME_GARBAGED(f) \
790 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
792 /* True if frame F is currently garbaged. */
793 #define FRAME_GARBAGED_P(f) (f)->garbaged
795 /* True means do not allow splitting this frame's window. */
796 #define FRAME_NO_SPLIT_P(f) (f)->no_split
798 /* Not really implemented. */
799 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
801 /* True if all windows except selected window and mini window
802 are frozen on frame F. */
803 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
805 /* True if a size change has been requested for frame F
806 but not yet really put into effect. This can be true temporarily
807 when an X event comes in at a bad time. */
808 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
810 /* The minibuffer window of frame F, if it has one; otherwise nil. */
811 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
813 /* The root window of the window tree of frame F. */
814 #define FRAME_ROOT_WINDOW(f) f->root_window
816 /* The currently selected window of the window tree of frame F. */
817 #define FRAME_SELECTED_WINDOW(f) f->selected_window
819 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
820 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
821 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
822 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
823 #define FRAME_FOCUS_FRAME(f) f->focus_frame
825 #ifdef HAVE_WINDOW_SYSTEM
827 /* This frame slot says whether scroll bars are currently enabled for frame F,
828 and which side they are on. */
829 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
830 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
831 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
832 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
833 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
834 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
835 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
837 #else /* not HAVE_WINDOW_SYSTEM */
839 /* If there is no window system, there are no scroll bars. */
840 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
841 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
842 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
843 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
845 #endif /* HAVE_WINDOW_SYSTEM */
847 /* Width that a scroll bar in frame F should have, if there is one.
848 Measured in pixels.
849 If scroll bars are turned off, this is still nonzero. */
850 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
852 /* Width that a scroll bar in frame F should have, if there is one.
853 Measured in columns (characters).
854 If scroll bars are turned off, this is still nonzero. */
855 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
857 /* Width of a scroll bar in frame F, measured in columns (characters),
858 but only if scroll bars are on the left. If scroll bars are on
859 the right in this frame, or there are no scroll bars, value is 0. */
861 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
862 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
863 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
864 : 0)
866 /* Width of a left scroll bar in frame F, measured in pixels */
868 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
869 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
870 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
871 : 0)
873 /* Width of a scroll bar in frame F, measured in columns (characters),
874 but only if scroll bars are on the right. If scroll bars are on
875 the left in this frame, or there are no scroll bars, value is 0. */
877 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
878 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
879 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
880 : 0)
882 /* Width of a right scroll bar area in frame F, measured in pixels */
884 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
885 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
886 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
887 : 0)
889 /* Actual width of a scroll bar in frame F, measured in columns. */
891 #define FRAME_SCROLL_BAR_COLS(f) \
892 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
893 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
894 : 0)
896 /* Actual width of a scroll bar area in frame F, measured in pixels. */
898 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
899 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
900 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
901 : 0)
903 /* Total width of frame F, in columns (characters),
904 including the width used by scroll bars if any. */
905 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
907 /* Set the character widths of frame F. WIDTH specifies a nominal
908 character text width. */
909 #define SET_FRAME_COLS(f, width) \
910 ((f)->text_cols = (width), \
911 (f)->total_cols = ((width) \
912 + FRAME_SCROLL_BAR_COLS (f) \
913 + FRAME_FRINGE_COLS (f)))
915 /* Set the pixel widths of frame F. WIDTH specifies a nominal pixel
916 text width. */
917 #define SET_FRAME_WIDTH(f, width) \
918 ((f)->text_width = (width), \
919 (f)->pixel_width = ((width) \
920 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
921 + FRAME_TOTAL_FRINGE_WIDTH (f) \
922 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
924 /* Set the pixel heights of frame F. HEIGHT specifies a nominal pixel
925 text width. */
926 #define SET_FRAME_HEIGHT(f, height) \
927 ((f)->text_height = (height), \
928 (f)->pixel_height = ((height) \
929 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
931 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
933 #define FRAME_CURSOR_X_LIMIT(f) \
934 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
936 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
938 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
939 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
940 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
942 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
943 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
944 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
945 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
947 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
948 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
950 /* Return a pointer to the face cache of frame F. */
952 #define FRAME_FACE_CACHE(F) (F)->face_cache
954 /* Return the size of message_buf of the frame F. We multiply the
955 width of the frame by 4 because multi-byte form may require at most
956 4-byte for a character. */
958 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
960 #define CHECK_FRAME(x) \
961 CHECK_TYPE (FRAMEP (x), Qframep, x)
963 #define CHECK_LIVE_FRAME(x) \
964 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
966 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
967 `for' loop which iterates over the elements of Vframe_list. The
968 loop will set FRAME_VAR, a Lisp_Object, to each frame in
969 Vframe_list in succession and execute the statement. LIST_VAR
970 should be a Lisp_Object too; it is used to iterate through the
971 Vframe_list.
973 This macro is a holdover from a time when multiple frames weren't always
974 supported. An alternate definition of the macro would expand to
975 something which executes the statement once. */
977 #define FOR_EACH_FRAME(list_var, frame_var) \
978 for ((list_var) = Vframe_list; \
979 (CONSP (list_var) \
980 && (frame_var = XCAR (list_var), true)); \
981 list_var = XCDR (list_var))
983 /* Reflect mouse movement when a complete frame update is performed. */
985 #define FRAME_MOUSE_UPDATE(frame) \
986 do { \
987 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
988 if (frame == hlinfo->mouse_face_mouse_frame) \
990 block_input (); \
991 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
992 hlinfo->mouse_face_mouse_x, \
993 hlinfo->mouse_face_mouse_y); \
994 unblock_input (); \
996 } while (false)
998 /* False means there are no visible garbaged frames. */
999 extern bool frame_garbaged;
1001 /* Set visibility of frame F.
1002 We call redisplay_other_windows to make sure the frame gets redisplayed
1003 if some changes were applied to it while it wasn't visible (and hence
1004 wasn't redisplayed). */
1006 INLINE void
1007 SET_FRAME_VISIBLE (struct frame *f, int v)
1009 eassert (0 <= v && v <= 2);
1010 if (v)
1012 if (v == 1 && f->visible != 1)
1013 redisplay_other_windows ();
1014 if (FRAME_GARBAGED_P (f))
1015 frame_garbaged = true;
1017 f->visible = v;
1020 /* Set iconify of frame F. */
1022 #define SET_FRAME_ICONIFIED(f, i) \
1023 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1025 extern Lisp_Object selected_frame;
1026 extern Lisp_Object Qframep, Qframe_live_p;
1027 extern Lisp_Object Qtty, Qtty_type;
1028 extern Lisp_Object Qtty_color_mode;
1029 extern Lisp_Object Qterminal;
1030 extern Lisp_Object Qnoelisp;
1032 extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1033 extern struct frame *decode_window_system_frame (Lisp_Object);
1034 extern struct frame *decode_live_frame (Lisp_Object);
1035 extern struct frame *decode_any_frame (Lisp_Object);
1036 extern struct frame *make_initial_frame (void);
1037 extern struct frame *make_frame (bool);
1038 #ifdef HAVE_WINDOW_SYSTEM
1039 extern struct frame *make_minibuffer_frame (void);
1040 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1041 struct kboard *,
1042 Lisp_Object);
1043 extern bool window_system_available (struct frame *);
1044 #else /* not HAVE_WINDOW_SYSTEM */
1045 #define window_system_available(f) ((void) (f), false)
1046 #endif /* HAVE_WINDOW_SYSTEM */
1047 extern void check_window_system (struct frame *);
1048 extern void frame_make_pointer_invisible (struct frame *);
1049 extern void frame_make_pointer_visible (struct frame *);
1050 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1052 extern Lisp_Object Vframe_list;
1054 /* Value is a pointer to the selected frame. If the selected frame
1055 isn't live, abort. */
1057 #define SELECTED_FRAME() \
1058 ((FRAMEP (selected_frame) \
1059 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1060 ? XFRAME (selected_frame) \
1061 : (emacs_abort (), (struct frame *) 0))
1064 /***********************************************************************
1065 Display-related Macros
1066 ***********************************************************************/
1068 /* Canonical y-unit on frame F.
1069 This value currently equals the line height of the frame (which is
1070 the height of the default font of F). */
1072 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1074 /* Canonical x-unit on frame F.
1075 This value currently equals the average width of the default font of F. */
1077 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1079 /* Pixel width of areas used to display truncation marks, continuation
1080 marks, overlay arrows. This is 0 for terminal frames. */
1082 #ifdef HAVE_WINDOW_SYSTEM
1084 /* Total width of fringes reserved for drawing truncation bitmaps,
1085 continuation bitmaps and alike. The width is in canonical char
1086 units of the frame. This must currently be the case because window
1087 sizes aren't pixel values. If it weren't the case, we wouldn't be
1088 able to split windows horizontally nicely. */
1090 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
1092 /* Pixel-width of the left and right fringe. */
1094 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
1095 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
1097 /* Total width of fringes in pixels. */
1099 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
1100 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
1102 /* Pixel-width of internal border lines */
1103 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
1105 /* Pixel-size of window border lines */
1106 #define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width)
1107 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width)
1109 #else /* not HAVE_WINDOW_SYSTEM */
1111 #define FRAME_FRINGE_COLS(F) 0
1112 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
1113 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
1114 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
1115 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
1116 #define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1117 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1119 #endif /* not HAVE_WINDOW_SYSTEM */
1121 /***********************************************************************
1122 Conversion between canonical units and pixels
1123 ***********************************************************************/
1125 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1126 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1127 represented as Lisp numbers, i.e. integers or floats. */
1129 /* Convert canonical value X to pixels. F is the frame whose
1130 canonical char width is to be used. X must be a Lisp integer or
1131 float. Value is a C integer. */
1133 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1134 (INTEGERP (X) \
1135 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1136 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1138 /* Convert canonical value Y to pixels. F is the frame whose
1139 canonical character height is to be used. X must be a Lisp integer
1140 or float. Value is a C integer. */
1142 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1143 (INTEGERP (Y) \
1144 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1145 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1147 /* Convert pixel-value X to canonical units. F is the frame whose
1148 canonical character width is to be used. X is a C integer. Result
1149 is a Lisp float if X is not a multiple of the canon width,
1150 otherwise it's a Lisp integer. */
1152 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1153 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1154 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1155 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1157 /* Convert pixel-value Y to canonical units. F is the frame whose
1158 canonical character height is to be used. Y is a C integer.
1159 Result is a Lisp float if Y is not a multiple of the canon width,
1160 otherwise it's a Lisp integer. */
1162 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1163 ((Y) % FRAME_LINE_HEIGHT (F) \
1164 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1165 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1169 /* Manipulating pixel sizes and character sizes.
1170 Knowledge of which factors affect the overall size of the window should
1171 be hidden in these macros, if that's possible.
1173 Return the upper/left pixel position of the character cell on frame F
1174 at ROW/COL. */
1176 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1177 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1178 + (row) * FRAME_LINE_HEIGHT (f))
1180 #define FRAME_COL_TO_PIXEL_X(f, col) \
1181 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1182 + (col) * FRAME_COLUMN_WIDTH (f))
1184 /* Return the pixel width/height of frame F if it has
1185 COLS columns/LINES rows. */
1187 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1188 (FRAME_COL_TO_PIXEL_X (f, cols) \
1189 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1190 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1191 + FRAME_INTERNAL_BORDER_WIDTH (f))
1193 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1194 ((lines) * FRAME_LINE_HEIGHT (f) \
1195 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1197 /* Return the row/column (zero-based) of the character cell containing
1198 the pixel on FRAME at Y/X. */
1200 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1201 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1202 ? (y) \
1203 : ((y) < FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1204 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1205 /* Arrange for the division to round down. */ \
1206 + FRAME_LINE_HEIGHT (f) - 1) \
1207 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1208 / FRAME_LINE_HEIGHT (f))
1210 #define FRAME_PIXEL_X_TO_COL(f, x) \
1211 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1212 / FRAME_COLUMN_WIDTH (f))
1214 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1215 frame F? */
1217 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1218 (FRAME_PIXEL_X_TO_COL (f, ((width) \
1219 - FRAME_INTERNAL_BORDER_WIDTH (f) \
1220 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1221 - FRAME_SCROLL_BAR_AREA_WIDTH (f)))) \
1223 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1224 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
1225 - FRAME_INTERNAL_BORDER_WIDTH (f))))
1227 /* Return the pixel width/height of frame F with a text size of
1228 width/height. */
1230 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1231 ((width) \
1232 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1233 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1234 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1236 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1237 ((height) + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1239 /* Return the text width/height of frame F with a pixel size of
1240 width/height. */
1242 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1243 ((width) \
1244 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1245 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1246 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1248 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1249 ((height) - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1251 /* Value is the smallest width of any character in any font on frame F. */
1253 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1254 FRAME_DISPLAY_INFO (f)->smallest_char_width
1256 /* Value is the smallest height of any font on frame F. */
1258 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1259 FRAME_DISPLAY_INFO (f)->smallest_font_height
1261 /***********************************************************************
1262 Frame Parameters
1263 ***********************************************************************/
1265 extern Lisp_Object Qauto_raise, Qauto_lower;
1266 extern Lisp_Object Qborder_color, Qborder_width;
1267 extern Lisp_Object Qbuffer_predicate;
1268 extern Lisp_Object Qcursor_color, Qcursor_type;
1269 extern Lisp_Object Qfont;
1270 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1271 extern Lisp_Object Qinternal_border_width;
1272 extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
1273 extern Lisp_Object Qtooltip;
1274 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
1275 extern Lisp_Object Qmouse_color;
1276 extern Lisp_Object Qname, Qtitle;
1277 extern Lisp_Object Qparent_id;
1278 extern Lisp_Object Qunsplittable, Qvisibility;
1279 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1280 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1281 extern Lisp_Object Qscreen_gamma;
1282 extern Lisp_Object Qline_spacing;
1283 extern Lisp_Object Qwait_for_wm;
1284 extern Lisp_Object Qfullscreen;
1285 extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
1286 extern Lisp_Object Qsticky;
1287 extern Lisp_Object Qfont_backend;
1288 extern Lisp_Object Qalpha;
1290 extern Lisp_Object Qleft_fringe, Qright_fringe;
1291 extern Lisp_Object Qheight, Qwidth;
1292 extern Lisp_Object Qminibuffer, Qmodeline;
1293 extern Lisp_Object Qx, Qw32, Qpc, Qns;
1294 extern Lisp_Object Qvisible;
1295 extern Lisp_Object Qdisplay_type;
1297 extern Lisp_Object Qx_resource_name;
1299 extern Lisp_Object Qtop, Qbox, Qbottom;
1300 extern Lisp_Object Qdisplay;
1302 extern Lisp_Object Qrun_hook_with_args;
1304 #ifdef HAVE_WINDOW_SYSTEM
1306 /* The class of this X application. */
1307 #define EMACS_CLASS "Emacs"
1309 /* These are in xterm.c, w32term.c, etc. */
1311 extern void x_set_scroll_bar_default_width (struct frame *);
1312 extern void x_set_offset (struct frame *, int, int, int);
1313 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1315 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1318 extern Lisp_Object Qface_set_after_frame_default;
1320 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1322 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1323 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1324 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1325 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1326 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1327 extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object);
1328 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1329 extern void x_set_internal_border_width (struct frame *, Lisp_Object,
1330 Lisp_Object);
1331 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1332 Lisp_Object);
1333 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1334 Lisp_Object);
1335 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1336 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1337 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1338 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1339 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object,
1340 Lisp_Object);
1341 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object,
1342 Lisp_Object);
1344 extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
1346 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1348 extern void validate_x_resource_name (void);
1350 extern Lisp_Object display_x_get_resource (Display_Info *,
1351 Lisp_Object attribute,
1352 Lisp_Object class,
1353 Lisp_Object component,
1354 Lisp_Object subclass);
1356 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1357 extern void x_set_window_size (struct frame *f, int change_grav,
1358 int width, int height, bool pixelwise);
1359 extern Lisp_Object x_get_focus_frame (struct frame *);
1360 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1361 extern void x_make_frame_visible (struct frame *f);
1362 extern void x_make_frame_invisible (struct frame *f);
1363 extern void x_iconify_frame (struct frame *f);
1364 extern void x_set_frame_alpha (struct frame *f);
1365 extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1366 extern void x_activate_menubar (struct frame *);
1367 extern void x_real_positions (struct frame *, int *, int *);
1368 extern void free_frame_menubar (struct frame *);
1369 extern void x_free_frame_resources (struct frame *);
1371 #if defined HAVE_X_WINDOWS
1372 extern void x_wm_set_icon_position (struct frame *, int, int);
1373 #if !defined USE_X_TOOLKIT
1374 extern char *x_get_resource_string (const char *, const char *);
1375 #endif
1376 extern void x_sync (struct frame *);
1377 #endif /* HAVE_X_WINDOWS */
1379 extern void x_query_colors (struct frame *f, XColor *, int);
1380 extern void x_query_color (struct frame *f, XColor *);
1381 extern void x_focus_frame (struct frame *);
1383 #ifndef HAVE_NS
1385 extern int x_bitmap_icon (struct frame *, Lisp_Object);
1387 /* Set F's bitmap icon, if specified among F's parameters. */
1389 INLINE void
1390 x_set_bitmap_icon (struct frame *f)
1392 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1394 if (CONSP (obj))
1395 x_bitmap_icon (f, XCDR (obj));
1398 #endif /* !HAVE_NS */
1399 #endif /* HAVE_WINDOW_SYSTEM */
1401 INLINE void
1402 flush_frame (struct frame *f)
1404 struct redisplay_interface *rif = FRAME_RIF (f);
1406 if (rif && rif->flush_display)
1407 rif->flush_display (f);
1410 /***********************************************************************
1411 Multimonitor data
1412 ***********************************************************************/
1414 #ifdef HAVE_WINDOW_SYSTEM
1416 struct MonitorInfo {
1417 XRectangle geom, work;
1418 int mm_width, mm_height;
1419 char *name;
1422 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1423 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1424 int n_monitors,
1425 int primary_monitor,
1426 Lisp_Object monitor_frames,
1427 const char *source);
1429 #endif /* HAVE_WINDOW_SYSTEM */
1432 INLINE_HEADER_END
1434 #endif /* not EMACS_FRAME_H */