Fix last commit in w32term.c.
[emacs.git] / src / frame.h
blob999a29d56ae96ac7f68d91b5c22a9002c8722126
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 #ifdef USE_X_TOOLKIT
196 /* Used to pass geometry parameters to toolkit functions. */
197 char *shell_position;
198 #endif
200 /* Glyph pool and matrix. */
201 struct glyph_pool *current_pool;
202 struct glyph_pool *desired_pool;
203 struct glyph_matrix *desired_matrix;
204 struct glyph_matrix *current_matrix;
206 /* Bitfield area begins here. Keep them together to avoid extra padding. */
208 /* True means that glyphs on this frame have been initialized so it can
209 be used for output. */
210 bool_bf glyphs_initialized_p : 1;
212 /* Set to true in change_frame_size when size of frame changed
213 Clear the frame in clear_garbaged_frames if set. */
214 bool_bf resized_p : 1;
216 /* Set to true if the default face for the frame has been
217 realized. Reset to zero whenever the default face changes.
218 Used to see the difference between a font change and face change. */
219 bool_bf default_face_done_p : 1;
221 /* Set to true if this frame has already been hscrolled during
222 current redisplay. */
223 bool_bf already_hscrolled_p : 1;
225 /* Set to true when current redisplay has updated frame. */
226 bool_bf updated_p : 1;
228 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
229 /* Set to true to minimize tool-bar height even when
230 auto-resize-tool-bar is set to grow-only. */
231 bool_bf minimize_tool_bar_window_p : 1;
232 #endif
234 #if defined (USE_GTK) || defined (HAVE_NS)
235 /* True means using a tool bar that comes from the toolkit. */
236 bool_bf external_tool_bar : 1;
237 #endif
239 /* True means that fonts have been loaded since the last glyph
240 matrix adjustments. */
241 bool_bf fonts_changed : 1;
243 /* True means that cursor type has been changed. */
244 bool_bf cursor_type_changed : 1;
246 /* True if it needs to be redisplayed. */
247 bool_bf redisplay : 1;
249 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
250 || defined (HAVE_NS) || defined (USE_GTK)
251 /* True means using a menu bar that comes from the X toolkit. */
252 bool_bf external_menu_bar : 1;
253 #endif
255 /* Next two bitfields are mutually exclusive. They might both be
256 zero if the frame has been made invisible without an icon. */
258 /* Nonzero if the frame is currently displayed; we check
259 it to see if we should bother updating the frame's contents.
261 On ttys and on Windows NT/9X, to avoid wasting effort updating
262 visible frames that are actually completely obscured by other
263 windows on the display, we bend the meaning of visible slightly:
264 if equal to 2, then the frame is obscured - we still consider
265 it to be "visible" as seen from lisp, but we don't bother
266 updating it. */
267 unsigned visible : 2;
269 /* True if the frame is currently iconified. Do not
270 set this directly, use SET_FRAME_ICONIFIED instead. */
271 bool_bf iconified : 1;
273 /* True if this frame should be fully redisplayed. Disables all
274 optimizations while rebuilding matrices and redrawing. */
275 bool_bf garbaged : 1;
277 /* False means, if this frame has just one window,
278 show no modeline for that window. */
279 bool_bf wants_modeline : 1;
281 /* True means raise this frame to the top of the heap when selected. */
282 bool_bf auto_raise : 1;
284 /* True means lower this frame to the bottom of the stack when left. */
285 bool_bf auto_lower : 1;
287 /* True if frame's root window can't be split. */
288 bool_bf no_split : 1;
290 /* If this is set, then Emacs won't change the frame name to indicate
291 the current buffer, etcetera. If the user explicitly sets the frame
292 name, this gets set. If the user sets the name to Qnil, this is
293 cleared. */
294 bool_bf explicit_name : 1;
296 /* True if size of some window on this frame has changed. */
297 bool_bf window_sizes_changed : 1;
299 /* True if the mouse has moved on this display device
300 since the last time we checked. */
301 bool_bf mouse_moved : 1;
303 /* True means that the pointer is invisible. */
304 bool_bf pointer_invisible : 1;
306 /* True means that all windows except mini-window and
307 selected window on this frame have frozen window starts. */
308 bool_bf frozen_window_starts : 1;
310 /* The output method says how the contents of this frame are
311 displayed. It could be using termcap, or using an X window.
312 This must be the same as the terminal->type. */
313 ENUM_BF (output_method) output_method : 3;
315 #ifdef HAVE_WINDOW_SYSTEM
317 /* See FULLSCREEN_ enum on top. */
318 ENUM_BF (fullscreen_type) want_fullscreen : 4;
320 /* If not vertical_scroll_bar_none, we should actually
321 display the scroll bars of this type on this frame. */
322 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
324 #endif /* HAVE_WINDOW_SYSTEM */
326 /* Bitfield area ends here. */
328 /* Margin at the top of the frame. Used to display the tool-bar. */
329 int tool_bar_lines;
331 /* Pixel height of tool bar. */
332 int tool_bar_height;
334 int n_tool_bar_rows;
335 int n_tool_bar_items;
337 /* A buffer for decode_mode_line. */
338 char *decode_mode_spec_buffer;
340 /* See do_line_insertion_deletion_costs for info on these arrays. */
341 /* Cost of inserting 1 line on this frame. */
342 int *insert_line_cost;
343 /* Cost of deleting 1 line on this frame. */
344 int *delete_line_cost;
345 /* Cost of inserting n lines on this frame. */
346 int *insert_n_lines_cost;
347 /* Cost of deleting n lines on this frame. */
348 int *delete_n_lines_cost;
350 /* Text width of this frame (excluding fringes, scroll bars and
351 internal border width) and text height (excluding internal border
352 width) in units of canonical characters. */
353 int text_cols, text_lines;
355 /* Total width of this frame (including fringes and scroll bars) in
356 units of canonical characters. */
357 int total_cols;
359 /* Text width of this frame (excluding fringes, scroll bars and
360 internal border width) and text height (excluding internal border
361 width) in pixels. */
362 int text_width, text_height;
364 /* New text height and width for pending size change. 0 if no change
365 pending. These values represent pixels or canonical character units
366 according to the value of new_pixelwise and correlate to the the
367 text width/height of the frame. */
368 int new_width, new_height;
370 /* Whether new_height and new_width shall be interpreted
371 in pixels. */
372 bool new_pixelwise;
374 /* Pixel position of the frame window (x and y offsets in root window). */
375 int left_pos, top_pos;
377 /* Size of the frame window (including internal border widths) in
378 pixels. */
379 int pixel_width, pixel_height;
381 /* These many pixels are the difference between the outer window (i.e. the
382 left and top of the window manager decoration) and FRAME_X_WINDOW. */
383 int x_pixels_diff, y_pixels_diff;
385 /* This is the gravity value for the specified window position. */
386 int win_gravity;
388 /* The geometry flags for this window. */
389 int size_hint_flags;
391 /* Border width of the frame window as known by the (X) window system. */
392 int border_width;
394 /* Width of the internal border. This is a line of background color
395 just inside the window's border. When the frame is selected,
396 a highlighting is displayed inside the internal border. */
397 int internal_border_width;
399 /* Width of borders between this frame's windows. */
400 int right_divider_width;
401 int bottom_divider_width;
403 /* Canonical X unit. Width of default font, in pixels. */
404 int column_width;
406 /* Canonical Y unit. Height of a line, in pixels. */
407 int line_height;
409 /* The terminal device that this frame uses. If this is NULL, then
410 the frame has been deleted. */
411 struct terminal *terminal;
413 /* Device-dependent, frame-local auxiliary data used for displaying
414 the contents. When the frame is deleted, this data is deleted as
415 well. */
416 union output_data
418 struct tty_output *tty; /* From termchar.h. */
419 struct x_output *x; /* From xterm.h. */
420 struct w32_output *w32; /* From w32term.h. */
421 struct ns_output *ns; /* From nsterm.h. */
422 intptr_t nothing;
424 output_data;
426 /* List of font-drivers available on the frame. */
427 struct font_driver_list *font_driver_list;
429 /* Total width of fringes reserved for drawing truncation bitmaps,
430 continuation bitmaps and alike. The width is in canonical char
431 units of the frame. This must currently be the case because window
432 sizes aren't pixel values. If it weren't the case, we wouldn't be
433 able to split windows horizontally nicely. */
434 int fringe_cols;
436 /* The extra width (in pixels) currently allotted for fringes. */
437 int left_fringe_width, right_fringe_width;
439 /* Number of lines of menu bar. */
440 int menu_bar_lines;
442 /* Pixel height of menubar. */
443 int menu_bar_height;
445 #if defined (HAVE_X_WINDOWS)
446 /* Used by x_wait_for_event when watching for an X event on this frame. */
447 int wait_event_type;
448 #endif
450 /* What kind of text cursor should we draw in the future?
451 This should always be filled_box_cursor or bar_cursor. */
452 enum text_cursor_kinds desired_cursor;
454 /* Width of bar cursor (if we are using that). */
455 int cursor_width;
457 /* What kind of text cursor should we draw when the cursor blinks off?
458 This can be filled_box_cursor or bar_cursor or no_cursor. */
459 enum text_cursor_kinds blink_off_cursor;
461 /* Width of bar cursor (if we are using that) for blink-off state. */
462 int blink_off_cursor_width;
464 /* Configured width of the scroll bar, in pixels and in characters.
465 config_scroll_bar_cols tracks config_scroll_bar_width if the
466 latter is positive; a zero value in config_scroll_bar_width means
467 to compute the actual width on the fly, using config_scroll_bar_cols
468 and the current font width. */
469 int config_scroll_bar_width;
470 int config_scroll_bar_cols;
472 /* The baud rate that was used to calculate costs for this frame. */
473 int cost_calculation_baud_rate;
475 /* Frame opacity
476 alpha[0]: alpha transparency of the active frame
477 alpha[1]: alpha transparency of inactive frames
478 Negative values mean not to change alpha. */
479 double alpha[2];
481 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
482 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
483 frame parameter. 0 means don't do gamma correction. */
484 double gamma;
486 /* Additional space to put between text lines on this frame. */
487 int extra_line_spacing;
489 /* All display backends seem to need these two pixel values. */
490 unsigned long background_pixel;
491 unsigned long foreground_pixel;
494 /* Most code should use these functions to set Lisp fields in struct frame. */
496 INLINE void
497 fset_buffer_list (struct frame *f, Lisp_Object val)
499 f->buffer_list = val;
501 INLINE void
502 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
504 f->buried_buffer_list = val;
506 INLINE void
507 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
509 f->condemned_scroll_bars = val;
511 INLINE void
512 fset_face_alist (struct frame *f, Lisp_Object val)
514 f->face_alist = val;
516 INLINE void
517 fset_focus_frame (struct frame *f, Lisp_Object val)
519 f->focus_frame = val;
521 INLINE void
522 fset_icon_name (struct frame *f, Lisp_Object val)
524 f->icon_name = val;
526 INLINE void
527 fset_menu_bar_items (struct frame *f, Lisp_Object val)
529 f->menu_bar_items = val;
531 INLINE void
532 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
534 f->menu_bar_vector = val;
536 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
537 INLINE void
538 fset_menu_bar_window (struct frame *f, Lisp_Object val)
540 f->menu_bar_window = val;
542 #endif
543 INLINE void
544 fset_name (struct frame *f, Lisp_Object val)
546 f->name = val;
548 INLINE void
549 fset_param_alist (struct frame *f, Lisp_Object val)
551 f->param_alist = val;
553 INLINE void
554 fset_root_window (struct frame *f, Lisp_Object val)
556 f->root_window = val;
558 INLINE void
559 fset_scroll_bars (struct frame *f, Lisp_Object val)
561 f->scroll_bars = val;
563 INLINE void
564 fset_selected_window (struct frame *f, Lisp_Object val)
566 f->selected_window = val;
568 INLINE void
569 fset_title (struct frame *f, Lisp_Object val)
571 f->title = val;
573 INLINE void
574 fset_tool_bar_items (struct frame *f, Lisp_Object val)
576 f->tool_bar_items = val;
578 #ifdef USE_GTK
579 INLINE void
580 fset_tool_bar_position (struct frame *f, Lisp_Object val)
582 f->tool_bar_position = val;
584 #endif /* USE_GTK */
585 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
586 INLINE void
587 fset_tool_bar_window (struct frame *f, Lisp_Object val)
589 f->tool_bar_window = val;
591 INLINE void
592 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
594 f->current_tool_bar_string = val;
596 INLINE void
597 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
599 f->desired_tool_bar_string = val;
601 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
603 #define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
605 INLINE double
606 default_pixels_per_inch_x (void)
608 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
609 ? XCAR (Vdisplay_pixels_per_inch)
610 : Vdisplay_pixels_per_inch);
611 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
614 INLINE double
615 default_pixels_per_inch_y (void)
617 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
618 ? XCDR (Vdisplay_pixels_per_inch)
619 : Vdisplay_pixels_per_inch);
620 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
623 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
625 /* Return a pointer to the image cache of frame F. */
626 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
628 #define XFRAME(p) \
629 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
630 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
632 /* Given a window, return its frame as a Lisp_Object. */
633 #define WINDOW_FRAME(w) ((w)->frame)
635 /* Test a frame for particular kinds of display methods. */
636 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
637 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
638 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
639 #ifndef HAVE_NTGUI
640 #define FRAME_W32_P(f) false
641 #else
642 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
643 #endif
644 #ifndef MSDOS
645 #define FRAME_MSDOS_P(f) false
646 #else
647 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
648 #endif
649 #ifndef HAVE_NS
650 #define FRAME_NS_P(f) false
651 #else
652 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
653 #endif
655 /* FRAME_WINDOW_P tests whether the frame is a window, and is
656 defined to be the predicate for the window system being used. */
658 #ifdef HAVE_X_WINDOWS
659 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
660 #endif
661 #ifdef HAVE_NTGUI
662 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
663 #endif
664 #ifdef HAVE_NS
665 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
666 #endif
667 #ifndef FRAME_WINDOW_P
668 #define FRAME_WINDOW_P(f) ((void) (f), false)
669 #endif
671 /* Dots per inch of the screen the frame F is on. */
673 #ifdef HAVE_WINDOW_SYSTEM
675 #define FRAME_RES_X(f) \
676 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
677 #define FRAME_RES_Y(f) \
678 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
680 #else /* !HAVE_WINDOW_SYSTEM */
682 /* Defaults when no window system available. */
684 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
685 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
687 #endif /* HAVE_WINDOW_SYSTEM */
689 /* Return a pointer to the structure holding information about the
690 region of text, if any, that is currently shown in mouse-face on
691 frame F. We need to define two versions because a TTY-only build
692 does not have FRAME_DISPLAY_INFO. */
693 #ifdef HAVE_WINDOW_SYSTEM
694 # define MOUSE_HL_INFO(F) \
695 (FRAME_WINDOW_P(F) \
696 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
697 : &(F)->output_data.tty->display_info->mouse_highlight)
698 #else
699 # define MOUSE_HL_INFO(F) \
700 (&(F)->output_data.tty->display_info->mouse_highlight)
701 #endif
703 /* True if frame F is still alive (not deleted). */
704 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
706 /* True if frame F is a minibuffer-only frame. */
707 #define FRAME_MINIBUF_ONLY_P(f) \
708 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
710 /* True if frame F contains it's own minibuffer window. Frame always has
711 minibuffer window, but it could use minibuffer window of another frame. */
712 #define FRAME_HAS_MINIBUF_P(f) \
713 (WINDOWP (f->minibuffer_window) \
714 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
716 /* Pixel width of frame F. */
717 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
719 /* Pixel height of frame F, including non-toolkit menu bar and
720 non-toolkit tool bar lines. */
721 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
723 /* Width of frame F, measured in canonical character columns,
724 not including scroll bars if any. */
725 #define FRAME_COLS(f) (f)->text_cols
727 /* Height of frame F, measured in canonical lines, including
728 non-toolkit menu bar and non-toolkit tool bar lines. */
729 #define FRAME_LINES(f) (f)->text_lines
731 /* Width of frame F, measured in pixels not including the width for
732 fringes, scroll bar, and internal borders. */
733 #define FRAME_TEXT_WIDTH(f) (f)->text_width
735 /* Height of frame F, measured in pixels not including the height
736 for internal borders. */
737 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
739 /* Number of lines of frame F used for menu bar.
740 This is relevant on terminal frames and on
741 X Windows when not using the X toolkit.
742 These lines are counted in FRAME_LINES. */
743 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
745 /* Pixel height of frame F's menu bar. */
746 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
748 /* True if this frame should display a tool bar
749 in a way that does not use any text lines. */
750 #if defined (USE_GTK) || defined (HAVE_NS)
751 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
752 #else
753 #define FRAME_EXTERNAL_TOOL_BAR(f) false
754 #endif
756 /* This is really supported only with GTK. */
757 #ifdef USE_GTK
758 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
759 #else
760 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
761 #endif
763 /* Number of lines of frame F used for the tool-bar. */
764 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
766 /* Pixel height of frame F's tool-bar. */
767 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
769 /* Lines above the top-most window in frame F. */
770 #define FRAME_TOP_MARGIN(F) \
771 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
773 /* Pixel height of frame F's top margin. */
774 #define FRAME_TOP_MARGIN_HEIGHT(F) \
775 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
777 /* True if this frame should display a menu bar
778 in a way that does not use any text lines. */
779 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
780 || defined (HAVE_NS) || defined (USE_GTK)
781 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
782 #else
783 #define FRAME_EXTERNAL_MENU_BAR(f) false
784 #endif
785 #define FRAME_VISIBLE_P(f) (f)->visible
787 /* True if frame F is currently visible but hidden. */
788 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
790 /* True if frame F is currently iconified. */
791 #define FRAME_ICONIFIED_P(f) (f)->iconified
793 /* Mark frame F as currently garbaged. */
794 #define SET_FRAME_GARBAGED(f) \
795 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
797 /* True if frame F is currently garbaged. */
798 #define FRAME_GARBAGED_P(f) (f)->garbaged
800 /* True means do not allow splitting this frame's window. */
801 #define FRAME_NO_SPLIT_P(f) (f)->no_split
803 /* Not really implemented. */
804 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
806 /* True if all windows except selected window and mini window
807 are frozen on frame F. */
808 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
810 /* True if a size change has been requested for frame F
811 but not yet really put into effect. This can be true temporarily
812 when an X event comes in at a bad time. */
813 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
815 /* The minibuffer window of frame F, if it has one; otherwise nil. */
816 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
818 /* The root window of the window tree of frame F. */
819 #define FRAME_ROOT_WINDOW(f) f->root_window
821 /* The currently selected window of the window tree of frame F. */
822 #define FRAME_SELECTED_WINDOW(f) f->selected_window
824 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
825 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
826 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
827 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
828 #define FRAME_FOCUS_FRAME(f) f->focus_frame
830 #ifdef HAVE_WINDOW_SYSTEM
832 /* This frame slot says whether scroll bars are currently enabled for frame F,
833 and which side they are on. */
834 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
835 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
836 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
837 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
838 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
839 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
840 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
842 #else /* not HAVE_WINDOW_SYSTEM */
844 /* If there is no window system, there are no scroll bars. */
845 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
846 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
847 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
848 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
850 #endif /* HAVE_WINDOW_SYSTEM */
852 /* Width that a scroll bar in frame F should have, if there is one.
853 Measured in pixels.
854 If scroll bars are turned off, this is still nonzero. */
855 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
857 /* Width that a scroll bar in frame F should have, if there is one.
858 Measured in columns (characters).
859 If scroll bars are turned off, this is still nonzero. */
860 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
862 /* Width of a scroll bar in frame F, measured in columns (characters),
863 but only if scroll bars are on the left. If scroll bars are on
864 the right in this frame, or there are no scroll bars, value is 0. */
866 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
867 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
868 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
869 : 0)
871 /* Width of a left scroll bar in frame F, measured in pixels */
873 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
874 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
875 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
876 : 0)
878 /* Width of a scroll bar in frame F, measured in columns (characters),
879 but only if scroll bars are on the right. If scroll bars are on
880 the left in this frame, or there are no scroll bars, value is 0. */
882 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
883 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
884 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
885 : 0)
887 /* Width of a right scroll bar area in frame F, measured in pixels */
889 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
890 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
891 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
892 : 0)
894 /* Actual width of a scroll bar in frame F, measured in columns. */
896 #define FRAME_SCROLL_BAR_COLS(f) \
897 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
898 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
899 : 0)
901 /* Actual width of a scroll bar area in frame F, measured in pixels. */
903 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
904 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
905 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
906 : 0)
908 /* Total width of frame F, in columns (characters),
909 including the width used by scroll bars if any. */
910 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
912 /* Set the character widths of frame F. WIDTH specifies a nominal
913 character text width. */
914 #define SET_FRAME_COLS(f, width) \
915 ((f)->text_cols = (width), \
916 (f)->total_cols = ((width) \
917 + FRAME_SCROLL_BAR_COLS (f) \
918 + FRAME_FRINGE_COLS (f)))
920 /* Set the pixel widths of frame F. WIDTH specifies a nominal pixel
921 text width. */
922 #define SET_FRAME_WIDTH(f, width) \
923 ((f)->text_width = (width), \
924 (f)->pixel_width = ((width) \
925 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
926 + FRAME_TOTAL_FRINGE_WIDTH (f) \
927 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
929 /* Set the pixel heights of frame F. HEIGHT specifies a nominal pixel
930 text width. */
931 #define SET_FRAME_HEIGHT(f, height) \
932 ((f)->text_height = (height), \
933 (f)->pixel_height = ((height) \
934 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
936 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
938 #define FRAME_CURSOR_X_LIMIT(f) \
939 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
941 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
943 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
944 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
945 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
947 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
948 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
949 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
950 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
952 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
953 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
955 /* Return a pointer to the face cache of frame F. */
957 #define FRAME_FACE_CACHE(F) (F)->face_cache
959 /* Return the size of message_buf of the frame F. We multiply the
960 width of the frame by 4 because multi-byte form may require at most
961 4-byte for a character. */
963 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
965 #define CHECK_FRAME(x) \
966 CHECK_TYPE (FRAMEP (x), Qframep, x)
968 #define CHECK_LIVE_FRAME(x) \
969 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
971 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
972 `for' loop which iterates over the elements of Vframe_list. The
973 loop will set FRAME_VAR, a Lisp_Object, to each frame in
974 Vframe_list in succession and execute the statement. LIST_VAR
975 should be a Lisp_Object too; it is used to iterate through the
976 Vframe_list.
978 This macro is a holdover from a time when multiple frames weren't always
979 supported. An alternate definition of the macro would expand to
980 something which executes the statement once. */
982 #define FOR_EACH_FRAME(list_var, frame_var) \
983 for ((list_var) = Vframe_list; \
984 (CONSP (list_var) \
985 && (frame_var = XCAR (list_var), true)); \
986 list_var = XCDR (list_var))
988 /* Reflect mouse movement when a complete frame update is performed. */
990 #define FRAME_MOUSE_UPDATE(frame) \
991 do { \
992 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
993 if (frame == hlinfo->mouse_face_mouse_frame) \
995 block_input (); \
996 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
997 hlinfo->mouse_face_mouse_x, \
998 hlinfo->mouse_face_mouse_y); \
999 unblock_input (); \
1001 } while (false)
1003 /* False means there are no visible garbaged frames. */
1004 extern bool frame_garbaged;
1006 /* Set visibility of frame F.
1007 We call redisplay_other_windows to make sure the frame gets redisplayed
1008 if some changes were applied to it while it wasn't visible (and hence
1009 wasn't redisplayed). */
1011 INLINE void
1012 SET_FRAME_VISIBLE (struct frame *f, int v)
1014 eassert (0 <= v && v <= 2);
1015 if (v)
1017 if (v == 1 && f->visible != 1)
1018 redisplay_other_windows ();
1019 if (FRAME_GARBAGED_P (f))
1020 frame_garbaged = true;
1022 f->visible = v;
1025 /* Set iconify of frame F. */
1027 #define SET_FRAME_ICONIFIED(f, i) \
1028 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1030 extern Lisp_Object selected_frame;
1031 extern Lisp_Object Qframep, Qframe_live_p;
1032 extern Lisp_Object Qtty, Qtty_type;
1033 extern Lisp_Object Qtty_color_mode;
1034 extern Lisp_Object Qterminal;
1035 extern Lisp_Object Qnoelisp;
1037 extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1038 extern struct frame *decode_window_system_frame (Lisp_Object);
1039 extern struct frame *decode_live_frame (Lisp_Object);
1040 extern struct frame *decode_any_frame (Lisp_Object);
1041 extern struct frame *make_initial_frame (void);
1042 extern struct frame *make_frame (bool);
1043 #ifdef HAVE_WINDOW_SYSTEM
1044 extern struct frame *make_minibuffer_frame (void);
1045 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1046 struct kboard *,
1047 Lisp_Object);
1048 extern bool window_system_available (struct frame *);
1049 #else /* not HAVE_WINDOW_SYSTEM */
1050 #define window_system_available(f) ((void) (f), false)
1051 #endif /* HAVE_WINDOW_SYSTEM */
1052 extern void check_window_system (struct frame *);
1053 extern void frame_make_pointer_invisible (struct frame *);
1054 extern void frame_make_pointer_visible (struct frame *);
1055 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1057 extern Lisp_Object Vframe_list;
1059 /* Value is a pointer to the selected frame. If the selected frame
1060 isn't live, abort. */
1062 #define SELECTED_FRAME() \
1063 ((FRAMEP (selected_frame) \
1064 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1065 ? XFRAME (selected_frame) \
1066 : (emacs_abort (), (struct frame *) 0))
1069 /***********************************************************************
1070 Display-related Macros
1071 ***********************************************************************/
1073 /* Canonical y-unit on frame F.
1074 This value currently equals the line height of the frame (which is
1075 the height of the default font of F). */
1077 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1079 /* Canonical x-unit on frame F.
1080 This value currently equals the average width of the default font of F. */
1082 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1084 /* Pixel width of areas used to display truncation marks, continuation
1085 marks, overlay arrows. This is 0 for terminal frames. */
1087 #ifdef HAVE_WINDOW_SYSTEM
1089 /* Total width of fringes reserved for drawing truncation bitmaps,
1090 continuation bitmaps and alike. The width is in canonical char
1091 units of the frame. This must currently be the case because window
1092 sizes aren't pixel values. If it weren't the case, we wouldn't be
1093 able to split windows horizontally nicely. */
1095 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
1097 /* Pixel-width of the left and right fringe. */
1099 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
1100 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
1102 /* Total width of fringes in pixels. */
1104 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
1105 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
1107 /* Pixel-width of internal border lines */
1108 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
1110 /* Pixel-size of window border lines */
1111 #define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width)
1112 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width)
1114 #else /* not HAVE_WINDOW_SYSTEM */
1116 #define FRAME_FRINGE_COLS(F) 0
1117 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
1118 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
1119 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
1120 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
1121 #define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1122 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1124 #endif /* not HAVE_WINDOW_SYSTEM */
1126 /***********************************************************************
1127 Conversion between canonical units and pixels
1128 ***********************************************************************/
1130 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1131 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1132 represented as Lisp numbers, i.e. integers or floats. */
1134 /* Convert canonical value X to pixels. F is the frame whose
1135 canonical char width is to be used. X must be a Lisp integer or
1136 float. Value is a C integer. */
1138 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1139 (INTEGERP (X) \
1140 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1141 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1143 /* Convert canonical value Y to pixels. F is the frame whose
1144 canonical character height is to be used. X must be a Lisp integer
1145 or float. Value is a C integer. */
1147 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1148 (INTEGERP (Y) \
1149 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1150 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1152 /* Convert pixel-value X to canonical units. F is the frame whose
1153 canonical character width is to be used. X is a C integer. Result
1154 is a Lisp float if X is not a multiple of the canon width,
1155 otherwise it's a Lisp integer. */
1157 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1158 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1159 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1160 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1162 /* Convert pixel-value Y to canonical units. F is the frame whose
1163 canonical character height is to be used. Y is a C integer.
1164 Result is a Lisp float if Y is not a multiple of the canon width,
1165 otherwise it's a Lisp integer. */
1167 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1168 ((Y) % FRAME_LINE_HEIGHT (F) \
1169 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1170 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1174 /* Manipulating pixel sizes and character sizes.
1175 Knowledge of which factors affect the overall size of the window should
1176 be hidden in these macros, if that's possible.
1178 Return the upper/left pixel position of the character cell on frame F
1179 at ROW/COL. */
1181 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1182 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1183 + (row) * FRAME_LINE_HEIGHT (f))
1185 #define FRAME_COL_TO_PIXEL_X(f, col) \
1186 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1187 + (col) * FRAME_COLUMN_WIDTH (f))
1189 /* Return the pixel width/height of frame F if it has
1190 COLS columns/LINES rows. */
1192 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1193 (FRAME_COL_TO_PIXEL_X (f, cols) \
1194 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1195 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1196 + FRAME_INTERNAL_BORDER_WIDTH (f))
1198 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1199 ((lines) * FRAME_LINE_HEIGHT (f) \
1200 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1202 /* Return the row/column (zero-based) of the character cell containing
1203 the pixel on FRAME at Y/X. */
1205 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1206 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1207 ? (y) \
1208 : ((y) < FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1209 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1210 /* Arrange for the division to round down. */ \
1211 + FRAME_LINE_HEIGHT (f) - 1) \
1212 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1213 / FRAME_LINE_HEIGHT (f))
1215 #define FRAME_PIXEL_X_TO_COL(f, x) \
1216 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1217 / FRAME_COLUMN_WIDTH (f))
1219 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1220 frame F? */
1222 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1223 (FRAME_PIXEL_X_TO_COL (f, ((width) \
1224 - FRAME_INTERNAL_BORDER_WIDTH (f) \
1225 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1226 - FRAME_SCROLL_BAR_AREA_WIDTH (f)))) \
1228 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1229 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
1230 - FRAME_INTERNAL_BORDER_WIDTH (f))))
1232 /* Return the pixel width/height of frame F with a text size of
1233 width/height. */
1235 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1236 ((width) \
1237 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1238 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1239 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1241 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1242 ((height) + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1244 /* Return the text width/height of frame F with a pixel size of
1245 width/height. */
1247 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1248 ((width) \
1249 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1250 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1251 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1253 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1254 ((height) - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1256 /* Value is the smallest width of any character in any font on frame F. */
1258 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1259 FRAME_DISPLAY_INFO (f)->smallest_char_width
1261 /* Value is the smallest height of any font on frame F. */
1263 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1264 FRAME_DISPLAY_INFO (f)->smallest_font_height
1266 /***********************************************************************
1267 Frame Parameters
1268 ***********************************************************************/
1270 extern Lisp_Object Qauto_raise, Qauto_lower;
1271 extern Lisp_Object Qborder_color, Qborder_width;
1272 extern Lisp_Object Qbuffer_predicate;
1273 extern Lisp_Object Qcursor_color, Qcursor_type;
1274 extern Lisp_Object Qfont;
1275 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1276 extern Lisp_Object Qinternal_border_width;
1277 extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
1278 extern Lisp_Object Qtooltip;
1279 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
1280 extern Lisp_Object Qmouse_color;
1281 extern Lisp_Object Qname, Qtitle;
1282 extern Lisp_Object Qparent_id;
1283 extern Lisp_Object Qunsplittable, Qvisibility;
1284 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1285 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1286 extern Lisp_Object Qscreen_gamma;
1287 extern Lisp_Object Qline_spacing;
1288 extern Lisp_Object Qwait_for_wm;
1289 extern Lisp_Object Qfullscreen;
1290 extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
1291 extern Lisp_Object Qsticky;
1292 extern Lisp_Object Qfont_backend;
1293 extern Lisp_Object Qalpha;
1295 extern Lisp_Object Qleft_fringe, Qright_fringe;
1296 extern Lisp_Object Qheight, Qwidth;
1297 extern Lisp_Object Qminibuffer, Qmodeline;
1298 extern Lisp_Object Qx, Qw32, Qpc, Qns;
1299 extern Lisp_Object Qvisible;
1300 extern Lisp_Object Qdisplay_type;
1302 extern Lisp_Object Qx_resource_name;
1304 extern Lisp_Object Qtop, Qbox, Qbottom;
1305 extern Lisp_Object Qdisplay;
1307 extern Lisp_Object Qrun_hook_with_args;
1309 #ifdef HAVE_WINDOW_SYSTEM
1311 /* The class of this X application. */
1312 #define EMACS_CLASS "Emacs"
1314 /* These are in xterm.c, w32term.c, etc. */
1316 extern void x_set_scroll_bar_default_width (struct frame *);
1317 extern void x_set_offset (struct frame *, int, int, int);
1318 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1320 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1323 extern Lisp_Object Qface_set_after_frame_default;
1325 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1327 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1328 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1329 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1330 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1331 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1332 extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object);
1333 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1334 extern void x_set_internal_border_width (struct frame *, Lisp_Object,
1335 Lisp_Object);
1336 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1337 Lisp_Object);
1338 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1339 Lisp_Object);
1340 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1341 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1342 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1343 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1344 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object,
1345 Lisp_Object);
1346 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object,
1347 Lisp_Object);
1349 extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
1351 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1353 extern void validate_x_resource_name (void);
1355 extern Lisp_Object display_x_get_resource (Display_Info *,
1356 Lisp_Object attribute,
1357 Lisp_Object class,
1358 Lisp_Object component,
1359 Lisp_Object subclass);
1361 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1362 extern void x_set_window_size (struct frame *f, int change_grav,
1363 int width, int height, bool pixelwise);
1364 extern Lisp_Object x_get_focus_frame (struct frame *);
1365 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1366 extern void x_make_frame_visible (struct frame *f);
1367 extern void x_make_frame_invisible (struct frame *f);
1368 extern void x_iconify_frame (struct frame *f);
1369 extern void x_set_frame_alpha (struct frame *f);
1370 extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1371 extern void x_activate_menubar (struct frame *);
1372 extern void x_real_positions (struct frame *, int *, int *);
1373 extern void free_frame_menubar (struct frame *);
1374 extern void x_free_frame_resources (struct frame *);
1376 #if defined HAVE_X_WINDOWS
1377 extern void x_wm_set_icon_position (struct frame *, int, int);
1378 #if !defined USE_X_TOOLKIT
1379 extern char *x_get_resource_string (const char *, const char *);
1380 #endif
1381 extern void x_sync (struct frame *);
1382 #endif /* HAVE_X_WINDOWS */
1384 extern void x_query_colors (struct frame *f, XColor *, int);
1385 extern void x_query_color (struct frame *f, XColor *);
1386 extern void x_focus_frame (struct frame *);
1388 #ifndef HAVE_NS
1390 extern int x_bitmap_icon (struct frame *, Lisp_Object);
1392 /* Set F's bitmap icon, if specified among F's parameters. */
1394 INLINE void
1395 x_set_bitmap_icon (struct frame *f)
1397 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1399 if (CONSP (obj))
1400 x_bitmap_icon (f, XCDR (obj));
1403 #endif /* !HAVE_NS */
1404 #endif /* HAVE_WINDOW_SYSTEM */
1406 INLINE void
1407 flush_frame (struct frame *f)
1409 struct redisplay_interface *rif = FRAME_RIF (f);
1411 if (rif && rif->flush_display)
1412 rif->flush_display (f);
1415 /***********************************************************************
1416 Multimonitor data
1417 ***********************************************************************/
1419 #ifdef HAVE_WINDOW_SYSTEM
1421 struct MonitorInfo {
1422 XRectangle geom, work;
1423 int mm_width, mm_height;
1424 char *name;
1427 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1428 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1429 int n_monitors,
1430 int primary_monitor,
1431 Lisp_Object monitor_frames,
1432 const char *source);
1434 #endif /* HAVE_WINDOW_SYSTEM */
1437 INLINE_HEADER_END
1439 #endif /* not EMACS_FRAME_H */