]> code.delx.au - gnu-emacs/blob - src/frame.h
Use bool for boolean, focusing on headers.
[gnu-emacs] / src / frame.h
1 /* Define frame-object for GNU Emacs.
2 Copyright (C) 1993-1994, 1999-2013 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
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.
15
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/>. */
18
19 /* Don't multiply include: dispextern.h includes macterm.h which
20 includes frame.h some emacs source includes both dispextern.h and
21 frame.h. */
22
23 #ifndef EMACS_FRAME_H
24 #define EMACS_FRAME_H
25
26 #include "dispextern.h"
27 #include "termhooks.h"
28 #include "window.h"
29
30 INLINE_HEADER_BEGIN
31
32 enum vertical_scroll_bar_type
33 {
34 vertical_scroll_bar_none,
35 vertical_scroll_bar_left,
36 vertical_scroll_bar_right
37 };
38
39 enum fullscreen_type
40 {
41 FULLSCREEN_NONE,
42 FULLSCREEN_WIDTH = 0x001,
43 FULLSCREEN_HEIGHT = 0x002,
44 FULLSCREEN_BOTH = 0x003,
45 FULLSCREEN_MAXIMIZED = 0x013,
46 FULLSCREEN_WAIT = 0x100
47 };
48
49 /* The structure representing a frame. */
50
51 struct frame
52 {
53 struct vectorlike_header header;
54
55 /* All Lisp_Object components must come first.
56 That ensures they are all aligned normally. */
57
58 /* Name of this frame: a Lisp string. It is used for looking up resources,
59 as well as for the title in some cases. */
60 Lisp_Object name;
61
62 /* The name to use for the icon, the last time
63 it was refreshed. nil means not explicitly specified. */
64 Lisp_Object icon_name;
65
66 /* This is the frame title specified explicitly, if any.
67 Usually it is nil. */
68 Lisp_Object title;
69
70 /* The frame which should receive keystrokes that occur in this
71 frame, or nil if they should go to the frame itself. This is
72 usually nil, but if the frame is minibufferless, we can use this
73 to redirect keystrokes to a surrogate minibuffer frame when
74 needed.
75
76 Note that a value of nil is different than having the field point
77 to the frame itself. Whenever the Fselect_frame function is used
78 to shift from one frame to the other, any redirections to the
79 original frame are shifted to the newly selected frame; if
80 focus_frame is nil, Fselect_frame will leave it alone. */
81 Lisp_Object focus_frame;
82
83 /* This frame's root window. Every frame has one.
84 If the frame has only a minibuffer window, this is it.
85 Otherwise, if the frame has a minibuffer window, this is its sibling. */
86 Lisp_Object root_window;
87
88 /* This frame's selected window.
89 Each frame has its own window hierarchy
90 and one of the windows in it is selected within the frame.
91 The selected window of the selected frame is Emacs's selected window. */
92 Lisp_Object selected_window;
93
94 /* This frame's minibuffer window.
95 Most frames have their own minibuffer windows,
96 but only the selected frame's minibuffer window
97 can actually appear to exist. */
98 Lisp_Object minibuffer_window;
99
100 /* Parameter alist of this frame.
101 These are the parameters specified when creating the frame
102 or modified with modify-frame-parameters. */
103 Lisp_Object param_alist;
104
105 /* List of scroll bars on this frame.
106 Actually, we don't specify exactly what is stored here at all; the
107 scroll bar implementation code can use it to store anything it likes.
108 This field is marked by the garbage collector. It is here
109 instead of in the `device' structure so that the garbage
110 collector doesn't need to look inside the window-system-dependent
111 structure. */
112 Lisp_Object scroll_bars;
113 Lisp_Object condemned_scroll_bars;
114
115 /* Vector describing the items to display in the menu bar.
116 Each item has four elements in this vector.
117 They are KEY, STRING, SUBMAP, and HPOS.
118 (HPOS is not used in when the X toolkit is in use.)
119 There are four additional elements of nil at the end, to terminate. */
120 Lisp_Object menu_bar_items;
121
122 /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */
123 Lisp_Object face_alist;
124
125 /* A vector that records the entire structure of this frame's menu bar.
126 For the format of the data, see extensive comments in xmenu.c.
127 Only the X toolkit version uses this. */
128 Lisp_Object menu_bar_vector;
129
130 /* Predicate for selecting buffers for other-buffer. */
131 Lisp_Object buffer_predicate;
132
133 /* List of buffers viewed in this frame, for other-buffer. */
134 Lisp_Object buffer_list;
135
136 /* List of buffers that were viewed, then buried in this frame. The
137 most recently buried buffer is first. For last-buffer. */
138 Lisp_Object buried_buffer_list;
139
140 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
141 /* A dummy window used to display menu bars under X when no X
142 toolkit support is available. */
143 Lisp_Object menu_bar_window;
144 #endif
145
146 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
147 /* A window used to display the tool-bar of a frame. */
148 Lisp_Object tool_bar_window;
149
150 /* Desired and current contents displayed in that window. */
151 Lisp_Object desired_tool_bar_string;
152 Lisp_Object current_tool_bar_string;
153 #endif
154
155 /* Desired and current tool-bar items. */
156 Lisp_Object tool_bar_items;
157
158 /* Where tool bar is, can be left, right, top or bottom. The native
159 tool bar only supports top. */
160 Lisp_Object tool_bar_position;
161
162 /* Beyond here, there should be no more Lisp_Object components. */
163
164 /* Cache of realized faces. */
165 struct face_cache *face_cache;
166
167 /* Number of elements in `menu_bar_vector' that have meaningful data. */
168 int menu_bar_items_used;
169
170 /* A buffer to hold the frame's name. We can't use the Lisp
171 string's pointer (`name', above) because it might get relocated. */
172 char *namebuf;
173
174 /* Glyph pool and matrix. */
175 struct glyph_pool *current_pool;
176 struct glyph_pool *desired_pool;
177 struct glyph_matrix *desired_matrix;
178 struct glyph_matrix *current_matrix;
179
180 /* True means that glyphs on this frame have been initialized so it can
181 be used for output. */
182 bool_bf glyphs_initialized_p : 1;
183
184 /* Set to true in change_frame_size when size of frame changed
185 Clear the frame in clear_garbaged_frames if set. */
186 bool_bf resized_p : 1;
187
188 /* Set to true if the default face for the frame has been
189 realized. Reset to zero whenever the default face changes.
190 Used to see the difference between a font change and face change. */
191 bool_bf default_face_done_p : 1;
192
193 /* Set to true if this frame has already been hscrolled during
194 current redisplay. */
195 bool_bf already_hscrolled_p : 1;
196
197 /* Set to true when current redisplay has updated frame. */
198 bool_bf updated_p : 1;
199
200 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
201 /* Set to true to minimize tool-bar height even when
202 auto-resize-tool-bar is set to grow-only. */
203 bool_bf minimize_tool_bar_window_p : 1;
204 #endif
205
206 #if defined (USE_GTK) || defined (HAVE_NS)
207 /* True means using a tool bar that comes from the toolkit. */
208 bool_bf external_tool_bar : 1;
209 #endif
210
211 /* True means that fonts have been loaded since the last glyph
212 matrix adjustments. */
213 bool_bf fonts_changed : 1;
214
215 /* True means that cursor type has been changed. */
216 bool_bf cursor_type_changed : 1;
217
218 /* True if it needs to be redisplayed. */
219 bool_bf redisplay : 1;
220
221 /* Margin at the top of the frame. Used to display the tool-bar. */
222 int tool_bar_lines;
223
224 /* Pixel height of tool bar. */
225 int tool_bar_height;
226
227 int n_tool_bar_rows;
228 int n_tool_bar_items;
229
230 /* A buffer for decode_mode_line. */
231 char *decode_mode_spec_buffer;
232
233 /* See do_line_insertion_deletion_costs for info on these arrays. */
234 /* Cost of inserting 1 line on this frame. */
235 int *insert_line_cost;
236 /* Cost of deleting 1 line on this frame. */
237 int *delete_line_cost;
238 /* Cost of inserting n lines on this frame. */
239 int *insert_n_lines_cost;
240 /* Cost of deleting n lines on this frame. */
241 int *delete_n_lines_cost;
242
243 /* Text width of this frame (excluding fringes, scroll bars and
244 internal border width) and text height (excluding internal border
245 width) in units of canonical characters. */
246 int text_cols, text_lines;
247
248 /* Total width of this frame (including fringes and scroll bars) in
249 units of canonical characters. */
250 int total_cols;
251
252 /* Text width of this frame (excluding fringes, scroll bars and
253 internal border width) and text height (excluding internal border
254 width) in pixels. */
255 int text_width, text_height;
256
257 /* New text height and width for pending size change. 0 if no change
258 pending. These values represent pixels or canonical character units
259 according to the value of new_pixelwise and correlate to the the
260 text width/height of the frame. */
261 int new_width, new_height;
262
263 /* Whether new_height and new_width shall be interpreted
264 in pixels. */
265 bool new_pixelwise;
266
267 /* Pixel position of the frame window (x and y offsets in root window). */
268 int left_pos, top_pos;
269
270 /* Size of the frame window (including internal border widths) in
271 pixels. */
272 int pixel_width, pixel_height;
273
274 /* These many pixels are the difference between the outer window (i.e. the
275 left and top of the window manager decoration) and FRAME_X_WINDOW. */
276 int x_pixels_diff, y_pixels_diff;
277
278 /* This is the gravity value for the specified window position. */
279 int win_gravity;
280
281 /* The geometry flags for this window. */
282 int size_hint_flags;
283
284 /* Border width of the frame window as known by the (X) window system. */
285 int border_width;
286
287 /* Width of the internal border. This is a line of background color
288 just inside the window's border. When the frame is selected,
289 a highlighting is displayed inside the internal border. */
290 int internal_border_width;
291
292 /* Width of borders between this frame's windows. */
293 int right_divider_width;
294 int bottom_divider_width;
295
296 /* Canonical X unit. Width of default font, in pixels. */
297 int column_width;
298
299 /* Canonical Y unit. Height of a line, in pixels. */
300 int line_height;
301
302 /* The output method says how the contents of this frame are
303 displayed. It could be using termcap, or using an X window.
304 This must be the same as the terminal->type. */
305 enum output_method output_method;
306
307 /* The terminal device that this frame uses. If this is NULL, then
308 the frame has been deleted. */
309 struct terminal *terminal;
310
311 /* Device-dependent, frame-local auxiliary data used for displaying
312 the contents. When the frame is deleted, this data is deleted as
313 well. */
314 union output_data
315 {
316 struct tty_output *tty; /* From termchar.h. */
317 struct x_output *x; /* From xterm.h. */
318 struct w32_output *w32; /* From w32term.h. */
319 struct ns_output *ns; /* From nsterm.h. */
320 intptr_t nothing;
321 }
322 output_data;
323
324 /* List of font-drivers available on the frame. */
325 struct font_driver_list *font_driver_list;
326 /* List of data specific to font-driver and frame, but common to
327 faces. */
328 struct font_data_list *font_data_list;
329
330 /* Total width of fringes reserved for drawing truncation bitmaps,
331 continuation bitmaps and alike. The width is in canonical char
332 units of the frame. This must currently be the case because window
333 sizes aren't pixel values. If it weren't the case, we wouldn't be
334 able to split windows horizontally nicely. */
335 int fringe_cols;
336
337 /* The extra width (in pixels) currently allotted for fringes. */
338 int left_fringe_width, right_fringe_width;
339
340 /* See FULLSCREEN_ enum below. */
341 enum fullscreen_type want_fullscreen;
342
343 /* Number of lines of menu bar. */
344 int menu_bar_lines;
345
346 /* Pixel height of menubar. */
347 int menu_bar_height;
348
349 #if defined (HAVE_X_WINDOWS)
350 /* Used by x_wait_for_event when watching for an X event on this frame. */
351 int wait_event_type;
352 #endif
353
354 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
355 || defined (HAVE_NS) || defined (USE_GTK)
356 /* True means using a menu bar that comes from the X toolkit. */
357 bool_bf external_menu_bar : 1;
358 #endif
359
360 /* Next two bitfields are mutually exclusive. They might both be
361 zero if the frame has been made invisible without an icon. */
362
363 /* Nonzero if the frame is currently displayed; we check
364 it to see if we should bother updating the frame's contents.
365
366 On ttys and on Windows NT/9X, to avoid wasting effort updating
367 visible frames that are actually completely obscured by other
368 windows on the display, we bend the meaning of visible slightly:
369 if equal to 2, then the frame is obscured - we still consider
370 it to be "visible" as seen from lisp, but we don't bother
371 updating it. */
372 unsigned visible : 2;
373
374 /* True if the frame is currently iconified. Do not
375 set this directly, use SET_FRAME_ICONIFIED instead. */
376 bool_bf iconified : 1;
377
378 /* True if this frame should be redrawn. */
379 bool_bf garbaged : 1;
380
381 /* False means, if this frame has just one window,
382 show no modeline for that window. */
383 bool_bf wants_modeline : 1;
384
385 /* True means raise this frame to the top of the heap when selected. */
386 bool_bf auto_raise : 1;
387
388 /* True means lower this frame to the bottom of the stack when left. */
389 bool_bf auto_lower : 1;
390
391 /* True if frame's root window can't be split. */
392 bool_bf no_split : 1;
393
394 /* If this is set, then Emacs won't change the frame name to indicate
395 the current buffer, etcetera. If the user explicitly sets the frame
396 name, this gets set. If the user sets the name to Qnil, this is
397 cleared. */
398 bool_bf explicit_name : 1;
399
400 /* True if size of some window on this frame has changed. */
401 bool_bf window_sizes_changed : 1;
402
403 /* True if the mouse has moved on this display device
404 since the last time we checked. */
405 bool_bf mouse_moved : 1;
406
407 /* True means that the pointer is invisible. */
408 bool_bf pointer_invisible : 1;
409
410 /* True means that all windows except mini-window and
411 selected window on this frame have frozen window starts. */
412 bool_bf frozen_window_starts : 1;
413
414 /* Nonzero if we should actually display the scroll bars on this frame. */
415 enum vertical_scroll_bar_type vertical_scroll_bar_type;
416
417 /* What kind of text cursor should we draw in the future?
418 This should always be filled_box_cursor or bar_cursor. */
419 enum text_cursor_kinds desired_cursor;
420
421 /* Width of bar cursor (if we are using that). */
422 int cursor_width;
423
424 /* What kind of text cursor should we draw when the cursor blinks off?
425 This can be filled_box_cursor or bar_cursor or no_cursor. */
426 enum text_cursor_kinds blink_off_cursor;
427
428 /* Width of bar cursor (if we are using that) for blink-off state. */
429 int blink_off_cursor_width;
430
431 /* Configured width of the scroll bar, in pixels and in characters.
432 config_scroll_bar_cols tracks config_scroll_bar_width if the
433 latter is positive; a zero value in config_scroll_bar_width means
434 to compute the actual width on the fly, using config_scroll_bar_cols
435 and the current font width. */
436 int config_scroll_bar_width;
437 int config_scroll_bar_cols;
438
439 /* The size of the extra width currently allotted for vertical
440 scroll bars in this frame, in pixels. */
441 int scroll_bar_actual_width;
442
443 /* The baud rate that was used to calculate costs for this frame. */
444 int cost_calculation_baud_rate;
445
446 /* frame opacity
447 alpha[0]: alpha transparency of the active frame
448 alpha[1]: alpha transparency of inactive frames
449 Negative values mean not to change alpha. */
450 double alpha[2];
451
452 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
453 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
454 frame parameter. 0 means don't do gamma correction. */
455 double gamma;
456
457 /* Additional space to put between text lines on this frame. */
458 int extra_line_spacing;
459
460 /* All display backends seem to need these two pixel values. */
461 unsigned long background_pixel;
462 unsigned long foreground_pixel;
463 };
464
465 /* Most code should use these functions to set Lisp fields in struct frame. */
466
467 INLINE void
468 fset_buffer_list (struct frame *f, Lisp_Object val)
469 {
470 f->buffer_list = val;
471 }
472 INLINE void
473 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
474 {
475 f->buried_buffer_list = val;
476 }
477 INLINE void
478 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
479 {
480 f->condemned_scroll_bars = val;
481 }
482 INLINE void
483 fset_face_alist (struct frame *f, Lisp_Object val)
484 {
485 f->face_alist = val;
486 }
487 INLINE void
488 fset_focus_frame (struct frame *f, Lisp_Object val)
489 {
490 f->focus_frame = val;
491 }
492 INLINE void
493 fset_icon_name (struct frame *f, Lisp_Object val)
494 {
495 f->icon_name = val;
496 }
497 INLINE void
498 fset_menu_bar_items (struct frame *f, Lisp_Object val)
499 {
500 f->menu_bar_items = val;
501 }
502 INLINE void
503 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
504 {
505 f->menu_bar_vector = val;
506 }
507 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
508 INLINE void
509 fset_menu_bar_window (struct frame *f, Lisp_Object val)
510 {
511 f->menu_bar_window = val;
512 }
513 #endif
514 INLINE void
515 fset_name (struct frame *f, Lisp_Object val)
516 {
517 f->name = val;
518 }
519 INLINE void
520 fset_param_alist (struct frame *f, Lisp_Object val)
521 {
522 f->param_alist = val;
523 }
524 INLINE void
525 fset_root_window (struct frame *f, Lisp_Object val)
526 {
527 f->root_window = val;
528 }
529 INLINE void
530 fset_scroll_bars (struct frame *f, Lisp_Object val)
531 {
532 f->scroll_bars = val;
533 }
534 INLINE void
535 fset_selected_window (struct frame *f, Lisp_Object val)
536 {
537 f->selected_window = val;
538 }
539 INLINE void
540 fset_title (struct frame *f, Lisp_Object val)
541 {
542 f->title = val;
543 }
544 INLINE void
545 fset_tool_bar_items (struct frame *f, Lisp_Object val)
546 {
547 f->tool_bar_items = val;
548 }
549 INLINE void
550 fset_tool_bar_position (struct frame *f, Lisp_Object val)
551 {
552 f->tool_bar_position = val;
553 }
554 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
555 INLINE void
556 fset_tool_bar_window (struct frame *f, Lisp_Object val)
557 {
558 f->tool_bar_window = val;
559 }
560 INLINE void
561 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
562 {
563 f->current_tool_bar_string = val;
564 }
565 INLINE void
566 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
567 {
568 f->desired_tool_bar_string = val;
569 }
570 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
571
572 #define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
573
574 INLINE double
575 default_pixels_per_inch_x (void)
576 {
577 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
578 ? XCAR (Vdisplay_pixels_per_inch)
579 : Vdisplay_pixels_per_inch);
580 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
581 }
582
583 INLINE double
584 default_pixels_per_inch_y (void)
585 {
586 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
587 ? XCDR (Vdisplay_pixels_per_inch)
588 : Vdisplay_pixels_per_inch);
589 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
590 }
591
592 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
593
594 /* Return a pointer to the image cache of frame F. */
595 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
596
597 #define XFRAME(p) \
598 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
599 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
600
601 /* Given a window, return its frame as a Lisp_Object. */
602 #define WINDOW_FRAME(w) ((w)->frame)
603
604 /* Test a frame for particular kinds of display methods. */
605 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
606 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
607 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
608 #ifndef HAVE_NTGUI
609 #define FRAME_W32_P(f) false
610 #else
611 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
612 #endif
613 #ifndef MSDOS
614 #define FRAME_MSDOS_P(f) false
615 #else
616 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
617 #endif
618 #ifndef HAVE_NS
619 #define FRAME_NS_P(f) false
620 #else
621 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
622 #endif
623
624 /* FRAME_WINDOW_P tests whether the frame is a window, and is
625 defined to be the predicate for the window system being used. */
626
627 #ifdef HAVE_X_WINDOWS
628 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
629 #endif
630 #ifdef HAVE_NTGUI
631 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
632 #endif
633 #ifdef HAVE_NS
634 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
635 #endif
636 #ifndef FRAME_WINDOW_P
637 #define FRAME_WINDOW_P(f) ((void) (f), false)
638 #endif
639
640 /* Dots per inch of the screen the frame F is on. */
641
642 #ifdef HAVE_WINDOW_SYSTEM
643
644 #define FRAME_RES_X(f) \
645 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
646 #define FRAME_RES_Y(f) \
647 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
648
649 #else /* !HAVE_WINDOW_SYSTEM */
650
651 /* Defaults when no window system available. */
652
653 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
654 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
655
656 #endif /* HAVE_WINDOW_SYSTEM */
657
658 /* Return a pointer to the structure holding information about the
659 region of text, if any, that is currently shown in mouse-face on
660 frame F. We need to define two versions because a TTY-only build
661 does not have FRAME_DISPLAY_INFO. */
662 #ifdef HAVE_WINDOW_SYSTEM
663 # define MOUSE_HL_INFO(F) \
664 (FRAME_WINDOW_P(F) \
665 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
666 : &(F)->output_data.tty->display_info->mouse_highlight)
667 #else
668 # define MOUSE_HL_INFO(F) \
669 (&(F)->output_data.tty->display_info->mouse_highlight)
670 #endif
671
672 /* True if frame F is still alive (not deleted). */
673 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
674
675 /* True if frame F is a minibuffer-only frame. */
676 #define FRAME_MINIBUF_ONLY_P(f) \
677 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
678
679 /* True if frame F contains it's own minibuffer window. Frame always has
680 minibuffer window, but it could use minibuffer window of another frame. */
681 #define FRAME_HAS_MINIBUF_P(f) \
682 (WINDOWP (f->minibuffer_window) \
683 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
684
685 /* Pixel width of frame F. */
686 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
687
688 /* Pixel height of frame F, including non-toolkit menu bar and
689 non-toolkit tool bar lines. */
690 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
691
692 /* Width of frame F, measured in canonical character columns,
693 not including scroll bars if any. */
694 #define FRAME_COLS(f) (f)->text_cols
695
696 /* Height of frame F, measured in canonical lines, including
697 non-toolkit menu bar and non-toolkit tool bar lines. */
698 #define FRAME_LINES(f) (f)->text_lines
699
700 /* Width of frame F, measured in pixels not including the width for
701 fringes, scroll bar, and internal borders. */
702 #define FRAME_TEXT_WIDTH(f) (f)->text_width
703
704 /* Height of frame F, measured in pixels not including the height
705 for internal borders. */
706 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
707
708 /* Number of lines of frame F used for menu bar.
709 This is relevant on terminal frames and on
710 X Windows when not using the X toolkit.
711 These lines are counted in FRAME_LINES. */
712 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
713
714 /* Pixel height of frame F's menu bar. */
715 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
716
717 /* True if this frame should display a tool bar
718 in a way that does not use any text lines. */
719 #if defined (USE_GTK) || defined (HAVE_NS)
720 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
721 #else
722 #define FRAME_EXTERNAL_TOOL_BAR(f) false
723 #endif
724
725 /* Number of lines of frame F used for the tool-bar. */
726 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
727
728 /* Pixel height of frame F's tool-bar. */
729 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
730
731 /* Lines above the top-most window in frame F. */
732 #define FRAME_TOP_MARGIN(F) \
733 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
734
735 /* Pixel height of frame F's top margin. */
736 #define FRAME_TOP_MARGIN_HEIGHT(F) \
737 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
738
739 /* True if this frame should display a menu bar
740 in a way that does not use any text lines. */
741 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
742 || defined (HAVE_NS) || defined (USE_GTK)
743 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
744 #else
745 #define FRAME_EXTERNAL_MENU_BAR(f) false
746 #endif
747 #define FRAME_VISIBLE_P(f) (f)->visible
748
749 /* True if frame F is currently visible but hidden. */
750 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
751
752 /* True if frame F is currently iconified. */
753 #define FRAME_ICONIFIED_P(f) (f)->iconified
754
755 /* Mark frame F as currently garbaged. */
756 #define SET_FRAME_GARBAGED(f) \
757 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
758
759 /* True if frame F is currently garbaged. */
760 #define FRAME_GARBAGED_P(f) (f)->garbaged
761
762 /* True means do not allow splitting this frame's window. */
763 #define FRAME_NO_SPLIT_P(f) (f)->no_split
764
765 /* Not really implemented. */
766 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
767
768 /* True if all windows except selected window and mini window
769 are frozen on frame F. */
770 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
771
772 /* True if a size change has been requested for frame F
773 but not yet really put into effect. This can be true temporarily
774 when an X event comes in at a bad time. */
775 #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
776
777 /* The minibuffer window of frame F, if it has one; otherwise nil. */
778 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
779
780 /* The root window of the window tree of frame F. */
781 #define FRAME_ROOT_WINDOW(f) f->root_window
782
783 /* The currently selected window of the window tree of frame F. */
784 #define FRAME_SELECTED_WINDOW(f) f->selected_window
785
786 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
787 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
788 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
789 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
790 #define FRAME_FOCUS_FRAME(f) f->focus_frame
791
792 /* This frame slot says whether scroll bars are currently enabled for frame F,
793 and which side they are on. */
794 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
795 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
796 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
797 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
798 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
799 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
800 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
801
802 /* Width that a scroll bar in frame F should have, if there is one.
803 Measured in pixels.
804 If scroll bars are turned off, this is still nonzero. */
805 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
806
807 /* Width that a scroll bar in frame F should have, if there is one.
808 Measured in columns (characters).
809 If scroll bars are turned off, this is still nonzero. */
810 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
811
812 /* Width of a scroll bar in frame F, measured in columns (characters),
813 but only if scroll bars are on the left. If scroll bars are on
814 the right in this frame, or there are no scroll bars, value is 0. */
815
816 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
817 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
818 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
819 : 0)
820
821 /* Width of a left scroll bar in frame F, measured in pixels */
822
823 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
824 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
825 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
826 : 0)
827
828 /* Width of a scroll bar in frame F, measured in columns (characters),
829 but only if scroll bars are on the right. If scroll bars are on
830 the left in this frame, or there are no scroll bars, value is 0. */
831
832 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
833 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
834 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
835 : 0)
836
837 /* Width of a right scroll bar area in frame F, measured in pixels */
838
839 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
840 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
841 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
842 : 0)
843
844 /* Actual width of a scroll bar in frame F, measured in columns. */
845
846 #define FRAME_SCROLL_BAR_COLS(f) \
847 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
848 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
849 : 0)
850
851 /* Actual width of a scroll bar area in frame F, measured in pixels. */
852
853 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
854 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
855 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
856 : 0)
857
858 /* Total width of frame F, in columns (characters),
859 including the width used by scroll bars if any. */
860 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
861
862 /* Set the character widths of frame F. WIDTH specifies a nominal
863 character text width. */
864 #define SET_FRAME_COLS(f, width) \
865 ((f)->text_cols = (width), \
866 (f)->total_cols = ((width) \
867 + FRAME_SCROLL_BAR_COLS (f) \
868 + FRAME_FRINGE_COLS (f)))
869
870 /* Set the pixel widths of frame F. WIDTH specifies a nominal pixel
871 text width. */
872 #define SET_FRAME_WIDTH(f, width) \
873 ((f)->text_width = (width), \
874 (f)->pixel_width = ((width) \
875 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
876 + FRAME_TOTAL_FRINGE_WIDTH (f) \
877 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
878
879 /* Set the pixel heights of frame F. HEIGHT specifies a nominal pixel
880 text width. */
881 #define SET_FRAME_HEIGHT(f, height) \
882 ((f)->text_height = (height), \
883 (f)->pixel_height = ((height) \
884 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
885
886 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
887
888 #define FRAME_CURSOR_X_LIMIT(f) \
889 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
890
891 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
892
893 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
894 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
895 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
896
897 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
898 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
899 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
900 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
901
902 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
903 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
904
905 /* Return a pointer to the face cache of frame F. */
906
907 #define FRAME_FACE_CACHE(F) (F)->face_cache
908
909 /* Return the size of message_buf of the frame F. We multiply the
910 width of the frame by 4 because multi-byte form may require at most
911 4-byte for a character. */
912
913 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
914
915 #define CHECK_FRAME(x) \
916 CHECK_TYPE (FRAMEP (x), Qframep, x)
917
918 #define CHECK_LIVE_FRAME(x) \
919 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
920
921 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
922 `for' loop which iterates over the elements of Vframe_list. The
923 loop will set FRAME_VAR, a Lisp_Object, to each frame in
924 Vframe_list in succession and execute the statement. LIST_VAR
925 should be a Lisp_Object too; it is used to iterate through the
926 Vframe_list.
927
928 This macro is a holdover from a time when multiple frames weren't always
929 supported. An alternate definition of the macro would expand to
930 something which executes the statement once. */
931
932 #define FOR_EACH_FRAME(list_var, frame_var) \
933 for ((list_var) = Vframe_list; \
934 (CONSP (list_var) \
935 && (frame_var = XCAR (list_var), true)); \
936 list_var = XCDR (list_var))
937
938 /* Reflect mouse movement when a complete frame update is performed. */
939
940 #define FRAME_MOUSE_UPDATE(frame) \
941 do { \
942 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
943 if (frame == hlinfo->mouse_face_mouse_frame) \
944 { \
945 block_input (); \
946 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
947 hlinfo->mouse_face_mouse_x, \
948 hlinfo->mouse_face_mouse_y); \
949 unblock_input (); \
950 } \
951 } while (true)
952
953 /* Set visibility of frame F.
954 We call redisplay_other_windows to make sure the frame gets redisplayed
955 if some changes were applied to it while it wasn't visible (and hence
956 wasn't redisplayed). */
957
958 INLINE void
959 SET_FRAME_VISIBLE (struct frame *f, int v)
960 {
961 eassert (0 <= v && v <= 2);
962 if (v == 1 && f->visible != 1)
963 redisplay_other_windows ();
964 f->visible = v;
965 }
966
967 /* Set iconify of frame F. */
968
969 #define SET_FRAME_ICONIFIED(f, i) \
970 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
971
972 extern Lisp_Object selected_frame;
973 extern Lisp_Object Qframep, Qframe_live_p;
974 extern Lisp_Object Qtty, Qtty_type;
975 extern Lisp_Object Qtty_color_mode;
976 extern Lisp_Object Qterminal;
977 extern Lisp_Object Qnoelisp;
978
979 /* True means there is at least one garbaged frame. */
980 extern bool frame_garbaged;
981
982 extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
983 extern struct frame *decode_window_system_frame (Lisp_Object);
984 extern struct frame *decode_live_frame (Lisp_Object);
985 extern struct frame *decode_any_frame (Lisp_Object);
986 extern struct frame *make_initial_frame (void);
987 extern struct frame *make_frame (bool);
988 #ifdef HAVE_WINDOW_SYSTEM
989 extern struct frame *make_minibuffer_frame (void);
990 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
991 struct kboard *,
992 Lisp_Object);
993 #endif /* HAVE_WINDOW_SYSTEM */
994 extern bool window_system_available (struct frame *);
995 extern void check_window_system (struct frame *);
996 extern void frame_make_pointer_invisible (void);
997 extern void frame_make_pointer_visible (void);
998 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
999
1000 extern Lisp_Object Vframe_list;
1001
1002 /* Value is a pointer to the selected frame. If the selected frame
1003 isn't live, abort. */
1004
1005 #define SELECTED_FRAME() \
1006 ((FRAMEP (selected_frame) \
1007 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1008 ? XFRAME (selected_frame) \
1009 : (emacs_abort (), (struct frame *) 0))
1010
1011 \f
1012 /***********************************************************************
1013 Display-related Macros
1014 ***********************************************************************/
1015
1016 /* Canonical y-unit on frame F.
1017 This value currently equals the line height of the frame (which is
1018 the height of the default font of F). */
1019
1020 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1021
1022 /* Canonical x-unit on frame F.
1023 This value currently equals the average width of the default font of F. */
1024
1025 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1026
1027 /* Pixel width of areas used to display truncation marks, continuation
1028 marks, overlay arrows. This is 0 for terminal frames. */
1029
1030 #ifdef HAVE_WINDOW_SYSTEM
1031
1032 /* Total width of fringes reserved for drawing truncation bitmaps,
1033 continuation bitmaps and alike. The width is in canonical char
1034 units of the frame. This must currently be the case because window
1035 sizes aren't pixel values. If it weren't the case, we wouldn't be
1036 able to split windows horizontally nicely. */
1037
1038 #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols)
1039
1040 /* Pixel-width of the left and right fringe. */
1041
1042 #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width)
1043 #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width)
1044
1045 /* Total width of fringes in pixels. */
1046
1047 #define FRAME_TOTAL_FRINGE_WIDTH(F) \
1048 (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F))
1049
1050 /* Pixel-width of internal border lines */
1051 #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
1052
1053 /* Pixel-size of window border lines */
1054 #define FRAME_RIGHT_DIVIDER_WIDTH(F) ((F)->right_divider_width)
1055 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) ((F)->bottom_divider_width)
1056
1057 #else /* not HAVE_WINDOW_SYSTEM */
1058
1059 #define FRAME_FRINGE_COLS(F) 0
1060 #define FRAME_TOTAL_FRINGE_WIDTH(F) 0
1061 #define FRAME_LEFT_FRINGE_WIDTH(F) 0
1062 #define FRAME_RIGHT_FRINGE_WIDTH(F) 0
1063 #define FRAME_INTERNAL_BORDER_WIDTH(F) 0
1064 #define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1065 #define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
1066
1067 #endif /* not HAVE_WINDOW_SYSTEM */
1068 \f
1069 /***********************************************************************
1070 Conversion between canonical units and pixels
1071 ***********************************************************************/
1072
1073 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1074 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1075 represented as Lisp numbers, i.e. integers or floats. */
1076
1077 /* Convert canonical value X to pixels. F is the frame whose
1078 canonical char width is to be used. X must be a Lisp integer or
1079 float. Value is a C integer. */
1080
1081 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1082 (INTEGERP (X) \
1083 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1084 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1085
1086 /* Convert canonical value Y to pixels. F is the frame whose
1087 canonical character height is to be used. X must be a Lisp integer
1088 or float. Value is a C integer. */
1089
1090 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1091 (INTEGERP (Y) \
1092 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1093 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1094
1095 /* Convert pixel-value X to canonical units. F is the frame whose
1096 canonical character width is to be used. X is a C integer. Result
1097 is a Lisp float if X is not a multiple of the canon width,
1098 otherwise it's a Lisp integer. */
1099
1100 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1101 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1102 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1103 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1104
1105 /* Convert pixel-value Y to canonical units. F is the frame whose
1106 canonical character height is to be used. Y is a C integer.
1107 Result is a Lisp float if Y is not a multiple of the canon width,
1108 otherwise it's a Lisp integer. */
1109
1110 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1111 ((Y) % FRAME_LINE_HEIGHT (F) \
1112 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1113 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1114
1115
1116 \f
1117 /* Manipulating pixel sizes and character sizes.
1118 Knowledge of which factors affect the overall size of the window should
1119 be hidden in these macros, if that's possible.
1120
1121 Return the upper/left pixel position of the character cell on frame F
1122 at ROW/COL. */
1123
1124 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1125 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1126 + (row) * FRAME_LINE_HEIGHT (f))
1127
1128 #define FRAME_COL_TO_PIXEL_X(f, col) \
1129 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1130 + (col) * FRAME_COLUMN_WIDTH (f))
1131
1132 /* Return the pixel width/height of frame F if it has
1133 COLS columns/LINES rows. */
1134
1135 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1136 (FRAME_COL_TO_PIXEL_X (f, cols) \
1137 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1138 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1139 + FRAME_INTERNAL_BORDER_WIDTH (f))
1140
1141 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1142 ((lines) * FRAME_LINE_HEIGHT (f) \
1143 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1144
1145 /* Return the row/column (zero-based) of the character cell containing
1146 the pixel on FRAME at Y/X. */
1147
1148 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1149 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1150 ? (y) \
1151 : ((y) < FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1152 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1153 /* Arrange for the division to round down. */ \
1154 + FRAME_LINE_HEIGHT (f) - 1) \
1155 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1156 / FRAME_LINE_HEIGHT (f))
1157
1158 #define FRAME_PIXEL_X_TO_COL(f, x) \
1159 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1160 / FRAME_COLUMN_WIDTH (f))
1161
1162 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1163 frame F? */
1164
1165 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1166 (FRAME_PIXEL_X_TO_COL (f, ((width) \
1167 - FRAME_INTERNAL_BORDER_WIDTH (f) \
1168 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1169 - FRAME_SCROLL_BAR_AREA_WIDTH (f)))) \
1170
1171 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1172 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
1173 - FRAME_INTERNAL_BORDER_WIDTH (f))))
1174
1175 /* Return the pixel width/height of frame F with a text size of
1176 width/height. */
1177
1178 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1179 ((width) \
1180 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1181 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1182 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1183
1184 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1185 ((height) + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1186
1187 /* Return the text width/height of frame F with a pixel size of
1188 width/height. */
1189
1190 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1191 ((width) \
1192 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1193 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1194 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1195
1196 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1197 ((height) - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1198
1199 /* Value is the smallest width of any character in any font on frame F. */
1200
1201 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1202 FRAME_DISPLAY_INFO (f)->smallest_char_width
1203
1204 /* Value is the smallest height of any font on frame F. */
1205
1206 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1207 FRAME_DISPLAY_INFO (f)->smallest_font_height
1208
1209 /***********************************************************************
1210 Frame Parameters
1211 ***********************************************************************/
1212
1213 extern Lisp_Object Qauto_raise, Qauto_lower;
1214 extern Lisp_Object Qborder_color, Qborder_width;
1215 extern Lisp_Object Qbuffer_predicate;
1216 extern Lisp_Object Qcursor_color, Qcursor_type;
1217 extern Lisp_Object Qfont;
1218 extern Lisp_Object Qbackground_color, Qforeground_color;
1219 extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1220 extern Lisp_Object Qinternal_border_width;
1221 extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
1222 extern Lisp_Object Qtooltip;
1223 extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
1224 extern Lisp_Object Qmouse_color;
1225 extern Lisp_Object Qname, Qtitle;
1226 extern Lisp_Object Qparent_id;
1227 extern Lisp_Object Qunsplittable, Qvisibility;
1228 extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1229 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1230 extern Lisp_Object Qscreen_gamma;
1231 extern Lisp_Object Qline_spacing;
1232 extern Lisp_Object Qwait_for_wm;
1233 extern Lisp_Object Qfullscreen;
1234 extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
1235 extern Lisp_Object Qsticky;
1236 extern Lisp_Object Qfont_backend;
1237 extern Lisp_Object Qalpha;
1238
1239 extern Lisp_Object Qleft_fringe, Qright_fringe;
1240 extern Lisp_Object Qheight, Qwidth;
1241 extern Lisp_Object Qminibuffer, Qmodeline;
1242 extern Lisp_Object Qx, Qw32, Qpc, Qns;
1243 extern Lisp_Object Qvisible;
1244 extern Lisp_Object Qdisplay_type;
1245
1246 extern Lisp_Object Qx_resource_name;
1247
1248 extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom;
1249 extern Lisp_Object Qdisplay;
1250
1251 extern Lisp_Object Qrun_hook_with_args;
1252
1253 #ifdef HAVE_WINDOW_SYSTEM
1254
1255 /* The class of this X application. */
1256 #define EMACS_CLASS "Emacs"
1257
1258 /* These are in xterm.c, w32term.c, etc. */
1259
1260 extern void x_set_scroll_bar_default_width (struct frame *);
1261 extern void x_set_offset (struct frame *, int, int, int);
1262 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1263
1264 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1265
1266
1267 extern Lisp_Object Qface_set_after_frame_default;
1268
1269 #ifdef HAVE_NTGUI
1270 extern void x_fullscreen_adjust (struct frame *f, int *, int *,
1271 int *, int *);
1272 #endif
1273
1274 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1275
1276 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1277 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1278 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1279 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1280 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1281 extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object);
1282 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1283 extern void x_set_internal_border_width (struct frame *, Lisp_Object,
1284 Lisp_Object);
1285 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1286 Lisp_Object);
1287 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1288 Lisp_Object);
1289 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1290 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1291 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1292 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1293 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object,
1294 Lisp_Object);
1295 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object,
1296 Lisp_Object);
1297
1298 extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
1299
1300 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1301
1302 extern void validate_x_resource_name (void);
1303
1304 extern Lisp_Object display_x_get_resource (Display_Info *,
1305 Lisp_Object attribute,
1306 Lisp_Object class,
1307 Lisp_Object component,
1308 Lisp_Object subclass);
1309
1310 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1311 extern void x_set_window_size (struct frame *f, int change_grav,
1312 int width, int height, bool pixelwise);
1313 extern Lisp_Object x_get_focus_frame (struct frame *);
1314 extern void x_set_mouse_position (struct frame *f, int h, int v);
1315 extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1316 extern void x_make_frame_visible (struct frame *f);
1317 extern void x_make_frame_invisible (struct frame *f);
1318 extern void x_iconify_frame (struct frame *f);
1319 extern void x_set_frame_alpha (struct frame *f);
1320 extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1321 extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1322 extern void x_activate_menubar (struct frame *);
1323 extern void x_real_positions (struct frame *, int *, int *);
1324 extern void free_frame_menubar (struct frame *);
1325 extern void x_free_frame_resources (struct frame *);
1326
1327 #if defined HAVE_X_WINDOWS
1328 extern void x_wm_set_icon_position (struct frame *, int, int);
1329 #if !defined USE_X_TOOLKIT
1330 extern char *x_get_resource_string (const char *, const char *);
1331 #endif
1332 extern void x_sync (struct frame *);
1333 #endif /* HAVE_X_WINDOWS */
1334
1335 extern void x_query_colors (struct frame *f, XColor *, int);
1336 extern void x_query_color (struct frame *f, XColor *);
1337 extern void x_focus_frame (struct frame *);
1338
1339 #ifndef HAVE_NS
1340
1341 extern int x_bitmap_icon (struct frame *, Lisp_Object);
1342
1343 /* Set F's bitmap icon, if specified among F's parameters. */
1344
1345 INLINE void
1346 x_set_bitmap_icon (struct frame *f)
1347 {
1348 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1349
1350 if (CONSP (obj))
1351 x_bitmap_icon (f, XCDR (obj));
1352 }
1353
1354 #endif /* !HAVE_NS */
1355
1356 #endif /* HAVE_WINDOW_SYSTEM */
1357
1358 INLINE void
1359 flush_frame (struct frame *f)
1360 {
1361 struct redisplay_interface *rif = FRAME_RIF (f);
1362
1363 if (rif && rif->flush_display)
1364 rif->flush_display (f);
1365 }
1366
1367 /***********************************************************************
1368 Multimonitor data
1369 ***********************************************************************/
1370
1371 #ifdef HAVE_WINDOW_SYSTEM
1372
1373 struct MonitorInfo {
1374 XRectangle geom, work;
1375 int mm_width, mm_height;
1376 char *name;
1377 };
1378
1379 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1380 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1381 int n_monitors,
1382 int primary_monitor,
1383 Lisp_Object monitor_frames,
1384 const char *source);
1385
1386 #endif /* HAVE_WINDOW_SYSTEM */
1387
1388
1389 INLINE_HEADER_END
1390
1391 #endif /* not EMACS_FRAME_H */