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