1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2017 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or (at
9 your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <https://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,
53 z_group_above_suspended
,
56 enum internal_border_part
59 INTERNAL_BORDER_LEFT_EDGE
,
60 INTERNAL_BORDER_TOP_LEFT_CORNER
,
61 INTERNAL_BORDER_TOP_EDGE
,
62 INTERNAL_BORDER_TOP_RIGHT_CORNER
,
63 INTERNAL_BORDER_RIGHT_EDGE
,
64 INTERNAL_BORDER_BOTTOM_RIGHT_CORNER
,
65 INTERNAL_BORDER_BOTTOM_EDGE
,
66 INTERNAL_BORDER_BOTTOM_LEFT_CORNER
,
70 enum ns_appearance_type
73 ns_appearance_vibrant_dark
76 #endif /* HAVE_WINDOW_SYSTEM */
78 /* The structure representing a frame. */
82 struct vectorlike_header header
;
84 /* All Lisp_Object components must come first.
85 That ensures they are all aligned normally. */
87 /* Name of this frame: a Lisp string. It is used for looking up resources,
88 as well as for the title in some cases. */
91 /* The name to use for the icon, the last time
92 it was refreshed. nil means not explicitly specified. */
93 Lisp_Object icon_name
;
95 /* This is the frame title specified explicitly, if any.
99 #if defined (HAVE_WINDOW_SYSTEM)
100 /* This frame's parent frame, if it has one. */
101 Lisp_Object parent_frame
;
102 #endif /* HAVE_WINDOW_SYSTEM */
104 /* The frame which should receive keystrokes that occur in this
105 frame, or nil if they should go to the frame itself. This is
106 usually nil, but if the frame is minibufferless, we can use this
107 to redirect keystrokes to a surrogate minibuffer frame when
110 Note that a value of nil is different than having the field point
111 to the frame itself. Whenever the Fselect_frame function is used
112 to shift from one frame to the other, any redirections to the
113 original frame are shifted to the newly selected frame; if
114 focus_frame is nil, Fselect_frame will leave it alone. */
115 Lisp_Object focus_frame
;
117 /* This frame's root window. Every frame has one.
118 If the frame has only a minibuffer window, this is it.
119 Otherwise, if the frame has a minibuffer window, this is its sibling. */
120 Lisp_Object root_window
;
122 /* This frame's selected window.
123 Each frame has its own window hierarchy
124 and one of the windows in it is selected within the frame.
125 The selected window of the selected frame is Emacs's selected window. */
126 Lisp_Object selected_window
;
128 /* This frame's minibuffer window.
129 Most frames have their own minibuffer windows,
130 but only the selected frame's minibuffer window
131 can actually appear to exist. */
132 Lisp_Object minibuffer_window
;
134 /* Parameter alist of this frame.
135 These are the parameters specified when creating the frame
136 or modified with modify-frame-parameters. */
137 Lisp_Object param_alist
;
139 /* List of scroll bars on this frame.
140 Actually, we don't specify exactly what is stored here at all; the
141 scroll bar implementation code can use it to store anything it likes.
142 This field is marked by the garbage collector. It is here
143 instead of in the `device' structure so that the garbage
144 collector doesn't need to look inside the window-system-dependent
146 Lisp_Object scroll_bars
;
147 Lisp_Object condemned_scroll_bars
;
149 /* Vector describing the items to display in the menu bar.
150 Each item has four elements in this vector.
151 They are KEY, STRING, SUBMAP, and HPOS.
152 (HPOS is not used in when the X toolkit is in use.)
153 There are four additional elements of nil at the end, to terminate. */
154 Lisp_Object menu_bar_items
;
156 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
157 Lisp_Object face_alist
;
159 /* A vector that records the entire structure of this frame's menu bar.
160 For the format of the data, see extensive comments in xmenu.c.
161 Only the X toolkit version uses this. */
162 Lisp_Object menu_bar_vector
;
164 /* Predicate for selecting buffers for other-buffer. */
165 Lisp_Object buffer_predicate
;
167 /* List of buffers viewed in this frame, for other-buffer. */
168 Lisp_Object buffer_list
;
170 /* List of buffers that were viewed, then buried in this frame. The
171 most recently buried buffer is first. For last-buffer. */
172 Lisp_Object buried_buffer_list
;
174 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
175 /* A dummy window used to display menu bars under X when no X
176 toolkit support is available. */
177 Lisp_Object menu_bar_window
;
180 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
181 /* A window used to display the tool-bar of a frame. */
182 Lisp_Object tool_bar_window
;
184 /* Desired and current contents displayed in that window. */
185 Lisp_Object desired_tool_bar_string
;
186 Lisp_Object current_tool_bar_string
;
189 /* Desired and current tool-bar items. */
190 Lisp_Object tool_bar_items
;
193 /* Where tool bar is, can be left, right, top or bottom.
194 Except with GTK, the only supported position is `top'. */
195 Lisp_Object tool_bar_position
;
198 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
199 /* List of data specific to font-driver and frame, but common to faces. */
200 Lisp_Object font_data
;
203 /* Beyond here, there should be no more Lisp_Object components. */
205 /* Cache of realized faces. */
206 struct face_cache
*face_cache
;
208 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
209 /* Tool-bar item index of the item on which a mouse button was pressed. */
210 int last_tool_bar_item
;
213 /* Number of elements in `menu_bar_vector' that have meaningful data. */
214 int menu_bar_items_used
;
216 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
217 /* A buffer to hold the frame's name. Since this is used by the
218 window system toolkit, we can't use the Lisp string's pointer
219 (`name', above) because it might get relocated. */
224 /* Used to pass geometry parameters to toolkit functions. */
225 char *shell_position
;
228 /* Glyph pool and matrix. */
229 struct glyph_pool
*current_pool
;
230 struct glyph_pool
*desired_pool
;
231 struct glyph_matrix
*desired_matrix
;
232 struct glyph_matrix
*current_matrix
;
234 /* Bitfield area begins here. Keep them together to avoid extra padding. */
236 /* True means that glyphs on this frame have been initialized so it can
237 be used for output. */
238 bool_bf glyphs_initialized_p
: 1;
240 /* Set to true in change_frame_size when size of frame changed
241 Clear the frame in clear_garbaged_frames if set. */
242 bool_bf resized_p
: 1;
244 /* Set to true if the default face for the frame has been
245 realized. Reset to zero whenever the default face changes.
246 Used to see the difference between a font change and face change. */
247 bool_bf default_face_done_p
: 1;
249 /* Set to true if this frame has already been hscrolled during
250 current redisplay. */
251 bool_bf already_hscrolled_p
: 1;
253 /* Set to true when current redisplay has updated frame. */
254 bool_bf updated_p
: 1;
256 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
257 /* Set to true to minimize tool-bar height even when
258 auto-resize-tool-bar is set to grow-only. */
259 bool_bf minimize_tool_bar_window_p
: 1;
262 #if defined (USE_GTK) || defined (HAVE_NS)
263 /* True means using a tool bar that comes from the toolkit. */
264 bool_bf external_tool_bar
: 1;
267 /* True means that fonts have been loaded since the last glyph
268 matrix adjustments. */
269 bool_bf fonts_changed
: 1;
271 /* True means that cursor type has been changed. */
272 bool_bf cursor_type_changed
: 1;
274 /* True if it needs to be redisplayed. */
275 bool_bf redisplay
: 1;
277 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
278 || defined (HAVE_NS) || defined (USE_GTK)
279 /* True means using a menu bar that comes from the X toolkit. */
280 bool_bf external_menu_bar
: 1;
283 /* Next two bitfields are mutually exclusive. They might both be
284 zero if the frame has been made invisible without an icon. */
286 /* Nonzero if the frame is currently displayed; we check
287 it to see if we should bother updating the frame's contents.
289 On ttys and on Windows NT/9X, to avoid wasting effort updating
290 visible frames that are actually completely obscured by other
291 windows on the display, we bend the meaning of visible slightly:
292 if equal to 2, then the frame is obscured - we still consider
293 it to be "visible" as seen from lisp, but we don't bother
295 unsigned visible
: 2;
297 /* True if the frame is currently iconified. Do not
298 set this directly, use SET_FRAME_ICONIFIED instead. */
299 bool_bf iconified
: 1;
301 /* True if this frame should be fully redisplayed. Disables all
302 optimizations while rebuilding matrices and redrawing. */
303 bool_bf garbaged
: 1;
305 /* False means, if this frame has just one window,
306 show no modeline for that window. */
307 bool_bf wants_modeline
: 1;
309 /* True means raise this frame to the top of the heap when selected. */
310 bool_bf auto_raise
: 1;
312 /* True means lower this frame to the bottom of the stack when left. */
313 bool_bf auto_lower
: 1;
315 /* True if frame's root window can't be split. */
316 bool_bf no_split
: 1;
318 /* If this is set, then Emacs won't change the frame name to indicate
319 the current buffer, etcetera. If the user explicitly sets the frame
320 name, this gets set. If the user sets the name to Qnil, this is
322 bool_bf explicit_name
: 1;
324 /* True if configuration of windows on this frame has changed since
325 last call of run_window_size_change_functions. */
326 bool_bf window_configuration_changed
: 1;
328 /* True if the mouse has moved on this display device
329 since the last time we checked. */
330 bool_bf mouse_moved
: 1;
332 /* True means that the pointer is invisible. */
333 bool_bf pointer_invisible
: 1;
335 /* True means that all windows except mini-window and
336 selected window on this frame have frozen window starts. */
337 bool_bf frozen_window_starts
: 1;
339 /* The output method says how the contents of this frame are
340 displayed. It could be using termcap, or using an X window.
341 This must be the same as the terminal->type. */
342 ENUM_BF (output_method
) output_method
: 3;
344 #ifdef HAVE_WINDOW_SYSTEM
345 /* See FULLSCREEN_ enum on top. */
346 ENUM_BF (fullscreen_type
) want_fullscreen
: 4;
348 /* If not vertical_scroll_bar_none, we should actually
349 display the scroll bars of this type on this frame. */
350 ENUM_BF (vertical_scroll_bar_type
) vertical_scroll_bar_type
: 2;
352 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
353 bool_bf horizontal_scroll_bars
: 1;
354 #endif /* HAVE_WINDOW_SYSTEM */
356 #if defined (HAVE_WINDOW_SYSTEM)
357 /* True if this is an undecorated frame. */
358 bool_bf undecorated
: 1;
361 /* True if this is an override_redirect frame. */
362 bool_bf override_redirect
: 1;
365 /* Nonzero if this frame's icon should not appear on its display's taskbar. */
366 bool_bf skip_taskbar
: 1;
368 /* Nonzero if this frame's window F's X window does not want to
369 receive input focus when it is mapped. */
370 bool_bf no_focus_on_map
: 1;
372 /* Nonzero if this frame's window does not want to receive input focus
373 via mouse clicks or by moving the mouse into it. */
374 bool_bf no_accept_focus
: 1;
376 /* The z-group this frame's window belongs to. */
377 ENUM_BF (z_group
) z_group
: 2;
379 /* Non-zero if display of truncation and continuation glyphs outside
380 the fringes is suppressed. */
381 bool_bf no_special_glyphs
: 1;
382 #endif /* HAVE_WINDOW_SYSTEM */
384 /* Whether new_height and new_width shall be interpreted
386 bool_bf new_pixelwise
: 1;
388 /* True means x_set_window_size requests can be processed for this
390 bool_bf can_x_set_window_size
: 1;
392 /* Set to true after this frame was made by `make-frame'. */
393 bool_bf after_make_frame
: 1;
395 /* Whether the tool bar height change should be taken into account. */
396 bool_bf tool_bar_redisplayed
: 1;
397 bool_bf tool_bar_resized
: 1;
399 /* Inhibit implied resize before after_make_frame is set. */
400 bool_bf inhibit_horizontal_resize
: 1;
401 bool_bf inhibit_vertical_resize
: 1;
403 /* Non-zero if this frame's faces need to be recomputed. */
404 bool_bf face_change
: 1;
406 /* Bitfield area ends here. */
408 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
411 /* Height of frame internal tool bar in pixels. */
415 int n_tool_bar_items
;
417 /* A buffer for decode_mode_line. */
418 char *decode_mode_spec_buffer
;
420 /* See do_line_insertion_deletion_costs for info on these arrays. */
421 /* Cost of inserting 1 line on this frame. */
422 int *insert_line_cost
;
423 /* Cost of deleting 1 line on this frame. */
424 int *delete_line_cost
;
425 /* Cost of inserting n lines on this frame. */
426 int *insert_n_lines_cost
;
427 /* Cost of deleting n lines on this frame. */
428 int *delete_n_lines_cost
;
430 /* Text width of this frame (excluding fringes, vertical scroll bar
431 and internal border widths) and text height (excluding menu bar,
432 tool bar, horizontal scroll bar and internal border widths) in
433 units of canonical characters. */
434 int text_cols
, text_lines
;
436 /* Total width of this frame (including fringes, vertical scroll bar
437 and internal border widths) and total height (including menu bar,
438 tool bar, horizontal scroll bar and internal border widths) in
439 units of canonical characters. */
440 int total_cols
, total_lines
;
442 /* Text width of this frame (excluding fringes, vertical scroll bar
443 and internal border widths) and text height (excluding menu bar,
444 tool bar, horizontal scroll bar and internal border widths) in
446 int text_width
, text_height
;
448 /* New text height and width for pending size change. 0 if no change
449 pending. These values represent pixels or canonical character units
450 according to the value of new_pixelwise and correlate to the the
451 text width/height of the frame. */
452 int new_width
, new_height
;
454 /* Pixel position of the frame window (x and y offsets in root window). */
455 int left_pos
, top_pos
;
457 /* Total width of this frame (including fringes, vertical scroll bar
458 and internal border widths) and total height (including internal
459 menu and tool bars, horizontal scroll bar and internal border
460 widths) in pixels. */
461 int pixel_width
, pixel_height
;
463 /* This is the gravity value for the specified window position. */
466 /* The geometry flags for this window. */
469 /* Border width of the frame window as known by the (X) window system. */
472 /* Width of the internal border. This is a line of background color
473 just inside the window's border. When the frame is selected,
474 a highlighting is displayed inside the internal border. */
475 int internal_border_width
;
477 /* Widths of dividers between this frame's windows in pixels. */
478 int right_divider_width
, bottom_divider_width
;
480 /* Widths of fringes in pixels. */
481 int left_fringe_width
, right_fringe_width
;
483 /* Total width of fringes reserved for drawing truncation bitmaps,
484 continuation bitmaps and alike - REMOVE THIS !!!!. */
487 /* Number of lines of menu bar. */
490 /* Pixel height of menubar. */
493 /* Canonical X unit. Width of default font, in pixels. */
496 /* Canonical Y unit. Height of a line, in pixels. */
499 /* The terminal device that this frame uses. If this is NULL, then
500 the frame has been deleted. */
501 struct terminal
*terminal
;
503 /* Device-dependent, frame-local auxiliary data used for displaying
504 the contents. When the frame is deleted, this data is deleted as
508 struct tty_output
*tty
; /* From termchar.h. */
509 struct x_output
*x
; /* From xterm.h. */
510 struct w32_output
*w32
; /* From w32term.h. */
511 struct ns_output
*ns
; /* From nsterm.h. */
516 /* List of font-drivers available on the frame. */
517 struct font_driver_list
*font_driver_list
;
519 #if defined (HAVE_X_WINDOWS)
520 /* Used by x_wait_for_event when watching for an X event on this frame. */
524 /* What kind of text cursor should we draw in the future?
525 This should always be filled_box_cursor or bar_cursor. */
526 enum text_cursor_kinds desired_cursor
;
528 /* Width of bar cursor (if we are using that). */
531 /* What kind of text cursor should we draw when the cursor blinks off?
532 This can be filled_box_cursor or bar_cursor or no_cursor. */
533 enum text_cursor_kinds blink_off_cursor
;
535 /* Width of bar cursor (if we are using that) for blink-off state. */
536 int blink_off_cursor_width
;
538 /* Configured width of the scroll bar, in pixels and in characters.
539 config_scroll_bar_cols tracks config_scroll_bar_width if the
540 latter is positive; a zero value in config_scroll_bar_width means
541 to compute the actual width on the fly, using config_scroll_bar_cols
542 and the current font width. */
543 int config_scroll_bar_width
;
544 int config_scroll_bar_cols
;
546 /* Configured height of the scroll bar, in pixels and in characters.
547 config_scroll_bar_lines tracks config_scroll_bar_height if the
548 latter is positive; a zero value in config_scroll_bar_height means
549 to compute the actual width on the fly, using
550 config_scroll_bar_lines and the current font width. */
551 int config_scroll_bar_height
;
552 int config_scroll_bar_lines
;
554 /* The baud rate that was used to calculate costs for this frame. */
555 int cost_calculation_baud_rate
;
558 alpha[0]: alpha transparency of the active frame
559 alpha[1]: alpha transparency of inactive frames
560 Negative values mean not to change alpha. */
563 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
564 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
565 frame parameter. 0 means don't do gamma correction. */
568 /* Additional space to put between text lines on this frame. */
569 int extra_line_spacing
;
571 /* All display backends seem to need these two pixel values. */
572 unsigned long background_pixel
;
573 unsigned long foreground_pixel
;
576 /* NSAppearance theme used on this frame. */
577 enum ns_appearance_type ns_appearance
;
578 bool_bf ns_transparent_titlebar
;
582 /* Most code should use these functions to set Lisp fields in struct frame. */
585 fset_buffer_list (struct frame
*f
, Lisp_Object val
)
587 f
->buffer_list
= val
;
590 fset_buried_buffer_list (struct frame
*f
, Lisp_Object val
)
592 f
->buried_buffer_list
= val
;
595 fset_condemned_scroll_bars (struct frame
*f
, Lisp_Object val
)
597 f
->condemned_scroll_bars
= val
;
600 fset_face_alist (struct frame
*f
, Lisp_Object val
)
604 #if defined (HAVE_WINDOW_SYSTEM)
606 fset_parent_frame (struct frame
*f
, Lisp_Object val
)
608 f
->parent_frame
= val
;
612 fset_focus_frame (struct frame
*f
, Lisp_Object val
)
614 f
->focus_frame
= val
;
617 fset_icon_name (struct frame
*f
, Lisp_Object val
)
622 fset_menu_bar_items (struct frame
*f
, Lisp_Object val
)
624 f
->menu_bar_items
= val
;
627 fset_menu_bar_vector (struct frame
*f
, Lisp_Object val
)
629 f
->menu_bar_vector
= val
;
631 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
633 fset_menu_bar_window (struct frame
*f
, Lisp_Object val
)
635 f
->menu_bar_window
= val
;
639 fset_name (struct frame
*f
, Lisp_Object val
)
644 fset_param_alist (struct frame
*f
, Lisp_Object val
)
646 f
->param_alist
= val
;
649 fset_root_window (struct frame
*f
, Lisp_Object val
)
651 f
->root_window
= val
;
654 fset_scroll_bars (struct frame
*f
, Lisp_Object val
)
656 f
->scroll_bars
= val
;
659 fset_selected_window (struct frame
*f
, Lisp_Object val
)
661 f
->selected_window
= val
;
664 fset_title (struct frame
*f
, Lisp_Object val
)
669 fset_tool_bar_items (struct frame
*f
, Lisp_Object val
)
671 f
->tool_bar_items
= val
;
675 fset_tool_bar_position (struct frame
*f
, Lisp_Object val
)
677 f
->tool_bar_position
= val
;
680 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
682 fset_tool_bar_window (struct frame
*f
, Lisp_Object val
)
684 f
->tool_bar_window
= val
;
687 fset_current_tool_bar_string (struct frame
*f
, Lisp_Object val
)
689 f
->current_tool_bar_string
= val
;
692 fset_desired_tool_bar_string (struct frame
*f
, Lisp_Object val
)
694 f
->desired_tool_bar_string
= val
;
696 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
699 NUMVAL (Lisp_Object x
)
701 return NUMBERP (x
) ? XFLOATINT (x
) : -1;
705 default_pixels_per_inch_x (void)
707 Lisp_Object v
= (CONSP (Vdisplay_pixels_per_inch
)
708 ? XCAR (Vdisplay_pixels_per_inch
)
709 : Vdisplay_pixels_per_inch
);
710 return NUMVAL (v
) > 0 ? NUMVAL (v
) : 72.0;
714 default_pixels_per_inch_y (void)
716 Lisp_Object v
= (CONSP (Vdisplay_pixels_per_inch
)
717 ? XCDR (Vdisplay_pixels_per_inch
)
718 : Vdisplay_pixels_per_inch
);
719 return NUMVAL (v
) > 0 ? NUMVAL (v
) : 72.0;
722 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
724 /* Return a pointer to the image cache of frame F. */
725 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
728 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
729 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
731 /* Given a window, return its frame as a Lisp_Object. */
732 #define WINDOW_FRAME(w) ((w)->frame)
734 /* Test a frame for particular kinds of display methods. */
735 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
736 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
737 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
739 #define FRAME_W32_P(f) false
741 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
744 #define FRAME_MSDOS_P(f) false
746 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
749 #define FRAME_NS_P(f) false
751 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
754 /* FRAME_WINDOW_P tests whether the frame is a window, and is
755 defined to be the predicate for the window system being used. */
757 #ifdef HAVE_X_WINDOWS
758 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
761 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
764 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
766 #ifndef FRAME_WINDOW_P
767 #define FRAME_WINDOW_P(f) ((void) (f), false)
770 /* Dots per inch of the screen the frame F is on. */
772 #ifdef HAVE_WINDOW_SYSTEM
774 #define FRAME_RES_X(f) \
775 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
776 #define FRAME_RES_Y(f) \
777 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
779 #else /* !HAVE_WINDOW_SYSTEM */
781 /* Defaults when no window system available. */
783 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
784 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
786 #endif /* HAVE_WINDOW_SYSTEM */
788 /* Return a pointer to the structure holding information about the
789 region of text, if any, that is currently shown in mouse-face on
790 frame F. We need to define two versions because a TTY-only build
791 does not have FRAME_DISPLAY_INFO. */
792 #ifdef HAVE_WINDOW_SYSTEM
793 # define MOUSE_HL_INFO(F) \
795 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
796 : &(F)->output_data.tty->display_info->mouse_highlight)
798 # define MOUSE_HL_INFO(F) \
799 (&(F)->output_data.tty->display_info->mouse_highlight)
802 /* True if frame F is still alive (not deleted). */
803 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
805 /* True if frame F is a minibuffer-only frame. */
806 #define FRAME_MINIBUF_ONLY_P(f) \
807 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
809 /* True if frame F contains it's own minibuffer window. Frame always has
810 minibuffer window, but it could use minibuffer window of another frame. */
811 #define FRAME_HAS_MINIBUF_P(f) \
812 (WINDOWP (f->minibuffer_window) \
813 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
815 /* Pixel width of frame F. */
816 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
818 /* Pixel height of frame F. */
819 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
821 /* Width of frame F, measured in canonical character columns,
822 not including scroll bars if any. */
823 #define FRAME_COLS(f) (f)->text_cols
825 /* Height of frame F, measured in canonical lines, including
826 non-toolkit menu bar and non-toolkit tool bar lines. */
827 #define FRAME_LINES(f) (f)->text_lines
829 /* Width of frame F, measured in pixels not including the width for
830 fringes, scroll bar, and internal borders. */
831 #define FRAME_TEXT_WIDTH(f) (f)->text_width
833 /* Height of frame F, measured in pixels not including the height
834 for scroll bar and internal borders. */
835 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
837 /* Number of lines of frame F used for menu bar.
838 This is relevant on terminal frames and on
839 X Windows when not using the X toolkit.
840 These lines are counted in FRAME_LINES. */
841 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
843 /* Pixel height of frame F's menu bar. */
844 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
846 /* True if this frame should display a tool bar
847 in a way that does not use any text lines. */
848 #if defined (USE_GTK) || defined (HAVE_NS)
849 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
851 #define FRAME_EXTERNAL_TOOL_BAR(f) false
854 /* This is really supported only with GTK. */
856 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
858 #define FRAME_TOOL_BAR_POSITION(f) ((void) (f), Qtop)
861 /* Number of lines of frame F used for the tool-bar. */
862 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
864 /* Pixel height of frame F's tool-bar. */
865 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
867 /* Lines above the top-most window in frame F. */
868 #define FRAME_TOP_MARGIN(F) \
869 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
871 /* Pixel height of frame F's top margin. */
872 #define FRAME_TOP_MARGIN_HEIGHT(F) \
873 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
875 /* True if this frame should display a menu bar
876 in a way that does not use any text lines. */
877 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
878 || defined (HAVE_NS) || defined (USE_GTK)
879 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
881 #define FRAME_EXTERNAL_MENU_BAR(f) false
884 /* True if frame F is currently visible. */
885 #define FRAME_VISIBLE_P(f) (f)->visible
887 /* True if frame F is currently visible but hidden. */
888 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
890 /* True if frame F is currently iconified. */
891 #define FRAME_ICONIFIED_P(f) (f)->iconified
893 /* Mark frame F as currently garbaged. */
894 #define SET_FRAME_GARBAGED(f) \
895 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
897 /* True if frame F is currently garbaged. */
898 #define FRAME_GARBAGED_P(f) (f)->garbaged
900 /* True means do not allow splitting this frame's window. */
901 #define FRAME_NO_SPLIT_P(f) (f)->no_split
903 /* Not really implemented. */
904 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
906 /* True if all windows except selected window and mini window
907 are frozen on frame F. */
908 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
910 /* True if the frame's window configuration has changed since last call
911 of run_window_size_change_functions. */
912 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
913 (f)->window_configuration_changed
915 /* The minibuffer window of frame F, if it has one; otherwise nil. */
916 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
918 /* The root window of the window tree of frame F. */
919 #define FRAME_ROOT_WINDOW(f) f->root_window
921 /* The currently selected window of the window tree of frame F. */
922 #define FRAME_SELECTED_WINDOW(f) f->selected_window
924 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
925 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
926 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
927 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
928 #define FRAME_FOCUS_FRAME(f) f->focus_frame
930 #ifdef HAVE_WINDOW_SYSTEM
931 /* This frame slot says whether scroll bars are currently enabled for frame F,
932 and which side they are on. */
933 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
934 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
935 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
936 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
937 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
938 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
939 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
940 #else /* not HAVE_WINDOW_SYSTEM */
941 /* If there is no window system, there are no scroll bars. */
942 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) \
943 ((void) (f), vertical_scroll_bar_none)
944 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) (f), 0)
945 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) (f), 0)
946 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) (f), 0)
947 #endif /* HAVE_WINDOW_SYSTEM */
949 #if defined (HAVE_WINDOW_SYSTEM)
950 #define FRAME_UNDECORATED(f) ((f)->undecorated)
952 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
954 #define FRAME_OVERRIDE_REDIRECT(f) ((f)->override_redirect)
956 #define FRAME_PARENT_FRAME(f) \
957 (NILP ((f)->parent_frame) \
959 : XFRAME ((f)->parent_frame))
960 #define FRAME_SKIP_TASKBAR(f) ((f)->skip_taskbar)
961 #define FRAME_NO_FOCUS_ON_MAP(f) ((f)->no_focus_on_map)
962 #define FRAME_NO_ACCEPT_FOCUS(f) ((f)->no_accept_focus)
963 #define FRAME_NO_SPECIAL_GLYPHS(f) ((f)->no_special_glyphs)
964 #define FRAME_Z_GROUP(f) ((f)->z_group)
965 #define FRAME_Z_GROUP_NONE(f) ((f)->z_group == z_group_none)
966 #define FRAME_Z_GROUP_ABOVE(f) ((f)->z_group == z_group_above)
967 #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f) \
968 ((f)->z_group == z_group_above_suspended)
969 #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below)
971 #define FRAME_NS_APPEARANCE(f) ((f)->ns_appearance)
972 #define FRAME_NS_TRANSPARENT_TITLEBAR(f) ((f)->ns_transparent_titlebar)
974 #else /* not HAVE_WINDOW_SYSTEM */
975 #define FRAME_UNDECORATED(f) ((void) (f), 0)
976 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
977 #define FRAME_PARENT_FRAME(f) ((void) (f), NULL)
978 #define FRAME_SKIP_TASKBAR(f) ((void) (f), 0)
979 #define FRAME_NO_FOCUS_ON_MAP(f) ((void) (f), 0)
980 #define FRAME_NO_ACCEPT_FOCUS(f) ((void) (f), 0)
981 #define FRAME_NO_SPECIAL_GLYPHS(f) ((void) (f), 0)
982 #define FRAME_Z_GROUP(f) ((void) (f), z_group_none)
983 #define FRAME_Z_GROUP_NONE(f) ((void) (f), true)
984 #define FRAME_Z_GROUP_ABOVE(f) ((void) (f), false)
985 #define FRAME_Z_GROUP_BELOW(f) ((void) (f), false)
986 #endif /* HAVE_WINDOW_SYSTEM */
988 /* Whether horizontal scroll bars are currently enabled for frame F. */
989 #if USE_HORIZONTAL_SCROLL_BARS
990 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
991 ((f)->horizontal_scroll_bars)
993 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) (f), 0)
996 /* Width that a scroll bar in frame F should have, if there is one.
998 If scroll bars are turned off, this is still nonzero. */
999 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
1001 /* Height that a scroll bar in frame F should have, if there is one.
1003 If scroll bars are turned off, this is still nonzero. */
1004 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
1006 /* Width that a scroll bar in frame F should have, if there is one.
1007 Measured in columns (characters).
1008 If scroll bars are turned off, this is still nonzero. */
1009 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
1011 /* Height that a scroll bar in frame F should have, if there is one.
1012 Measured in lines (characters).
1013 If scroll bars are turned off, this is still nonzero. */
1014 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
1016 /* Width of a left scroll bar in frame F, measured in pixels */
1017 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
1018 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1019 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1022 /* Width of a right scroll bar area in frame F, measured in pixels */
1023 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
1024 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1025 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1028 /* Width of a left scroll bar in frame F, measured in columns
1029 (characters), but only if scroll bars are on the left. If scroll
1030 bars are on the right in this frame, or there are no scroll bars,
1032 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
1033 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
1034 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1037 /* Width of a right scroll bar in frame F, measured in columns
1038 (characters), but only if scroll bars are on the right. If scroll
1039 bars are on the left in this frame, or there are no scroll bars,
1041 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
1042 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
1043 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1046 /* Width of a vertical scroll bar area in frame F, measured in
1048 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
1049 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1050 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
1053 /* Height of horizontal scroll bar area in frame F, measured in
1055 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
1056 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1057 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
1060 /* Width of vertical scroll bar in frame F, measured in columns. */
1061 #define FRAME_SCROLL_BAR_COLS(f) \
1062 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
1063 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
1066 /* Height of horizontal scroll bar in frame F, measured in lines. */
1067 #define FRAME_SCROLL_BAR_LINES(f) \
1068 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
1069 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
1072 /* Total width of frame F, in columns (characters),
1073 including the width used by scroll bars if any. */
1074 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
1076 /* Total height of frame F, in lines (characters),
1077 including the height used by scroll bars if any. */
1078 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
1080 /* Set the character widths of frame F. WIDTH specifies a nominal
1081 character text width. */
1082 #define SET_FRAME_COLS(f, width) \
1083 ((f)->text_cols = (width), \
1084 (f)->total_cols = ((width) \
1085 + FRAME_SCROLL_BAR_COLS (f) \
1086 + FRAME_FRINGE_COLS (f)))
1088 /* Set the character heights of frame F. HEIGHT specifies a nominal
1089 character text height. */
1090 #define SET_FRAME_LINES(f, height) \
1091 ((f)->text_lines = (height), \
1092 (f)->total_lines = ((height) \
1093 + FRAME_TOP_MARGIN (f) \
1094 + FRAME_SCROLL_BAR_LINES (f)))
1096 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
1098 #define SET_FRAME_WIDTH(f, width) \
1099 ((f)->text_width = (width), \
1100 (f)->pixel_width = ((width) \
1101 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1102 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1103 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1105 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
1107 #define SET_FRAME_HEIGHT(f, height) \
1108 ((f)->text_height = (height), \
1109 (f)->pixel_height = ((height) \
1110 + FRAME_TOP_MARGIN_HEIGHT (f) \
1111 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1112 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
1114 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1115 #define FRAME_CURSOR_X_LIMIT(f) \
1116 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1118 /* Nonzero if frame F has scroll bars. */
1119 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1120 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1122 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1123 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1125 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1126 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1127 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1128 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1130 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1131 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1133 /* Return a pointer to the face cache of frame F. */
1135 #define FRAME_FACE_CACHE(F) (F)->face_cache
1137 /* Return the size of message_buf of the frame F. We multiply the
1138 width of the frame by 4 because multi-byte form may require at most
1139 4-byte for a character. */
1141 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1143 #define CHECK_FRAME(x) \
1144 CHECK_TYPE (FRAMEP (x), Qframep, x)
1146 #define CHECK_LIVE_FRAME(x) \
1147 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1149 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1150 `for' loop which iterates over the elements of Vframe_list. The
1151 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1152 Vframe_list in succession and execute the statement. Vframe_list
1153 should be nonempty, so the body is executed at least once. LIST_VAR
1154 should be a Lisp_Object too; it is used to iterate through the
1155 Vframe_list. Note that this macro walks over child frames and
1156 the tooltip frame as well.
1158 This macro is a holdover from a time when multiple frames weren't always
1159 supported. An alternate definition of the macro would expand to
1160 something which executes the statement once. */
1162 #define FOR_EACH_FRAME(list_var, frame_var) \
1163 for ((list_var) = (eassume (CONSP (Vframe_list)), Vframe_list); \
1165 && (frame_var = XCAR (list_var), true)); \
1166 list_var = XCDR (list_var))
1168 /* Reflect mouse movement when a complete frame update is performed. */
1170 #define FRAME_MOUSE_UPDATE(frame) \
1172 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1173 if (frame == hlinfo->mouse_face_mouse_frame) \
1176 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1177 hlinfo->mouse_face_mouse_x, \
1178 hlinfo->mouse_face_mouse_y); \
1183 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1185 #define AUTO_FRAME_ARG(name, parameter, value) \
1186 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1188 /* False means there are no visible garbaged frames. */
1189 extern bool frame_garbaged
;
1191 /* Set visibility of frame F.
1192 We call redisplay_other_windows to make sure the frame gets redisplayed
1193 if some changes were applied to it while it wasn't visible (and hence
1194 wasn't redisplayed). */
1197 SET_FRAME_VISIBLE (struct frame
*f
, int v
)
1199 eassert (0 <= v
&& v
<= 2);
1202 if (v
== 1 && f
->visible
!= 1)
1203 redisplay_other_windows ();
1204 if (FRAME_GARBAGED_P (f
))
1205 frame_garbaged
= true;
1210 /* Set iconify of frame F. */
1212 #define SET_FRAME_ICONIFIED(f, i) \
1213 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1215 extern Lisp_Object selected_frame
;
1217 #if ! (defined USE_GTK || defined HAVE_NS)
1218 extern int frame_default_tool_bar_height
;
1221 #ifdef HAVE_WINDOW_SYSTEM
1222 # define WINDOW_SYSTEM_RETURN
1224 # define WINDOW_SYSTEM_RETURN _Noreturn
1227 extern WINDOW_SYSTEM_RETURN
struct frame
*
1228 decode_window_system_frame (Lisp_Object
);
1229 extern struct frame
*decode_live_frame (Lisp_Object
);
1230 extern struct frame
*decode_any_frame (Lisp_Object
);
1231 extern struct frame
*make_initial_frame (void);
1232 extern struct frame
*make_frame (bool);
1233 #ifdef HAVE_WINDOW_SYSTEM
1234 extern struct frame
*make_minibuffer_frame (void);
1235 extern struct frame
*make_frame_without_minibuffer (Lisp_Object
,
1238 extern bool display_available (void);
1242 window_system_available (struct frame
*f
)
1244 #ifdef HAVE_WINDOW_SYSTEM
1245 return f
? FRAME_WINDOW_P (f
) || FRAME_MSDOS_P (f
) : display_available ();
1251 extern WINDOW_SYSTEM_RETURN
void check_window_system (struct frame
*);
1252 extern void frame_make_pointer_invisible (struct frame
*);
1253 extern void frame_make_pointer_visible (struct frame
*);
1254 extern Lisp_Object
delete_frame (Lisp_Object
, Lisp_Object
);
1255 extern bool frame_inhibit_resize (struct frame
*, bool, Lisp_Object
);
1256 extern void adjust_frame_size (struct frame
*, int, int, int, bool, Lisp_Object
);
1257 extern void frame_size_history_add (struct frame
*f
, Lisp_Object fun_symbol
,
1258 int width
, int height
, Lisp_Object rest
);
1260 extern Lisp_Object Vframe_list
;
1262 /* Value is a pointer to the selected frame. If the selected frame
1263 isn't live, abort. */
1265 #define SELECTED_FRAME() \
1266 ((FRAMEP (selected_frame) \
1267 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1268 ? XFRAME (selected_frame) \
1269 : (emacs_abort (), (struct frame *) 0))
1272 /***********************************************************************
1273 Display-related Macros
1274 ***********************************************************************/
1276 /* Canonical y-unit on frame F.
1277 This value currently equals the line height of the frame (which is
1278 the height of the default font of F). */
1279 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1281 /* Canonical x-unit on frame F.
1282 This value currently equals the average width of the default font of F. */
1283 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1285 /* Get a frame's window system dimension. If no window system, this is 0. */
1288 frame_dimension (int x
)
1290 #ifdef HAVE_WINDOW_SYSTEM
1297 /* Total width of fringes reserved for drawing truncation bitmaps,
1298 continuation bitmaps and alike. The width is in canonical char
1299 units of the frame. This must currently be the case because window
1300 sizes aren't pixel values. If it weren't the case, we wouldn't be
1301 able to split windows horizontally nicely. */
1303 FRAME_FRINGE_COLS (struct frame
*f
)
1305 return frame_dimension (f
->fringe_cols
);
1308 /* Pixel-width of the left and right fringe. */
1311 FRAME_LEFT_FRINGE_WIDTH (struct frame
*f
)
1313 return frame_dimension (f
->left_fringe_width
);
1316 FRAME_RIGHT_FRINGE_WIDTH (struct frame
*f
)
1318 return frame_dimension (f
->right_fringe_width
);
1321 /* Total width of fringes in pixels. */
1324 FRAME_TOTAL_FRINGE_WIDTH (struct frame
*f
)
1326 return FRAME_LEFT_FRINGE_WIDTH (f
) + FRAME_RIGHT_FRINGE_WIDTH (f
);
1329 /* Pixel-width of internal border lines. */
1331 FRAME_INTERNAL_BORDER_WIDTH (struct frame
*f
)
1333 return frame_dimension (f
->internal_border_width
);
1336 /* Pixel-size of window divider lines. */
1338 FRAME_RIGHT_DIVIDER_WIDTH (struct frame
*f
)
1340 return frame_dimension (f
->right_divider_width
);
1344 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame
*f
)
1346 return frame_dimension (f
->bottom_divider_width
);
1349 /***********************************************************************
1350 Conversion between canonical units and pixels
1351 ***********************************************************************/
1353 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1354 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1355 represented as Lisp numbers, i.e. integers or floats. */
1357 /* Convert canonical value X to pixels. F is the frame whose
1358 canonical char width is to be used. X must be a Lisp integer or
1359 float. Value is a C integer. */
1360 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1362 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1363 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1365 /* Convert canonical value Y to pixels. F is the frame whose
1366 canonical character height is to be used. X must be a Lisp integer
1367 or float. Value is a C integer. */
1368 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1370 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1371 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1373 /* Convert pixel-value X to canonical units. F is the frame whose
1374 canonical character width is to be used. X is a C integer. Result
1375 is a Lisp float if X is not a multiple of the canon width,
1376 otherwise it's a Lisp integer. */
1377 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1378 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1379 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1380 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1382 /* Convert pixel-value Y to canonical units. F is the frame whose
1383 canonical character height is to be used. Y is a C integer.
1384 Result is a Lisp float if Y is not a multiple of the canon width,
1385 otherwise it's a Lisp integer. */
1386 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1387 ((Y) % FRAME_LINE_HEIGHT (F) \
1388 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1389 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1393 /* Manipulating pixel sizes and character sizes.
1394 Knowledge of which factors affect the overall size of the window should
1395 be hidden in these macros, if that's possible.
1397 Return the upper/left pixel position of the character cell on frame F
1399 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1400 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1401 + (row) * FRAME_LINE_HEIGHT (f))
1403 #define FRAME_COL_TO_PIXEL_X(f, col) \
1404 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1405 + (col) * FRAME_COLUMN_WIDTH (f))
1407 /* Return the pixel width/height of frame F if it has
1408 COLS columns/LINES rows. */
1409 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1410 ((cols) * FRAME_COLUMN_WIDTH (f) \
1411 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1412 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1413 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1415 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1416 ((lines) * FRAME_LINE_HEIGHT (f) \
1417 + FRAME_TOP_MARGIN_HEIGHT (f) \
1418 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1419 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1421 /* Return the row/column (zero-based) of the character cell containing
1422 the pixel on FRAME at Y/X. */
1423 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1424 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1426 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1427 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1428 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1429 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1430 /* Arrange for the division to round down. */ \
1431 + FRAME_LINE_HEIGHT (f) - 1) \
1432 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1433 / FRAME_LINE_HEIGHT (f))
1435 #define FRAME_PIXEL_X_TO_COL(f, x) \
1436 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1437 / FRAME_COLUMN_WIDTH (f))
1439 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1440 frame F (so we round down)? */
1441 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1443 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1444 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1445 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1446 / FRAME_COLUMN_WIDTH (f)) \
1448 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1450 - FRAME_TOP_MARGIN_HEIGHT (f) \
1451 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1452 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1453 / FRAME_LINE_HEIGHT (f))
1455 /* Return the pixel width/height of frame F with a text size of
1457 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1459 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1460 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1461 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1463 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1465 + FRAME_TOP_MARGIN_HEIGHT (f) \
1466 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1467 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1469 /* Return the text width/height of frame F with a pixel size of
1471 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1473 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1474 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1475 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1477 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1479 - FRAME_TOP_MARGIN_HEIGHT (f) \
1480 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1481 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1483 /* Return the width/height reserved for the windows of frame F. */
1484 #define FRAME_WINDOWS_WIDTH(f) \
1485 (FRAME_PIXEL_WIDTH (f) \
1486 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1488 #define FRAME_WINDOWS_HEIGHT(f) \
1489 (FRAME_PIXEL_HEIGHT (f) \
1490 - FRAME_TOP_MARGIN_HEIGHT (f) \
1491 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1493 /* Value is the smallest width of any character in any font on frame F. */
1494 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1495 FRAME_DISPLAY_INFO (f)->smallest_char_width
1497 /* Value is the smallest height of any font on frame F. */
1498 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1499 FRAME_DISPLAY_INFO (f)->smallest_font_height
1501 /***********************************************************************
1503 ***********************************************************************/
1505 #ifdef HAVE_WINDOW_SYSTEM
1507 /* The class of this X application. */
1508 #define EMACS_CLASS "Emacs"
1510 extern void x_set_scroll_bar_default_width (struct frame
*);
1511 extern void x_set_scroll_bar_default_height (struct frame
*);
1512 extern void x_set_offset (struct frame
*, int, int, int);
1513 extern void x_wm_set_size_hint (struct frame
*f
, long flags
, bool user_position
);
1514 extern Lisp_Object
x_new_font (struct frame
*, Lisp_Object
, int);
1515 extern void x_set_frame_parameters (struct frame
*, Lisp_Object
);
1516 extern void x_set_fullscreen (struct frame
*, Lisp_Object
, Lisp_Object
);
1517 extern void x_set_line_spacing (struct frame
*, Lisp_Object
, Lisp_Object
);
1518 extern void x_set_screen_gamma (struct frame
*, Lisp_Object
, Lisp_Object
);
1519 extern void x_set_font (struct frame
*, Lisp_Object
, Lisp_Object
);
1520 extern void x_set_font_backend (struct frame
*, Lisp_Object
, Lisp_Object
);
1521 extern void x_set_left_fringe (struct frame
*, Lisp_Object
, Lisp_Object
);
1522 extern void x_set_right_fringe (struct frame
*, Lisp_Object
, Lisp_Object
);
1523 extern void x_set_border_width (struct frame
*, Lisp_Object
, Lisp_Object
);
1524 extern void x_set_right_divider_width (struct frame
*, Lisp_Object
,
1526 extern void x_set_bottom_divider_width (struct frame
*, Lisp_Object
,
1528 extern void x_set_visibility (struct frame
*, Lisp_Object
, Lisp_Object
);
1529 extern void x_set_autoraise (struct frame
*, Lisp_Object
, Lisp_Object
);
1530 extern void x_set_autolower (struct frame
*, Lisp_Object
, Lisp_Object
);
1531 extern void x_set_unsplittable (struct frame
*, Lisp_Object
, Lisp_Object
);
1532 extern void x_set_vertical_scroll_bars (struct frame
*, Lisp_Object
, Lisp_Object
);
1533 extern void x_set_horizontal_scroll_bars (struct frame
*, Lisp_Object
, Lisp_Object
);
1534 extern void x_set_scroll_bar_width (struct frame
*, Lisp_Object
, Lisp_Object
);
1535 extern void x_set_scroll_bar_height (struct frame
*, Lisp_Object
, Lisp_Object
);
1537 extern long x_figure_window_size (struct frame
*, Lisp_Object
, bool, int *, int *);
1539 extern void x_set_alpha (struct frame
*, Lisp_Object
, Lisp_Object
);
1540 extern void x_set_no_special_glyphs (struct frame
*, Lisp_Object
, Lisp_Object
);
1542 extern void validate_x_resource_name (void);
1544 extern Lisp_Object
display_x_get_resource (Display_Info
*,
1545 Lisp_Object attribute
,
1547 Lisp_Object component
,
1548 Lisp_Object subclass
);
1550 extern void set_frame_menubar (struct frame
*f
, bool first_time
, bool deep_p
);
1551 extern void x_set_window_size (struct frame
*f
, bool change_gravity
,
1552 int width
, int height
, bool pixelwise
);
1553 extern Lisp_Object
x_get_focus_frame (struct frame
*);
1554 extern void frame_set_mouse_pixel_position (struct frame
*f
, int pix_x
, int pix_y
);
1555 extern void x_make_frame_visible (struct frame
*f
);
1556 extern void x_make_frame_invisible (struct frame
*f
);
1557 extern void x_iconify_frame (struct frame
*f
);
1558 extern void x_set_frame_alpha (struct frame
*f
);
1559 extern void x_activate_menubar (struct frame
*);
1560 extern void x_real_positions (struct frame
*, int *, int *);
1561 extern void free_frame_menubar (struct frame
*);
1562 extern void x_free_frame_resources (struct frame
*);
1563 extern bool frame_ancestor_p (struct frame
*af
, struct frame
*df
);
1564 extern enum internal_border_part
frame_internal_border_part (struct frame
*f
, int x
, int y
);
1566 #if defined HAVE_X_WINDOWS
1567 extern void x_wm_set_icon_position (struct frame
*, int, int);
1568 #if !defined USE_X_TOOLKIT
1569 extern char *x_get_resource_string (const char *, const char *);
1571 extern void x_sync (struct frame
*);
1572 #endif /* HAVE_X_WINDOWS */
1574 extern void x_query_colors (struct frame
*f
, XColor
*, int);
1575 extern void x_focus_frame (struct frame
*, bool);
1579 extern bool x_bitmap_icon (struct frame
*, Lisp_Object
);
1581 /* Set F's bitmap icon, if specified among F's parameters. */
1584 x_set_bitmap_icon (struct frame
*f
)
1586 Lisp_Object obj
= assq_no_quit (Qicon_type
, f
->param_alist
);
1588 if (CONSP (obj
) && !NILP (XCDR (obj
)))
1589 x_bitmap_icon (f
, XCDR (obj
));
1592 #endif /* !HAVE_NS */
1593 #endif /* HAVE_WINDOW_SYSTEM */
1596 flush_frame (struct frame
*f
)
1598 struct redisplay_interface
*rif
= FRAME_RIF (f
);
1600 if (rif
&& rif
->flush_display
)
1601 rif
->flush_display (f
);
1604 /***********************************************************************
1606 ***********************************************************************/
1608 #ifdef HAVE_WINDOW_SYSTEM
1610 struct MonitorInfo
{
1611 XRectangle geom
, work
;
1612 int mm_width
, mm_height
;
1616 extern void free_monitors (struct MonitorInfo
*monitors
, int n_monitors
);
1617 extern Lisp_Object
make_monitor_attribute_list (struct MonitorInfo
*monitors
,
1619 int primary_monitor
,
1620 Lisp_Object monitor_frames
,
1621 const char *source
);
1623 #endif /* HAVE_WINDOW_SYSTEM */
1628 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1629 This is for functions like x_set_horizontal_scroll_bars that have
1630 no effect in this case. */
1631 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1632 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1635 #endif /* not EMACS_FRAME_H */