1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2016 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or (at
9 your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 #include "termhooks.h"
27 enum vertical_scroll_bar_type
29 vertical_scroll_bar_none
,
30 vertical_scroll_bar_left
,
31 vertical_scroll_bar_right
34 #ifdef HAVE_WINDOW_SYSTEM
39 FULLSCREEN_WIDTH
= 0x1,
40 FULLSCREEN_HEIGHT
= 0x2,
41 FULLSCREEN_BOTH
= 0x3, /* Not a typo but means "width and height". */
42 FULLSCREEN_MAXIMIZED
= 0x4,
48 #endif /* HAVE_WINDOW_SYSTEM */
50 /* The structure representing a frame. */
54 struct vectorlike_header header
;
56 /* All Lisp_Object components must come first.
57 That ensures they are all aligned normally. */
59 /* Name of this frame: a Lisp string. It is used for looking up resources,
60 as well as for the title in some cases. */
63 /* The name to use for the icon, the last time
64 it was refreshed. nil means not explicitly specified. */
65 Lisp_Object icon_name
;
67 /* This is the frame title specified explicitly, if any.
71 /* The frame which should receive keystrokes that occur in this
72 frame, or nil if they should go to the frame itself. This is
73 usually nil, but if the frame is minibufferless, we can use this
74 to redirect keystrokes to a surrogate minibuffer frame when
77 Note that a value of nil is different than having the field point
78 to the frame itself. Whenever the Fselect_frame function is used
79 to shift from one frame to the other, any redirections to the
80 original frame are shifted to the newly selected frame; if
81 focus_frame is nil, Fselect_frame will leave it alone. */
82 Lisp_Object focus_frame
;
84 /* This frame's root window. Every frame has one.
85 If the frame has only a minibuffer window, this is it.
86 Otherwise, if the frame has a minibuffer window, this is its sibling. */
87 Lisp_Object root_window
;
89 /* This frame's selected window.
90 Each frame has its own window hierarchy
91 and one of the windows in it is selected within the frame.
92 The selected window of the selected frame is Emacs's selected window. */
93 Lisp_Object selected_window
;
95 /* This frame's minibuffer window.
96 Most frames have their own minibuffer windows,
97 but only the selected frame's minibuffer window
98 can actually appear to exist. */
99 Lisp_Object minibuffer_window
;
101 /* Parameter alist of this frame.
102 These are the parameters specified when creating the frame
103 or modified with modify-frame-parameters. */
104 Lisp_Object param_alist
;
106 /* List of scroll bars on this frame.
107 Actually, we don't specify exactly what is stored here at all; the
108 scroll bar implementation code can use it to store anything it likes.
109 This field is marked by the garbage collector. It is here
110 instead of in the `device' structure so that the garbage
111 collector doesn't need to look inside the window-system-dependent
113 Lisp_Object scroll_bars
;
114 Lisp_Object condemned_scroll_bars
;
116 /* Vector describing the items to display in the menu bar.
117 Each item has four elements in this vector.
118 They are KEY, STRING, SUBMAP, and HPOS.
119 (HPOS is not used in when the X toolkit is in use.)
120 There are four additional elements of nil at the end, to terminate. */
121 Lisp_Object menu_bar_items
;
123 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
124 Lisp_Object face_alist
;
126 /* A vector that records the entire structure of this frame's menu bar.
127 For the format of the data, see extensive comments in xmenu.c.
128 Only the X toolkit version uses this. */
129 Lisp_Object menu_bar_vector
;
131 /* Predicate for selecting buffers for other-buffer. */
132 Lisp_Object buffer_predicate
;
134 /* List of buffers viewed in this frame, for other-buffer. */
135 Lisp_Object buffer_list
;
137 /* List of buffers that were viewed, then buried in this frame. The
138 most recently buried buffer is first. For last-buffer. */
139 Lisp_Object buried_buffer_list
;
141 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
142 /* A dummy window used to display menu bars under X when no X
143 toolkit support is available. */
144 Lisp_Object menu_bar_window
;
147 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
148 /* A window used to display the tool-bar of a frame. */
149 Lisp_Object tool_bar_window
;
151 /* Desired and current contents displayed in that window. */
152 Lisp_Object desired_tool_bar_string
;
153 Lisp_Object current_tool_bar_string
;
156 /* Desired and current tool-bar items. */
157 Lisp_Object tool_bar_items
;
160 /* Where tool bar is, can be left, right, top or bottom.
161 Except with GTK, the only supported position is `top'. */
162 Lisp_Object tool_bar_position
;
165 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
166 /* List of data specific to font-driver and frame, but common to faces. */
167 Lisp_Object font_data
;
170 /* Beyond here, there should be no more Lisp_Object components. */
172 /* Cache of realized faces. */
173 struct face_cache
*face_cache
;
175 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
176 /* Tool-bar item index of the item on which a mouse button was pressed. */
177 int last_tool_bar_item
;
180 /* Number of elements in `menu_bar_vector' that have meaningful data. */
181 int menu_bar_items_used
;
183 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
184 /* A buffer to hold the frame's name. Since this is used by the
185 window system toolkit, we can't use the Lisp string's pointer
186 (`name', above) because it might get relocated. */
191 /* Used to pass geometry parameters to toolkit functions. */
192 char *shell_position
;
195 /* Glyph pool and matrix. */
196 struct glyph_pool
*current_pool
;
197 struct glyph_pool
*desired_pool
;
198 struct glyph_matrix
*desired_matrix
;
199 struct glyph_matrix
*current_matrix
;
201 /* Bitfield area begins here. Keep them together to avoid extra padding. */
203 /* True means that glyphs on this frame have been initialized so it can
204 be used for output. */
205 bool_bf glyphs_initialized_p
: 1;
207 /* Set to true in change_frame_size when size of frame changed
208 Clear the frame in clear_garbaged_frames if set. */
209 bool_bf resized_p
: 1;
211 /* Set to true if the default face for the frame has been
212 realized. Reset to zero whenever the default face changes.
213 Used to see the difference between a font change and face change. */
214 bool_bf default_face_done_p
: 1;
216 /* Set to true if this frame has already been hscrolled during
217 current redisplay. */
218 bool_bf already_hscrolled_p
: 1;
220 /* Set to true when current redisplay has updated frame. */
221 bool_bf updated_p
: 1;
223 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
224 /* Set to true to minimize tool-bar height even when
225 auto-resize-tool-bar is set to grow-only. */
226 bool_bf minimize_tool_bar_window_p
: 1;
229 #if defined (USE_GTK) || defined (HAVE_NS)
230 /* True means using a tool bar that comes from the toolkit. */
231 bool_bf external_tool_bar
: 1;
234 /* True means that fonts have been loaded since the last glyph
235 matrix adjustments. */
236 bool_bf fonts_changed
: 1;
238 /* True means that cursor type has been changed. */
239 bool_bf cursor_type_changed
: 1;
241 /* True if it needs to be redisplayed. */
242 bool_bf redisplay
: 1;
244 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
245 || defined (HAVE_NS) || defined (USE_GTK)
246 /* True means using a menu bar that comes from the X toolkit. */
247 bool_bf external_menu_bar
: 1;
250 /* Next two bitfields are mutually exclusive. They might both be
251 zero if the frame has been made invisible without an icon. */
253 /* Nonzero if the frame is currently displayed; we check
254 it to see if we should bother updating the frame's contents.
256 On ttys and on Windows NT/9X, to avoid wasting effort updating
257 visible frames that are actually completely obscured by other
258 windows on the display, we bend the meaning of visible slightly:
259 if equal to 2, then the frame is obscured - we still consider
260 it to be "visible" as seen from lisp, but we don't bother
262 unsigned visible
: 2;
264 /* True if the frame is currently iconified. Do not
265 set this directly, use SET_FRAME_ICONIFIED instead. */
266 bool_bf iconified
: 1;
268 /* True if this frame should be fully redisplayed. Disables all
269 optimizations while rebuilding matrices and redrawing. */
270 bool_bf garbaged
: 1;
272 /* False means, if this frame has just one window,
273 show no modeline for that window. */
274 bool_bf wants_modeline
: 1;
276 /* True means raise this frame to the top of the heap when selected. */
277 bool_bf auto_raise
: 1;
279 /* True means lower this frame to the bottom of the stack when left. */
280 bool_bf auto_lower
: 1;
282 /* True if frame's root window can't be split. */
283 bool_bf no_split
: 1;
285 /* If this is set, then Emacs won't change the frame name to indicate
286 the current buffer, etcetera. If the user explicitly sets the frame
287 name, this gets set. If the user sets the name to Qnil, this is
289 bool_bf explicit_name
: 1;
291 /* True if configuration of windows on this frame has changed since
292 last call of run_window_size_change_functions. */
293 bool_bf window_configuration_changed
: 1;
295 /* True if the mouse has moved on this display device
296 since the last time we checked. */
297 bool_bf mouse_moved
: 1;
299 /* True means that the pointer is invisible. */
300 bool_bf pointer_invisible
: 1;
302 /* True means that all windows except mini-window and
303 selected window on this frame have frozen window starts. */
304 bool_bf frozen_window_starts
: 1;
306 /* The output method says how the contents of this frame are
307 displayed. It could be using termcap, or using an X window.
308 This must be the same as the terminal->type. */
309 ENUM_BF (output_method
) output_method
: 3;
311 #ifdef HAVE_WINDOW_SYSTEM
312 /* True if this frame is a tooltip frame. */
315 /* See FULLSCREEN_ enum on top. */
316 ENUM_BF (fullscreen_type
) want_fullscreen
: 4;
318 /* If not vertical_scroll_bar_none, we should actually
319 display the scroll bars of this type on this frame. */
320 ENUM_BF (vertical_scroll_bar_type
) vertical_scroll_bar_type
: 2;
322 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
323 bool_bf horizontal_scroll_bars
: 1;
324 #endif /* HAVE_WINDOW_SYSTEM */
326 /* Whether new_height and new_width shall be interpreted
328 bool_bf new_pixelwise
: 1;
330 /* True means x_set_window_size requests can be processed for this
332 bool_bf can_x_set_window_size
: 1;
334 /* Set to true after this frame was made by `make-frame'. */
335 bool_bf after_make_frame
: 1;
337 /* Whether the tool bar height change should be taken into account. */
338 bool_bf tool_bar_redisplayed
: 1;
339 bool_bf tool_bar_resized
: 1;
341 /* Inhibit implied resize before after_make_frame is set. */
342 bool_bf inhibit_horizontal_resize
: 1;
343 bool_bf inhibit_vertical_resize
: 1;
345 /* Non-zero if this frame's faces need to be recomputed. */
346 bool_bf face_change
: 1;
348 /* Bitfield area ends here. */
350 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
353 /* Height of frame internal tool bar in pixels. */
357 int n_tool_bar_items
;
359 /* A buffer for decode_mode_line. */
360 char *decode_mode_spec_buffer
;
362 /* See do_line_insertion_deletion_costs for info on these arrays. */
363 /* Cost of inserting 1 line on this frame. */
364 int *insert_line_cost
;
365 /* Cost of deleting 1 line on this frame. */
366 int *delete_line_cost
;
367 /* Cost of inserting n lines on this frame. */
368 int *insert_n_lines_cost
;
369 /* Cost of deleting n lines on this frame. */
370 int *delete_n_lines_cost
;
372 /* Text width of this frame (excluding fringes, vertical scroll bar
373 and internal border widths) and text height (excluding menu bar,
374 tool bar, horizontal scroll bar and internal border widths) in
375 units of canonical characters. */
376 int text_cols
, text_lines
;
378 /* Total width of this frame (including fringes, vertical scroll bar
379 and internal border widths) and total height (including menu bar,
380 tool bar, horizontal scroll bar and internal border widths) in
381 units of canonical characters. */
382 int total_cols
, total_lines
;
384 /* Text width of this frame (excluding fringes, vertical scroll bar
385 and internal border widths) and text height (excluding menu bar,
386 tool bar, horizontal scroll bar and internal border widths) in
388 int text_width
, text_height
;
390 /* New text height and width for pending size change. 0 if no change
391 pending. These values represent pixels or canonical character units
392 according to the value of new_pixelwise and correlate to the the
393 text width/height of the frame. */
394 int new_width
, new_height
;
396 /* Pixel position of the frame window (x and y offsets in root window). */
397 int left_pos
, top_pos
;
399 /* Total width of this frame (including fringes, vertical scroll bar
400 and internal border widths) and total height (including internal
401 menu and tool bars, horizontal scroll bar and internal border
402 widths) in pixels. */
403 int pixel_width
, pixel_height
;
405 /* This is the gravity value for the specified window position. */
408 /* The geometry flags for this window. */
411 /* Border width of the frame window as known by the (X) window system. */
414 /* Width of the internal border. This is a line of background color
415 just inside the window's border. When the frame is selected,
416 a highlighting is displayed inside the internal border. */
417 int internal_border_width
;
419 /* Widths of dividers between this frame's windows in pixels. */
420 int right_divider_width
, bottom_divider_width
;
422 /* Widths of fringes in pixels. */
423 int left_fringe_width
, right_fringe_width
;
425 /* Total width of fringes reserved for drawing truncation bitmaps,
426 continuation bitmaps and alike - REMOVE THIS !!!!. */
429 /* Number of lines of menu bar. */
432 /* Pixel height of menubar. */
435 /* Canonical X unit. Width of default font, in pixels. */
438 /* Canonical Y unit. Height of a line, in pixels. */
441 /* The terminal device that this frame uses. If this is NULL, then
442 the frame has been deleted. */
443 struct terminal
*terminal
;
445 /* Device-dependent, frame-local auxiliary data used for displaying
446 the contents. When the frame is deleted, this data is deleted as
450 struct tty_output
*tty
; /* From termchar.h. */
451 struct x_output
*x
; /* From xterm.h. */
452 struct w32_output
*w32
; /* From w32term.h. */
453 struct ns_output
*ns
; /* From nsterm.h. */
458 /* List of font-drivers available on the frame. */
459 struct font_driver_list
*font_driver_list
;
461 #if defined (HAVE_X_WINDOWS)
462 /* Used by x_wait_for_event when watching for an X event on this frame. */
466 /* What kind of text cursor should we draw in the future?
467 This should always be filled_box_cursor or bar_cursor. */
468 enum text_cursor_kinds desired_cursor
;
470 /* Width of bar cursor (if we are using that). */
473 /* What kind of text cursor should we draw when the cursor blinks off?
474 This can be filled_box_cursor or bar_cursor or no_cursor. */
475 enum text_cursor_kinds blink_off_cursor
;
477 /* Width of bar cursor (if we are using that) for blink-off state. */
478 int blink_off_cursor_width
;
480 /* Configured width of the scroll bar, in pixels and in characters.
481 config_scroll_bar_cols tracks config_scroll_bar_width if the
482 latter is positive; a zero value in config_scroll_bar_width means
483 to compute the actual width on the fly, using config_scroll_bar_cols
484 and the current font width. */
485 int config_scroll_bar_width
;
486 int config_scroll_bar_cols
;
488 /* Configured height of the scroll bar, in pixels and in characters.
489 config_scroll_bar_lines tracks config_scroll_bar_height if the
490 latter is positive; a zero value in config_scroll_bar_height means
491 to compute the actual width on the fly, using
492 config_scroll_bar_lines and the current font width. */
493 int config_scroll_bar_height
;
494 int config_scroll_bar_lines
;
496 /* The baud rate that was used to calculate costs for this frame. */
497 int cost_calculation_baud_rate
;
500 alpha[0]: alpha transparency of the active frame
501 alpha[1]: alpha transparency of inactive frames
502 Negative values mean not to change alpha. */
505 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
506 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
507 frame parameter. 0 means don't do gamma correction. */
510 /* Additional space to put between text lines on this frame. */
511 int extra_line_spacing
;
513 /* All display backends seem to need these two pixel values. */
514 unsigned long background_pixel
;
515 unsigned long foreground_pixel
;
518 /* Most code should use these functions to set Lisp fields in struct frame. */
521 fset_buffer_list (struct frame
*f
, Lisp_Object val
)
523 f
->buffer_list
= val
;
526 fset_buried_buffer_list (struct frame
*f
, Lisp_Object val
)
528 f
->buried_buffer_list
= val
;
531 fset_condemned_scroll_bars (struct frame
*f
, Lisp_Object val
)
533 f
->condemned_scroll_bars
= val
;
536 fset_face_alist (struct frame
*f
, Lisp_Object val
)
541 fset_focus_frame (struct frame
*f
, Lisp_Object val
)
543 f
->focus_frame
= val
;
546 fset_icon_name (struct frame
*f
, Lisp_Object val
)
551 fset_menu_bar_items (struct frame
*f
, Lisp_Object val
)
553 f
->menu_bar_items
= val
;
556 fset_menu_bar_vector (struct frame
*f
, Lisp_Object val
)
558 f
->menu_bar_vector
= val
;
560 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
562 fset_menu_bar_window (struct frame
*f
, Lisp_Object val
)
564 f
->menu_bar_window
= val
;
568 fset_name (struct frame
*f
, Lisp_Object val
)
573 fset_param_alist (struct frame
*f
, Lisp_Object val
)
575 f
->param_alist
= val
;
578 fset_root_window (struct frame
*f
, Lisp_Object val
)
580 f
->root_window
= val
;
583 fset_scroll_bars (struct frame
*f
, Lisp_Object val
)
585 f
->scroll_bars
= val
;
588 fset_selected_window (struct frame
*f
, Lisp_Object val
)
590 f
->selected_window
= val
;
593 fset_title (struct frame
*f
, Lisp_Object val
)
598 fset_tool_bar_items (struct frame
*f
, Lisp_Object val
)
600 f
->tool_bar_items
= val
;
604 fset_tool_bar_position (struct frame
*f
, Lisp_Object val
)
606 f
->tool_bar_position
= val
;
609 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
611 fset_tool_bar_window (struct frame
*f
, Lisp_Object val
)
613 f
->tool_bar_window
= val
;
616 fset_current_tool_bar_string (struct frame
*f
, Lisp_Object val
)
618 f
->current_tool_bar_string
= val
;
621 fset_desired_tool_bar_string (struct frame
*f
, Lisp_Object val
)
623 f
->desired_tool_bar_string
= val
;
625 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
627 #define NUMVAL(X) (NUMBERP (X) ? XFLOATINT (X) : -1)
630 default_pixels_per_inch_x (void)
632 Lisp_Object v
= (CONSP (Vdisplay_pixels_per_inch
)
633 ? XCAR (Vdisplay_pixels_per_inch
)
634 : Vdisplay_pixels_per_inch
);
635 return NUMVAL (v
) > 0 ? NUMVAL (v
) : 72.0;
639 default_pixels_per_inch_y (void)
641 Lisp_Object v
= (CONSP (Vdisplay_pixels_per_inch
)
642 ? XCDR (Vdisplay_pixels_per_inch
)
643 : Vdisplay_pixels_per_inch
);
644 return NUMVAL (v
) > 0 ? NUMVAL (v
) : 72.0;
647 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
649 /* Return a pointer to the image cache of frame F. */
650 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
653 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
654 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
656 /* Given a window, return its frame as a Lisp_Object. */
657 #define WINDOW_FRAME(w) ((w)->frame)
659 /* Test a frame for particular kinds of display methods. */
660 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
661 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
662 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
664 #define FRAME_W32_P(f) false
666 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
669 #define FRAME_MSDOS_P(f) false
671 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
674 #define FRAME_NS_P(f) false
676 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
679 /* FRAME_WINDOW_P tests whether the frame is a window, and is
680 defined to be the predicate for the window system being used. */
682 #ifdef HAVE_X_WINDOWS
683 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
686 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
689 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
691 #ifndef FRAME_WINDOW_P
692 #define FRAME_WINDOW_P(f) ((void) (f), false)
695 /* Dots per inch of the screen the frame F is on. */
697 #ifdef HAVE_WINDOW_SYSTEM
699 #define FRAME_RES_X(f) \
700 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
701 #define FRAME_RES_Y(f) \
702 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
704 #else /* !HAVE_WINDOW_SYSTEM */
706 /* Defaults when no window system available. */
708 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
709 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
711 #endif /* HAVE_WINDOW_SYSTEM */
713 /* Return a pointer to the structure holding information about the
714 region of text, if any, that is currently shown in mouse-face on
715 frame F. We need to define two versions because a TTY-only build
716 does not have FRAME_DISPLAY_INFO. */
717 #ifdef HAVE_WINDOW_SYSTEM
718 # define MOUSE_HL_INFO(F) \
720 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
721 : &(F)->output_data.tty->display_info->mouse_highlight)
723 # define MOUSE_HL_INFO(F) \
724 (&(F)->output_data.tty->display_info->mouse_highlight)
727 /* True if frame F is still alive (not deleted). */
728 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
730 /* True if frame F is a minibuffer-only frame. */
731 #define FRAME_MINIBUF_ONLY_P(f) \
732 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
734 /* True if frame F contains it's own minibuffer window. Frame always has
735 minibuffer window, but it could use minibuffer window of another frame. */
736 #define FRAME_HAS_MINIBUF_P(f) \
737 (WINDOWP (f->minibuffer_window) \
738 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
740 /* Pixel width of frame F. */
741 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
743 /* Pixel height of frame F. */
744 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
746 /* Width of frame F, measured in canonical character columns,
747 not including scroll bars if any. */
748 #define FRAME_COLS(f) (f)->text_cols
750 /* Height of frame F, measured in canonical lines, including
751 non-toolkit menu bar and non-toolkit tool bar lines. */
752 #define FRAME_LINES(f) (f)->text_lines
754 /* Width of frame F, measured in pixels not including the width for
755 fringes, scroll bar, and internal borders. */
756 #define FRAME_TEXT_WIDTH(f) (f)->text_width
758 /* Height of frame F, measured in pixels not including the height
759 for scroll bar and internal borders. */
760 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
762 /* Number of lines of frame F used for menu bar.
763 This is relevant on terminal frames and on
764 X Windows when not using the X toolkit.
765 These lines are counted in FRAME_LINES. */
766 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
768 /* Pixel height of frame F's menu bar. */
769 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
771 /* True if this frame should display a tool bar
772 in a way that does not use any text lines. */
773 #if defined (USE_GTK) || defined (HAVE_NS)
774 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
776 #define FRAME_EXTERNAL_TOOL_BAR(f) false
779 /* This is really supported only with GTK. */
781 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
783 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
786 /* Number of lines of frame F used for the tool-bar. */
787 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
789 /* Pixel height of frame F's tool-bar. */
790 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
792 /* Lines above the top-most window in frame F. */
793 #define FRAME_TOP_MARGIN(F) \
794 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
796 /* Pixel height of frame F's top margin. */
797 #define FRAME_TOP_MARGIN_HEIGHT(F) \
798 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
800 /* True if this frame should display a menu bar
801 in a way that does not use any text lines. */
802 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
803 || defined (HAVE_NS) || defined (USE_GTK)
804 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
806 #define FRAME_EXTERNAL_MENU_BAR(f) false
809 /* True if frame F is currently visible. */
810 #define FRAME_VISIBLE_P(f) (f)->visible
812 /* True if frame F is currently visible but hidden. */
813 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
815 /* True if frame F is currently iconified. */
816 #define FRAME_ICONIFIED_P(f) (f)->iconified
818 /* Mark frame F as currently garbaged. */
819 #define SET_FRAME_GARBAGED(f) \
820 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
822 /* True if frame F is currently garbaged. */
823 #define FRAME_GARBAGED_P(f) (f)->garbaged
825 /* True means do not allow splitting this frame's window. */
826 #define FRAME_NO_SPLIT_P(f) (f)->no_split
828 /* Not really implemented. */
829 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
831 /* True if all windows except selected window and mini window
832 are frozen on frame F. */
833 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
835 /* True if the frame's window configuration has changed since last call
836 of run_window_size_change_functions. */
837 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
838 (f)->window_configuration_changed
840 /* The minibuffer window of frame F, if it has one; otherwise nil. */
841 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
843 /* The root window of the window tree of frame F. */
844 #define FRAME_ROOT_WINDOW(f) f->root_window
846 /* The currently selected window of the window tree of frame F. */
847 #define FRAME_SELECTED_WINDOW(f) f->selected_window
849 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
850 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
851 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
852 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
853 #define FRAME_FOCUS_FRAME(f) f->focus_frame
855 #ifdef HAVE_WINDOW_SYSTEM
857 /* This frame slot says whether scroll bars are currently enabled for frame F,
858 and which side they are on. */
859 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
860 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
861 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
862 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
863 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
864 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
865 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
867 /* Whether F is a tooltip frame. */
868 #define FRAME_TOOLTIP_P(f) ((f)->tooltip)
870 #else /* not HAVE_WINDOW_SYSTEM */
872 /* If there is no window system, there are no scroll bars. */
873 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
874 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
875 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
876 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
878 /* If there is no window system, there are no tooltips. */
879 #define FRAME_TOOLTIP_P(f) ((void) f, 0)
881 #endif /* HAVE_WINDOW_SYSTEM */
883 /* Whether horizontal scroll bars are currently enabled for frame F. */
884 #if USE_HORIZONTAL_SCROLL_BARS
885 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
886 ((f)->horizontal_scroll_bars)
888 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
891 /* Width that a scroll bar in frame F should have, if there is one.
893 If scroll bars are turned off, this is still nonzero. */
894 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
896 /* Height that a scroll bar in frame F should have, if there is one.
898 If scroll bars are turned off, this is still nonzero. */
899 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
901 /* Width that a scroll bar in frame F should have, if there is one.
902 Measured in columns (characters).
903 If scroll bars are turned off, this is still nonzero. */
904 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
906 /* Height that a scroll bar in frame F should have, if there is one.
907 Measured in lines (characters).
908 If scroll bars are turned off, this is still nonzero. */
909 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
911 /* Width of a left scroll bar in frame F, measured in pixels */
912 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
913 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
914 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
917 /* Width of a right scroll bar area in frame F, measured in pixels */
918 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
919 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
920 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
923 /* Width of a left scroll bar in frame F, measured in columns
924 (characters), but only if scroll bars are on the left. If scroll
925 bars are on the right in this frame, or there are no scroll bars,
927 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
928 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
929 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
932 /* Width of a right scroll bar in frame F, measured in columns
933 (characters), but only if scroll bars are on the right. If scroll
934 bars are on the left in this frame, or there are no scroll bars,
936 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
937 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
938 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
941 /* Width of a vertical scroll bar area in frame F, measured in
943 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
944 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
945 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
948 /* Height of horizontal scroll bar area in frame F, measured in
950 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
951 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
952 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
955 /* Width of vertical scroll bar in frame F, measured in columns. */
956 #define FRAME_SCROLL_BAR_COLS(f) \
957 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
958 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
961 /* Height of horizontal scroll bar in frame F, measured in lines. */
962 #define FRAME_SCROLL_BAR_LINES(f) \
963 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
964 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
967 /* Total width of frame F, in columns (characters),
968 including the width used by scroll bars if any. */
969 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
971 /* Total height of frame F, in lines (characters),
972 including the height used by scroll bars if any. */
973 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
975 /* Set the character widths of frame F. WIDTH specifies a nominal
976 character text width. */
977 #define SET_FRAME_COLS(f, width) \
978 ((f)->text_cols = (width), \
979 (f)->total_cols = ((width) \
980 + FRAME_SCROLL_BAR_COLS (f) \
981 + FRAME_FRINGE_COLS (f)))
983 /* Set the character heights of frame F. HEIGHT specifies a nominal
984 character text height. */
985 #define SET_FRAME_LINES(f, height) \
986 ((f)->text_lines = (height), \
987 (f)->total_lines = ((height) \
988 + FRAME_TOP_MARGIN (f) \
989 + FRAME_SCROLL_BAR_LINES (f)))
991 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
993 #define SET_FRAME_WIDTH(f, width) \
994 ((f)->text_width = (width), \
995 (f)->pixel_width = ((width) \
996 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
997 + FRAME_TOTAL_FRINGE_WIDTH (f) \
998 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1000 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
1002 #define SET_FRAME_HEIGHT(f, height) \
1003 ((f)->text_height = (height), \
1004 (f)->pixel_height = ((height) \
1005 + FRAME_TOP_MARGIN_HEIGHT (f) \
1006 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1007 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1009 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1010 #define FRAME_CURSOR_X_LIMIT(f) \
1011 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1013 /* Nonzero if frame F has scroll bars. */
1014 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1015 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1017 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1018 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1020 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1021 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1022 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1023 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1025 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1026 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1028 /* Return a pointer to the face cache of frame F. */
1030 #define FRAME_FACE_CACHE(F) (F)->face_cache
1032 /* Return the size of message_buf of the frame F. We multiply the
1033 width of the frame by 4 because multi-byte form may require at most
1034 4-byte for a character. */
1036 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1038 #define CHECK_FRAME(x) \
1039 CHECK_TYPE (FRAMEP (x), Qframep, x)
1041 #define CHECK_LIVE_FRAME(x) \
1042 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1044 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1045 `for' loop which iterates over the elements of Vframe_list. The
1046 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1047 Vframe_list in succession and execute the statement. LIST_VAR
1048 should be a Lisp_Object too; it is used to iterate through the
1051 This macro is a holdover from a time when multiple frames weren't always
1052 supported. An alternate definition of the macro would expand to
1053 something which executes the statement once. */
1055 #define FOR_EACH_FRAME(list_var, frame_var) \
1056 for ((list_var) = Vframe_list; \
1058 && (frame_var = XCAR (list_var), true)); \
1059 list_var = XCDR (list_var))
1061 /* Reflect mouse movement when a complete frame update is performed. */
1063 #define FRAME_MOUSE_UPDATE(frame) \
1065 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1066 if (frame == hlinfo->mouse_face_mouse_frame) \
1069 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1070 hlinfo->mouse_face_mouse_x, \
1071 hlinfo->mouse_face_mouse_y); \
1076 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1078 #define AUTO_FRAME_ARG(name, parameter, value) \
1079 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1081 /* False means there are no visible garbaged frames. */
1082 extern bool frame_garbaged
;
1084 /* Set visibility of frame F.
1085 We call redisplay_other_windows to make sure the frame gets redisplayed
1086 if some changes were applied to it while it wasn't visible (and hence
1087 wasn't redisplayed). */
1090 SET_FRAME_VISIBLE (struct frame
*f
, int v
)
1092 eassert (0 <= v
&& v
<= 2);
1095 if (v
== 1 && f
->visible
!= 1)
1096 redisplay_other_windows ();
1097 if (FRAME_GARBAGED_P (f
))
1098 frame_garbaged
= true;
1103 /* Set iconify of frame F. */
1105 #define SET_FRAME_ICONIFIED(f, i) \
1106 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1108 extern Lisp_Object selected_frame
;
1110 #if ! (defined USE_GTK || defined HAVE_NS)
1111 extern int frame_default_tool_bar_height
;
1114 #ifdef HAVE_WINDOW_SYSTEM
1115 # define WINDOW_SYSTEM_RETURN
1117 # define WINDOW_SYSTEM_RETURN _Noreturn
1120 extern WINDOW_SYSTEM_RETURN
struct frame
*
1121 decode_window_system_frame (Lisp_Object
);
1122 extern struct frame
*decode_live_frame (Lisp_Object
);
1123 extern struct frame
*decode_any_frame (Lisp_Object
);
1124 extern struct frame
*make_initial_frame (void);
1125 extern struct frame
*make_frame (bool);
1126 #ifdef HAVE_WINDOW_SYSTEM
1127 extern struct frame
*make_minibuffer_frame (void);
1128 extern struct frame
*make_frame_without_minibuffer (Lisp_Object
,
1131 extern bool display_available (void);
1135 window_system_available (struct frame
*f
)
1137 #ifdef HAVE_WINDOW_SYSTEM
1138 return f
? FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
) : display_available ();
1144 extern WINDOW_SYSTEM_RETURN
void check_window_system (struct frame
*);
1145 extern void frame_make_pointer_invisible (struct frame
*);
1146 extern void frame_make_pointer_visible (struct frame
*);
1147 extern Lisp_Object
delete_frame (Lisp_Object
, Lisp_Object
);
1148 extern bool frame_inhibit_resize (struct frame
*, bool, Lisp_Object
);
1149 extern void adjust_frame_size (struct frame
*, int, int, int, bool, Lisp_Object
);
1150 extern void frame_size_history_add (struct frame
*f
, Lisp_Object fun_symbol
,
1151 int width
, int height
, Lisp_Object rest
);
1153 extern Lisp_Object Vframe_list
;
1155 /* Value is a pointer to the selected frame. If the selected frame
1156 isn't live, abort. */
1158 #define SELECTED_FRAME() \
1159 ((FRAMEP (selected_frame) \
1160 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1161 ? XFRAME (selected_frame) \
1162 : (emacs_abort (), (struct frame *) 0))
1165 /***********************************************************************
1166 Display-related Macros
1167 ***********************************************************************/
1169 /* Canonical y-unit on frame F.
1170 This value currently equals the line height of the frame (which is
1171 the height of the default font of F). */
1172 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1174 /* Canonical x-unit on frame F.
1175 This value currently equals the average width of the default font of F. */
1176 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1178 /* Get a frame's window system dimension. If no window system, this is 0. */
1181 frame_dimension (int x
)
1183 #ifdef HAVE_WINDOW_SYSTEM
1190 /* Total width of fringes reserved for drawing truncation bitmaps,
1191 continuation bitmaps and alike. The width is in canonical char
1192 units of the frame. This must currently be the case because window
1193 sizes aren't pixel values. If it weren't the case, we wouldn't be
1194 able to split windows horizontally nicely. */
1196 FRAME_FRINGE_COLS (struct frame
*f
)
1198 return frame_dimension (f
->fringe_cols
);
1201 /* Pixel-width of the left and right fringe. */
1204 FRAME_LEFT_FRINGE_WIDTH (struct frame
*f
)
1206 return frame_dimension (f
->left_fringe_width
);
1209 FRAME_RIGHT_FRINGE_WIDTH (struct frame
*f
)
1211 return frame_dimension (f
->right_fringe_width
);
1214 /* Total width of fringes in pixels. */
1217 FRAME_TOTAL_FRINGE_WIDTH (struct frame
*f
)
1219 return FRAME_LEFT_FRINGE_WIDTH (f
) + FRAME_RIGHT_FRINGE_WIDTH (f
);
1222 /* Pixel-width of internal border lines */
1224 FRAME_INTERNAL_BORDER_WIDTH (struct frame
*f
)
1226 return frame_dimension (f
->internal_border_width
);
1229 /* Pixel-size of window border lines */
1231 FRAME_RIGHT_DIVIDER_WIDTH (struct frame
*f
)
1233 return frame_dimension (f
->right_divider_width
);
1236 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame
*f
)
1238 return frame_dimension (f
->bottom_divider_width
);
1241 /***********************************************************************
1242 Conversion between canonical units and pixels
1243 ***********************************************************************/
1245 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1246 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1247 represented as Lisp numbers, i.e. integers or floats. */
1249 /* Convert canonical value X to pixels. F is the frame whose
1250 canonical char width is to be used. X must be a Lisp integer or
1251 float. Value is a C integer. */
1252 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1254 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1255 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1257 /* Convert canonical value Y to pixels. F is the frame whose
1258 canonical character height is to be used. X must be a Lisp integer
1259 or float. Value is a C integer. */
1260 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1262 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1263 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1265 /* Convert pixel-value X to canonical units. F is the frame whose
1266 canonical character width is to be used. X is a C integer. Result
1267 is a Lisp float if X is not a multiple of the canon width,
1268 otherwise it's a Lisp integer. */
1269 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1270 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1271 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1272 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1274 /* Convert pixel-value Y to canonical units. F is the frame whose
1275 canonical character height is to be used. Y is a C integer.
1276 Result is a Lisp float if Y is not a multiple of the canon width,
1277 otherwise it's a Lisp integer. */
1278 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1279 ((Y) % FRAME_LINE_HEIGHT (F) \
1280 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1281 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1285 /* Manipulating pixel sizes and character sizes.
1286 Knowledge of which factors affect the overall size of the window should
1287 be hidden in these macros, if that's possible.
1289 Return the upper/left pixel position of the character cell on frame F
1291 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1292 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1293 + (row) * FRAME_LINE_HEIGHT (f))
1295 #define FRAME_COL_TO_PIXEL_X(f, col) \
1296 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1297 + (col) * FRAME_COLUMN_WIDTH (f))
1299 /* Return the pixel width/height of frame F if it has
1300 COLS columns/LINES rows. */
1301 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1302 ((cols) * FRAME_COLUMN_WIDTH (f) \
1303 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1304 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1305 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1307 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1308 ((lines) * FRAME_LINE_HEIGHT (f) \
1309 + FRAME_TOP_MARGIN_HEIGHT (f) \
1310 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1311 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1313 /* Return the row/column (zero-based) of the character cell containing
1314 the pixel on FRAME at Y/X. */
1315 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1316 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1318 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1319 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1320 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1321 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1322 /* Arrange for the division to round down. */ \
1323 + FRAME_LINE_HEIGHT (f) - 1) \
1324 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1325 / FRAME_LINE_HEIGHT (f))
1327 #define FRAME_PIXEL_X_TO_COL(f, x) \
1328 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1329 / FRAME_COLUMN_WIDTH (f))
1331 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1332 frame F (so we round down)? */
1333 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1335 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1336 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1337 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1338 / FRAME_COLUMN_WIDTH (f)) \
1340 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1342 - FRAME_TOP_MARGIN_HEIGHT (f) \
1343 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1344 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1345 / FRAME_LINE_HEIGHT (f))
1347 /* Return the pixel width/height of frame F with a text size of
1349 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1351 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1352 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1353 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1355 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1357 + FRAME_TOP_MARGIN_HEIGHT (f) \
1358 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1359 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1361 /* Return the text width/height of frame F with a pixel size of
1363 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1365 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1366 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1367 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1369 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1371 - FRAME_TOP_MARGIN_HEIGHT (f) \
1372 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1373 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1375 /* Return the width/height reserved for the windows of frame F. */
1376 #define FRAME_WINDOWS_WIDTH(f) \
1377 (FRAME_PIXEL_WIDTH (f) \
1378 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1380 #define FRAME_WINDOWS_HEIGHT(f) \
1381 (FRAME_PIXEL_HEIGHT (f) \
1382 - FRAME_TOP_MARGIN_HEIGHT (f) \
1383 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1385 /* Value is the smallest width of any character in any font on frame F. */
1386 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1387 FRAME_DISPLAY_INFO (f)->smallest_char_width
1389 /* Value is the smallest height of any font on frame F. */
1390 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1391 FRAME_DISPLAY_INFO (f)->smallest_font_height
1393 /***********************************************************************
1395 ***********************************************************************/
1397 #ifdef HAVE_WINDOW_SYSTEM
1399 /* The class of this X application. */
1400 #define EMACS_CLASS "Emacs"
1402 extern void x_set_scroll_bar_default_width (struct frame
*);
1403 extern void x_set_scroll_bar_default_height (struct frame
*);
1404 extern void x_set_offset (struct frame
*, int, int, int);
1405 extern void x_wm_set_size_hint (struct frame
*f
, long flags
, bool user_position
);
1406 extern Lisp_Object
x_new_font (struct frame
*, Lisp_Object
, int);
1407 extern void x_set_frame_parameters (struct frame
*, Lisp_Object
);
1408 extern void x_set_fullscreen (struct frame
*, Lisp_Object
, Lisp_Object
);
1409 extern void x_set_line_spacing (struct frame
*, Lisp_Object
, Lisp_Object
);
1410 extern void x_set_screen_gamma (struct frame
*, Lisp_Object
, Lisp_Object
);
1411 extern void x_set_font (struct frame
*, Lisp_Object
, Lisp_Object
);
1412 extern void x_set_font_backend (struct frame
*, Lisp_Object
, Lisp_Object
);
1413 extern void x_set_left_fringe (struct frame
*, Lisp_Object
, Lisp_Object
);
1414 extern void x_set_right_fringe (struct frame
*, Lisp_Object
, Lisp_Object
);
1415 extern void x_set_border_width (struct frame
*, Lisp_Object
, Lisp_Object
);
1416 extern void x_set_right_divider_width (struct frame
*, Lisp_Object
,
1418 extern void x_set_bottom_divider_width (struct frame
*, Lisp_Object
,
1420 extern void x_set_visibility (struct frame
*, Lisp_Object
, Lisp_Object
);
1421 extern void x_set_autoraise (struct frame
*, Lisp_Object
, Lisp_Object
);
1422 extern void x_set_autolower (struct frame
*, Lisp_Object
, Lisp_Object
);
1423 extern void x_set_unsplittable (struct frame
*, Lisp_Object
, Lisp_Object
);
1424 extern void x_set_vertical_scroll_bars (struct frame
*, Lisp_Object
, Lisp_Object
);
1425 extern void x_set_horizontal_scroll_bars (struct frame
*, Lisp_Object
, Lisp_Object
);
1426 extern void x_set_scroll_bar_width (struct frame
*, Lisp_Object
, Lisp_Object
);
1427 extern void x_set_scroll_bar_height (struct frame
*, Lisp_Object
, Lisp_Object
);
1429 extern long x_figure_window_size (struct frame
*, Lisp_Object
, bool, int *, int *);
1431 extern void x_set_alpha (struct frame
*, Lisp_Object
, Lisp_Object
);
1433 extern void validate_x_resource_name (void);
1435 extern Lisp_Object
display_x_get_resource (Display_Info
*,
1436 Lisp_Object attribute
,
1438 Lisp_Object component
,
1439 Lisp_Object subclass
);
1441 extern void set_frame_menubar (struct frame
*f
, bool first_time
, bool deep_p
);
1442 extern void x_set_window_size (struct frame
*f
, bool change_gravity
,
1443 int width
, int height
, bool pixelwise
);
1444 extern Lisp_Object
x_get_focus_frame (struct frame
*);
1445 extern void frame_set_mouse_pixel_position (struct frame
*f
, int pix_x
, int pix_y
);
1446 extern void x_make_frame_visible (struct frame
*f
);
1447 extern void x_make_frame_invisible (struct frame
*f
);
1448 extern void x_iconify_frame (struct frame
*f
);
1449 extern void x_set_frame_alpha (struct frame
*f
);
1450 extern void x_activate_menubar (struct frame
*);
1451 extern void x_real_positions (struct frame
*, int *, int *);
1452 extern void free_frame_menubar (struct frame
*);
1453 extern void x_free_frame_resources (struct frame
*);
1455 #if defined HAVE_X_WINDOWS
1456 extern void x_wm_set_icon_position (struct frame
*, int, int);
1457 #if !defined USE_X_TOOLKIT
1458 extern char *x_get_resource_string (const char *, const char *);
1460 extern void x_sync (struct frame
*);
1461 #endif /* HAVE_X_WINDOWS */
1463 extern void x_query_colors (struct frame
*f
, XColor
*, int);
1464 extern void x_focus_frame (struct frame
*);
1468 extern bool x_bitmap_icon (struct frame
*, Lisp_Object
);
1470 /* Set F's bitmap icon, if specified among F's parameters. */
1473 x_set_bitmap_icon (struct frame
*f
)
1475 Lisp_Object obj
= assq_no_quit (Qicon_type
, f
->param_alist
);
1477 if (CONSP (obj
) && !NILP (XCDR (obj
)))
1478 x_bitmap_icon (f
, XCDR (obj
));
1481 #endif /* !HAVE_NS */
1482 #endif /* HAVE_WINDOW_SYSTEM */
1485 flush_frame (struct frame
*f
)
1487 struct redisplay_interface
*rif
= FRAME_RIF (f
);
1489 if (rif
&& rif
->flush_display
)
1490 rif
->flush_display (f
);
1493 /***********************************************************************
1495 ***********************************************************************/
1497 #ifdef HAVE_WINDOW_SYSTEM
1499 struct MonitorInfo
{
1500 XRectangle geom
, work
;
1501 int mm_width
, mm_height
;
1505 extern void free_monitors (struct MonitorInfo
*monitors
, int n_monitors
);
1506 extern Lisp_Object
make_monitor_attribute_list (struct MonitorInfo
*monitors
,
1508 int primary_monitor
,
1509 Lisp_Object monitor_frames
,
1510 const char *source
);
1512 #endif /* HAVE_WINDOW_SYSTEM */
1517 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1518 This is for functions like x_set_horizontal_scroll_bars that have
1519 no effect in this case. */
1520 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1521 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1524 #endif /* not EMACS_FRAME_H */