declare smobs in alloc.c
[bpt/emacs.git] / src / frame.h
CommitLineData
ff11dfa1 1/* Define frame-object for GNU Emacs.
ba318903 2 Copyright (C) 1993-1994, 1999-2014 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
bfd55935
DA
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
a390930c 172 /* Number of elements in `menu_bar_vector' that have meaningful data. */
d230cb74 173 int menu_bar_items_used;
a390930c 174
3b83d631
GM
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. */
bd601e2a
KH
177 char *namebuf;
178
b09cca6a 179 /* Glyph pool and matrix. */
3b83d631
GM
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
96c06863 185 /* True means that glyphs on this frame have been initialized so it can
3b83d631 186 be used for output. */
96c06863 187 bool_bf glyphs_initialized_p : 1;
21015f9c 188
96c06863 189 /* Set to true in change_frame_size when size of frame changed
e3d7bd83 190 Clear the frame in clear_garbaged_frames if set. */
96c06863 191 bool_bf resized_p : 1;
e3d7bd83 192
96c06863 193 /* Set to true if the default face for the frame has been
e3d7bd83
DN
194 realized. Reset to zero whenever the default face changes.
195 Used to see the difference between a font change and face change. */
96c06863 196 bool_bf default_face_done_p : 1;
e3d7bd83 197
96c06863 198 /* Set to true if this frame has already been hscrolled during
e3d7bd83 199 current redisplay. */
96c06863 200 bool_bf already_hscrolled_p : 1;
e3d7bd83 201
96c06863
PE
202 /* Set to true when current redisplay has updated frame. */
203 bool_bf updated_p : 1;
e3d7bd83 204
742516e0 205#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
96c06863 206 /* Set to true to minimize tool-bar height even when
e3d7bd83 207 auto-resize-tool-bar is set to grow-only. */
96c06863 208 bool_bf minimize_tool_bar_window_p : 1;
742516e0 209#endif
e3d7bd83 210
9e2a2647 211#if defined (USE_GTK) || defined (HAVE_NS)
96c06863
PE
212 /* True means using a tool bar that comes from the toolkit. */
213 bool_bf external_tool_bar : 1;
488dd4c4
JD
214#endif
215
96c06863 216 /* True means that fonts have been loaded since the last glyph
bd0443bb 217 matrix adjustments. */
96c06863 218 bool_bf fonts_changed : 1;
bd0443bb 219
96c06863
PE
220 /* True means that cursor type has been changed. */
221 bool_bf cursor_type_changed : 1;
655ab9a3
SM
222
223 /* True if it needs to be redisplayed. */
96c06863 224 bool_bf redisplay : 1;
7f6c6450 225
9ea173e8
GM
226 /* Margin at the top of the frame. Used to display the tool-bar. */
227 int tool_bar_lines;
3b83d631 228
880e6158
MR
229 /* Pixel height of tool bar. */
230 int tool_bar_height;
231
045cff16 232 int n_tool_bar_rows;
e3303a23 233 int n_tool_bar_items;
177c0ea7 234
655ab9a3 235 /* A buffer for decode_mode_line. */
3b83d631 236 char *decode_mode_spec_buffer;
21015f9c 237
655ab9a3
SM
238 /* See do_line_insertion_deletion_costs for info on these arrays. */
239 /* Cost of inserting 1 line on this frame. */
21015f9c 240 int *insert_line_cost;
655ab9a3 241 /* Cost of deleting 1 line on this frame. */
21015f9c 242 int *delete_line_cost;
655ab9a3 243 /* Cost of inserting n lines on this frame. */
21015f9c 244 int *insert_n_lines_cost;
655ab9a3 245 /* Cost of deleting n lines on this frame. */
21015f9c
RS
246 int *delete_n_lines_cost;
247
880e6158
MR
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;
b45afe99 261
880e6158 262 /* New text height and width for pending size change. 0 if no change
f224e500 263 pending. These values represent pixels or canonical character units
880e6158
MR
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;
b45afe99 267
880e6158
MR
268 /* Whether new_height and new_width shall be interpreted
269 in pixels. */
270 bool new_pixelwise;
b45afe99
KS
271
272 /* Pixel position of the frame window (x and y offsets in root window). */
273 int left_pos, top_pos;
274
880e6158
MR
275 /* Size of the frame window (including internal border widths) in
276 pixels. */
277 int pixel_width, pixel_height;
b45afe99
KS
278
279 /* These many pixels are the difference between the outer window (i.e. the
655ab9a3 280 left and top of the window manager decoration) and FRAME_X_WINDOW. */
b45afe99
KS
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;
21015f9c 288
b45afe99
KS
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
880e6158
MR
297 /* Width of borders between this frame's windows. */
298 int right_divider_width;
299 int bottom_divider_width;
300
b45afe99
KS
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;
21015f9c 306
428a555e
KL
307 /* The output method says how the contents of this frame are
308 displayed. It could be using termcap, or using an X window.
6ed8eeff 309 This must be the same as the terminal->type. */
efa4ce8b
JB
310 enum output_method output_method;
311
6ed8eeff 312 /* The terminal device that this frame uses. If this is NULL, then
655ab9a3 313 the frame has been deleted. */
6ed8eeff 314 struct terminal *terminal;
63bb3d8e 315
7e59217d 316 /* Device-dependent, frame-local auxiliary data used for displaying
428a555e 317 the contents. When the frame is deleted, this data is deleted as
655ab9a3 318 well. */
3b83d631
GM
319 union output_data
320 {
655ab9a3
SM
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. */
d311d28c 325 intptr_t nothing;
3b83d631
GM
326 }
327 output_data;
efa4ce8b 328
655ab9a3 329 /* List of font-drivers available on the frame. */
adf494ff 330 struct font_driver_list *font_driver_list;
6aae9c92
KH
331 /* List of data specific to font-driver and frame, but common to
332 faces. */
333 struct font_data_list *font_data_list;
adf494ff 334
b45afe99
KS
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
655ab9a3 345 /* See FULLSCREEN_ enum below. */
2806a183 346 enum fullscreen_type want_fullscreen;
b45afe99 347
6d05db81
RS
348 /* Number of lines of menu bar. */
349 int menu_bar_lines;
350
880e6158
MR
351 /* Pixel height of menubar. */
352 int menu_bar_height;
353
f8eb1572
DA
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
655ab9a3
SM
359#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
360 || defined (HAVE_NS) || defined (USE_GTK)
96c06863
PE
361 /* True means using a menu bar that comes from the X toolkit. */
362 bool_bf external_menu_bar : 1;
655ab9a3
SM
363#endif
364
edfa7fa0
DA
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
a4659527 369 it to see if we should bother updating the frame's contents.
efa4ce8b 370
6548cf00
KL
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:
edfa7fa0 374 if equal to 2, then the frame is obscured - we still consider
6548cf00 375 it to be "visible" as seen from lisp, but we don't bother
655ab9a3 376 updating it. */
4e0f6479 377 unsigned visible : 2;
a4659527 378
96c06863 379 /* True if the frame is currently iconified. Do not
edfa7fa0 380 set this directly, use SET_FRAME_ICONIFIED instead. */
96c06863 381 bool_bf iconified : 1;
efa4ce8b 382
114d739b
SM
383 /* True if this frame should be fully redisplayed. Disables all
384 optimizations while rebuilding matrices and redrawing. */
96c06863 385 bool_bf garbaged : 1;
efa4ce8b 386
96c06863 387 /* False means, if this frame has just one window,
efa4ce8b 388 show no modeline for that window. */
96c06863 389 bool_bf wants_modeline : 1;
efa4ce8b 390
96c06863
PE
391 /* True means raise this frame to the top of the heap when selected. */
392 bool_bf auto_raise : 1;
efa4ce8b 393
96c06863
PE
394 /* True means lower this frame to the bottom of the stack when left. */
395 bool_bf auto_lower : 1;
efa4ce8b 396
ff11dfa1 397 /* True if frame's root window can't be split. */
96c06863 398 bool_bf no_split : 1;
efa4ce8b 399
fbfed6f0
JB
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. */
96c06863 404 bool_bf explicit_name : 1;
fbfed6f0 405
96c06863
PE
406 /* True if size of some window on this frame has changed. */
407 bool_bf window_sizes_changed : 1;
adc12f0f 408
96c06863 409 /* True if the mouse has moved on this display device
e3d7bd83 410 since the last time we checked. */
96c06863 411 bool_bf mouse_moved : 1;
e3d7bd83 412
96c06863
PE
413 /* True means that the pointer is invisible. */
414 bool_bf pointer_invisible : 1;
e044e4fc 415
96c06863 416 /* True means that all windows except mini-window and
d2e113bc 417 selected window on this frame have frozen window starts. */
96c06863 418 bool_bf frozen_window_starts : 1;
d2e113bc 419
3737fee7 420 /* Nonzero if we should actually display the scroll bars on this frame. */
e3d7bd83
DN
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
b45afe99
KS
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
95b999aa
RS
445 /* The baud rate that was used to calculate costs for this frame. */
446 int cost_calculation_baud_rate;
6462918c 447
caecb91c 448 /* Frame opacity
91a47a68 449 alpha[0]: alpha transparency of the active frame
f2d5c00f
CY
450 alpha[1]: alpha transparency of inactive frames
451 Negative values mean not to change alpha. */
91a47a68
DN
452 double alpha[2];
453
b61cbba3
GM
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;
d1738c45
GM
458
459 /* Additional space to put between text lines on this frame. */
460 int extra_line_spacing;
f1c69c61 461
caecb91c 462 /* All display backends seem to need these two pixel values. */
28d7d09f
KL
463 unsigned long background_pixel;
464 unsigned long foreground_pixel;
efa4ce8b
JB
465};
466
f00af5b1
PE
467/* Most code should use these functions to set Lisp fields in struct frame. */
468
00382e8b 469INLINE void
f00af5b1
PE
470fset_buffer_list (struct frame *f, Lisp_Object val)
471{
472 f->buffer_list = val;
473}
00382e8b 474INLINE void
f00af5b1
PE
475fset_buried_buffer_list (struct frame *f, Lisp_Object val)
476{
477 f->buried_buffer_list = val;
478}
00382e8b 479INLINE void
f00af5b1
PE
480fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
481{
482 f->condemned_scroll_bars = val;
483}
00382e8b 484INLINE void
f00af5b1
PE
485fset_face_alist (struct frame *f, Lisp_Object val)
486{
487 f->face_alist = val;
488}
00382e8b 489INLINE void
f00af5b1
PE
490fset_focus_frame (struct frame *f, Lisp_Object val)
491{
492 f->focus_frame = val;
493}
00382e8b 494INLINE void
f00af5b1
PE
495fset_icon_name (struct frame *f, Lisp_Object val)
496{
497 f->icon_name = val;
498}
00382e8b 499INLINE void
f00af5b1
PE
500fset_menu_bar_items (struct frame *f, Lisp_Object val)
501{
502 f->menu_bar_items = val;
503}
00382e8b 504INLINE void
f00af5b1
PE
505fset_menu_bar_vector (struct frame *f, Lisp_Object val)
506{
507 f->menu_bar_vector = val;
508}
5a49b79c 509#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
00382e8b 510INLINE void
f00af5b1
PE
511fset_menu_bar_window (struct frame *f, Lisp_Object val)
512{
513 f->menu_bar_window = val;
514}
5a49b79c 515#endif
00382e8b 516INLINE void
f00af5b1
PE
517fset_name (struct frame *f, Lisp_Object val)
518{
519 f->name = val;
520}
00382e8b 521INLINE void
f00af5b1
PE
522fset_param_alist (struct frame *f, Lisp_Object val)
523{
524 f->param_alist = val;
525}
00382e8b 526INLINE void
f00af5b1
PE
527fset_root_window (struct frame *f, Lisp_Object val)
528{
529 f->root_window = val;
530}
00382e8b 531INLINE void
f00af5b1
PE
532fset_scroll_bars (struct frame *f, Lisp_Object val)
533{
534 f->scroll_bars = val;
535}
00382e8b 536INLINE void
f00af5b1
PE
537fset_selected_window (struct frame *f, Lisp_Object val)
538{
539 f->selected_window = val;
540}
00382e8b 541INLINE void
f00af5b1
PE
542fset_title (struct frame *f, Lisp_Object val)
543{
544 f->title = val;
545}
00382e8b 546INLINE void
f00af5b1
PE
547fset_tool_bar_items (struct frame *f, Lisp_Object val)
548{
549 f->tool_bar_items = val;
550}
00382e8b 551INLINE void
f00af5b1
PE
552fset_tool_bar_position (struct frame *f, Lisp_Object val)
553{
554 f->tool_bar_position = val;
555}
742516e0 556#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
00382e8b 557INLINE void
f00af5b1
PE
558fset_tool_bar_window (struct frame *f, Lisp_Object val)
559{
560 f->tool_bar_window = val;
561}
00382e8b 562INLINE void
742516e0
DA
563fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
564{
565 f->current_tool_bar_string = val;
566}
00382e8b 567INLINE void
742516e0
DA
568fset_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 */
f00af5b1 573
42143acd
DA
574#define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
575
00382e8b 576INLINE double
42143acd
DA
577default_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
00382e8b 585INLINE double
42143acd
DA
586default_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
6ed8eeff 594#define FRAME_KBOARD(f) ((f)->terminal->kboard)
37ea66e1 595
354884c4
SM
596/* Return a pointer to the image cache of frame F. */
597#define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
598
b263a6b0 599#define XFRAME(p) \
49609976 600 (eassert (FRAMEP (p)), (struct frame *) SCM_SMOB_DATA (p))
aac03cca 601#define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
ff11dfa1 602
cea6021b 603/* Given a window, return its frame as a Lisp_Object. */
fd16b54c 604#define WINDOW_FRAME(w) ((w)->frame)
ff11dfa1 605
cea6021b 606/* Test a frame for particular kinds of display methods. */
3224dac1 607#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
cea6021b 608#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
efa7f0f9 609#define FRAME_X_P(f) ((f)->output_method == output_x_window)
0fda9b75 610#ifndef HAVE_NTGUI
96c06863 611#define FRAME_W32_P(f) false
ff687885 612#else
fbd6baed 613#define FRAME_W32_P(f) ((f)->output_method == output_w32)
ff687885
DN
614#endif
615#ifndef MSDOS
96c06863 616#define FRAME_MSDOS_P(f) false
ff687885 617#else
6f181713 618#define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
ff687885
DN
619#endif
620#ifndef HAVE_NS
96c06863 621#define FRAME_NS_P(f) false
ff687885 622#else
edfda783 623#define FRAME_NS_P(f) ((f)->output_method == output_ns)
ff687885 624#endif
42143acd 625
efa7f0f9
GV
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. */
3b83d631 628
efa7f0f9
GV
629#ifdef HAVE_X_WINDOWS
630#define FRAME_WINDOW_P(f) FRAME_X_P (f)
631#endif
632#ifdef HAVE_NTGUI
fbd6baed 633#define FRAME_WINDOW_P(f) FRAME_W32_P (f)
efa7f0f9 634#endif
edfda783
AR
635#ifdef HAVE_NS
636#define FRAME_WINDOW_P(f) FRAME_NS_P(f)
637#endif
7651b07e 638#ifndef FRAME_WINDOW_P
96c06863 639#define FRAME_WINDOW_P(f) ((void) (f), false)
7651b07e 640#endif
efa7f0f9 641
aad3612f
DA
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
7ea692f6
EZ
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
8e5ba371 662 frame F. We need to define two versions because a TTY-only build
aad3612f 663 does not have FRAME_DISPLAY_INFO. */
8e5ba371
EZ
664#ifdef HAVE_WINDOW_SYSTEM
665# define MOUSE_HL_INFO(F) \
021f2e1a 666 (FRAME_WINDOW_P(F) \
aad3612f 667 ? &FRAME_DISPLAY_INFO(F)->mouse_highlight \
021f2e1a 668 : &(F)->output_data.tty->display_info->mouse_highlight)
8e5ba371
EZ
669#else
670# define MOUSE_HL_INFO(F) \
021f2e1a 671 (&(F)->output_data.tty->display_info->mouse_highlight)
8e5ba371 672#endif
7ea692f6 673
96c06863 674/* True if frame F is still alive (not deleted). */
6ed8eeff 675#define FRAME_LIVE_P(f) ((f)->terminal != 0)
cea6021b 676
96c06863 677/* True if frame F is a minibuffer-only frame. */
ff11dfa1
JB
678#define FRAME_MINIBUF_ONLY_P(f) \
679 EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
cea6021b 680
96c06863 681/* True if frame F contains it's own minibuffer window. Frame always has
1a23cd48
DA
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)
cea6021b 686
880e6158
MR
687/* Pixel width of frame F. */
688#define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
689
b45afe99
KS
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
880e6158
MR
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
b45afe99
KS
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
880e6158
MR
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
cea6021b
RS
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.
b45afe99 713 These lines are counted in FRAME_LINES. */
6d05db81 714#define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
cea6021b 715
880e6158
MR
716/* Pixel height of frame F's menu bar. */
717#define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
718
96c06863 719/* True if this frame should display a tool bar
488dd4c4 720 in a way that does not use any text lines. */
9e2a2647 721#if defined (USE_GTK) || defined (HAVE_NS)
488dd4c4
JD
722#define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
723#else
96c06863 724#define FRAME_EXTERNAL_TOOL_BAR(f) false
488dd4c4
JD
725#endif
726
9ea173e8 727/* Number of lines of frame F used for the tool-bar. */
9ea173e8 728#define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
3b83d631 729
880e6158
MR
730/* Pixel height of frame F's tool-bar. */
731#define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
488dd4c4 732
3b83d631 733/* Lines above the top-most window in frame F. */
3b83d631 734#define FRAME_TOP_MARGIN(F) \
021f2e1a 735 (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
3b83d631 736
880e6158
MR
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))
4b00d3b1 740
96c06863 741/* True if this frame should display a menu bar
cea6021b 742 in a way that does not use any text lines. */
9e2a2647 743#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
edfda783 744 || defined (HAVE_NS) || defined (USE_GTK)
9c95189b 745#define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
4c8888a0 746#else
96c06863 747#define FRAME_EXTERNAL_MENU_BAR(f) false
4c8888a0 748#endif
edfa7fa0 749#define FRAME_VISIBLE_P(f) (f)->visible
cea6021b 750
96c06863 751/* True if frame F is currently visible but hidden. */
0969b893 752#define FRAME_OBSCURED_P(f) ((f)->visible > 1)
cea6021b 753
96c06863 754/* True if frame F is currently iconified. */
cea6021b
RS
755#define FRAME_ICONIFIED_P(f) (f)->iconified
756
edfa7fa0 757/* Mark frame F as currently garbaged. */
655ab9a3
SM
758#define SET_FRAME_GARBAGED(f) \
759 (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
edfa7fa0 760
96c06863 761/* True if frame F is currently garbaged. */
ff11dfa1 762#define FRAME_GARBAGED_P(f) (f)->garbaged
cea6021b 763
96c06863 764/* True means do not allow splitting this frame's window. */
ff11dfa1 765#define FRAME_NO_SPLIT_P(f) (f)->no_split
cea6021b
RS
766
767/* Not really implemented. */
ff11dfa1 768#define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
cea6021b 769
96c06863 770/* True if all windows except selected window and mini window
d2e113bc
DA
771 are frozen on frame F. */
772#define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
773
96c06863 774/* True if a size change has been requested for frame F
cea6021b
RS
775 but not yet really put into effect. This can be true temporarily
776 when an X event comes in at a bad time. */
adc12f0f 777#define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed
cea6021b
RS
778
779/* The minibuffer window of frame F, if it has one; otherwise nil. */
e69b0960 780#define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
cea6021b
RS
781
782/* The root window of the window tree of frame F. */
e69b0960 783#define FRAME_ROOT_WINDOW(f) f->root_window
cea6021b
RS
784
785/* The currently selected window of the window tree of frame F. */
e69b0960 786#define FRAME_SELECTED_WINDOW(f) f->selected_window
cea6021b 787
177c0ea7
JB
788#define FRAME_INSERT_COST(f) (f)->insert_line_cost
789#define FRAME_DELETE_COST(f) (f)->delete_line_cost
ff11dfa1
JB
790#define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
791#define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
e69b0960 792#define FRAME_FOCUS_FRAME(f) f->focus_frame
cea6021b 793
cea6021b
RS
794/* This frame slot says whether scroll bars are currently enabled for frame F,
795 and which side they are on. */
a3211441
RS
796#define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
797#define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
021f2e1a 798 ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
a3211441 799#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
021f2e1a 800 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
a3211441 801#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
021f2e1a 802 ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
cea6021b
RS
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. */
b45afe99 807#define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
cea6021b
RS
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. */
b45afe99 812#define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
cea6021b
RS
813
814/* Width of a scroll bar in frame F, measured in columns (characters),
7d81cf83
GM
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
b45afe99 818#define FRAME_LEFT_SCROLL_BAR_COLS(f) \
021f2e1a
AS
819 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
820 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
821 : 0)
7d81cf83 822
b45afe99
KS
823/* Width of a left scroll bar in frame F, measured in pixels */
824
021f2e1a 825#define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \
b45afe99 826 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \
880e6158 827 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
b45afe99
KS
828 : 0)
829
7d81cf83
GM
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
b45afe99 834#define FRAME_RIGHT_SCROLL_BAR_COLS(f) \
021f2e1a
AS
835 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
836 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
837 : 0)
cea6021b 838
b45afe99
KS
839/* Width of a right scroll bar area in frame F, measured in pixels */
840
021f2e1a 841#define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \
b45afe99 842 (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \
880e6158 843 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
b45afe99
KS
844 : 0)
845
846/* Actual width of a scroll bar in frame F, measured in columns. */
847
848#define FRAME_SCROLL_BAR_COLS(f) \
021f2e1a
AS
849 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
850 ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
851 : 0)
cea6021b 852
b45afe99
KS
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) \
880e6158 857 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
b45afe99
KS
858 : 0)
859
cea6021b
RS
860/* Total width of frame F, in columns (characters),
861 including the width used by scroll bars if any. */
b45afe99 862#define FRAME_TOTAL_COLS(f) ((f)->total_cols)
cea6021b 863
880e6158
MR
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)))
cea6021b 887
4ff34795 888/* Maximum + 1 legitimate value for FRAME_CURSOR_X. */
b45afe99 889
4ff34795 890#define FRAME_CURSOR_X_LIMIT(f) \
021f2e1a 891 (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
cea6021b 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) \
96c06863 937 && (frame_var = XCAR (list_var), true)); \
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 } \
dd1fb8cb 953 } while (false)
e5d77022 954
caecb91c
SM
955/* False means there are no visible garbaged frames. */
956extern bool frame_garbaged;
957
655ab9a3
SM
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). */
edfa7fa0 962
95b3d095
PE
963INLINE void
964SET_FRAME_VISIBLE (struct frame *f, int v)
965{
966 eassert (0 <= v && v <= 2);
caecb91c
SM
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 }
95b3d095
PE
974 f->visible = v;
975}
edfa7fa0
DA
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
5492865b 982extern Lisp_Object selected_frame;
5e02ce11 983extern Lisp_Object Qframep, Qframe_live_p;
2666355c 984extern Lisp_Object Qtty, Qtty_type;
8848b728 985extern Lisp_Object Qtty_color_mode;
959067a1 986extern Lisp_Object Qterminal;
c53956fe 987extern Lisp_Object Qnoelisp;
efa4ce8b 988
0ff162fc 989extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
7452b7bd 990extern struct frame *decode_window_system_frame (Lisp_Object);
d9f07150
DA
991extern struct frame *decode_live_frame (Lisp_Object);
992extern struct frame *decode_any_frame (Lisp_Object);
383e0970 993extern struct frame *make_initial_frame (void);
959067a1 994extern struct frame *make_frame (bool);
c9e5d3d1 995#ifdef HAVE_WINDOW_SYSTEM
383e0970
J
996extern struct frame *make_minibuffer_frame (void);
997extern struct frame *make_frame_without_minibuffer (Lisp_Object,
998 struct kboard *,
999 Lisp_Object);
7452b7bd 1000extern bool window_system_available (struct frame *);
bd009aef
DA
1001#else /* not HAVE_WINDOW_SYSTEM */
1002#define window_system_available(f) ((void) (f), false)
1003#endif /* HAVE_WINDOW_SYSTEM */
7452b7bd 1004extern void check_window_system (struct frame *);
632fd57c
DA
1005extern void frame_make_pointer_invisible (struct frame *);
1006extern void frame_make_pointer_visible (struct frame *);
383e0970 1007extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
efa4ce8b 1008
ff11dfa1 1009extern Lisp_Object Vframe_list;
650afd94
GM
1010
1011/* Value is a pointer to the selected frame. If the selected frame
b975254e 1012 isn't live, abort. */
650afd94
GM
1013
1014#define SELECTED_FRAME() \
1015 ((FRAMEP (selected_frame) \
1016 && FRAME_LIVE_P (XFRAME (selected_frame))) \
1017 ? XFRAME (selected_frame) \
1088b922 1018 : (emacs_abort (), (struct frame *) 0))
3b83d631
GM
1019
1020\f
1021/***********************************************************************
1022 Display-related Macros
1023 ***********************************************************************/
1024
d3378f02 1025/* Canonical y-unit on frame F.
b45afe99
KS
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)
3b83d631 1030
d3378f02 1031/* Canonical x-unit on frame F.
0fc63cc4 1032 This value currently equals the average width of the default font of F. */
3b83d631 1033
b45afe99 1034#define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
3b83d631 1035
3b83d631 1036/* Pixel width of areas used to display truncation marks, continuation
5cb26370 1037 marks, overlay arrows. This is 0 for terminal frames. */
3b83d631
GM
1038
1039#ifdef HAVE_WINDOW_SYSTEM
aa5b8e15 1040
b45afe99
KS
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
b45afe99 1059/* Pixel-width of internal border lines */
b45afe99 1060#define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width)
177c0ea7 1061
880e6158
MR
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
aa5b8e15
GM
1066#else /* not HAVE_WINDOW_SYSTEM */
1067
986f10ad 1068#define FRAME_FRINGE_COLS(F) 0
b45afe99 1069#define FRAME_TOTAL_FRINGE_WIDTH(F) 0
986f10ad 1070#define FRAME_LEFT_FRINGE_WIDTH(F) 0
8432bb78 1071#define FRAME_RIGHT_FRINGE_WIDTH(F) 0
b45afe99 1072#define FRAME_INTERNAL_BORDER_WIDTH(F) 0
880e6158
MR
1073#define FRAME_RIGHT_DIVIDER_WIDTH(F) 0
1074#define FRAME_BOTTOM_DIVIDER_WIDTH(F) 0
aa5b8e15
GM
1075
1076#endif /* not HAVE_WINDOW_SYSTEM */
3b83d631
GM
1077\f
1078/***********************************************************************
1079 Conversion between canonical units and pixels
1080 ***********************************************************************/
1081
b45afe99
KS
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. */
3b83d631
GM
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. */
177c0ea7 1089
b45afe99 1090#define FRAME_PIXEL_X_FROM_CANON_X(F, X) \
021f2e1a
AS
1091 (INTEGERP (X) \
1092 ? XINT (X) * FRAME_COLUMN_WIDTH (F) \
1093 : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F)))
177c0ea7 1094
3b83d631
GM
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. */
177c0ea7 1098
b45afe99 1099#define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \
021f2e1a
AS
1100 (INTEGERP (Y) \
1101 ? XINT (Y) * FRAME_LINE_HEIGHT (F) \
1102 : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F)))
3b83d631
GM
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
b45afe99 1109#define FRAME_CANON_X_FROM_PIXEL_X(F, X) \
021f2e1a
AS
1110 ((X) % FRAME_COLUMN_WIDTH (F) != 0 \
1111 ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \
1112 : make_number ((X) / FRAME_COLUMN_WIDTH (F)))
3b83d631
GM
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
b45afe99 1119#define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \
021f2e1a
AS
1120 ((Y) % FRAME_LINE_HEIGHT (F) \
1121 ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \
1122 : make_number ((Y) / FRAME_LINE_HEIGHT (F)))
b45afe99
KS
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
880e6158 1133#define FRAME_LINE_TO_PIXEL_Y(f, row) \
16009a0e 1134 (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
b45afe99
KS
1135 + (row) * FRAME_LINE_HEIGHT (f))
1136
880e6158
MR
1137#define FRAME_COL_TO_PIXEL_X(f, col) \
1138 (FRAME_INTERNAL_BORDER_WIDTH (f) \
b45afe99
KS
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) \
880e6158
MR
1145 (FRAME_COL_TO_PIXEL_X (f, cols) \
1146 + FRAME_SCROLL_BAR_AREA_WIDTH (f) \
1147 + FRAME_TOTAL_FRINGE_WIDTH (f) \
b45afe99
KS
1148 + FRAME_INTERNAL_BORDER_WIDTH (f))
1149
1150#define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
880e6158 1151 ((lines) * FRAME_LINE_HEIGHT (f) \
f016f225 1152 + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
b45afe99 1153
b45afe99
KS
1154/* Return the row/column (zero-based) of the character cell containing
1155 the pixel on FRAME at Y/X. */
1156
880e6158
MR
1157#define FRAME_PIXEL_Y_TO_LINE(f, y) \
1158 (((y) < FRAME_TOP_MARGIN_HEIGHT (f) \
1159 ? (y) \
4b00d3b1
YM
1160 : ((y) < FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
1161 ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f) + FRAME_INTERNAL_BORDER_WIDTH (f) \
880e6158
MR
1162 /* Arrange for the division to round down. */ \
1163 + FRAME_LINE_HEIGHT (f) - 1) \
1164 : (y) - FRAME_INTERNAL_BORDER_WIDTH (f))) \
b45afe99
KS
1165 / FRAME_LINE_HEIGHT (f))
1166
880e6158 1167#define FRAME_PIXEL_X_TO_COL(f, x) \
b45afe99
KS
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
880e6158
MR
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)))) \
b45afe99 1179
880e6158
MR
1180#define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \
1181 (FRAME_PIXEL_Y_TO_LINE (f, ((height) \
b45afe99 1182 - FRAME_INTERNAL_BORDER_WIDTH (f))))
177c0ea7 1183
880e6158 1184/* Return the pixel width/height of frame F with a text size of
f224e500 1185 width/height. */
880e6158
MR
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
f224e500 1197 width/height. */
880e6158
MR
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
c7cc32f7
DA
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
5e02ce11
KS
1217
1218/***********************************************************************
1219 Frame Parameters
1220 ***********************************************************************/
1221
1222extern Lisp_Object Qauto_raise, Qauto_lower;
1223extern Lisp_Object Qborder_color, Qborder_width;
955cbe7b 1224extern Lisp_Object Qbuffer_predicate;
5e02ce11
KS
1225extern Lisp_Object Qcursor_color, Qcursor_type;
1226extern Lisp_Object Qfont;
5e02ce11
KS
1227extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top;
1228extern Lisp_Object Qinternal_border_width;
880e6158 1229extern Lisp_Object Qright_divider_width, Qbottom_divider_width;
99f3388e 1230extern Lisp_Object Qtooltip;
2b4e6277 1231extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines, Qtool_bar_position;
5e02ce11
KS
1232extern Lisp_Object Qmouse_color;
1233extern Lisp_Object Qname, Qtitle;
1234extern Lisp_Object Qparent_id;
1235extern Lisp_Object Qunsplittable, Qvisibility;
1236extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars;
1237extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
1238extern Lisp_Object Qscreen_gamma;
1239extern Lisp_Object Qline_spacing;
1240extern Lisp_Object Qwait_for_wm;
1241extern Lisp_Object Qfullscreen;
3f1c6666 1242extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth, Qmaximized;
acd51077 1243extern Lisp_Object Qsticky;
1a8a83b2 1244extern Lisp_Object Qfont_backend;
50a73869 1245extern Lisp_Object Qalpha;
5e02ce11
KS
1246
1247extern Lisp_Object Qleft_fringe, Qright_fringe;
1248extern Lisp_Object Qheight, Qwidth;
1249extern Lisp_Object Qminibuffer, Qmodeline;
4b298d5a 1250extern Lisp_Object Qx, Qw32, Qpc, Qns;
5e02ce11
KS
1251extern Lisp_Object Qvisible;
1252extern Lisp_Object Qdisplay_type;
5e02ce11
KS
1253
1254extern Lisp_Object Qx_resource_name;
1255
bfeabdc3 1256extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom;
5e02ce11
KS
1257extern Lisp_Object Qdisplay;
1258
99f3388e
DN
1259extern Lisp_Object Qrun_hook_with_args;
1260
5e02ce11
KS
1261#ifdef HAVE_WINDOW_SYSTEM
1262
1263/* The class of this X application. */
1264#define EMACS_CLASS "Emacs"
1265
5e02ce11
KS
1266/* These are in xterm.c, w32term.c, etc. */
1267
383e0970
J
1268extern void x_set_scroll_bar_default_width (struct frame *);
1269extern void x_set_offset (struct frame *, int, int, int);
a10c8269 1270extern void x_wm_set_size_hint (struct frame *f, long flags, bool user_position);
5e02ce11 1271
383e0970 1272extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
5e02ce11 1273
5e02ce11
KS
1274
1275extern Lisp_Object Qface_set_after_frame_default;
1276
0fda9b75 1277#ifdef HAVE_NTGUI
383e0970
J
1278extern void x_fullscreen_adjust (struct frame *f, int *, int *,
1279 int *, int *);
81626931 1280#endif
383e0970
J
1281
1282extern void x_set_frame_parameters (struct frame *, Lisp_Object);
383e0970
J
1283
1284extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
1285extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
1286extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
1287extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
1288extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
1289extern void x_set_fringe_width (struct frame *, Lisp_Object, Lisp_Object);
1290extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
1291extern void x_set_internal_border_width (struct frame *, Lisp_Object,
1292 Lisp_Object);
880e6158
MR
1293extern void x_set_right_divider_width (struct frame *, Lisp_Object,
1294 Lisp_Object);
1295extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
1296 Lisp_Object);
383e0970
J
1297extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
1298extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
1299extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
1300extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
1301extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object,
1302 Lisp_Object);
1303extern void x_set_scroll_bar_width (struct frame *, Lisp_Object,
1304 Lisp_Object);
1305
959067a1 1306extern long x_figure_window_size (struct frame *, Lisp_Object, bool);
5e02ce11 1307
383e0970 1308extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
5e02ce11 1309
383e0970 1310extern void validate_x_resource_name (void);
0ff162fc 1311
facfbbbd
SM
1312extern 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
18e27ea8 1318extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
17a2cbbd 1319extern void x_set_window_size (struct frame *f, int change_grav,
880e6158 1320 int width, int height, bool pixelwise);
17a2cbbd 1321extern Lisp_Object x_get_focus_frame (struct frame *);
2b511374 1322extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
17a2cbbd
DC
1323extern void x_make_frame_visible (struct frame *f);
1324extern void x_make_frame_invisible (struct frame *f);
1325extern void x_iconify_frame (struct frame *f);
17a2cbbd 1326extern void x_set_frame_alpha (struct frame *f);
880e6158 1327extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
17a2cbbd
DC
1328extern void x_activate_menubar (struct frame *);
1329extern void x_real_positions (struct frame *, int *, int *);
17a2cbbd
DC
1330extern void free_frame_menubar (struct frame *);
1331extern void x_free_frame_resources (struct frame *);
1332
52b8a085
DA
1333#if defined HAVE_X_WINDOWS
1334extern void x_wm_set_icon_position (struct frame *, int, int);
1335#if !defined USE_X_TOOLKIT
018c5e19
PE
1336extern char *x_get_resource_string (const char *, const char *);
1337#endif
83fc0554
DA
1338extern void x_sync (struct frame *);
1339#endif /* HAVE_X_WINDOWS */
018c5e19 1340
17a2cbbd 1341extern void x_query_colors (struct frame *f, XColor *, int);
0fda9b75 1342extern void x_query_color (struct frame *f, XColor *);
fcd42c11 1343extern void x_focus_frame (struct frame *);
17a2cbbd 1344
2cd98812
DA
1345#ifndef HAVE_NS
1346
1347extern int x_bitmap_icon (struct frame *, Lisp_Object);
1348
1349/* Set F's bitmap icon, if specified among F's parameters. */
1350
00382e8b 1351INLINE void
2cd98812
DA
1352x_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 */
35a38932
DA
1361#endif /* HAVE_WINDOW_SYSTEM */
1362
1363INLINE void
1364flush_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
6799bb26
JD
1372/***********************************************************************
1373 Multimonitor data
1374 ***********************************************************************/
1375
1376#ifdef HAVE_WINDOW_SYSTEM
1377
1378struct MonitorInfo {
1379 XRectangle geom, work;
1380 int mm_width, mm_height;
1381 char *name;
1382};
1383
1384extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
1385extern 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
5e02ce11 1393
f00af5b1
PE
1394INLINE_HEADER_END
1395
84e01749 1396#endif /* not EMACS_FRAME_H */