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