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