]> code.delx.au - gnu-emacs/blob - src/frame.h
5e3ee68942a882da3b6879a579df88ea3a7703b9
[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 /* See FULLSCREEN_ enum on top. */
313 ENUM_BF (fullscreen_type) want_fullscreen : 4;
314
315 /* If not vertical_scroll_bar_none, we should actually
316 display the scroll bars of this type on this frame. */
317 ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
318
319 /* Nonzero if we should actually display horizontal scroll bars on this frame. */
320 bool_bf horizontal_scroll_bars : 1;
321 #endif /* HAVE_WINDOW_SYSTEM */
322
323 /* Whether new_height and new_width shall be interpreted
324 in pixels. */
325 bool_bf new_pixelwise : 1;
326
327 /* True means x_set_window_size requests can be processed for this
328 frame. */
329 bool_bf can_x_set_window_size : 1;
330
331 /* Set to true after this frame was made by `make-frame'. */
332 bool_bf after_make_frame : 1;
333
334 /* Whether the tool bar height change should be taken into account. */
335 bool_bf tool_bar_redisplayed : 1;
336 bool_bf tool_bar_resized : 1;
337
338 /* Inhibit implied resize before after_make_frame is set. */
339 bool_bf inhibit_horizontal_resize : 1;
340 bool_bf inhibit_vertical_resize : 1;
341
342 /* Non-zero if this frame's faces need to be recomputed. */
343 bool_bf face_change : 1;
344
345 /* Bitfield area ends here. */
346
347 /* Number of lines (rounded up) of tool bar. REMOVE THIS */
348 int tool_bar_lines;
349
350 /* Height of frame internal tool bar in pixels. */
351 int tool_bar_height;
352
353 int n_tool_bar_rows;
354 int n_tool_bar_items;
355
356 /* A buffer for decode_mode_line. */
357 char *decode_mode_spec_buffer;
358
359 /* See do_line_insertion_deletion_costs for info on these arrays. */
360 /* Cost of inserting 1 line on this frame. */
361 int *insert_line_cost;
362 /* Cost of deleting 1 line on this frame. */
363 int *delete_line_cost;
364 /* Cost of inserting n lines on this frame. */
365 int *insert_n_lines_cost;
366 /* Cost of deleting n lines on this frame. */
367 int *delete_n_lines_cost;
368
369 /* Text width of this frame (excluding fringes, vertical scroll bar
370 and internal border widths) and text height (excluding menu bar,
371 tool bar, horizontal scroll bar and internal border widths) in
372 units of canonical characters. */
373 int text_cols, text_lines;
374
375 /* Total width of this frame (including fringes, vertical scroll bar
376 and internal border widths) and total height (including menu bar,
377 tool bar, horizontal scroll bar and internal border widths) in
378 units of canonical characters. */
379 int total_cols, total_lines;
380
381 /* Text width of this frame (excluding fringes, vertical scroll bar
382 and internal border widths) and text height (excluding menu bar,
383 tool bar, horizontal scroll bar and internal border widths) in
384 pixels. */
385 int text_width, text_height;
386
387 /* New text height and width for pending size change. 0 if no change
388 pending. These values represent pixels or canonical character units
389 according to the value of new_pixelwise and correlate to the the
390 text width/height of the frame. */
391 int new_width, new_height;
392
393 /* Pixel position of the frame window (x and y offsets in root window). */
394 int left_pos, top_pos;
395
396 /* Total width of this frame (including fringes, vertical scroll bar
397 and internal border widths) and total height (including internal
398 menu and tool bars, horizontal scroll bar and internal border
399 widths) in pixels. */
400 int pixel_width, pixel_height;
401
402 /* This is the gravity value for the specified window position. */
403 int win_gravity;
404
405 /* The geometry flags for this window. */
406 int size_hint_flags;
407
408 /* Border width of the frame window as known by the (X) window system. */
409 int border_width;
410
411 /* Width of the internal border. This is a line of background color
412 just inside the window's border. When the frame is selected,
413 a highlighting is displayed inside the internal border. */
414 int internal_border_width;
415
416 /* Widths of dividers between this frame's windows in pixels. */
417 int right_divider_width, bottom_divider_width;
418
419 /* Widths of fringes in pixels. */
420 int left_fringe_width, right_fringe_width;
421
422 /* Total width of fringes reserved for drawing truncation bitmaps,
423 continuation bitmaps and alike - REMOVE THIS !!!!. */
424 int fringe_cols;
425
426 /* Number of lines of menu bar. */
427 int menu_bar_lines;
428
429 /* Pixel height of menubar. */
430 int menu_bar_height;
431
432 /* Canonical X unit. Width of default font, in pixels. */
433 int column_width;
434
435 /* Canonical Y unit. Height of a line, in pixels. */
436 int line_height;
437
438 /* The terminal device that this frame uses. If this is NULL, then
439 the frame has been deleted. */
440 struct terminal *terminal;
441
442 /* Device-dependent, frame-local auxiliary data used for displaying
443 the contents. When the frame is deleted, this data is deleted as
444 well. */
445 union output_data
446 {
447 struct tty_output *tty; /* From termchar.h. */
448 struct x_output *x; /* From xterm.h. */
449 struct w32_output *w32; /* From w32term.h. */
450 struct ns_output *ns; /* From nsterm.h. */
451 intptr_t nothing;
452 }
453 output_data;
454
455 /* List of font-drivers available on the frame. */
456 struct font_driver_list *font_driver_list;
457
458 #if defined (HAVE_X_WINDOWS)
459 /* Used by x_wait_for_event when watching for an X event on this frame. */
460 int wait_event_type;
461 #endif
462
463 /* What kind of text cursor should we draw in the future?
464 This should always be filled_box_cursor or bar_cursor. */
465 enum text_cursor_kinds desired_cursor;
466
467 /* Width of bar cursor (if we are using that). */
468 int cursor_width;
469
470 /* What kind of text cursor should we draw when the cursor blinks off?
471 This can be filled_box_cursor or bar_cursor or no_cursor. */
472 enum text_cursor_kinds blink_off_cursor;
473
474 /* Width of bar cursor (if we are using that) for blink-off state. */
475 int blink_off_cursor_width;
476
477 /* Configured width of the scroll bar, in pixels and in characters.
478 config_scroll_bar_cols tracks config_scroll_bar_width if the
479 latter is positive; a zero value in config_scroll_bar_width means
480 to compute the actual width on the fly, using config_scroll_bar_cols
481 and the current font width. */
482 int config_scroll_bar_width;
483 int config_scroll_bar_cols;
484
485 /* Configured height of the scroll bar, in pixels and in characters.
486 config_scroll_bar_lines tracks config_scroll_bar_height if the
487 latter is positive; a zero value in config_scroll_bar_height means
488 to compute the actual width on the fly, using
489 config_scroll_bar_lines and the current font width. */
490 int config_scroll_bar_height;
491 int config_scroll_bar_lines;
492
493 /* The baud rate that was used to calculate costs for this frame. */
494 int cost_calculation_baud_rate;
495
496 /* Frame opacity
497 alpha[0]: alpha transparency of the active frame
498 alpha[1]: alpha transparency of inactive frames
499 Negative values mean not to change alpha. */
500 double alpha[2];
501
502 /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA *
503 SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
504 frame parameter. 0 means don't do gamma correction. */
505 double gamma;
506
507 /* Additional space to put between text lines on this frame. */
508 int extra_line_spacing;
509
510 /* All display backends seem to need these two pixel values. */
511 unsigned long background_pixel;
512 unsigned long foreground_pixel;
513 };
514
515 /* Most code should use these functions to set Lisp fields in struct frame. */
516
517 INLINE void
518 fset_buffer_list (struct frame *f, Lisp_Object val)
519 {
520 f->buffer_list = val;
521 }
522 INLINE void
523 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
524 {
525 f->buried_buffer_list = val;
526 }
527 INLINE void
528 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
529 {
530 f->condemned_scroll_bars = val;
531 }
532 INLINE void
533 fset_face_alist (struct frame *f, Lisp_Object val)
534 {
535 f->face_alist = val;
536 }
537 INLINE void
538 fset_focus_frame (struct frame *f, Lisp_Object val)
539 {
540 f->focus_frame = val;
541 }
542 INLINE void
543 fset_icon_name (struct frame *f, Lisp_Object val)
544 {
545 f->icon_name = val;
546 }
547 INLINE void
548 fset_menu_bar_items (struct frame *f, Lisp_Object val)
549 {
550 f->menu_bar_items = val;
551 }
552 INLINE void
553 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
554 {
555 f->menu_bar_vector = val;
556 }
557 #if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
558 INLINE void
559 fset_menu_bar_window (struct frame *f, Lisp_Object val)
560 {
561 f->menu_bar_window = val;
562 }
563 #endif
564 INLINE void
565 fset_name (struct frame *f, Lisp_Object val)
566 {
567 f->name = val;
568 }
569 INLINE void
570 fset_param_alist (struct frame *f, Lisp_Object val)
571 {
572 f->param_alist = val;
573 }
574 INLINE void
575 fset_root_window (struct frame *f, Lisp_Object val)
576 {
577 f->root_window = val;
578 }
579 INLINE void
580 fset_scroll_bars (struct frame *f, Lisp_Object val)
581 {
582 f->scroll_bars = val;
583 }
584 INLINE void
585 fset_selected_window (struct frame *f, Lisp_Object val)
586 {
587 f->selected_window = val;
588 }
589 INLINE void
590 fset_title (struct frame *f, Lisp_Object val)
591 {
592 f->title = val;
593 }
594 INLINE void
595 fset_tool_bar_items (struct frame *f, Lisp_Object val)
596 {
597 f->tool_bar_items = val;
598 }
599 #ifdef USE_GTK
600 INLINE void
601 fset_tool_bar_position (struct frame *f, Lisp_Object val)
602 {
603 f->tool_bar_position = val;
604 }
605 #endif /* USE_GTK */
606 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
607 INLINE void
608 fset_tool_bar_window (struct frame *f, Lisp_Object val)
609 {
610 f->tool_bar_window = val;
611 }
612 INLINE void
613 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
614 {
615 f->current_tool_bar_string = val;
616 }
617 INLINE void
618 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
619 {
620 f->desired_tool_bar_string = val;
621 }
622 #endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
623
624 #define NUMVAL(X) (NUMBERP (X) ? XFLOATINT (X) : -1)
625
626 INLINE double
627 default_pixels_per_inch_x (void)
628 {
629 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
630 ? XCAR (Vdisplay_pixels_per_inch)
631 : Vdisplay_pixels_per_inch);
632 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
633 }
634
635 INLINE double
636 default_pixels_per_inch_y (void)
637 {
638 Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
639 ? XCDR (Vdisplay_pixels_per_inch)
640 : Vdisplay_pixels_per_inch);
641 return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
642 }
643
644 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
645
646 /* Return a pointer to the image cache of frame F. */
647 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
648
649 #define XFRAME(p) \
650 (eassert (FRAMEP (p)), (struct frame *) XUNTAG (p, Lisp_Vectorlike))
651 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
652
653 /* Given a window, return its frame as a Lisp_Object. */
654 #define WINDOW_FRAME(w) ((w)->frame)
655
656 /* Test a frame for particular kinds of display methods. */
657 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
658 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
659 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
660 #ifndef HAVE_NTGUI
661 #define FRAME_W32_P(f) false
662 #else
663 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
664 #endif
665 #ifndef MSDOS
666 #define FRAME_MSDOS_P(f) false
667 #else
668 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
669 #endif
670 #ifndef HAVE_NS
671 #define FRAME_NS_P(f) false
672 #else
673 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
674 #endif
675
676 /* FRAME_WINDOW_P tests whether the frame is a window, and is
677 defined to be the predicate for the window system being used. */
678
679 #ifdef HAVE_X_WINDOWS
680 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
681 #endif
682 #ifdef HAVE_NTGUI
683 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
684 #endif
685 #ifdef HAVE_NS
686 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
687 #endif
688 #ifndef FRAME_WINDOW_P
689 #define FRAME_WINDOW_P(f) ((void) (f), false)
690 #endif
691
692 /* Dots per inch of the screen the frame F is on. */
693
694 #ifdef HAVE_WINDOW_SYSTEM
695
696 #define FRAME_RES_X(f) \
697 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
698 #define FRAME_RES_Y(f) \
699 (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
700
701 #else /* !HAVE_WINDOW_SYSTEM */
702
703 /* Defaults when no window system available. */
704
705 #define FRAME_RES_X(f) default_pixels_per_inch_x ()
706 #define FRAME_RES_Y(f) default_pixels_per_inch_y ()
707
708 #endif /* HAVE_WINDOW_SYSTEM */
709
710 /* Return a pointer to the structure holding information about the
711 region of text, if any, that is currently shown in mouse-face on
712 frame F. We need to define two versions because a TTY-only build
713 does not have FRAME_DISPLAY_INFO. */
714 #ifdef HAVE_WINDOW_SYSTEM
715 # define MOUSE_HL_INFO(F) \
716 (FRAME_WINDOW_P(F) \
717 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
718 : &(F)->output_data.tty->display_info->mouse_highlight)
719 #else
720 # define MOUSE_HL_INFO(F) \
721 (&(F)->output_data.tty->display_info->mouse_highlight)
722 #endif
723
724 /* True if frame F is still alive (not deleted). */
725 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
726
727 /* True if frame F is a minibuffer-only frame. */
728 #define FRAME_MINIBUF_ONLY_P(f) \
729 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
730
731 /* True if frame F contains it's own minibuffer window. Frame always has
732 minibuffer window, but it could use minibuffer window of another frame. */
733 #define FRAME_HAS_MINIBUF_P(f) \
734 (WINDOWP (f->minibuffer_window) \
735 && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
736
737 /* Pixel width of frame F. */
738 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
739
740 /* Pixel height of frame F. */
741 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
742
743 /* Width of frame F, measured in canonical character columns,
744 not including scroll bars if any. */
745 #define FRAME_COLS(f) (f)->text_cols
746
747 /* Height of frame F, measured in canonical lines, including
748 non-toolkit menu bar and non-toolkit tool bar lines. */
749 #define FRAME_LINES(f) (f)->text_lines
750
751 /* Width of frame F, measured in pixels not including the width for
752 fringes, scroll bar, and internal borders. */
753 #define FRAME_TEXT_WIDTH(f) (f)->text_width
754
755 /* Height of frame F, measured in pixels not including the height
756 for scroll bar and internal borders. */
757 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
758
759 /* Number of lines of frame F used for menu bar.
760 This is relevant on terminal frames and on
761 X Windows when not using the X toolkit.
762 These lines are counted in FRAME_LINES. */
763 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
764
765 /* Pixel height of frame F's menu bar. */
766 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
767
768 /* True if this frame should display a tool bar
769 in a way that does not use any text lines. */
770 #if defined (USE_GTK) || defined (HAVE_NS)
771 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
772 #else
773 #define FRAME_EXTERNAL_TOOL_BAR(f) false
774 #endif
775
776 /* This is really supported only with GTK. */
777 #ifdef USE_GTK
778 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
779 #else
780 #define FRAME_TOOL_BAR_POSITION(f) ((void) f, Qtop)
781 #endif
782
783 /* Number of lines of frame F used for the tool-bar. */
784 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
785
786 /* Pixel height of frame F's tool-bar. */
787 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
788
789 /* Lines above the top-most window in frame F. */
790 #define FRAME_TOP_MARGIN(F) \
791 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
792
793 /* Pixel height of frame F's top margin. */
794 #define FRAME_TOP_MARGIN_HEIGHT(F) \
795 (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
796
797 /* True if this frame should display a menu bar
798 in a way that does not use any text lines. */
799 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
800 || defined (HAVE_NS) || defined (USE_GTK)
801 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
802 #else
803 #define FRAME_EXTERNAL_MENU_BAR(f) false
804 #endif
805
806 /* True if frame F is currently visible. */
807 #define FRAME_VISIBLE_P(f) (f)->visible
808
809 /* True if frame F is currently visible but hidden. */
810 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
811
812 /* True if frame F is currently iconified. */
813 #define FRAME_ICONIFIED_P(f) (f)->iconified
814
815 /* Mark frame F as currently garbaged. */
816 #define SET_FRAME_GARBAGED(f) \
817 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
818
819 /* True if frame F is currently garbaged. */
820 #define FRAME_GARBAGED_P(f) (f)->garbaged
821
822 /* True means do not allow splitting this frame's window. */
823 #define FRAME_NO_SPLIT_P(f) (f)->no_split
824
825 /* Not really implemented. */
826 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
827
828 /* True if all windows except selected window and mini window
829 are frozen on frame F. */
830 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
831
832 /* True if the frame's window configuration has changed since last call
833 of run_window_size_change_functions. */
834 #define FRAME_WINDOW_CONFIGURATION_CHANGED(f) \
835 (f)->window_configuration_changed
836
837 /* The minibuffer window of frame F, if it has one; otherwise nil. */
838 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
839
840 /* The root window of the window tree of frame F. */
841 #define FRAME_ROOT_WINDOW(f) f->root_window
842
843 /* The currently selected window of the window tree of frame F. */
844 #define FRAME_SELECTED_WINDOW(f) f->selected_window
845
846 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
847 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
848 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
849 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
850 #define FRAME_FOCUS_FRAME(f) f->focus_frame
851
852 #ifdef HAVE_WINDOW_SYSTEM
853
854 /* This frame slot says whether scroll bars are currently enabled for frame F,
855 and which side they are on. */
856 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
857 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
858 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
859 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
860 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
861 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
862 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
863
864 #else /* not HAVE_WINDOW_SYSTEM */
865
866 /* If there is no window system, there are no scroll bars. */
867 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((void) f, vertical_scroll_bar_none)
868 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
869 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
870 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
871
872 #endif /* HAVE_WINDOW_SYSTEM */
873
874 /* Whether horizontal scroll bars are currently enabled for frame F. */
875 #if USE_HORIZONTAL_SCROLL_BARS
876 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
877 ((f)->horizontal_scroll_bars)
878 #else
879 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
880 #endif
881
882 /* Width that a scroll bar in frame F should have, if there is one.
883 Measured in pixels.
884 If scroll bars are turned off, this is still nonzero. */
885 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
886
887 /* Height that a scroll bar in frame F should have, if there is one.
888 Measured in pixels.
889 If scroll bars are turned off, this is still nonzero. */
890 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
891
892 /* Width that a scroll bar in frame F should have, if there is one.
893 Measured in columns (characters).
894 If scroll bars are turned off, this is still nonzero. */
895 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
896
897 /* Height that a scroll bar in frame F should have, if there is one.
898 Measured in lines (characters).
899 If scroll bars are turned off, this is still nonzero. */
900 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
901
902 /* Width of a left scroll bar in frame F, measured in pixels */
903 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
904 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
905 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
906 : 0)
907
908 /* Width of a right scroll bar area in frame F, measured in pixels */
909 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
910 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
911 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
912 : 0)
913
914 /* Width of a left scroll bar in frame F, measured in columns
915 (characters), but only if scroll bars are on the left. If scroll
916 bars are on the right in this frame, or there are no scroll bars,
917 value is 0. */
918 #define FRAME_LEFT_SCROLL_BAR_COLS(f) \
919 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
920 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
921 : 0)
922
923 /* Width of a right scroll bar in frame F, measured in columns
924 (characters), but only if scroll bars are on the right. If scroll
925 bars are on the left in this frame, or there are no scroll bars,
926 value is 0. */
927 #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
928 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
929 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
930 : 0)
931
932 /* Width of a vertical scroll bar area in frame F, measured in
933 pixels. */
934 #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \
935 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
936 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
937 : 0)
938
939 /* Height of horizontal scroll bar area in frame F, measured in
940 pixels. */
941 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
942 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
943 ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
944 : 0)
945
946 /* Width of vertical scroll bar in frame F, measured in columns. */
947 #define FRAME_SCROLL_BAR_COLS(f) \
948 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
949 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
950 : 0)
951
952 /* Height of horizontal scroll bar in frame F, measured in lines. */
953 #define FRAME_SCROLL_BAR_LINES(f) \
954 (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
955 ? FRAME_CONFIG_SCROLL_BAR_LINES (f) \
956 : 0)
957
958 /* Total width of frame F, in columns (characters),
959 including the width used by scroll bars if any. */
960 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
961
962 /* Total height of frame F, in lines (characters),
963 including the height used by scroll bars if any. */
964 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
965
966 /* Set the character widths of frame F. WIDTH specifies a nominal
967 character text width. */
968 #define SET_FRAME_COLS(f, width) \
969 ((f)->text_cols = (width), \
970 (f)->total_cols = ((width) \
971 + FRAME_SCROLL_BAR_COLS (f) \
972 + FRAME_FRINGE_COLS (f)))
973
974 /* Set the character heights of frame F. HEIGHT specifies a nominal
975 character text height. */
976 #define SET_FRAME_LINES(f, height) \
977 ((f)->text_lines = (height), \
978 (f)->total_lines = ((height) \
979 + FRAME_TOP_MARGIN (f) \
980 + FRAME_SCROLL_BAR_LINES (f)))
981
982 /* Set the widths of frame F. WIDTH specifies a nominal pixel text
983 width. */
984 #define SET_FRAME_WIDTH(f, width) \
985 ((f)->text_width = (width), \
986 (f)->pixel_width = ((width) \
987 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
988 + FRAME_TOTAL_FRINGE_WIDTH (f) \
989 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
990
991 /* Set the heights of frame F. HEIGHT specifies a nominal pixel text
992 height. */
993 #define SET_FRAME_HEIGHT(f, height) \
994 ((f)->text_height = (height), \
995 (f)->pixel_height = ((height) \
996 + FRAME_TOP_MARGIN_HEIGHT (f) \
997 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
998 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f)))
999
1000 /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
1001 #define FRAME_CURSOR_X_LIMIT(f) \
1002 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
1003
1004 /* Nonzero if frame F has scroll bars. */
1005 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
1006 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
1007
1008 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
1009 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
1010
1011 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
1012 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
1013 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
1014 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
1015
1016 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
1017 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
1018
1019 /* Return a pointer to the face cache of frame F. */
1020
1021 #define FRAME_FACE_CACHE(F) (F)->face_cache
1022
1023 /* Return the size of message_buf of the frame F. We multiply the
1024 width of the frame by 4 because multi-byte form may require at most
1025 4-byte for a character. */
1026
1027 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
1028
1029 #define CHECK_FRAME(x) \
1030 CHECK_TYPE (FRAMEP (x), Qframep, x)
1031
1032 #define CHECK_LIVE_FRAME(x) \
1033 CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
1034
1035 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
1036 `for' loop which iterates over the elements of Vframe_list. The
1037 loop will set FRAME_VAR, a Lisp_Object, to each frame in
1038 Vframe_list in succession and execute the statement. LIST_VAR
1039 should be a Lisp_Object too; it is used to iterate through the
1040 Vframe_list.
1041
1042 This macro is a holdover from a time when multiple frames weren't always
1043 supported. An alternate definition of the macro would expand to
1044 something which executes the statement once. */
1045
1046 #define FOR_EACH_FRAME(list_var, frame_var) \
1047 for ((list_var) = Vframe_list; \
1048 (CONSP (list_var) \
1049 && (frame_var = XCAR (list_var), true)); \
1050 list_var = XCDR (list_var))
1051
1052 /* Reflect mouse movement when a complete frame update is performed. */
1053
1054 #define FRAME_MOUSE_UPDATE(frame) \
1055 do { \
1056 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame); \
1057 if (frame == hlinfo->mouse_face_mouse_frame) \
1058 { \
1059 block_input (); \
1060 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
1061 hlinfo->mouse_face_mouse_x, \
1062 hlinfo->mouse_face_mouse_y); \
1063 unblock_input (); \
1064 } \
1065 } while (false)
1066
1067 /* Handy macro to construct an argument to Fmodify_frame_parameters. */
1068
1069 #define AUTO_FRAME_ARG(name, parameter, value) \
1070 AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
1071
1072 /* False means there are no visible garbaged frames. */
1073 extern bool frame_garbaged;
1074
1075 /* Set visibility of frame F.
1076 We call redisplay_other_windows to make sure the frame gets redisplayed
1077 if some changes were applied to it while it wasn't visible (and hence
1078 wasn't redisplayed). */
1079
1080 INLINE void
1081 SET_FRAME_VISIBLE (struct frame *f, int v)
1082 {
1083 eassert (0 <= v && v <= 2);
1084 if (v)
1085 {
1086 if (v == 1 && f->visible != 1)
1087 redisplay_other_windows ();
1088 if (FRAME_GARBAGED_P (f))
1089 frame_garbaged = true;
1090 }
1091 f->visible = v;
1092 }
1093
1094 /* Set iconify of frame F. */
1095
1096 #define SET_FRAME_ICONIFIED(f, i) \
1097 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
1098
1099 extern Lisp_Object selected_frame;
1100
1101 #if ! (defined USE_GTK || defined HAVE_NS)
1102 extern int frame_default_tool_bar_height;
1103 #endif
1104
1105 #ifdef HAVE_WINDOW_SYSTEM
1106 # define WINDOW_SYSTEM_RETURN
1107 #else
1108 # define WINDOW_SYSTEM_RETURN _Noreturn
1109 #endif
1110
1111 extern WINDOW_SYSTEM_RETURN struct frame *
1112 decode_window_system_frame (Lisp_Object);
1113 extern struct frame *decode_live_frame (Lisp_Object);
1114 extern struct frame *decode_any_frame (Lisp_Object);
1115 extern struct frame *make_initial_frame (void);
1116 extern struct frame *make_frame (bool);
1117 #ifdef HAVE_WINDOW_SYSTEM
1118 extern struct frame *make_minibuffer_frame (void);
1119 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
1120 struct kboard *,
1121 Lisp_Object);
1122 extern bool display_available (void);
1123 #endif
1124
1125 INLINE bool
1126 window_system_available (struct frame *f)
1127 {
1128 #ifdef HAVE_WINDOW_SYSTEM
1129 return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
1130 #else
1131 return false;
1132 #endif
1133 }
1134
1135 extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
1136 extern void frame_make_pointer_invisible (struct frame *);
1137 extern void frame_make_pointer_visible (struct frame *);
1138 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
1139 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
1140 extern void adjust_frame_size (struct frame *, int, int, int, bool, Lisp_Object);
1141 extern void frame_size_history_add (struct frame *f, Lisp_Object fun_symbol,
1142 int width, int height, Lisp_Object rest);
1143
1144 extern Lisp_Object Vframe_list;
1145
1146 /* Value is a pointer to the selected frame. If the selected frame
1147 isn't live, abort. */
1148
1149 #define SELECTED_FRAME() \
1150 ((FRAMEP (selected_frame) \
1151 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1152 ? XFRAME (selected_frame) \
1153 : (emacs_abort (), (struct frame *) 0))
1154
1155 \f
1156 /***********************************************************************
1157 Display-related Macros
1158 ***********************************************************************/
1159
1160 /* Canonical y-unit on frame F.
1161 This value currently equals the line height of the frame (which is
1162 the height of the default font of F). */
1163 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
1164
1165 /* Canonical x-unit on frame F.
1166 This value currently equals the average width of the default font of F. */
1167 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
1168
1169 /* Get a frame's window system dimension. If no window system, this is 0. */
1170
1171 INLINE int
1172 frame_dimension (int x)
1173 {
1174 #ifdef HAVE_WINDOW_SYSTEM
1175 return x;
1176 #else
1177 return 0;
1178 #endif
1179 }
1180
1181 /* Total width of fringes reserved for drawing truncation bitmaps,
1182 continuation bitmaps and alike. The width is in canonical char
1183 units of the frame. This must currently be the case because window
1184 sizes aren't pixel values. If it weren't the case, we wouldn't be
1185 able to split windows horizontally nicely. */
1186 INLINE int
1187 FRAME_FRINGE_COLS (struct frame *f)
1188 {
1189 return frame_dimension (f->fringe_cols);
1190 }
1191
1192 /* Pixel-width of the left and right fringe. */
1193
1194 INLINE int
1195 FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
1196 {
1197 return frame_dimension (f->left_fringe_width);
1198 }
1199 INLINE int
1200 FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
1201 {
1202 return frame_dimension (f->right_fringe_width);
1203 }
1204
1205 /* Total width of fringes in pixels. */
1206
1207 INLINE int
1208 FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
1209 {
1210 return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
1211 }
1212
1213 /* Pixel-width of internal border lines */
1214 INLINE int
1215 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
1216 {
1217 return frame_dimension (f->internal_border_width);
1218 }
1219
1220 /* Pixel-size of window border lines */
1221 INLINE int
1222 FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
1223 {
1224 return frame_dimension (f->right_divider_width);
1225 }
1226 INLINE int
1227 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
1228 {
1229 return frame_dimension (f->bottom_divider_width);
1230 }
1231 \f
1232 /***********************************************************************
1233 Conversion between canonical units and pixels
1234 ***********************************************************************/
1235
1236 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
1237 y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are
1238 represented as Lisp numbers, i.e. integers or floats. */
1239
1240 /* Convert canonical value X to pixels. F is the frame whose
1241 canonical char width is to be used. X must be a Lisp integer or
1242 float. Value is a C integer. */
1243 #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
1244 (INTEGERP (X) \
1245 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1246 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
1247
1248 /* Convert canonical value Y to pixels. F is the frame whose
1249 canonical character height is to be used. X must be a Lisp integer
1250 or float. Value is a C integer. */
1251 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
1252 (INTEGERP (Y) \
1253 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1254 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
1255
1256 /* Convert pixel-value X to canonical units. F is the frame whose
1257 canonical character width is to be used. X is a C integer. Result
1258 is a Lisp float if X is not a multiple of the canon width,
1259 otherwise it's a Lisp integer. */
1260 #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
1261 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1262 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1263 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
1264
1265 /* Convert pixel-value Y to canonical units. F is the frame whose
1266 canonical character height is to be used. Y is a C integer.
1267 Result is a Lisp float if Y is not a multiple of the canon width,
1268 otherwise it's a Lisp integer. */
1269 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
1270 ((Y) % FRAME_LINE_HEIGHT (F) \
1271 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1272 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
1273
1274
1275 \f
1276 /* Manipulating pixel sizes and character sizes.
1277 Knowledge of which factors affect the overall size of the window should
1278 be hidden in these macros, if that's possible.
1279
1280 Return the upper/left pixel position of the character cell on frame F
1281 at ROW/COL. */
1282 #define FRAME_LINE_TO_PIXEL_Y(f, row) \
1283 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
1284 + (row) * FRAME_LINE_HEIGHT (f))
1285
1286 #define FRAME_COL_TO_PIXEL_X(f, col) \
1287 (FRAME_INTERNAL_BORDER_WIDTH (f) \
1288 + (col) * FRAME_COLUMN_WIDTH (f))
1289
1290 /* Return the pixel width/height of frame F if it has
1291 COLS columns/LINES rows. */
1292 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
1293 ((cols) * FRAME_COLUMN_WIDTH (f) \
1294 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1295 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1296 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1297
1298 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
1299 ((lines) * FRAME_LINE_HEIGHT (f) \
1300 + FRAME_TOP_MARGIN_HEIGHT (f) \
1301 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1302 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1303
1304 /* Return the row/column (zero-based) of the character cell containing
1305 the pixel on FRAME at Y/X. */
1306 #define FRAME_PIXEL_Y_TO_LINE(f, y) \
1307 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1308 ? (y) \
1309 : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f) \
1310 + FRAME_INTERNAL_BORDER_WIDTH (f)) \
1311 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) \
1312 + FRAME_INTERNAL_BORDER_WIDTH (f) \
1313 /* Arrange for the division to round down. */ \
1314 + FRAME_LINE_HEIGHT (f) - 1) \
1315 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
1316 / FRAME_LINE_HEIGHT (f))
1317
1318 #define FRAME_PIXEL_X_TO_COL(f, x) \
1319 (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \
1320 / FRAME_COLUMN_WIDTH (f))
1321
1322 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
1323 frame F (so we round down)? */
1324 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \
1325 (((width) \
1326 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1327 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1328 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1329 / FRAME_COLUMN_WIDTH (f)) \
1330
1331 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1332 (((height) \
1333 - FRAME_TOP_MARGIN_HEIGHT (f) \
1334 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1335 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)) \
1336 / FRAME_LINE_HEIGHT (f))
1337
1338 /* Return the pixel width/height of frame F with a text size of
1339 width/height. */
1340 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width) \
1341 ((width) \
1342 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1343 + FRAME_TOTAL_FRINGE_WIDTH (f) \
1344 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1345
1346 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height) \
1347 ((height) \
1348 + FRAME_TOP_MARGIN_HEIGHT (f) \
1349 + FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1350 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1351
1352 /* Return the text width/height of frame F with a pixel size of
1353 width/height. */
1354 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width) \
1355 ((width) \
1356 - FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1357 - FRAME_TOTAL_FRINGE_WIDTH (f) \
1358 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1359
1360 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height) \
1361 ((height) \
1362 - FRAME_TOP_MARGIN_HEIGHT (f) \
1363 - FRAME_SCROLL_BAR_AREA_HEIGHT (f) \
1364 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1365
1366 /* Return the width/height reserved for the windows of frame F. */
1367 #define FRAME_WINDOWS_WIDTH(f) \
1368 (FRAME_PIXEL_WIDTH (f) \
1369 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1370
1371 #define FRAME_WINDOWS_HEIGHT(f) \
1372 (FRAME_PIXEL_HEIGHT (f) \
1373 - FRAME_TOP_MARGIN_HEIGHT (f) \
1374 - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
1375
1376 /* Value is the smallest width of any character in any font on frame F. */
1377 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
1378 FRAME_DISPLAY_INFO (f)->smallest_char_width
1379
1380 /* Value is the smallest height of any font on frame F. */
1381 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
1382 FRAME_DISPLAY_INFO (f)->smallest_font_height
1383
1384 /***********************************************************************
1385 Frame Parameters
1386 ***********************************************************************/
1387
1388 #ifdef HAVE_WINDOW_SYSTEM
1389
1390 /* The class of this X application. */
1391 #define EMACS_CLASS "Emacs"
1392
1393 extern void x_set_scroll_bar_default_width (struct frame *);
1394 extern void x_set_scroll_bar_default_height (struct frame *);
1395 extern void x_set_offset (struct frame *, int, int, int);
1396 extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
1397 extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1398 extern void x_set_frame_parameters (struct frame *, Lisp_Object);
1399 extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1400 extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1401 extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1402 extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1403 extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1404 extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
1405 extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
1406 extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1407 extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1408 Lisp_Object);
1409 extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1410 Lisp_Object);
1411 extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1412 extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1413 extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1414 extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1415 extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1416 extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
1417 extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
1418 extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
1419
1420 extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, int *);
1421
1422 extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
1423
1424 extern void validate_x_resource_name (void);
1425
1426 extern Lisp_Object display_x_get_resource (Display_Info *,
1427 Lisp_Object attribute,
1428 Lisp_Object class,
1429 Lisp_Object component,
1430 Lisp_Object subclass);
1431
1432 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1433 extern void x_set_window_size (struct frame *f, bool change_gravity,
1434 int width, int height, bool pixelwise);
1435 extern Lisp_Object x_get_focus_frame (struct frame *);
1436 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1437 extern void x_make_frame_visible (struct frame *f);
1438 extern void x_make_frame_invisible (struct frame *f);
1439 extern void x_iconify_frame (struct frame *f);
1440 extern void x_set_frame_alpha (struct frame *f);
1441 extern void x_activate_menubar (struct frame *);
1442 extern void x_real_positions (struct frame *, int *, int *);
1443 extern void free_frame_menubar (struct frame *);
1444 extern void x_free_frame_resources (struct frame *);
1445
1446 #if defined HAVE_X_WINDOWS
1447 extern void x_wm_set_icon_position (struct frame *, int, int);
1448 #if !defined USE_X_TOOLKIT
1449 extern char *x_get_resource_string (const char *, const char *);
1450 #endif
1451 extern void x_sync (struct frame *);
1452 #endif /* HAVE_X_WINDOWS */
1453
1454 extern void x_query_colors (struct frame *f, XColor *, int);
1455 extern void x_focus_frame (struct frame *);
1456
1457 #ifndef HAVE_NS
1458
1459 extern bool x_bitmap_icon (struct frame *, Lisp_Object);
1460
1461 /* Set F's bitmap icon, if specified among F's parameters. */
1462
1463 INLINE void
1464 x_set_bitmap_icon (struct frame *f)
1465 {
1466 Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
1467
1468 if (CONSP (obj) && !NILP (XCDR (obj)))
1469 x_bitmap_icon (f, XCDR (obj));
1470 }
1471
1472 #endif /* !HAVE_NS */
1473 #endif /* HAVE_WINDOW_SYSTEM */
1474
1475 INLINE void
1476 flush_frame (struct frame *f)
1477 {
1478 struct redisplay_interface *rif = FRAME_RIF (f);
1479
1480 if (rif && rif->flush_display)
1481 rif->flush_display (f);
1482 }
1483
1484 /***********************************************************************
1485 Multimonitor data
1486 ***********************************************************************/
1487
1488 #ifdef HAVE_WINDOW_SYSTEM
1489
1490 struct MonitorInfo {
1491 XRectangle geom, work;
1492 int mm_width, mm_height;
1493 char *name;
1494 };
1495
1496 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1497 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
1498 int n_monitors,
1499 int primary_monitor,
1500 Lisp_Object monitor_frames,
1501 const char *source);
1502
1503 #endif /* HAVE_WINDOW_SYSTEM */
1504
1505
1506 INLINE_HEADER_END
1507
1508 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1509 This is for functions like x_set_horizontal_scroll_bars that have
1510 no effect in this case. */
1511 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1512 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1513 #endif
1514
1515 #endif /* not EMACS_FRAME_H */