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