Make ">>" act as double template ender in C++ Mode.
[emacs.git] / src / frame.h
blob0f34770d9b43f688693084939e4be64fe63d0f9f
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
316 /* See FULLSCREEN_ enum on top. */
317 ENUM_BF (fullscreen_type) want_fullscreen : 4;
319 /* If not vertical_scroll_bar_none, we should actually
320 display the scroll bars of this type on this frame. */
321 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
323 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
324 bool_bf horizontal_scroll_bars : 1;
325 #endif /* HAVE_WINDOW_SYSTEM */
327 /* Whether new_height and new_width shall be interpreted
328 in pixels. */
329 bool_bf new_pixelwise : 1;
331 /* True if frame has been added to Vframe_list and is henceforth
332 considered official. For in-official frames we neither process
333 x_set_window_size requests nor do we allow running
334 window-configuration-change-hook when resizing windows. */
335 bool_bf official : 1;
337 /* Bitfield area ends here. */
339 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
340 int tool_bar_lines;
342 /* Height of frame internal tool bar in pixels. */
343 int tool_bar_height;
345 int n_tool_bar_rows;
346 int n_tool_bar_items;
348 /* A buffer for decode_mode_line. */
349 char *decode_mode_spec_buffer;
351 /* See do_line_insertion_deletion_costs for info on these arrays. */
352 /* Cost of inserting 1 line on this frame. */
353 int *insert_line_cost;
354 /* Cost of deleting 1 line on this frame. */
355 int *delete_line_cost;
356 /* Cost of inserting n lines on this frame. */
357 int *insert_n_lines_cost;
358 /* Cost of deleting n lines on this frame. */
359 int *delete_n_lines_cost;
361 /* Text width of this frame (excluding fringes, vertical scroll bar
362 and internal border widths) and text height (excluding menu bar,
363 tool bar, horizontal scroll bar and internal border widths) in
364 units of canonical characters. */
365 int text_cols, text_lines;
367 /* Total width of this frame (including fringes, vertical scroll bar
368 and internal border widths) and total height (including menu bar,
369 tool bar, horizontal scroll bar and internal border widths) in
370 units of canonical characters. */
371 int total_cols, total_lines;
373 /* Text width of this frame (excluding fringes, vertical scroll bar
374 and internal border widths) and text height (excluding menu bar,
375 tool bar, horizontal scroll bar and internal border widths) in
376 pixels. */
377 int text_width, text_height;
379 /* New text height and width for pending size change. 0 if no change
380 pending. These values represent pixels or canonical character units
381 according to the value of new_pixelwise and correlate to the the
382 text width/height of the frame. */
383 int new_width, new_height;
385 /* Pixel position of the frame window (x and y offsets in root window). */
386 int left_pos, top_pos;
388 /* Total width of this frame (including fringes, vertical scroll bar
389 and internal border widths) and total height (including menu bar,
390 tool bar, horizontal scroll bar and internal border widths) in
391 pixels. */
392 int pixel_width, pixel_height;
394 /* These many pixels are the difference between the outer window (i.e. the
395 left and top of the window manager decoration) and FRAME_X_WINDOW. */
396 int x_pixels_diff, y_pixels_diff;
398 /* This is the gravity value for the specified window position. */
399 int win_gravity;
401 /* The geometry flags for this window. */
402 int size_hint_flags;
404 /* Border width of the frame window as known by the (X) window system. */
405 int border_width;
407 /* Width of the internal border. This is a line of background color
408 just inside the window's border. When the frame is selected,
409 a highlighting is displayed inside the internal border. */
410 int internal_border_width;
412 /* Widths of dividers between this frame's windows in pixels. */
413 int right_divider_width, bottom_divider_width;
415 /* Widths of fringes in pixels. */
416 int left_fringe_width, right_fringe_width;
418 /* Total width of fringes reserved for drawing truncation bitmaps,
419 continuation bitmaps and alike - REMOVE THIS !!!!. */
420 int fringe_cols;
422 /* Number of lines of menu bar. */
423 int menu_bar_lines;
425 /* Pixel height of menubar. */
426 int menu_bar_height;
428 /* Canonical X unit. Width of default font, in pixels. */
429 int column_width;
431 /* Canonical Y unit. Height of a line, in pixels. */
432 int line_height;
434 /* The terminal device that this frame uses. If this is NULL, then
435 the frame has been deleted. */
436 struct terminal *terminal;
438 /* Device-dependent, frame-local auxiliary data used for displaying
439 the contents. When the frame is deleted, this data is deleted as
440 well. */
441 union output_data
443 struct tty_output *tty; /* From termchar.h. */
444 struct x_output *x; /* From xterm.h. */
445 struct w32_output *w32; /* From w32term.h. */
446 struct ns_output *ns; /* From nsterm.h. */
447 intptr_t nothing;
449 output_data;
451 /* List of font-drivers available on the frame. */
452 struct font_driver_list *font_driver_list;
454 #if defined (HAVE_X_WINDOWS)
455 /* Used by x_wait_for_event when watching for an X event on this frame. */
456 int wait_event_type;
457 #endif
459 /* What kind of text cursor should we draw in the future?
460 This should always be filled_box_cursor or bar_cursor. */
461 enum text_cursor_kinds desired_cursor;
463 /* Width of bar cursor (if we are using that). */
464 int cursor_width;
466 /* What kind of text cursor should we draw when the cursor blinks off?
467 This can be filled_box_cursor or bar_cursor or no_cursor. */
468 enum text_cursor_kinds blink_off_cursor;
470 /* Width of bar cursor (if we are using that) for blink-off state. */
471 int blink_off_cursor_width;
473 /* Configured width of the scroll bar, in pixels and in characters.
474 config_scroll_bar_cols tracks config_scroll_bar_width if the
475 latter is positive; a zero value in config_scroll_bar_width means
476 to compute the actual width on the fly, using config_scroll_bar_cols
477 and the current font width. */
478 int config_scroll_bar_width;
479 int config_scroll_bar_cols;
481 /* Configured height of the scroll bar, in pixels and in characters.
482 config_scroll_bar_lines tracks config_scroll_bar_height if the
483 latter is positive; a zero value in config_scroll_bar_height means
484 to compute the actual width on the fly, using
485 config_scroll_bar_lines and the current font width. */
486 int config_scroll_bar_height;
487 int config_scroll_bar_lines;
489 /* The baud rate that was used to calculate costs for this frame. */
490 int cost_calculation_baud_rate;
492 /* Frame opacity
493 alpha[0]: alpha transparency of the active frame
494 alpha[1]: alpha transparency of inactive frames
495 Negative values mean not to change alpha. */
496 double alpha[2];
498 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
499 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
500 frame parameter. 0 means don't do gamma correction. */
501 double gamma;
503 /* Additional space to put between text lines on this frame. */
504 int extra_line_spacing;
506 /* All display backends seem to need these two pixel values. */
507 unsigned long background_pixel;
508 unsigned long foreground_pixel;
511 /* Most code should use these functions to set Lisp fields in struct frame. */
513 INLINE void
514 fset_buffer_list (struct frame *f, Lisp_Object val)
516 f->buffer_list = val;
518 INLINE void
519 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
521 f->buried_buffer_list = val;
523 INLINE void
524 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
526 f->condemned_scroll_bars = val;
528 INLINE void
529 fset_face_alist (struct frame *f, Lisp_Object val)
531 f->face_alist = val;
533 INLINE void
534 fset_focus_frame (struct frame *f, Lisp_Object val)
536 f->focus_frame = val;
538 INLINE void
539 fset_icon_name (struct frame *f, Lisp_Object val)
541 f->icon_name = val;
543 INLINE void
544 fset_menu_bar_items (struct frame *f, Lisp_Object val)
546 f->menu_bar_items = val;
548 INLINE void
549 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
551 f->menu_bar_vector = val;
553 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
554 INLINE void
555 fset_menu_bar_window (struct frame *f, Lisp_Object val)
557 f->menu_bar_window = val;
559 #endif
560 INLINE void
561 fset_name (struct frame *f, Lisp_Object val)
563 f->name = val;
565 INLINE void
566 fset_param_alist (struct frame *f, Lisp_Object val)
568 f->param_alist = val;
570 INLINE void
571 fset_root_window (struct frame *f, Lisp_Object val)
573 f->root_window = val;
575 INLINE void
576 fset_scroll_bars (struct frame *f, Lisp_Object val)
578 f->scroll_bars = val;
580 INLINE void
581 fset_selected_window (struct frame *f, Lisp_Object val)
583 f->selected_window = val;
585 INLINE void
586 fset_title (struct frame *f, Lisp_Object val)
588 f->title = val;
590 INLINE void
591 fset_tool_bar_items (struct frame *f, Lisp_Object val)
593 f->tool_bar_items = val;
595 #ifdef USE_GTK
596 INLINE void
597 fset_tool_bar_position (struct frame *f, Lisp_Object val)
599 f->tool_bar_position = val;
601 #endif /* USE_GTK */
602 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
603 INLINE void
604 fset_tool_bar_window (struct frame *f, Lisp_Object val)
606 f->tool_bar_window = val;
608 INLINE void
609 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
611 f->current_tool_bar_string = val;
613 INLINE void
614 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
616 f->desired_tool_bar_string = val;
618 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
620 #define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
622 INLINE double
623 default_pixels_per_inch_x (void)
625 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
626 ? XCAR (Vdisplay_pixels_per_inch)
627 : Vdisplay_pixels_per_inch);
628 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
631 INLINE double
632 default_pixels_per_inch_y (void)
634 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
635 ? XCDR (Vdisplay_pixels_per_inch)
636 : Vdisplay_pixels_per_inch);
637 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
640 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
642 /* Return a pointer to the image cache of frame F. */
643 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
645 #define XFRAME(p) \
646 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
647 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
649 /* Given a window, return its frame as a Lisp_Object. */
650 #define WINDOW_FRAME(w) ((w)->frame)
652 /* Test a frame for particular kinds of display methods. */
653 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
654 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
655 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
656 #ifndef HAVE_NTGUI
657 #define FRAME_W32_P(f) false
658 #else
659 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
660 #endif
661 #ifndef MSDOS
662 #define FRAME_MSDOS_P(f) false
663 #else
664 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
665 #endif
666 #ifndef HAVE_NS
667 #define FRAME_NS_P(f) false
668 #else
669 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
670 #endif
672 /* FRAME_WINDOW_P tests whether the frame is a window, and is
673 defined to be the predicate for the window system being used. */
675 #ifdef HAVE_X_WINDOWS
676 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
677 #endif
678 #ifdef HAVE_NTGUI
679 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
680 #endif
681 #ifdef HAVE_NS
682 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
683 #endif
684 #ifndef FRAME_WINDOW_P
685 #define FRAME_WINDOW_P(f) ((void) (f), false)
686 #endif
688 /* Dots per inch of the screen the frame F is on. */
690 #ifdef HAVE_WINDOW_SYSTEM
692 #define FRAME_RES_X(f) \
693 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
694 #define FRAME_RES_Y(f) \
695 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
697 #else /* !HAVE_WINDOW_SYSTEM */
699 /* Defaults when no window system available. */
701 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
702 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
704 #endif /* HAVE_WINDOW_SYSTEM */
706 /* Return a pointer to the structure holding information about the
707 region of text, if any, that is currently shown in mouse-face on
708 frame F. We need to define two versions because a TTY-only build
709 does not have FRAME_DISPLAY_INFO. */
710 #ifdef HAVE_WINDOW_SYSTEM
711 # define MOUSE_HL_INFO(F) \
712 (FRAME_WINDOW_P(F) \
713 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
714 : &(F)->output_data.tty->display_info->mouse_highlight)
715 #else
716 # define MOUSE_HL_INFO(F) \
717 (&(F)->output_data.tty->display_info->mouse_highlight)
718 #endif
720 /* True if frame F is still alive (not deleted). */
721 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
723 /* True if frame F is a minibuffer-only frame. */
724 #define FRAME_MINIBUF_ONLY_P(f) \
725 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
727 /* True if frame F contains it's own minibuffer window. Frame always has
728 minibuffer window, but it could use minibuffer window of another frame. */
729 #define FRAME_HAS_MINIBUF_P(f) \
730 (WINDOWP (f->minibuffer_window) \
731 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
733 /* Pixel width of frame F. */
734 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
736 /* Pixel height of frame F. */
737 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
739 /* Width of frame F, measured in canonical character columns,
740 not including scroll bars if any. */
741 #define FRAME_COLS(f) (f)->text_cols
743 /* Height of frame F, measured in canonical lines, including
744 non-toolkit menu bar and non-toolkit tool bar lines. */
745 #define FRAME_LINES(f) (f)->text_lines
747 /* Width of frame F, measured in pixels not including the width for
748 fringes, scroll bar, and internal borders. */
749 #define FRAME_TEXT_WIDTH(f) (f)->text_width
751 /* Height of frame F, measured in pixels not including the height
752 for scroll bar and internal borders. */
753 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
755 /* Number of lines of frame F used for menu bar.
756 This is relevant on terminal frames and on
757 X Windows when not using the X toolkit.
758 These lines are counted in FRAME_LINES. */
759 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
761 /* Pixel height of frame F's menu bar. */
762 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
764 /* True if this frame should display a tool bar
765 in a way that does not use any text lines. */
766 #if defined (USE_GTK) || defined (HAVE_NS)
767 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
768 #else
769 #define FRAME_EXTERNAL_TOOL_BAR(f) false
770 #endif
772 /* This is really supported only with GTK. */
773 #ifdef USE_GTK
774 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
775 #else
776 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
777 #endif
779 /* Number of lines of frame F used for the tool-bar. */
780 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
782 /* Pixel height of frame F's tool-bar. */
783 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
785 /* Lines above the top-most window in frame F. */
786 #define FRAME_TOP_MARGIN(F) \
787 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
789 /* Pixel height of frame F's top margin. */
790 #define FRAME_TOP_MARGIN_HEIGHT(F) \
791 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
793 /* True if this frame should display a menu bar
794 in a way that does not use any text lines. */
795 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
796 || defined (HAVE_NS) || defined (USE_GTK)
797 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
798 #else
799 #define FRAME_EXTERNAL_MENU_BAR(f) false
800 #endif
802 /* True if frame F is currently visible. */
803 #define FRAME_VISIBLE_P(f) (f)->visible
805 /* True if frame F is currently visible but hidden. */
806 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
808 /* True if frame F is currently iconified. */
809 #define FRAME_ICONIFIED_P(f) (f)->iconified
811 /* Mark frame F as currently garbaged. */
812 #define SET_FRAME_GARBAGED(f) \
813 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
815 /* True if frame F is currently garbaged. */
816 #define FRAME_GARBAGED_P(f) (f)->garbaged
818 /* True means do not allow splitting this frame's window. */
819 #define FRAME_NO_SPLIT_P(f) (f)->no_split
821 /* Not really implemented. */
822 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
824 /* True if all windows except selected window and mini window
825 are frozen on frame F. */
826 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
828 /* True if a size change has been requested for frame F
829 but not yet really put into effect. This can be true temporarily
830 when an X event comes in at a bad time. */
831 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
833 /* The minibuffer window of frame F, if it has one; otherwise nil. */
834 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
836 /* The root window of the window tree of frame F. */
837 #define FRAME_ROOT_WINDOW(f) f->root_window
839 /* The currently selected window of the window tree of frame F. */
840 #define FRAME_SELECTED_WINDOW(f) f->selected_window
842 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
843 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
844 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
845 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
846 #define FRAME_FOCUS_FRAME(f) f->focus_frame
848 #ifdef HAVE_WINDOW_SYSTEM
850 /* This frame slot says whether scroll bars are currently enabled for frame F,
851 and which side they are on. */
852 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
853 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
854 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
855 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
856 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
857 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
858 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
860 #else /* not HAVE_WINDOW_SYSTEM */
862 /* If there is no window system, there are no scroll bars. */
863 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
864 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
865 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
866 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
868 #endif /* HAVE_WINDOW_SYSTEM */
870 /* Whether horizontal scroll bars are currently enabled for frame F. */
871 #if (defined (HAVE_WINDOW_SYSTEM) \
872 && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS)) \
873 || defined (HAVE_NTGUI)))
874 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
875 ((f)->horizontal_scroll_bars)
876 #else
877 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
878 #endif
880 /* Width that a scroll bar in frame F should have, if there is one.
881 Measured in pixels.
882 If scroll bars are turned off, this is still nonzero. */
883 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
885 /* Height that a scroll bar in frame F should have, if there is one.
886 Measured in pixels.
887 If scroll bars are turned off, this is still nonzero. */
888 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
890 /* Width that a scroll bar in frame F should have, if there is one.
891 Measured in columns (characters).
892 If scroll bars are turned off, this is still nonzero. */
893 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
895 /* Height that a scroll bar in frame F should have, if there is one.
896 Measured in lines (characters).
897 If scroll bars are turned off, this is still nonzero. */
898 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
900 /* Width of a left scroll bar in frame F, measured in pixels */
901 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
902 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
903 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
904 : 0)
906 /* Width of a right scroll bar area in frame F, measured in pixels */
907 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
908 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
909 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
910 : 0)
912 /* Width of a left scroll bar in frame F, measured in columns
913 (characters), but only if scroll bars are on the left. If scroll
914 bars are on the right in this frame, or there are no scroll bars,
915 value is 0. */
916 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
917 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
918 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
919 : 0)
921 /* Width of a right scroll bar in frame F, measured in columns
922 (characters), but only if scroll bars are on the right. If scroll
923 bars are on the left in this frame, or there are no scroll bars,
924 value is 0. */
925 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
926 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
927 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
928 : 0)
930 /* Width of a vertical scroll bar area in frame F, measured in
931 pixels. */
932 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
933 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
934 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
935 : 0)
937 /* Height of horizontal scroll bar area in frame F, measured in
938 pixels. */
939 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
940 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
941 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
942 : 0)
944 /* Width of vertical scroll bar in frame F, measured in columns. */
945 #define FRAME_SCROLL_BAR_COLS(f) \
946 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
947 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
948 : 0)
950 /* Height of horizontal scroll bar in frame F, measured in lines. */
951 #define FRAME_SCROLL_BAR_LINES(f) \
952 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
953 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
954 : 0)
956 /* Total width of frame F, in columns (characters),
957 including the width used by scroll bars if any. */
958 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
960 /* Total height of frame F, in lines (characters),
961 including the height used by scroll bars if any. */
962 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
964 /* Set the character widths of frame F. WIDTH specifies a nominal
965 character text width. */
966 #define SET_FRAME_COLS(f, width) \
967 ((f)->text_cols = (width), \
968 (f)->total_cols = ((width) \
969 + FRAME_SCROLL_BAR_COLS (f) \
970 + FRAME_FRINGE_COLS (f)))
972 /* Set the character heights of frame F. HEIGHT specifies a nominal
973 character text height. */
974 #define SET_FRAME_LINES(f, height) \
975 ((f)->text_lines = (height), \
976 (f)->total_lines = ((height) \
977 + FRAME_TOP_MARGIN (f) \
978 + FRAME_SCROLL_BAR_LINES (f)))
980 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
981 width. */
982 #define SET_FRAME_WIDTH(f, width) \
983 ((f)->text_width = (width), \
984 (f)->pixel_width = ((width) \
985 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
986 + FRAME_TOTAL_FRINGE_WIDTH (f) \
987 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
989 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
990 height. */
991 #define SET_FRAME_HEIGHT(f, height) \
992 ((f)->text_height = (height), \
993 (f)->pixel_height = ((height) \
994 + FRAME_TOP_MARGIN_HEIGHT (f) \
995 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
996 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
998 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
999 #define FRAME_CURSOR_X_LIMIT(f) \
1000 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1002 /* Nonzero if frame F has scroll bars. */
1003 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1004 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1006 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1007 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1009 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1010 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1011 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1012 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1014 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1015 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1017 /* Return a pointer to the face cache of frame F. */
1019 #define FRAME_FACE_CACHE(F) (F)->face_cache
1021 /* Return the size of message_buf of the frame F. We multiply the
1022 width of the frame by 4 because multi-byte form may require at most
1023 4-byte for a character. */
1025 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1027 #define CHECK_FRAME(x) \
1028 CHECK_TYPE (FRAMEP (x), Qframep, x)
1030 #define CHECK_LIVE_FRAME(x) \
1031 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1033 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1034 `for' loop which iterates over the elements of Vframe_list. The
1035 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1036 Vframe_list in succession and execute the statement. LIST_VAR
1037 should be a Lisp_Object too; it is used to iterate through the
1038 Vframe_list.
1040 This macro is a holdover from a time when multiple frames weren't always
1041 supported. An alternate definition of the macro would expand to
1042 something which executes the statement once. */
1044 #define FOR_EACH_FRAME(list_var, frame_var) \
1045 for ((list_var) = Vframe_list; \
1046 (CONSP (list_var) \
1047 && (frame_var = XCAR (list_var), true)); \
1048 list_var = XCDR (list_var))
1050 /* Reflect mouse movement when a complete frame update is performed. */
1052 #define FRAME_MOUSE_UPDATE(frame) \
1053 do { \
1054 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1055 if (frame == hlinfo->mouse_face_mouse_frame) \
1057 block_input (); \
1058 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1059 hlinfo->mouse_face_mouse_x, \
1060 hlinfo->mouse_face_mouse_y); \
1061 unblock_input (); \
1063 } while (false)
1065 /* False means there are no visible garbaged frames. */
1066 extern bool frame_garbaged;
1068 /* Set visibility of frame F.
1069 We call redisplay_other_windows to make sure the frame gets redisplayed
1070 if some changes were applied to it while it wasn't visible (and hence
1071 wasn't redisplayed). */
1073 INLINE void
1074 SET_FRAME_VISIBLE (struct frame *f, int v)
1076 eassert (0 <= v && v <= 2);
1077 if (v)
1079 if (v == 1 && f->visible != 1)
1080 redisplay_other_windows ();
1081 if (FRAME_GARBAGED_P (f))
1082 frame_garbaged = true;
1084 f->visible = v;
1087 /* Set iconify of frame F. */
1089 #define SET_FRAME_ICONIFIED(f, i) \
1090 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1092 extern Lisp_Object selected_frame;
1093 extern Lisp_Object Qframep, Qframe_live_p;
1094 extern Lisp_Object Qtty, Qtty_type;
1095 extern Lisp_Object Qtty_color_mode;
1096 extern Lisp_Object Qterminal;
1097 extern Lisp_Object Qnoelisp;
1099 extern struct frame *decode_window_system_frame (Lisp_Object);
1100 extern struct frame *decode_live_frame (Lisp_Object);
1101 extern struct frame *decode_any_frame (Lisp_Object);
1102 extern struct frame *make_initial_frame (void);
1103 extern struct frame *make_frame (bool);
1104 #ifdef HAVE_WINDOW_SYSTEM
1105 extern struct frame *make_minibuffer_frame (void);
1106 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1107 struct kboard *,
1108 Lisp_Object);
1109 extern bool window_system_available (struct frame *);
1110 #else /* not HAVE_WINDOW_SYSTEM */
1111 #define window_system_available(f) ((void) (f), false)
1112 #endif /* HAVE_WINDOW_SYSTEM */
1113 extern void check_window_system (struct frame *);
1114 extern void frame_make_pointer_invisible (struct frame *);
1115 extern void frame_make_pointer_visible (struct frame *);
1116 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1117 extern bool frame_inhibit_resize (struct frame *, bool);
1118 extern void adjust_frame_size (struct frame *, int, int, int, bool);
1120 extern Lisp_Object Vframe_list;
1122 /* Value is a pointer to the selected frame. If the selected frame
1123 isn't live, abort. */
1125 #define SELECTED_FRAME() \
1126 ((FRAMEP (selected_frame) \
1127 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1128 ? XFRAME (selected_frame) \
1129 : (emacs_abort (), (struct frame *) 0))
1132 /***********************************************************************
1133 Display-related Macros
1134 ***********************************************************************/
1136 /* Canonical y-unit on frame F.
1137 This value currently equals the line height of the frame (which is
1138 the height of the default font of F). */
1139 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1141 /* Canonical x-unit on frame F.
1142 This value currently equals the average width of the default font of F. */
1143 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1145 /* Pixel width of areas used to display truncation marks, continuation
1146 marks, overlay arrows. This is 0 for terminal frames. */
1148 #ifdef HAVE_WINDOW_SYSTEM
1150 /* Total width of fringes reserved for drawing truncation bitmaps,
1151 continuation bitmaps and alike. The width is in canonical char
1152 units of the frame. This must currently be the case because window
1153 sizes aren't pixel values. If it weren't the case, we wouldn't be
1154 able to split windows horizontally nicely. */
1155 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
1157 /* Pixel-width of the left and right fringe. */
1159 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
1160 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
1162 /* Total width of fringes in pixels. */
1164 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
1165 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
1167 /* Pixel-width of internal border lines */
1168 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
1170 /* Pixel-size of window border lines */
1171 #define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width)
1172 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width)
1174 #else /* not HAVE_WINDOW_SYSTEM */
1176 #define FRAME_FRINGE_COLS(F) 0
1177 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
1178 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
1179 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
1180 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
1181 #define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1182 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1184 #endif /* not HAVE_WINDOW_SYSTEM */
1186 /***********************************************************************
1187 Conversion between canonical units and pixels
1188 ***********************************************************************/
1190 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1191 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1192 represented as Lisp numbers, i.e. integers or floats. */
1194 /* Convert canonical value X to pixels. F is the frame whose
1195 canonical char width is to be used. X must be a Lisp integer or
1196 float. Value is a C integer. */
1197 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1198 (INTEGERP (X) \
1199 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1200 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1202 /* Convert canonical value Y to pixels. F is the frame whose
1203 canonical character height is to be used. X must be a Lisp integer
1204 or float. Value is a C integer. */
1205 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1206 (INTEGERP (Y) \
1207 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1208 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1210 /* Convert pixel-value X to canonical units. F is the frame whose
1211 canonical character width is to be used. X is a C integer. Result
1212 is a Lisp float if X is not a multiple of the canon width,
1213 otherwise it's a Lisp integer. */
1214 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1215 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1216 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1217 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1219 /* Convert pixel-value Y to canonical units. F is the frame whose
1220 canonical character height is to be used. Y is a C integer.
1221 Result is a Lisp float if Y is not a multiple of the canon width,
1222 otherwise it's a Lisp integer. */
1223 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1224 ((Y) % FRAME_LINE_HEIGHT (F) \
1225 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1226 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1230 /* Manipulating pixel sizes and character sizes.
1231 Knowledge of which factors affect the overall size of the window should
1232 be hidden in these macros, if that's possible.
1234 Return the upper/left pixel position of the character cell on frame F
1235 at ROW/COL. */
1236 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1237 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1238 + (row) * FRAME_LINE_HEIGHT (f))
1240 #define FRAME_COL_TO_PIXEL_X(f, col) \
1241 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1242 + (col) * FRAME_COLUMN_WIDTH (f))
1244 /* Return the pixel width/height of frame F if it has
1245 COLS columns/LINES rows. */
1246 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1247 ((cols) * FRAME_COLUMN_WIDTH (f) \
1248 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1249 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1250 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1252 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1253 ((lines) * FRAME_LINE_HEIGHT (f) \
1254 + FRAME_TOP_MARGIN_HEIGHT (f) \
1255 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1256 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1258 /* Return the row/column (zero-based) of the character cell containing
1259 the pixel on FRAME at Y/X. */
1260 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1261 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1262 ? (y) \
1263 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1264 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1265 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1266 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1267 /* Arrange for the division to round down. */ \
1268 + FRAME_LINE_HEIGHT (f) - 1) \
1269 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1270 / FRAME_LINE_HEIGHT (f))
1272 #define FRAME_PIXEL_X_TO_COL(f, x) \
1273 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1274 / FRAME_COLUMN_WIDTH (f))
1276 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1277 frame F (so we round down)? */
1278 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1279 (((width) \
1280 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1281 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1282 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1283 / FRAME_COLUMN_WIDTH (f)) \
1285 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1286 (((height) \
1287 - FRAME_TOP_MARGIN_HEIGHT (f) \
1288 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1289 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1290 / FRAME_LINE_HEIGHT (f))
1292 /* Return the pixel width/height of frame F with a text size of
1293 width/heigh. */
1294 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1295 ((width) \
1296 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1297 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1298 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1300 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1301 ((height) \
1302 + FRAME_TOP_MARGIN_HEIGHT (f) \
1303 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1304 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1306 /* Return the text width/height of frame F with a pixel size of
1307 width/height. */
1308 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1309 ((width) \
1310 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1311 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1312 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1314 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1315 ((height) \
1316 - FRAME_TOP_MARGIN_HEIGHT (f) \
1317 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1318 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1320 /* Return the width/height reserved for the windows of frame F. */
1321 #define FRAME_WINDOWS_WIDTH(f) \
1322 (FRAME_PIXEL_WIDTH (f) \
1323 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1325 #define FRAME_WINDOWS_HEIGHT(f) \
1326 (FRAME_PIXEL_HEIGHT (f) \
1327 - FRAME_TOP_MARGIN_HEIGHT (f) \
1328 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1330 /* Value is the smallest width of any character in any font on frame F. */
1331 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1332 FRAME_DISPLAY_INFO (f)->smallest_char_width
1334 /* Value is the smallest height of any font on frame F. */
1335 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1336 FRAME_DISPLAY_INFO (f)->smallest_font_height
1338 /***********************************************************************
1339 Frame Parameters
1340 ***********************************************************************/
1342 extern Lisp_Object Qauto_raise, Qauto_lower;
1343 extern Lisp_Object Qborder_color, Qborder_width;
1344 extern Lisp_Object Qbuffer_predicate;
1345 extern Lisp_Object Qcursor_color, Qcursor_type;
1346 extern Lisp_Object Qfont;
1347 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1348 extern Lisp_Object Qinternal_border_width;
1349 extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
1350 extern Lisp_Object Qtooltip;
1351 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
1352 extern Lisp_Object Qmouse_color;
1353 extern Lisp_Object Qname, Qtitle;
1354 extern Lisp_Object Qparent_id;
1355 extern Lisp_Object Qunsplittable, Qvisibility;
1356 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1357 extern Lisp_Object Qscroll_bar_height, Qhorizontal_scroll_bars;
1358 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1359 extern Lisp_Object Qscreen_gamma;
1360 extern Lisp_Object Qline_spacing;
1361 extern Lisp_Object Qwait_for_wm;
1362 extern Lisp_Object Qfullscreen;
1363 extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
1364 extern Lisp_Object Qsticky;
1365 extern Lisp_Object Qfont_backend;
1366 extern Lisp_Object Qalpha;
1368 extern Lisp_Object Qleft_fringe, Qright_fringe;
1369 extern Lisp_Object Qheight, Qwidth;
1370 extern Lisp_Object Qminibuffer, Qmodeline;
1371 extern Lisp_Object Qx, Qw32, Qpc, Qns;
1372 extern Lisp_Object Qvisible;
1373 extern Lisp_Object Qdisplay_type;
1375 extern Lisp_Object Qx_resource_name;
1377 extern Lisp_Object Qtop, Qbox, Qbottom;
1378 extern Lisp_Object Qdisplay;
1380 extern Lisp_Object Qrun_hook_with_args;
1382 #ifdef HAVE_WINDOW_SYSTEM
1384 /* The class of this X application. */
1385 #define EMACS_CLASS "Emacs"
1387 extern void x_set_scroll_bar_default_width (struct frame *);
1388 extern void x_set_scroll_bar_default_height (struct frame *);
1389 extern void x_set_offset (struct frame *, int, int, int);
1390 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1391 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1392 extern Lisp_Object Qface_set_after_frame_default;
1393 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1394 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1395 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1396 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1397 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1398 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1399 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1400 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1401 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1402 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1403 Lisp_Object);
1404 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1405 Lisp_Object);
1406 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1407 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1408 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1409 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1410 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1411 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1412 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1413 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1415 extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
1417 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1419 extern void validate_x_resource_name (void);
1421 extern Lisp_Object display_x_get_resource (Display_Info *,
1422 Lisp_Object attribute,
1423 Lisp_Object class,
1424 Lisp_Object component,
1425 Lisp_Object subclass);
1427 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1428 extern void x_set_window_size (struct frame *f, int change_grav,
1429 int width, int height, bool pixelwise);
1430 extern Lisp_Object x_get_focus_frame (struct frame *);
1431 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1432 extern void x_make_frame_visible (struct frame *f);
1433 extern void x_make_frame_invisible (struct frame *f);
1434 extern void x_iconify_frame (struct frame *f);
1435 extern void x_set_frame_alpha (struct frame *f);
1436 extern void x_activate_menubar (struct frame *);
1437 extern void x_real_positions (struct frame *, int *, int *);
1438 extern void free_frame_menubar (struct frame *);
1439 extern void x_free_frame_resources (struct frame *);
1441 #if defined HAVE_X_WINDOWS
1442 extern void x_wm_set_icon_position (struct frame *, int, int);
1443 #if !defined USE_X_TOOLKIT
1444 extern char *x_get_resource_string (const char *, const char *);
1445 #endif
1446 extern void x_sync (struct frame *);
1447 #endif /* HAVE_X_WINDOWS */
1449 extern void x_query_colors (struct frame *f, XColor *, int);
1450 extern void x_query_color (struct frame *f, XColor *);
1451 extern void x_focus_frame (struct frame *);
1453 #ifndef HAVE_NS
1455 extern int x_bitmap_icon (struct frame *, Lisp_Object);
1457 /* Set F's bitmap icon, if specified among F's parameters. */
1459 INLINE void
1460 x_set_bitmap_icon (struct frame *f)
1462 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1464 if (CONSP (obj))
1465 x_bitmap_icon (f, XCDR (obj));
1468 #endif /* !HAVE_NS */
1469 #endif /* HAVE_WINDOW_SYSTEM */
1471 INLINE void
1472 flush_frame (struct frame *f)
1474 struct redisplay_interface *rif = FRAME_RIF (f);
1476 if (rif && rif->flush_display)
1477 rif->flush_display (f);
1480 /***********************************************************************
1481 Multimonitor data
1482 ***********************************************************************/
1484 #ifdef HAVE_WINDOW_SYSTEM
1486 struct MonitorInfo {
1487 XRectangle geom, work;
1488 int mm_width, mm_height;
1489 char *name;
1492 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1493 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1494 int n_monitors,
1495 int primary_monitor,
1496 Lisp_Object monitor_frames,
1497 const char *source);
1499 #endif /* HAVE_WINDOW_SYSTEM */
1502 INLINE_HEADER_END
1504 #endif /* not EMACS_FRAME_H */